.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.glass-card {
    background: var(--color-glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--color-glass-border);
}

.ai-pulse {
    animation: pulse-glow 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.conversation-scroll::-webkit-scrollbar { width: 4px; }
.conversation-scroll::-webkit-scrollbar-track { background: transparent; }
.conversation-scroll::-webkit-scrollbar-thumb { background: var(--color-scrollbar); border-radius: 10px; }

.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 16px); }
.safe-top    { padding-top:    env(safe-area-inset-top,    0px);  }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    min-height: 100dvh;
    overscroll-behavior-y: auto;
}

html {
    scroll-behavior: smooth;
}

/* ─── Client dashboard layout (fixed sidebar + scrolling main) ─── */
body.client-app {
    min-height: 100dvh;
    background-color: var(--color-app-bg);
    overflow-x: hidden;
    overflow-y: visible;
}

html.app-shell-root body.client-app {
    overflow-x: hidden;
    overflow-y: visible;
    max-width: none;
}

.client-layout {
    width: 100%;
    min-height: 100dvh;
}

/* Desktop sidebar — fixed, never scrolls away */
.client-sidebar {
    display: none;
    flex-direction: column;
    width: 16rem;
    background: var(--color-sidebar-bg);
    border-right: 1px solid var(--color-sidebar-border);
    color: var(--color-sidebar-text, var(--color-on-surface));
}

@media (min-width: 768px) {
    .client-sidebar {
        display: flex;
        position: fixed;
        left: 0;
        top: 0;
        z-index: 40;
        height: 100dvh;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

.client-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--color-sidebar-border);
    flex-shrink: 0;
    overflow: visible;
    min-height: 4.5rem;
}

.client-sidebar-brand .brand-logo-img--sidebar {
    height: 2.5rem;
    width: auto;
    max-width: 100%;
    min-width: 0;
    object-fit: contain;
    object-position: left center;
}

.client-sidebar-nav {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.client-sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--color-sidebar-border);
}

.client-sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 12px;
    color: var(--color-sidebar-muted);
    text-decoration: none;
    font-family: 'Google Sans Flex', Inter, system-ui, sans-serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    transition: background 0.15s, color 0.15s;
}

.client-sidebar-link .material-symbols-outlined {
    color: inherit;
    opacity: 0.95;
    font-size: 22px;
}

.client-sidebar-link:hover {
    background: var(--color-nav-hover);
    color: var(--color-sidebar-text, var(--color-on-surface));
}

.client-sidebar-link.is-active {
    background: var(--color-nav-active-bg);
    color: var(--color-nav-active-text);
}

.client-sidebar-link--logout {
    color: #ffb4ab;
}

.client-sidebar-link--logout:hover {
    background: var(--color-nav-logout-hover);
}

.conv-media-img {
    display: block;
    max-width: min(100%, 280px);
}

.conv-voice-player {
    height: 36px;
}

.conv-media-placeholder {
    opacity: 0.85;
}

/* Bottom navigation — Material 3 style (client mobile + admin) */
.app-bottom-nav,
#client-mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    min-height: 64px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--color-nav-bg);
    border-top: 1px solid var(--color-nav-border);
    box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.04);
}

@media (min-width: 768px) {
    .app-bottom-nav,
    #client-mobile-nav {
        display: none !important;
    }
}

/* Main content column — offset for fixed sidebar */
.client-main {
    min-width: 0;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .client-main {
        margin-left: 16rem;
        width: auto;
    }
}

@media (max-width: 767px) {
    .client-main {
        padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
    }
}

.client-main--form .client-inner {
    padding-bottom: 3rem;
}

.client-inner {
    width: 100%;
    max-width: 72rem;
    margin-left: auto;
    margin-right: auto;
    padding: 0 1rem 2.5rem;
    box-sizing: border-box;
    overflow-wrap: anywhere;
}

@media (min-width: 768px) {
    .client-inner {
        padding: 0 1.5rem 2.5rem;
    }
}

.client-inner--narrow {
    max-width: 44rem;
}

.client-inner--wide {
    max-width: 76rem;
}

.client-inner--full {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
}

.client-main--chat {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    padding-bottom: 0;
    min-width: 0;
    overflow-x: hidden;
}

.client-main--chat > .client-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: none;
    padding: 0;
    min-height: 0;
}

.client-chat-frame {
    display: grid;
    grid-template-rows: auto 1fr auto;
    flex: 1;
    min-height: 0;
    min-width: 0;
    width: 100%;
    overflow: hidden;
}

.client-chat-body {
    display: flex;
    flex-direction: row;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.client-lead-intel {
    max-height: 100%;
}

/* Chat view: lock viewport so thread scrolls internally (fixes empty/white mobile thread) */
body.client-chat-view {
    overflow: hidden;
    height: 100dvh;
    max-height: 100dvh;
}

body.client-chat-view .client-layout {
    height: 100dvh;
    overflow: hidden;
}

body.client-chat-view .client-main--chat {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

body.client-chat-view .client-main--chat > .client-inner {
    height: 100%;
    min-height: 0;
}

body.client-chat-view .client-chat-frame {
    height: 100%;
    min-height: 0;
}

body.client-chat-view #client-mobile-nav {
    display: none !important;
}

#conversation-thread.conversation-thread {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 1rem;
    padding-bottom: 1.5rem;
    background: var(--color-surface-container-low, #f3f4f6);
}

@media (min-width: 768px) {
    body.client-chat-view #client-mobile-nav {
        display: none !important;
    }

    .client-chat-frame {
        min-height: 100dvh;
    }
}

@media (max-width: 767px) {
    .client-main--chat {
        padding-bottom: 0;
    }
}

.client-page-header {
    position: sticky;
    top: 0;
    z-index: 30;
    padding: max(0.875rem, env(safe-area-inset-top, 0px)) 0 0.75rem;
    margin: 0 0 0.75rem;
    background: var(--color-header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-header-border);
}

.client-page-header__row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.client-page-header__main {
    flex: 1;
    min-width: 0;
}

.client-page-header__title {
    font-family: 'Google Sans Flex', Inter, system-ui, sans-serif;
    font-size: 1.375rem;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--color-on-surface);
    margin: 0;
}

.client-page-header__subtitle {
    margin: 4px 0 0;
    font-size: 0.875rem;
    line-height: 1.35;
    color: var(--color-subtitle);
}

.client-page-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding-top: 2px;
}

.client-mobile-menu-btn {
    position: relative;
    z-index: 10052;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--color-icon-btn-border);
    background: var(--color-icon-btn-bg);
    color: var(--color-on-surface-variant);
    box-shadow: 0 1px 3px var(--color-card-shadow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, background 0.15s ease;
}

.client-mobile-menu-btn:active {
    transform: scale(0.94);
}

.client-mobile-menu-btn .material-symbols-outlined {
    font-size: 22px;
}

.client-mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10050;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.client-mobile-menu-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.client-mobile-menu-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: auto;
    width: min(88vw, 300px);
    height: auto;
    max-height: 100dvh;
    z-index: 10051;
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    border-right: 1px solid var(--color-sidebar-border);
    transform: translateX(-105%);
    transition: transform 0.28s ease;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top, 0px);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    overflow: hidden;
}

.client-mobile-menu-drawer.open {
    transform: translateX(0);
    pointer-events: auto;
}

.client-mobile-menu-drawer .client-mobile-menu-btn {
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-sidebar-text);
    box-shadow: none;
}

.client-mobile-menu-drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 14px 12px;
    border-bottom: 1px solid var(--color-sidebar-border);
    flex-shrink: 0;
}

.client-mobile-menu-drawer__head .brand-logo-img--sidebar {
    height: 2.25rem;
    max-width: 100%;
}

.client-mobile-menu-drawer__body {
    flex: 0 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px 8px;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 8.5rem);
    -webkit-overflow-scrolling: touch;
}

.client-mobile-menu-drawer__foot {
    flex-shrink: 0;
    padding: 6px 8px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--color-sidebar-border);
}

.client-mobile-menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 12px;
    color: var(--color-sidebar-muted);
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.client-mobile-menu-link .material-symbols-outlined {
    font-size: 22px;
    color: inherit;
    opacity: 0.95;
}

.client-mobile-menu-link.is-active {
    background: var(--color-nav-active-bg);
    color: var(--color-nav-active-text);
}

.client-mobile-menu-link.is-active .material-symbols-outlined {
    color: inherit;
}

.client-mobile-menu-link:active {
    background: var(--color-nav-hover);
    color: var(--color-sidebar-text);
}

.client-mobile-menu-link__badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-sidebar-muted);
}

.client-mobile-menu-link--logout {
    color: #ffb4ab;
}

.client-mobile-menu-link--logout .material-symbols-outlined {
    color: #ffb4ab;
}

.client-mobile-menu-link--logout:active {
    background: var(--color-nav-logout-hover);
}

@media (min-width: 768px) {
    .client-mobile-menu-overlay,
    .client-mobile-menu-drawer {
        display: none !important;
    }
}

.theme-toggle--client {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--color-icon-btn-border);
    background: var(--color-icon-btn-bg);
    color: var(--color-on-surface-variant);
    box-shadow: 0 1px 3px var(--color-card-shadow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, background 0.15s ease;
}

.theme-toggle--client:active {
    transform: scale(0.94);
}

.theme-toggle--client .material-symbols-outlined {
    font-size: 22px;
}

@media (min-width: 768px) {
    .client-page-header {
        padding: 1rem 0;
    }

    .client-page-header__title {
        font-size: 1.75rem;
    }
}

/* Sticky save bar (bot setup) — stays inside main column */
.client-save-bar {
    position: sticky;
    bottom: 0;
    z-index: 25;
    margin-top: 1.5rem;
    margin-left: -1rem;
    margin-right: -1rem;
    padding: 12px 1rem;
    background: var(--color-save-bar-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--color-save-bar-border);
}

@media (min-width: 768px) {
    .client-save-bar {
        margin-left: -1.5rem;
        margin-right: -1.5rem;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
        bottom: 0;
    }
}

@media (max-width: 767px) {
    .client-save-bar {
        bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
    }
}

/* @deprecated — use .client-save-bar */
.client-bottom-bar {
    position: sticky;
    z-index: 25;
    margin-top: 1.5rem;
    padding: 12px 0;
    background: rgba(248, 249, 250, 0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(225, 227, 228, 0.6);
}

/* Floating action button */
.client-fab {
    position: fixed;
    z-index: 90;
    right: 1rem;
    bottom: calc(4.5rem + 1rem + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
    .client-fab {
        right: 1.5rem;
        bottom: 1.5rem;
    }
}

.client-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.client-stat-grid:has(> :nth-child(5):last-child) {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.5rem;
}

.client-stat-grid:has(> :nth-child(5):last-child) > :nth-child(-n+3) {
    grid-column: span 2;
}

.client-stat-grid:has(> :nth-child(5):last-child) > :nth-child(4),
.client-stat-grid:has(> :nth-child(5):last-child) > :nth-child(5) {
    grid-column: span 3;
}

.client-stat-grid--6,
.client-stat-grid:has(> :nth-child(6):last-child) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

@media (min-width: 1024px) {
    .client-stat-grid:not(:has(> :nth-child(5):last-child)):not(:has(> :nth-child(6):last-child)) {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .client-stat-grid:has(> :nth-child(5):last-child) {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 0.75rem;
    }

    .client-stat-grid--6,
    .client-stat-grid:has(> :nth-child(6):last-child) {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 0.75rem;
    }
}

.client-plan-grid {
    display: grid;
    gap: 1rem;
    align-items: stretch;
}

@media (min-width: 768px) {
    .client-plan-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.client-plan-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
}

.client-plan-card-top {
    flex: 1 1 auto;
}

.client-plan-card-action {
    margin-top: auto;
    padding-top: 1rem;
}

/* Legacy class aliases */
.client-fixed-bar {
    position: fixed;
    z-index: 30;
}

body.app-shell .app-scroll-main {
    min-height: 100dvh;
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    body.app-shell .app-scroll-main {
        margin-left: 16rem;
    }
}

* {
    -webkit-tap-highlight-color: transparent;
}

button, a, [role="button"] {
    touch-action: manipulation;
}

nav, .bottom-nav {
    user-select: none;
    -webkit-user-select: none;
}

.toast-container {
    position: fixed;
    top: env(safe-area-inset-top, 16px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: calc(100% - 32px);
    max-width: 400px;
}

.toast {
    pointer-events: auto;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-family: 'Google Sans Flex', Inter, system-ui, sans-serif;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    animation: toast-in 0.3s ease;
}

.toast-success { background: #4aad36; color: #ffffff; }
.toast-error   { background: #ffdad6; color: #93000a; }
.toast-info    { background: var(--color-toast-info-bg); color: var(--color-toast-info-text); }

html.dark .toast-error {
    background: var(--color-error-container);
    color: var(--color-on-error-container);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.bottom-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.bottom-sheet-overlay.open {
    opacity: 1;
    visibility: visible;
}

.iqp-confirm {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}
.iqp-confirm__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.38);
}
.iqp-confirm__card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 22px 22px 18px;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.16);
}
.iqp-confirm__title {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    color: #0f172a;
}
.iqp-confirm__body {
    margin: 0 0 20px;
    font-size: 13.5px;
    line-height: 1.55;
    color: #64748b;
}
.iqp-confirm__actions {
    display: flex;
    gap: 10px;
}
.iqp-confirm__btn {
    flex: 1;
    height: 44px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}
.iqp-confirm__btn--cancel {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #334155;
}
.iqp-confirm__btn--ok {
    background: #1FA855;
    border: 0;
    color: #ffffff;
}
.iqp-confirm__btn--danger {
    background: #dc2626;
    border: 0;
    color: #ffffff;
}
html.dark .iqp-confirm__backdrop,
html.client-dark .iqp-confirm__backdrop {
    background: rgba(2, 6, 23, 0.5);
}
html.dark .iqp-confirm__card,
html.client-dark .iqp-confirm__card {
    background: #1e293b;
    border-color: #334155;
}
html.dark .iqp-confirm__title,
html.client-dark .iqp-confirm__title {
    color: #f8fafc;
}
html.dark .iqp-confirm__body,
html.client-dark .iqp-confirm__body {
    color: #94a3b8;
}
html.dark .iqp-confirm__btn--cancel,
html.client-dark .iqp-confirm__btn--cancel {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-sheet-bg);
    border-radius: 16px 16px 0 0;
    z-index: 101;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    max-height: 85vh;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 16px);
}

.bottom-sheet.open {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--color-sheet-handle);
    border-radius: 9999px;
    margin: 12px auto;
}

/* Auth / onboarding flows — mobile-first, responsive on tablet & desktop */
.plan-card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    width: 100%;
}

@media (min-width: 640px) {
    .plan-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .plan-card-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.plan-card-option {
    min-width: 0;
}

.auth-flow-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 30;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    background: rgba(248, 249, 250, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(187, 203, 185, 0.6);
}

.auth-flow-footer-inner {
    width: 100%;
    margin: 0 auto;
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.auth-flow-footer-inner .flex-1,
.auth-flow-footer-inner button[type="submit"],
.auth-flow-footer-inner > button {
    min-height: 56px;
}

.question-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@media (min-width: 480px) {
    .question-row {
        flex-direction: row;
        align-items: stretch;
    }

    .question-row select {
        width: auto;
        min-width: 9rem;
        flex-shrink: 0;
    }
}

.onboarding-channel-card {
    display: block;
    width: 100%;
}

.onboarding-channel-card input[type="radio"] {
    vertical-align: middle;
    margin-right: 8px;
}

/* ─── Mobile app shell (admin + client dashboards) ─── */
html.app-shell-root,
html.app-shell-root body {
    overflow-x: hidden;
    max-width: 100vw;
}

.app-shell {
    overflow-x: hidden;
    max-width: 100vw;
}

.app-main {
    overflow-x: hidden;
    max-width: 100vw;
}

@media (max-width: 767px) {
    .app-main {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }

    .app-header {
        padding-top: max(12px, env(safe-area-inset-top, 0px));
        padding-right: 56px; /* notification bell */
    }

    body.admin-app .app-header,
    body.admin-app .app-header-tight {
        padding-top: 0.75rem;
        padding-right: 1rem;
    }

    .app-header-tight {
        padding-right: 56px;
    }

    .app-headline {
        font-size: 22px;
        line-height: 28px;
        font-weight: 700;
        letter-spacing: -0.02em;
    }

    .app-subhead {
        font-size: 13px;
        line-height: 18px;
    }

    .stat-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .stat-card {
        min-width: 0;
    }

    .stat-card .stat-value {
        font-size: 24px;
        line-height: 28px;
    }

    .quick-actions-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .quick-actions-grid a {
        justify-content: center;
        text-align: center;
        font-size: 13px;
        min-height: 44px;
    }
}

.app-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 2px 6px;
    color: var(--color-nav-link);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    min-width: 0;
}

.app-nav-link:active {
    opacity: 0.85;
}

.app-nav-icon-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.app-nav-link .material-symbols-outlined {
    font-size: 22px;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.app-nav-link.active {
    color: var(--color-nav-active-text);
}

.app-nav-link.active .material-symbols-outlined {
    color: var(--color-nav-active-text);
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.app-nav-label {
    font-family: 'Google Sans Flex', Inter, system-ui, sans-serif;
    font-size: 10px;
    font-weight: 600;
    line-height: 12px;
    letter-spacing: 0.02em;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-bell-root--inline {
    position: relative;
    flex-shrink: 0;
}

.notification-bell-root--admin {
    position: relative;
    flex-shrink: 0;
}

.notification-bell-root--fixed {
    position: fixed;
    top: max(12px, env(safe-area-inset-top, 0px));
    right: 12px;
    left: auto;
    z-index: 55;
}

@media (min-width: 768px) {
    .notification-bell-root--fixed {
        top: 1rem;
        right: 1.5rem;
    }
}

.notification-bell-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--color-icon-btn-border);
    background: var(--color-icon-btn-bg);
    color: var(--color-on-surface-variant);
    box-shadow: 0 1px 3px var(--color-card-shadow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.notification-bell-btn:active {
    transform: scale(0.94);
}

.notification-bell-btn .material-symbols-outlined {
    font-size: 22px;
}

.notification-bell-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: #ba1a1a;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--color-app-bg);
}

.notification-bell-badge.hidden {
    display: none;
}

.notification-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(calc(100vw - 2rem), 360px);
    background: var(--color-surface-container-lowest);
    border: 1px solid var(--color-outline-variant);
    border-radius: 16px;
    box-shadow: 0 8px 32px var(--color-card-shadow);
    overflow: hidden;
    z-index: 60;
}

.notification-panel.hidden {
    display: none;
}

.notification-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-panel-divider);
    background: var(--color-panel-head);
}

.notification-panel__mark-all {
    border: none;
    background: none;
    color: var(--color-nav-active-text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
}

.notification-panel__list {
    max-height: 320px;
    overflow-y: auto;
}

.notification-panel__footer {
    display: block;
    text-align: center;
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-nav-active-text);
    border-top: 1px solid var(--color-panel-divider);
    text-decoration: none;
}

.notification-panel__footer:hover {
    background: var(--color-surface-container-low);
}

.client-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.btn-icon-sm {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-icon-btn-border);
    background: var(--color-icon-btn-bg);
    color: var(--color-on-surface-variant);
}

.btn-icon-sm.danger {
    border-color: var(--color-danger-zone-border);
    background: var(--color-danger-zone-bg);
    color: #ba1a1a;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

/* 5-stat grids: 3 + 2 rows (see design-v2.css for full rules) */
.stat-grid:has(> :nth-child(5):last-child) {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
}

.stat-grid:has(> :nth-child(5):last-child) > :nth-child(-n+3) {
    grid-column: span 2;
}

.stat-grid:has(> :nth-child(5):last-child) > :nth-child(4),
.stat-grid:has(> :nth-child(5):last-child) > :nth-child(5) {
    grid-column: span 3;
}

.stat-card {
    min-width: 0;
}

.danger-zone {
    border: 1px solid var(--color-danger-zone-border);
    background: var(--color-danger-zone-bg);
    border-radius: 16px;
    padding: 16px;
}

@media (min-width: 768px) {
    .stat-grid:not(:has(> :nth-child(5):last-child)) {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .app-headline {
        font-size: 28px;
        line-height: 36px;
    }
}

/* ─── Client mobile app — Material 3 polish ─── */
body.client-app {
    background: var(--color-app-bg);
    -webkit-font-smoothing: antialiased;
}

.client-app .client-main {
    background: var(--color-app-bg);
}

.client-app .bg-surface-container-lowest.rounded-2xl.border,
.client-app .client-card {
    background: var(--color-surface-container-lowest);
    border: none !important;
    border-radius: 16px;
    box-shadow: 0 1px 2px var(--color-card-shadow), 0 4px 16px var(--color-card-shadow);
}

html.dark .client-app .bg-surface-container-lowest.rounded-2xl.border,
html.dark .client-app .client-card,
html.dark .client-stat-grid > div {
    border: 1px solid var(--color-outline-variant) !important;
    box-shadow: none;
}

.client-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4aad36 0%, #6bc956 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(74, 173, 54, 0.25);
}

.client-segment-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px;
    background: var(--color-segment-track);
    border-radius: 14px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.client-segment-tabs::-webkit-scrollbar {
    display: none;
}

.client-segment-tab {
    flex: 1 0 auto;
    min-width: 0;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--color-subtitle);
    font-family: 'Google Sans Flex', Inter, system-ui, sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.client-segment-tab.is-active {
    background: var(--color-surface-container-lowest);
    color: var(--color-nav-active-text);
    box-shadow: 0 1px 4px var(--color-card-shadow);
}

.client-app input[type="text"],
.client-app input[type="email"],
.client-app input[type="password"],
.client-app input[type="search"],
.client-app input[type="url"],
.client-app input[type="tel"],
.client-app textarea,
.client-app select {
    background: var(--color-surface-container) !important;
    border: 1px solid transparent !important;
    border-radius: 12px !important;
    color: var(--color-on-surface) !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.client-app input:focus,
.client-app textarea:focus,
.client-app select:focus {
    border-color: rgba(74, 173, 54, 0.35) !important;
    box-shadow: 0 0 0 3px rgba(74, 173, 54, 0.12) !important;
    outline: none;
}

.client-app label.text-label-sm,
.client-app .font-label.uppercase {
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--color-subtitle);
}

.client-app .rounded-full.font-label.text-label-sm {
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    border: none;
    background: var(--color-surface-container);
    color: var(--color-subtitle);
}

.client-app a.rounded-full.font-label.text-label-sm.bg-primary-container,
.client-app .rounded-full.bg-primary-container.text-on-primary-container {
    background: #4aad36 !important;
    color: #1c1104 !important;
}

.client-app button[type="submit"].bg-primary,
.client-app .bg-primary.text-on-primary.rounded-xl {
    background: linear-gradient(180deg, #6bc956 0%, #4aad36 100%) !important;
    box-shadow: 0 2px 8px rgba(74, 173, 54, 0.28);
    border: none;
}

.client-stat-grid > div {
    background: var(--color-surface-container-lowest);
    border: none !important;
    box-shadow: 0 1px 2px var(--color-card-shadow), 0 4px 16px var(--color-card-shadow);
}

.client-usage-bar {
    height: 0.5rem;
    width: 100%;
    background: var(--color-surface-container);
    border-radius: 9999px;
    overflow: hidden;
}

.client-usage-bar__fill {
    display: block;
    height: 100%;
    max-width: 100%;
    background: var(--color-primary, #4aad36);
    border-radius: 9999px;
    transition: width 0.25s ease;
}

#client-mobile-nav.app-bottom-nav {
    background: color-mix(in srgb, var(--color-nav-bg) 96%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--color-nav-border);
    box-shadow: 0 -4px 24px var(--color-nav-shadow);
}

.login-remember-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.login-remember-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #4aad36;
}

.login-remember-row label {
    font-size: 14px;
    color: var(--color-subtitle);
    cursor: pointer;
}

.theme-option-btn.is-active {
    border-color: #6bc956;
    background: color-mix(in srgb, #6bc956 14%, var(--color-surface-container));
    color: var(--color-on-surface);
}

html.dark .theme-option-btn.is-active {
    color: #6bc956;
}

/* ─── Order pipeline kanban ─── */
.orders-kanban {
    display: grid;
    grid-template-columns: repeat(4, minmax(220px, 1fr));
    gap: 12px;
    align-items: start;
    overflow-x: auto;
    padding-bottom: 8px;
}

@media (max-width: 1023px) {
    .orders-kanban {
        grid-template-columns: repeat(4, minmax(260px, 1fr));
    }
}

.kanban-column {
    background: var(--color-surface-container-low);
    border: 1px solid var(--color-outline-variant);
    border-radius: 16px;
    min-height: 320px;
    display: flex;
    flex-direction: column;
}

.kanban-column__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-outline-variant);
}

.kanban-column__count {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    background: var(--color-surface-container-highest);
    padding: 2px 8px;
    border-radius: 999px;
}

.kanban-column__body {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kanban-empty {
    padding: 16px 8px;
    text-align: center;
}

.kanban-card {
    background: var(--color-surface-container-lowest);
    border: 1px solid var(--color-outline-variant);
    border-radius: 14px;
    padding: 12px;
}

.kanban-card__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.kanban-card__items {
    margin: 6px 0 0;
    padding-left: 16px;
}

.kanban-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.kanban-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--color-outline-variant);
    background: var(--color-surface-container);
    color: var(--color-on-surface);
    text-decoration: none;
    cursor: pointer;
}

.kanban-btn--primary {
    background: var(--color-primary);
    color: var(--color-on-primary);
    border-color: transparent;
}

.kanban-btn:active {
    transform: scale(0.97);
}

.kanban-card--dragging {
    opacity: 0.55;
    transform: scale(0.98);
}

.kanban-card--ghost {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    opacity: 0.95;
}

.kanban-card--busy {
    opacity: 0.6;
    pointer-events: none;
}

.kanban-column__body--over {
    outline: 2px dashed var(--color-primary);
    outline-offset: -4px;
    background: color-mix(in srgb, var(--color-primary) 6%, transparent);
}

@media (max-width: 767px) {
    .kanban-card {
        touch-action: none;
        cursor: grab;
    }

    .kanban-card:active {
        cursor: grabbing;
    }
}

/* ─── Admin panel: sidebar, flash messages, readable hints ─── */
.admin-sidebar {
    width: 16rem;
    max-width: 16rem;
    overflow: hidden;
    height: 100dvh;
    max-height: 100dvh;
}

.admin-sidebar-body {
    -webkit-overflow-scrolling: touch;
}

.admin-sidebar-footer {
    margin-top: 0.5rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
}

.admin-sidebar-icon,
.admin-section-icon {
    font-size: 22px !important;
    width: 22px;
    height: 22px;
    line-height: 22px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.admin-sidebar-link {
    max-width: 100%;
}

.admin-sidebar-logout {
    color: #ffb4ab !important;
}

.admin-sidebar-logout:hover {
    background: rgba(255, 180, 171, 0.12) !important;
}

.admin-sidebar-logout .admin-sidebar-icon {
    color: inherit;
}

/* Admin mobile top bar + sidebar drawer */
.admin-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 56;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: max(8px, env(safe-area-inset-top, 0px)) 12px 8px;
    background: var(--color-app-bg);
    border-bottom: 1px solid var(--color-outline-variant);
}

.admin-toolbar__brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.admin-toolbar__title {
    font-family: var(--font-headline, inherit);
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-toolbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.admin-sidebar-toggle {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--color-icon-btn-border);
    background: var(--color-icon-btn-bg);
    color: var(--color-on-surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.admin-sidebar-toggle .material-symbols-outlined {
    font-size: 24px;
}

.admin-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 48;
    background: rgba(0, 0, 0, 0.45);
}

.admin-sidebar-overlay.is-open {
    display: block;
}

@media (max-width: 767px) {
    body.admin-app {
        padding-top: calc(56px + env(safe-area-inset-top, 0px));
    }

    .admin-sidebar {
        display: flex !important;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        z-index: 50;
    }

    .admin-sidebar.is-open {
        transform: translateX(0);
        z-index: 10001;
    }

    body.admin-app:has(.admin-sidebar.is-open) .app-bottom-nav,
    body.admin-app.admin-sidebar-open .app-bottom-nav {
        visibility: hidden;
        pointer-events: none;
    }

    .admin-toolbar .notification-panel {
        position: fixed;
        top: calc(56px + env(safe-area-inset-top, 0px) + 8px);
        right: 12px;
        left: auto;
    }
}

@media (min-width: 768px) {
    .admin-toolbar {
        left: 16rem;
        background: transparent;
        border-bottom: none;
        justify-content: flex-end;
        min-height: 0;
        padding: 1rem 1.5rem 0;
        pointer-events: none;
    }

    .admin-toolbar__brand,
    .admin-sidebar-toggle {
        display: none;
    }

    .admin-toolbar__actions {
        pointer-events: auto;
    }

    .admin-sidebar {
        display: flex !important;
    }

    body.admin-app {
        padding-top: 0;
    }
}

.app-flash {
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.app-flash-success {
    background: rgba(74, 173, 54, 0.14);
    border: 1px solid rgba(74, 173, 54, 0.45);
    color: var(--color-on-surface);
}

html.dark .app-flash-success {
    background: rgba(74, 173, 54, 0.18);
    border-color: rgba(107, 201, 86, 0.58);
    color: #ecf7ea;
}

.app-flash-error {
    background: var(--color-error-container);
    border: 1px solid rgba(186, 26, 26, 0.35);
    color: var(--color-on-error-container);
}

html.dark .app-flash-error {
    border-color: rgba(255, 180, 171, 0.35);
}

/* Legacy admin success banners — still used on some pages */
html.dark .app-shell .bg-primary-container\/20.border-primary.text-on-primary-container {
    background: rgba(74, 173, 54, 0.18) !important;
    border-color: rgba(107, 201, 86, 0.58) !important;
    color: #ecf7ea !important;
}

.admin-meta-text {
    font-size: 13px;
    line-height: 1.55;
    color: var(--color-on-surface-variant);
}

html.dark .admin-meta-text {
    color: #c8cdd6;
}

.admin-meta-text code,
.admin-settings-list code {
    word-break: break-word;
    font-size: 12px;
}

.admin-warning-box {
    background: rgba(186, 26, 26, 0.08);
    border: 1px solid rgba(186, 26, 26, 0.28);
}

html.dark .admin-warning-box {
    background: rgba(255, 180, 171, 0.08);
    border-color: rgba(255, 180, 171, 0.28);
}

html.dark .admin-warning-box .text-on-surface-variant,
html.dark .admin-warning-box .admin-meta-text {
    color: #f3d4d1;
}

/* Shipment tracking */
.shipment-card-meta {
    margin-top: 8px;
    padding: 8px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--color-secondary) 8%, transparent);
    border: 1px solid var(--color-outline-variant);
}

.shipment-card-meta__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.shipment-courier-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--color-surface-container-high);
}

.shipment-tracking-line {
    font-family: ui-monospace, monospace;
    word-break: break-all;
}

.shipment-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.shipment-modal[hidden] {
    display: none !important;
}

.shipment-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.shipment-modal__panel {
    position: relative;
    width: min(520px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: var(--color-surface-container-lowest);
    border: 1px solid var(--color-outline-variant);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
}

.shipment-modal__panel--sm {
    width: min(420px, 100%);
}

.shipment-modal__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.shipment-modal__close {
    border: none;
    background: transparent;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: var(--color-on-surface-variant);
}

.shipment-timeline__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.shipment-timeline__item {
    position: relative;
    padding-left: 24px;
    padding-bottom: 16px;
    border-left: 2px solid var(--color-outline-variant);
    margin-left: 8px;
}

.shipment-timeline__item:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.shipment-timeline__dot {
    position: absolute;
    left: -7px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid var(--color-surface-container-lowest);
}

.admin-settings-list {
    overflow-wrap: anywhere;
}

.app-main.max-w-2xl,
.app-main .max-w-2xl {
    min-width: 0;
}

.password-field {
    position: relative;
}

.password-field [data-password-input] {
    padding-right: 3rem !important;
}

.password-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: transparent;
    color: var(--color-outline);
    cursor: pointer;
    border-radius: 9999px;
}

.password-toggle:active {
    opacity: 0.7;
}

/* ─── Auth pages (login, register) — compact professional forms ─── */
.auth-page {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--color-background);
    color: var(--color-on-surface);
}

.auth-page__theme {
    position: absolute;
    top: 0;
    right: 0;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top, 0px));
    z-index: 10;
}

.auth-page__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top, 0px));
}

.auth-page__main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px;
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
}

.auth-card {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 28px 24px 24px;
    background: var(--color-surface-container-lowest);
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-card-lg, 24px);
    box-shadow: var(--shadow-card);
}

@media (min-width: 640px) {
    .auth-card {
        padding: 32px 28px 28px;
    }
}

.auth-card__logo {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.auth-card__footer {
    margin-top: 20px;
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-on-surface-variant);
}

.auth-card__footer a {
    color: var(--color-accent-dim, #3d9430);
    font-weight: 600;
    text-decoration: none;
}

.auth-card__footer a:hover {
    text-decoration: underline;
}

.auth-card__note {
    margin-top: 10px;
    text-align: center;
    font-size: 13px;
    line-height: 1.45;
    color: var(--color-on-surface-variant);
}

.auth-alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--color-error-container);
    color: var(--color-on-error-container);
    font-size: 14px;
    line-height: 1.45;
}

.auth-alert--lock {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-field__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.auth-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-on-surface);
    letter-spacing: 0.01em;
}

.auth-label-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-accent-dim, #3d9430);
    text-decoration: none;
    flex-shrink: 0;
}

.auth-forgot-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-accent-dim, #3d9430);
    text-decoration: none;
}

.auth-forgot-link:hover {
    color: var(--color-accent, #4aad36);
    text-decoration: underline;
}

.auth-input {
    width: 100%;
    min-width: 0;
    height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--color-outline-variant);
    background: var(--color-surface-container-lowest);
    color: var(--color-on-surface);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.auth-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    height: 44px;
    padding: 0 14px 0 0;
    border-radius: 12px;
    border: 1px solid var(--color-outline-variant);
    background: var(--color-surface-container-lowest);
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-input-group:hover {
    border-color: var(--color-outline);
}

.auth-input-group:focus-within {
    border-color: var(--color-accent, #4aad36);
    box-shadow: 0 0 0 3px rgba(74, 173, 54, 0.14);
}

.auth-input-group__icon {
    flex-shrink: 0;
    padding-left: 14px;
    font-size: 20px;
    line-height: 1;
    color: var(--color-on-surface-variant);
    pointer-events: none;
}

.auth-input--grouped {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-weight: 500;
    font-size: 14px;
}

.auth-input--grouped:focus {
    outline: none;
    border: none;
    box-shadow: none;
}

.auth-input-group--password {
    position: relative;
    padding-right: 3rem;
}

.auth-input-group--password .auth-input--grouped {
    padding-right: 0.25rem;
    font-size: 14px;
}

.auth-input-group--password .auth-input--grouped::placeholder {
    font-size: 0.8125rem;
    font-weight: 500;
}

.auth-input-group--password .password-toggle {
    position: absolute;
    right: 0.375rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
}

.auth-input-group--password .password-toggle .material-symbols-outlined {
    font-size: 1.25rem;
}

.auth-input::placeholder {
    color: var(--color-on-surface-variant);
    font-weight: 500;
    opacity: 0.85;
}

.auth-input--grouped::placeholder {
    font-weight: 500;
}

.auth-input:focus {
    outline: none;
    border-color: var(--color-accent, #4aad36);
    box-shadow: 0 0 0 3px rgba(74, 173, 54, 0.14);
}

.auth-input:-webkit-autofill,
.auth-input:-webkit-autofill:hover,
.auth-input:-webkit-autofill:focus,
.auth-input-group .auth-input:-webkit-autofill,
.auth-input-group .auth-input:-webkit-autofill:hover,
.auth-input-group .auth-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--color-surface-container-lowest) inset;
    -webkit-text-fill-color: var(--color-on-surface);
    caret-color: var(--color-on-surface);
}

.auth-field .password-field [data-password-input] {
    padding-right: 2.75rem !important;
}

.auth-field .password-toggle {
    right: 0.5rem;
    width: 2rem;
    height: 2rem;
}

.auth-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 44px;
    margin-top: 4px;
    border: 1px solid var(--color-outline-variant);
    border-radius: 12px;
    background: var(--color-surface-container-lowest);
    color: var(--color-on-surface);
    font-family: 'Google Sans Flex', Inter, system-ui, sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.auth-submit__icon {
    font-size: 20px;
    line-height: 1;
    color: var(--color-on-surface-variant);
}

.auth-submit--email:hover:not(:disabled) {
    border-color: var(--color-accent, #4aad36);
    background: var(--color-surface-container-low);
}

.auth-submit--email:active:not(:disabled) {
    transform: scale(0.98);
}

.auth-submit:not(.auth-submit--email) {
    height: 48px;
    border: none;
    background: var(--color-accent-dim, #3d9430);
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
}

.auth-submit:not(.auth-submit--email):hover:not(:disabled) {
    background: var(--color-accent, #4aad36);
}

.auth-submit:not(.auth-submit--email):active:not(:disabled) {
    transform: scale(0.98);
}

.auth-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--color-outline-variant);
    background: var(--color-surface-container-lowest);
    color: var(--color-on-surface);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.auth-oauth-btn:hover {
    border-color: var(--color-outline);
}

.auth-oauth-btn--facebook:hover {
    border-color: #1877f2;
}

.auth-oauth-btn:active {
    transform: scale(0.98);
}

.auth-oauth-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-oauth-btn--facebook {
    background: #1877f2;
    border-color: #1877f2;
    color: #ffffff;
}

.auth-oauth-btn--facebook svg {
    color: #ffffff;
}

.auth-oauth-btn--facebook:active {
    background: #166fe5;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
}

.auth-divider__line {
    flex: 1;
    height: 1px;
    background: var(--color-outline-variant);
}

.auth-divider__text {
    font-size: 13px;
    color: var(--color-outline);
}

.auth-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    padding: 2px 0;
}

.auth-checkbox input[type="checkbox"] {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.auth-checkbox span {
    font-size: 14px;
    line-height: 1.4;
    color: var(--color-on-surface-variant);
}

.auth-hero {
    text-align: center;
    margin-bottom: 20px;
}

.auth-hero--left {
    text-align: left;
    margin-bottom: 20px;
}

.auth-hero__eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-outline);
    margin-bottom: 6px;
}

.auth-hero__title {
    font-family: 'Google Sans Flex', Inter, system-ui, sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-on-surface);
    margin: 0 0 8px;
}

.auth-hero__subtitle {
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-on-surface-variant);
    margin: 0;
}

@media (min-width: 640px) {
    .auth-hero__title {
        font-size: 1.625rem;
    }
}

/* ─── Leads page (mobile-first polish) ─── */
.leads-page .client-main {
    overflow-x: hidden;
    max-width: 100%;
}

.leads-page .client-inner {
    padding-top: 0.25rem;
}

.leads-page .client-page-header__actions {
    gap: 6px;
}

.leads-page .client-page-header__actions .btn-icon-sm {
    width: 40px;
    height: 40px;
    border-radius: 12px;
}

.leads-page .client-page-header__actions .btn-icon-sm .material-symbols-outlined {
    font-size: 22px;
}

.leads-page .client-page-header__row {
    align-items: center;
}

.leads-info-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(74, 173, 54, 0.1);
    border: 1px solid rgba(74, 173, 54, 0.28);
}

html.dark .leads-info-banner {
    background: rgba(74, 173, 54, 0.14);
    border-color: rgba(107, 201, 86, 0.35);
}

.leads-info-banner__icon {
    font-size: 20px;
    color: #4aad36;
    flex-shrink: 0;
    margin-top: 1px;
}

.leads-info-banner__text {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--color-on-surface-variant);
}

.leads-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leads-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px;
    background: var(--color-segment-track);
    border-radius: 14px;
}

@media (max-width: 767px) {
    .leads-filter-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
    }

    .leads-filter-tabs::-webkit-scrollbar {
        display: none;
    }
}

.leads-filter-tab {
    flex: 0 0 auto;
    padding: 9px 14px;
    border-radius: 10px;
    font-family: 'Google Sans Flex', Inter, system-ui, sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
    white-space: nowrap;
    color: var(--color-subtitle);
    background: transparent;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.leads-filter-tab.is-active {
    background: var(--color-surface-container-lowest);
    color: var(--color-nav-active-text);
    box-shadow: 0 1px 4px var(--color-card-shadow);
}

.leads-list {
    box-shadow: 0 1px 2px var(--color-card-shadow), 0 4px 16px var(--color-card-shadow);
}

.lead-row__link {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

.lead-row__link:active {
    background: var(--color-surface-container-low);
}

.lead-row__avatar {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--color-secondary-container);
    color: var(--color-on-secondary-container);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Google Sans Flex', Inter, system-ui, sans-serif;
    font-size: 13px;
    font-weight: 700;
}

.lead-row__body {
    flex: 1;
    min-width: 0;
}

.lead-row__top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.lead-row__name {
    margin: 0;
    font-family: 'Google Sans Flex', Inter, system-ui, sans-serif;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lead-row__time {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--color-outline);
}

.lead-row__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.lead-row__channel {
    font-size: 16px;
    color: var(--color-outline);
}

.lead-row__tag {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--color-surface-container);
    color: var(--color-on-surface-variant);
}

.lead-row__preview {
    margin: 6px 0 0;
    font-size: 0.875rem;
    line-height: 1.35;
    color: var(--color-on-surface-variant);
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .leads-page .client-page-header {
        padding-top: 1rem;
    }

    .leads-filter-tabs {
        flex-wrap: wrap;
        mask-image: none;
        -webkit-mask-image: none;
    }
}

/* ─── Conversation page header & composer ─── */
.conversation-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 8px;
    background: color-mix(in srgb, var(--color-background) 94%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-outline-variant);
    padding: max(8px, env(safe-area-inset-top, 0px)) 12px 10px;
    min-width: 0;
}

@media (min-width: 768px) {
    .conversation-header {
        gap: 12px;
        padding: 12px 24px;
    }
}

.conversation-header__back,
.conversation-header__icon-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--color-on-surface);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, background 0.15s ease;
}

.conversation-header__back .material-symbols-outlined,
.conversation-header__icon-btn .material-symbols-outlined {
    font-size: 22px;
}

@media (min-width: 768px) {
    .conversation-header__back,
    .conversation-header__icon-btn {
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }
}

/* Flat icon buttons in chat header — no heavy bordered boxes on mobile */
body.client-chat-view .conversation-header .conversation-header__icon-btn,
body.client-chat-view .conversation-header .conversation-header__back {
    border: none;
    box-shadow: none;
    background: transparent;
}

body.client-chat-view .conversation-header .conversation-header__actions-secondary .client-mobile-menu-btn,
body.client-chat-view .conversation-header .conversation-header__actions-secondary .theme-toggle--client {
    width: 40px;
    height: 40px;
}

.conversation-header__back:active,
.conversation-header__icon-btn:active {
    transform: scale(0.94);
    background: var(--color-surface-container);
}

.conversation-header__identity {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.conversation-header__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.conversation-header__avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--color-secondary-container);
    color: var(--color-on-secondary-container);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

@media (max-width: 767px) {
    .conversation-header__avatar {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }
}

.conversation-header__name {
    font-family: 'Google Sans Flex', Inter, system-ui, sans-serif;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

@media (min-width: 768px) {
    .conversation-header__name {
        font-size: 1.0625rem;
    }
}

.conversation-header__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.conversation-header__actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.conversation-header__actions-secondary {
    align-items: center;
    gap: 4px;
}

.conversation-header__intervene {
    height: 36px;
    min-width: 36px;
    padding: 0;
    border: none;
    border-radius: 10px;
    font-family: 'Google Sans Flex', Inter, system-ui, sans-serif;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.conversation-header__intervene .material-symbols-outlined {
    font-size: 20px;
}

.conversation-header__intervene-label {
    display: none;
}

@media (min-width: 768px) {
    .conversation-header__intervene {
        height: 40px;
        min-width: auto;
        padding: 0 14px;
        border-radius: 12px;
    }

    .conversation-header__intervene-label {
        display: inline;
    }

    .conversation-header__identity {
        flex: 1;
    }

    .conversation-header__text {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 10px;
    }

    .conversation-header__meta {
        margin-left: 2px;
    }
}

.conversation-header__intervene:active {
    transform: scale(0.94);
}

.conversation-header__intervene--pause {
    background: var(--color-secondary);
    color: var(--color-on-secondary);
}

.conversation-header__intervene--resume {
    background: var(--color-primary);
    color: var(--color-on-primary);
}

.conversation-header__channel {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-on-surface-variant);
    text-transform: capitalize;
}

.conversation-header__channel .material-symbols-outlined {
    font-size: 16px;
    color: var(--color-outline);
}

.conversation-composer {
    background: var(--color-surface-container-lowest);
    border-top: 1px solid var(--color-outline-variant);
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
    z-index: 20;
    min-width: 0;
}

.conversation-composer__status {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

@media (min-width: 480px) {
    .conversation-composer__status {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }
}

.conversation-composer__pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--color-surface-container-low);
    border: 1px solid var(--color-outline-variant);
    max-width: 100%;
}

.conversation-composer__pill-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-on-surface-variant);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-composer__hint {
    margin: 0;
    font-size: 11px;
    line-height: 1.35;
    color: var(--color-outline);
    font-style: italic;
}

.conv-msg {
    max-width: min(85%, 420px);
}
