/* File: public/style.css — all site styling for the app (FRAMEWORK: change the palette in :root).
 * Betty palette (teal): primary #0F766E, primary-dark #134E4A, accent #2DD4BF (on dark) / #0D9488 (on white), bg #FFFFFF, text #000000.
 * Light accents on dark surfaces: #99F6E4 (hero title), #5EEAD4 (footer links).
 * No inline CSS anywhere else (except email HTML in mailer.php).
 */

:root {
    --primary:       #0F766E;
    --primary-dark:  #134E4A;
    --secondary:     #2DD4BF;
    --secondary-dark:#0D9488;
    --bg:            #FFFFFF;
    --text:          #000000;
    --muted:         #6b7b8a;
    --white:         #FFFFFF;
    --border:        #dce0e8;
    --border-gold:   rgba(45,212,191,0.45);
    --danger:        #C0392B;
    --danger-dark:   #a5342a;
    --shadow:        0 2px 8px rgba(19,78,74,0.08);
    --shadow-lg:     0 8px 24px rgba(19,78,74,0.12);
    --radius:        10px;
}

* { box-sizing: border-box; }

html { margin: 0; padding: 0; height: 100%; }
body { margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }

h1, h2, h3, h4, h5, h6 { color: var(--primary); line-height: 1.25; }

/* ---------- Header ---------- */
.site-header {
    background-color: var(--white);
    border-bottom: 2px solid rgba(45,212,191,0.45);
    box-shadow: var(--shadow);
}
.header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.brand {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
}
.brand-sub {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.4px;
    text-transform: uppercase;
}
.header-nav { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    line-height: 1.2;
}
.btn-primary { background-color: var(--primary); color: var(--white); }
.btn-primary:hover { background-color: var(--primary-dark); }
.btn-secondary { background-color: var(--white); color: var(--primary); border-color: var(--secondary); }
.btn-secondary:hover { background-color: rgba(45,212,191,0.08); }
.btn-danger { background-color: var(--danger); color: var(--white); }
.btn-danger:hover { background-color: var(--danger-dark); }
.btn-large { padding: 14px 28px; font-size: 17px; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-block { display: block; width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Hero ---------- */
.hero {
    background: linear-gradient(135deg, #0F766E 0%, #134E4A 100%);
    padding: 24px 24px 10px;
}
.hero-inner { max-width: 760px; margin: 0 auto; text-align: center; }
.hero-inner h1 { font-size: 40px; margin: 0 0 16px; color: #99F6E4; }
.hero-lead { font-size: 19px; color: rgba(255,255,255,0.92); margin: 0 auto 16px; max-width: 620px; text-align: justify; }
.hero-lead-secondary { font-size: 19px; color: rgba(255,255,255,0.92); margin-bottom: 28px !important; text-align: justify; }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.hero-note { font-size: 13px; color: rgba(255,255,255,0.60); }

/* ---------- Sections ---------- */
.section { padding: 20px 24px; }
.section-alt { background-color: #fafbff; padding-top: 12px; }
.section-inner { max-width: 1120px; margin: 0 auto; }
.section-title { font-size: 30px; text-align: center; margin: 0 0 16px; color: var(--primary); }

.steps-grid, .features-grid {
    display: grid;
    gap: 16px;
}
.steps-grid { grid-template-columns: repeat(3, 1fr); }
.features-grid { grid-template-columns: repeat(2, 1fr); }

.step-card, .feature-card {
    background-color: var(--white);
    border: 1.5px solid var(--border-gold);
    border-radius: var(--radius);
    padding: 18px 22px;
    box-shadow: var(--shadow);
}
.section-alt .feature-card { background-color: #fafbff; border-color: var(--border-gold); }
.step-card h3, .feature-card h3 { margin: 12px 0 8px; font-size: 20px; color: var(--primary); }
.step-card p, .feature-card p { margin: 0; color: #2a2a2a; }
.step-number {
    width: 44px; height: 44px;
    border-radius: 50%;
    background-color: var(--secondary);
    color: var(--primary-dark);
    font-weight: 800;
    font-size: 20px;
    display: flex; align-items: center; justify-content: center;
}

.disclaimer-section { background-color: #fafbff; padding-top: 12px; padding-bottom: 14px; }
.disclaimer-card {
    background: var(--white);
    border: 2px solid rgba(45,212,191,0.55);
    border-radius: 14px;
    padding: 24px 32px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 36px;
    align-items: flex-start;
}
.disclaimer-icon-col {
    flex: 0 0 auto; display: flex; flex-direction: column; align-items: center;
    gap: 14px; min-width: 120px;
}
.disclaimer-icon-lg {
    width: 80px; height: 80px; display: flex; align-items: center; justify-content: center;
    background: rgba(208,2,27,0.07); border-radius: 50%; border: 2px solid rgba(208,2,27,0.3);
    color: #D0021B;
}
.disclaimer-icon-lg svg { width: 40px; height: 40px; }
.disclaimer-icon-label {
    font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
    color: #D0021B; text-transform: uppercase; white-space: nowrap;
}
.disclaimer-body { flex: 1 1 0; }
.disclaimer-title { color: #D0021B !important; }
.disclaimer-text { text-align: left; color: #000000; font-size: 16px; line-height: 1.65; margin: 0; }
@media (max-width: 700px) {
    .disclaimer-card { flex-direction: column; align-items: center; padding: 20px; gap: 18px; }
    .disclaimer-icon-col { min-width: unset; }
}

/* ---------- Footer ---------- */
.site-footer {
    background-color: #134E4A;
    color: #cfd8e0;
    padding: 10px 24px;
    margin-top: auto;
}
.footer-inner { max-width: 1120px; margin: 0 auto; text-align: center; }
.footer-links { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-bottom: 6px; }
.footer-links a { color: #5EEAD4; text-decoration: none; font-weight: 600; }
.footer-links a:hover { text-decoration: underline; }
.footer-tagline { margin: 3px 0; font-size: 14px; color: #9fb0c0; }
.footer-copy { margin: 3px 0 0; font-size: 13px; color: #8496a6; }

/* ---------- Auth / forms ---------- */
.auth-main {
    max-width: 640px;
    margin: 0 auto;
    padding: 48px 24px;
}
.auth-card {
    background-color: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 36px;
    max-width: 460px;
    margin: 0 auto;
}
.auth-card-wide { max-width: 640px; }
.auth-main-full { max-width: 1120px; }
.auth-card-full { max-width: 100%; }
.auth-card h1 { margin: 0 0 8px; font-size: 26px; }
.auth-sub { color: var(--muted); margin: 0 0 24px; }
.auth-alt { text-align: center; margin: 16px 0 0; font-size: 14px; }

.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background-color: var(--white);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(27, 108, 168, 0.12);
}
textarea { resize: vertical; }
.field-hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

.disclaimer-box {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px;
    margin: 8px 0 24px;
    background-color: #FAFCFE;
}
.disclaimer-box legend { font-weight: 700; padding: 0 8px; font-size: 14px; }
.checkbox-line {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-weight: 400;
    margin-bottom: 14px;
    font-size: 14px;
    color: #4a5a6a;
}
.checkbox-line input { width: auto; margin-top: 4px; flex-shrink: 0; }
.checkbox-line:last-child { margin-bottom: 0; }

/* ---------- Alerts ---------- */
.alert { border-radius: 8px; padding: 14px 16px; margin-bottom: 20px; font-size: 14px; }
.alert ul { margin: 0; padding-left: 20px; }
.alert-error { background-color: #FDECEA; color: #922; border: 1px solid #F5C6C0; }
.alert-success { background-color: #E7F6EF; color: #1c6b4c; border: 1px solid #B9E3CE; }

/* ---------- Profile ---------- */
.profile-meta { background-color: var(--bg); border-radius: 8px; padding: 16px 18px; margin-bottom: 24px; }
.profile-meta p { margin: 4px 0; font-size: 14px; }
.profile-section-title { font-size: 18px; margin: 28px 0 14px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ---------- Legal pages ---------- */
.legal-main { max-width: 820px; margin: 0 auto; padding: 48px 24px; }
.legal-inner { background-color: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; box-shadow: var(--shadow); }
.legal-inner h1 { font-size: 30px; margin: 0 0 4px; }
.legal-inner h2 { font-size: 19px; margin: 28px 0 8px; color: var(--primary); }
.legal-updated { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.legal-inner h3 { font-size: 16px; margin: 18px 0 6px; color: var(--primary); }
.legal-region-note { background-color: #fdf6e3; border: 1px solid var(--border-gold); border-radius: var(--radius); padding: 12px 16px; font-size: 14px; margin: 0 0 20px; }
.legal-country-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 18px; font-size: 14px; }
.legal-country-form label { color: var(--muted); }
.legal-country-form select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; max-width: 260px; }
.legal-table { width: 100%; border-collapse: collapse; margin: 12px 0 8px; font-size: 14px; }
.legal-table th, .legal-table td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.legal-table th { background-color: #f6f8fb; color: var(--primary); }


/* ---------- App shell (dashboard) ---------- */
.app-body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.app-header {
    background-color: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.app-header-right { display: flex; align-items: center; gap: 10px; }
.app-user { font-size: 14px; color: var(--muted); margin-right: 4px; }
/* Moved into the drawer — hidden in the header on all screen sizes */
.app-user       { display: none; }
.header-auth-btn { display: none; }

.app-shell { display: flex; flex: 1; min-height: 0; }


/* ---------- Admin ---------- */
.admin-main { max-width: 1120px; margin: 0 auto; padding: 32px 24px; }
.admin-main h1 { margin: 0 0 4px; }
.admin-sub { color: var(--muted); margin: 0 0 24px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
    background-color: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px; text-align: center; box-shadow: var(--shadow);
}
.stat-number { display: block; font-size: 34px; font-weight: 800; color: var(--primary); }
.stat-label { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
.admin-section { margin-bottom: 36px; }
.admin-section h2 { font-size: 20px; margin: 0 0 14px; }
.table-wrap { overflow-x: auto; background-color: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table th { background-color: #F3F8FC; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-inline-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.admin-inline-form input, .admin-inline-form select { width: auto; flex: 1; min-width: 140px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-ok { background-color: #E7F6EF; color: #1c6b4c; }
.badge-off { background-color: #FDECEA; color: #922; }

/* ---------- Error / staging screen ---------- */
.error-screen {
    max-width: 480px;
    margin: 80px auto;
    padding: 48px 32px;
    background-color: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.error-screen h1 { font-size: 64px; margin: 0 0 12px; color: var(--primary); }
.error-screen p { color: var(--muted); margin: 8px 0; }


/* ---------- Betty chat (dashboard.php) ---------- */
.chat-sidebar {
    width: 280px; flex-shrink: 0; display: flex; flex-direction: column; gap: 12px;
    padding: 16px; border-right: 1px solid var(--border); background-color: #F7FAFA; min-height: 0;
}
.conversation-list { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; }
.conversation-item { margin: 0 0 4px; }
.conversation-link {
    width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 8px;
    padding: 8px 10px; font: inherit; font-size: 14px; color: var(--text); cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conversation-link:hover { background-color: var(--white); border-color: var(--border); }
.conversation-item.active .conversation-link { background-color: var(--white); border-color: var(--secondary); font-weight: 600; }
.chat-usage { margin: 0; font-size: 12px; color: var(--muted); }
.chat-usage a { color: var(--primary); }

.chat-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px 20px; }
.chat-titlebar { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.chat-title-input { flex: 1; border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; font: inherit; font-weight: 700; font-size: 17px; background: none; }
.chat-title-input:hover:not(:disabled), .chat-title-input:focus { border-color: var(--border); outline: none; }
.chat-limit { margin: 0 0 8px; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 8px 2px; }
.chat-welcome { margin: auto; max-width: 560px; text-align: center; color: var(--muted); }
.chat-welcome h1 { color: var(--primary); font-size: 26px; margin: 0 0 8px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.msg-user { align-self: flex-end; background-color: var(--primary); color: var(--white); border-bottom-right-radius: 4px; }
.msg-assistant { align-self: flex-start; background-color: #F1F5F5; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-assistant p { margin: 0 0 8px; }
.msg-assistant p:last-child { margin-bottom: 0; }
.msg-assistant h3, .msg-assistant h4, .msg-assistant h5, .msg-assistant h6 { margin: 10px 0 6px; color: var(--primary-dark); }
.msg-assistant ul, .msg-assistant ol { margin: 4px 0 8px; padding-left: 22px; }
.msg-assistant code { background-color: var(--white); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.msg-assistant pre { background-color: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 10px; overflow-x: auto; }
.msg-assistant pre code { border: none; padding: 0; }
.msg-assistant a { color: var(--primary); }
.msg-typing { color: var(--muted); font-style: italic; }
.msg-error { align-self: center; max-width: 90%; background-color: #FDECEA; color: #922; border: 1px solid #f3c4bf; font-size: 14px; }
.chat-file-chip { align-self: flex-start; margin: 6px 0 0; padding: 4px 10px; border: 1px solid var(--border); border-radius: 16px; font-size: 13px; background-color: var(--white); }
.chat-file-chip button { background: none; border: none; cursor: pointer; font-size: 16px; line-height: 1; color: var(--muted); }
.chat-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.chat-form textarea { flex: 1; resize: none; min-height: 44px; max-height: 200px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; }
.chat-form textarea:focus { outline: 2px solid var(--secondary); outline-offset: 0; }
.chat-attach { padding-left: 12px; padding-right: 12px; }
.chat-note { margin: 6px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
@media (max-width: 600px) {
    .chat-sidebar { width: auto; border-right: none; border-bottom: 1px solid var(--border); }
    .conversation-list { max-height: 30vh; }
    .chat-panel { padding: 10px 12px; }
    .msg { max-width: 92%; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .steps-grid { grid-template-columns: 1fr; }
    .features-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .hero-inner h1 { font-size: 30px; }
    .form-row { grid-template-columns: 1fr; }
    .msg { max-width: 90%; }
    .report-sheet { padding: 28px 22px; }
    .report-header { flex-direction: column; }
    .report-headmeta { text-align: left; }
}
@media (max-width: 600px) {
    /* --- Mobile: abandon the fixed-viewport "app shell". Let the whole page
       flow and scroll like a normal document. This restores native
       pull-to-refresh and guarantees the header, sidebar and chat are all
       visible/scrollable on every mobile browser (Samsung Internet, Chrome,
       Android WebView, etc.). --- */
    html { height: auto; }
    .app-body {
        display: block;      /* was flex column with fixed height */
        height: auto;
        min-height: 100vh;
        overflow: visible;   /* body scrolls natively -> pull-to-refresh works */
    }
    /* Keep the header reachable while the page scrolls. */
    .app-header {
        position: sticky;
        top: 0;
        z-index: 100;
        padding: 8px 12px;
        flex-wrap: nowrap;
    }
    .brand-sub { display: none; }  /* Hide the sub-text on mobile */
    .app-user { display: none; }   /* Hide "Hi, [name]" — saves header width */
    .header-logo { height: 36px; }

    .app-shell {
        display: block;      /* stack sidebar above chat in normal flow */
        overflow: visible;
        min-height: 0;
    }
    /* .sidebar — drawer positioning handled by the universal base .sidebar rule */
    .chat-panel {
        display: block;
        overflow: visible;
        min-height: 0;
    }
    .chat-messages {
        overflow: visible;   /* grows with content; the page (body) scrolls */
        min-height: 40vh;
        /* keep flex column (gap + msg align-self) — just let height grow */
        display: flex;
        flex-direction: column;
        flex: 0 1 auto;
    }
    /* Unrelated mobile rules — keep these */
    .stats-grid { grid-template-columns: 1fr; }
}


/* ---------- Header logo / brand ---------- */
.header-brand {
    align-items: center;
}
.header-logo {
    height: 48px;
    width: auto;
    display: block;
    flex-shrink: 0;
}
.brand-text {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
}

/* Report header logo (report_view.php) */
.report-header-logo {
    height: 168px;
    width: auto;
    display: block;
    margin: 0 auto 8px;
}


/* ═══════════════════════════════════════════════════════════════
   Hamburger button + Right-side Drawer
   Universal: on ALL screen sizes the sidebar is hidden and slides in
   as a right drawer via the always-visible hamburger button.
   ═══════════════════════════════════════════════════════════════ */

/* ---- Hamburger toggle button (visible on all screen sizes) ---- */
.hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--primary);
    font-size: 22px;
    flex-shrink: 0;
    line-height: 1;
    padding: 0;
    transition: background 0.15s, border-color 0.15s;
}
.hamburger-btn:hover { background: rgba(45,212,191,0.12); border-color: var(--secondary); }

/* ---- Overlay (dims the page when the drawer is open) ---- */
.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 450;
    background: rgba(0,0,0,0.45);
}
.drawer-overlay.drawer-open { display: block; }

/* Prevent page scroll behind the open drawer */
body.drawer-open { overflow: hidden; }

/* ---- Drawer-top: navy header + nav links ----
   Shown inside the sidebar drawer on all screen sizes. */
.drawer-top { display: flex; flex-direction: column; flex-shrink: 0; }

.drawer-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--primary);
    flex-shrink: 0;
}
.drawer-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    margin: 0;
}
.drawer-close-btn {
    background: none;
    border: none;
    color: var(--secondary);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.15s;
}
.drawer-close-btn:hover { color: #fff; }

.drawer-mobile-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.drawer-nav-link {
    display: block;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.15s;
}
.drawer-nav-link:hover { background: #f0f4f8; }

/* Menu screen-awareness: hide the link to the currently active page/tab. */
.hidden { display: none !important; }

/* ---- Accordion navigation groups ---- */
.nav-group { display: flex; flex-direction: column; }
.nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}
.nav-group-toggle:hover { background: #f0f4f8; }
.nav-group-label { flex: 1; }
.nav-chevron {
    display: inline-block;
    font-size: 18px;
    line-height: 1;
    color: var(--muted, #64748b);
    transition: transform 0.2s ease;
}
.nav-group.expanded .nav-chevron { transform: rotate(90deg); }
.nav-sub {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    padding-left: 12px;
    margin-top: 0;
}
.nav-group.expanded .nav-sub { margin-top: 6px; }
.nav-sub-link {
    font-weight: 500;
    font-size: 13.5px;
}


/* Drawer behaviour is now universal (all screen sizes) — see the base
   .hamburger-btn, .sidebar, .drawer-top and #newChatBtn rules above.
   The mobile-specific scroll fixes live in @media (max-width: 600px). */


/* ---- Profile page: standalone right-side drawer ---- */
.profile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    height: 100dvh;
    width: min(85vw, 300px);
    z-index: 500;
    background: var(--white);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 20px rgba(19,78,74,0.18);
    transform: translateX(110%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}
.profile-drawer.drawer-open { transform: translateX(0); }

/* Section separator label inside profile drawer */
.drawer-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 14px 16px 6px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

/* Tab links inside the drawer */
.drawer-tab-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 16px 16px;
}
.drawer-tab-link {
    appearance: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
    width: 100%;
}
.drawer-tab-link:hover { background: #f0f4f8; }




/* ============================================================
   Admin impersonation banner
   ============================================================ */
.impersonation-banner {
    background: #7C3AED; color: #fff; padding: 10px 20px;
    display: flex; align-items: center; justify-content: center; gap: 16px;
    font-size: 0.875rem; position: sticky; top: 0; z-index: 200;
    flex-wrap: wrap; text-align: center;
}
.impersonation-exit {
    color: #fff; font-weight: 700; border: 1px solid rgba(255,255,255,0.5);
    border-radius: 6px; padding: 4px 12px; text-decoration: none; font-size: 0.8rem;
}
.impersonation-exit:hover { background: rgba(255,255,255,0.15); }


/* ---------- Settings page (settings.php) ---------- */
.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; }
.settings-section { padding-inline: 0; max-width: 760px; }
.settings-section h2 { margin: 0 0 6px; font-size: 1.25rem; }
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.setting-row-stack { flex-direction: column; align-items: stretch; gap: 12px; }
.setting-text { flex: 1; min-width: 0; }
.setting-label { font-weight: 600; color: var(--primary); display: block; }
.setting-label-inline { font-weight: 600; color: var(--primary); }
.setting-value { min-width: 3.2em; font-variant-numeric: tabular-nums; color: var(--muted); }
.setting-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.setting-controls select { flex: 1 1 240px; min-width: 0; }
.setting-controls input[type="range"] { flex: 1 1 200px; accent-color: var(--primary); }

.switch { position: relative; display: inline-block; flex-shrink: 0; width: 50px; height: 28px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch-slider { position: absolute; inset: 0; border-radius: 999px; background: #CBD5E1; transition: background 0.15s ease; }
.switch-slider::before { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.15s ease; }
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(22px); }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--primary); outline-offset: 2px; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; align-self: flex-start; }
.segmented label { position: relative; margin: 0; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: 8px 16px; font-weight: 600; color: var(--primary); border-right: 1px solid var(--border); }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--primary); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -2px; }
@media (max-width: 480px) { .segmented span { padding: 8px 12px; } }


.setting-error { color: #C62828; font-weight: 600; font-size: 14px; }

/* ===== Plans & Billing (billing.php) ===== */
.billing-note { border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; border: 1px solid var(--border); background: #F8FAFC; }
.billing-note.ok { background: #F0FDF4; border-color: #BBF7D0; color: #166534; }
.billing-note.warn { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.billing-current { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
                   border: 1px solid var(--border-gold); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 22px; box-shadow: var(--shadow); }
.billing-current h2 { margin: 0 0 4px; font-size: 1.15rem; }
.billing-current p { margin: 2px 0; color: var(--muted); }
.billing-current form { margin: 0; }
.billing-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.billing-toolbar .field-hint { margin: 0; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.plan-card { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; background: var(--white); box-shadow: var(--shadow); }
.plan-card.is-current { border-color: var(--secondary); box-shadow: 0 0 0 2px var(--border-gold), var(--shadow); }
.plan-card h3 { margin: 0 0 4px; font-size: 1.1rem; color: var(--primary); }
.plan-card .plan-desc { margin: 0 0 12px; color: var(--muted); font-size: 0.92rem; }
.plan-price { font-size: 1.7rem; font-weight: 700; color: var(--primary); line-height: 1.1; }
.plan-price small { font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.plan-trial { font-size: 0.82rem; color: #15803D; margin: 4px 0 0; }
.plan-card ul { list-style: none; padding: 0; margin: 14px 0 16px; flex: 1; }
.plan-card li { padding: 3px 0 3px 22px; position: relative; font-size: 0.92rem; }
.plan-card li::before { content: '\2713'; position: absolute; left: 0; color: var(--secondary-dark); font-weight: 700; }
.plan-card li.no { color: var(--muted); }
.plan-card li.no::before { content: '\2014'; color: var(--border); }
.plan-card form { margin: 0; }
.plan-card .btn { width: 100%; }
.plan-badge { display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
              background: var(--secondary); color: #fff; border-radius: 999px; padding: 2px 9px; margin-bottom: 8px; align-self: flex-start; }
.plan-period[hidden] { display: none; }
.billing-legal { font-size: 0.8rem; color: var(--muted); margin-top: 18px; }

