/* ═══════════════════════════════════════════════════════════════
   Mobile-first polish — landing, app, steps, dashboard, admin
   ═══════════════════════════════════════════════════════════════ */

.mobile-sticky-cta {
    display: none;
}

@media (max-width: 768px) {
    html.site-nav-open,
    body.site-nav-open,
    html.app-menu-open,
    body.app-menu-open {
        overflow: hidden;
        touch-action: none;
    }

    .site-nav-backdrop,
    .app-menu-backdrop {
        position: fixed;
        inset: 0;
        z-index: 95;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.22s ease, visibility 0.22s ease;
    }

    .site-nav-backdrop.is-visible,
    .app-menu-backdrop.is-visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .site-nav-backdrop[hidden],
    .app-menu-backdrop[hidden] {
        display: block !important;
    }

    .site-nav-backdrop[hidden]:not(.is-visible),
    .app-menu-backdrop[hidden]:not(.is-visible) {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    :root {
        --header-h: 64px;
        --icon-box: 44px;
    }

    html {
        scroll-padding-top: calc(var(--header-h) + 12px);
    }

    body {
        font-size: 16px;
        line-height: 1.7;
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .container {
        width: min(100% - 24px, var(--container));
    }

    /* ── Buttons & touch ── */
    .btn {
        min-height: 48px;
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .btn-sm {
        min-height: 44px;
        padding: 10px 18px;
    }

    .btn-lg {
        min-height: 52px;
        padding: 14px 22px;
        font-size: 1rem;
    }

    .btn:active {
        transform: scale(0.98);
    }

    /* ── Landing header ── */
    .landing-page {
        --header-h: 76px;
    }

    .site-header {
        height: var(--header-h);
    }

    .landing-page .site-header .site-header-shell__brand img {
        height: 34px;
    }

    .site-header-shell__brand img {
        height: 36px;
    }

    .header-capacity {
        order: 3;
        margin-right: auto;
        margin-left: 8px;
    }

    .header-inner {
        flex-wrap: wrap;
        gap: 8px;
    }

    .site-nav {
        max-height: calc(100dvh - var(--header-h));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .nav-link {
        min-height: 48px;
        font-size: 0.95rem;
    }

    /* ── Landing hero ── */
    .hero {
        min-height: auto;
        padding-top: calc(var(--header-h) + 20px);
        padding-bottom: 32px;
    }

    .hero-content h1 {
        font-size: clamp(1.65rem, 7vw, 2.2rem);
        margin-bottom: 16px;
    }

    .hero-lead {
        font-size: 0.95rem;
        margin-bottom: 24px;
        gap: 0.55em;
    }

    .hero-lead-line {
        line-height: 1.75;
        text-align: right;
    }

    .hero-card {
        padding: 22px 18px;
        border-radius: var(--radius-lg);
    }

    .hero-card-list li {
        padding: 12px 0;
        font-size: 0.88rem;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-card strong {
        font-size: 1.1rem;
    }

    .section {
        padding: 52px 0;
    }

    .section-head {
        margin-bottom: 28px;
    }

    .section-head h2 {
        font-size: clamp(1.35rem, 5.5vw, 1.75rem);
    }

    .section-head p {
        font-size: 0.92rem;
        text-align: right;
        text-wrap: pretty;
    }

    .feature-card {
        padding: 22px 18px;
    }

    .feature-card h3 {
        font-size: 1rem;
    }

    .plan-card {
        padding: 20px 16px;
    }

    .plan-intro {
        font-size: 0.92rem;
        line-height: 1.9;
    }

    .highlight-item {
        padding: 20px 12px;
    }

    .step-marker {
        width: 48px;
        height: 48px;
    }

    .landing-page .step-body h3 {
        font-size: 0.95rem;
    }

    .cta-banner {
        padding-bottom: 64px;
    }

    .cta-box {
        padding: 24px 18px;
        gap: 20px;
    }

    .footer-grid {
        padding: 36px 0 24px;
    }

    /* ── App shell ── */
    .app-page {
        --header-h: 72px;
    }

    .app-topbar-actions {
        position: fixed;
        top: calc(var(--header-h) + env(safe-area-inset-top, 0px));
        left: 12px;
        right: 12px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 12px;
        border-radius: var(--radius-lg);
        background: rgba(8, 8, 8, 0.98);
        border: 1px solid var(--border);
        box-shadow: var(--shadow);
        backdrop-filter: blur(20px);
        transform: translateY(-12px);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: transform 0.22s ease, opacity 0.22s ease, visibility 0.22s ease;
        z-index: 110;
    }

    .app-topbar-actions.is-open {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .app-topbar-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .app-topbar-actions--guest {
        position: static;
        transform: none;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        flex-direction: row;
        padding: 0;
        border: none;
        box-shadow: none;
        background: transparent;
        backdrop-filter: none;
    }

    .app-topbar-actions--guest .btn {
        width: auto;
    }

    .app-main {
        padding: var(--space-4) 0 calc(var(--space-8) + env(safe-area-inset-bottom));
    }

    .app-card {
        padding: var(--space-5) var(--space-4);
        border-radius: var(--radius-md);
        box-shadow: none;
    }

    .app-card--narrow,
    .app-card--wide,
    .app-card--step {
        max-width: none;
    }

    /* ── Page header & forms ── */
    .page-header {
        margin-bottom: 22px;
    }

    .page-header-icon {
        width: 48px;
        height: 48px;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .page-header .subtitle {
        font-size: 0.88rem;
    }

    .form-control,
    .form-input,
    .step-field-card input:not([type="file"]),
    .step-field-card select,
    .jalali-trigger,
    .spicker-trigger {
        min-height: 52px;
        font-size: 16px;
        padding: 14px 16px;
    }

    .form-label,
    .form-group label,
    .step-field-card label {
        font-size: 0.88rem;
        margin-bottom: 10px;
    }

    .otp-digit,
    .code-input {
        width: 52px;
        height: 58px;
        font-size: 1.35rem;
    }

    /* ── Step progress ── */
    .step-progress {
        margin-bottom: 20px;
        padding-bottom: 16px;
    }

    .step-progress-track {
        justify-content: flex-start;
        gap: 0;
        padding: 4px 2px 8px;
        scroll-snap-type: x mandatory;
    }

    .step-progress-item {
        scroll-snap-align: center;
        min-width: 56px;
    }

    .step-progress-dot {
        width: 36px;
        height: 36px;
        font-size: 0.78rem;
    }

    .step-progress-label {
        font-size: 0.62rem;
    }

    .step-progress-line {
        min-width: 10px;
        max-width: 24px;
        margin-top: 18px;
    }

    .step-head {
        margin-bottom: var(--space-5);
    }

    .step-head h2 {
        font-size: 1.2rem;
    }

    .step-head p {
        font-size: 0.85rem;
    }

    .step-alert {
        padding: var(--space-3) var(--space-4);
        font-size: 0.85rem;
    }

    .step-option {
        padding: 22px 16px;
    }

    .saved-panel {
        padding: var(--space-3) var(--space-4);
    }

    .saved-grid {
        grid-template-columns: 1fr 1fr;
    }

    .app-page--step .step-body {
        padding-bottom: 4px;
    }

    /* Sticky step actions */
    .app-page--step .step-actions {
        position: sticky;
        bottom: 0;
        z-index: 30;
        margin: 20px calc(-1 * var(--space-4)) calc(-1 * var(--space-5));
        padding: 10px var(--space-4) calc(10px + env(safe-area-inset-bottom));
        background: rgba(8, 8, 8, 0.94);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
    }

    .step-actions .btn-prev,
    .step-actions .btn-next {
        min-height: 50px;
        font-size: 0.95rem;
    }

    /* ── Dashboard ── */
    .dash-hero,
    .dash-status {
        padding: var(--space-5) var(--space-4);
    }

    .dash-grid {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

    .dash-card {
        padding: var(--space-4);
    }

    .dash-card .value {
        font-size: 0.95rem;
    }

    .dash-actions {
        flex-direction: column;
        gap: var(--space-2);
    }

    .dash-actions .btn {
        width: 100%;
        min-width: 0;
    }

    /* ── Modals & pickers (mobile bottom sheet only) ── */
    .step-modal,
    .admin-modal {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

@media (max-width: 639px) {
    .jalali-popup,
    .spicker-popup,
    .admin-modal-shell {
        border-radius: 16px;
        max-height: min(92dvh, 640px);
        width: min(100%, 100%);
    }

    .step-modal-box {
        width: min(100%, 100%);
        max-height: calc(100dvh - max(12px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom)));
    }

    .contract-card-modal-box {
        max-height: min(90dvh, 600px);
    }

    .step-confirm-grid {
        gap: 8px;
    }

    .step-confirm-item {
        padding: 12px 14px;
    }
}

@media (max-width: 768px) {
    .capacity-banner,
    .capacity-compact {
        font-size: 0.82rem;
    }

    /* ── Admin ── */
    .admin-topbar {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .admin-login-wrap {
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .admin-login-card {
        padding: 28px 20px;
    }

    .admin-table-wrap {
        margin: 0 -12px;
        border-radius: 0;
    }

    /* ── Landing sticky CTA ── */
    .mobile-sticky-cta {
        display: flex;
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom));
        z-index: 90;
        padding: 0;
        animation: mobile-cta-in 0.4s ease;
    }

    .mobile-sticky-cta .btn {
        width: 100%;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    }

    .landing-page {
        padding-bottom: calc(72px + env(safe-area-inset-bottom));
    }

    @keyframes mobile-cta-in {
        from { opacity: 0; transform: translateY(16px); }
        to { opacity: 1; transform: translateY(0); }
    }
}

@media (max-width: 480px) {
    .container {
        width: min(100% - 20px, var(--container));
    }

    .hero-stats {
        gap: 10px;
    }

    .saved-grid {
        grid-template-columns: 1fr;
    }

    .plan-highlights {
        grid-template-columns: 1fr;
    }

    .otp-box,
    .code-box {
        gap: 8px;
    }

    .otp-digit,
    .code-input {
        width: 46px;
        height: 54px;
        font-size: 1.2rem;
    }

    .step-progress-label {
        display: none;
    }

    .step-progress-item.active .step-progress-label {
        display: block;
    }
}

@media (max-width: 768px) and (hover: none) {
    .feature-card:hover,
    .dash-card:hover,
    .stat-card:hover,
    .step-option:hover {
        transform: none;
    }

    .btn-primary:hover {
        transform: none;
    }
}
