/* AetherGuard Portal — shared theme for client.aetherguard.xyz and
   management.aetherguard.xyz. Same type system as aetherguard.xyz (Space
   Grotesk display + Inter body) so both portals read as the same company
   as the marketing site, not a bolted-on afterthought. */

@font-face {
    font-family: "Inter";
    src: url("/assets/fonts/Inter-var-latin.woff2") format("woff2");
    font-weight: 400 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Space Grotesk";
    src: url("/assets/fonts/SpaceGrotesk-var-latin.woff2") format("woff2");
    font-weight: 500 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --ink: #10151c;
    --ink-soft: #4b5768;
    --ink-faint: #8993a3;
    --surface: #f4f6f9;
    --panel: #ffffff;
    --border: #e3e7ed;

    --navy: #0a0f18;
    --navy-soft: #131b28;
    --navy-elevated: #1b2536;
    --navy-border: rgba(255, 255, 255, 0.08);
    --navy-ink-faint: #7887a0;

    --brand: #2f7fe0;
    --brand-dark: #1f63b8;
    --brand-soft: #e8f1fd;
    --cyan: #4fd1e0;
    --steel: #97a2b4;

    --danger: #d0392f;
    --danger-soft: #fbe9e7;
    --warning: #b8720a;
    --warning-soft: #fdf1de;
    --success: #1c8a4a;
    --success-soft: #e5f6ea;
    --info: #2464c9;
    --info-soft: #e8f0fd;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(16, 21, 28, 0.04), 0 8px 24px -8px rgba(16, 21, 28, 0.10);
    --shadow-sm: 0 1px 2px rgba(16, 21, 28, 0.06);
    --font-display: "Space Grotesk", "Inter", -apple-system, sans-serif;
    --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color-scheme: light;
}

/* Dark theme — same palette as aetherguard.xyz (#070b13/#0d1320/#2f6bff) so the
   portals feel like the same product as the marketing site, not a different
   app bolted on. This is the default theme; :root above is the opt-out. */
[data-theme="dark"] {
    --ink: #eef2f8;
    --ink-soft: #b7c2d6;
    --ink-faint: #8b98af;
    --surface: #070b13;
    --panel: #0d1320;
    --border: #1d2636;

    --brand-soft: rgba(47, 107, 255, 0.16);
    --steel: #7c8aa3;

    --danger-soft: rgba(208, 57, 47, 0.18);
    --warning-soft: rgba(184, 114, 10, 0.18);
    --success-soft: rgba(28, 138, 74, 0.18);
    --info-soft: rgba(36, 100, 201, 0.18);

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -8px rgba(0, 0, 0, 0.5);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
}
[data-theme="dark"] input[type=text], [data-theme="dark"] input[type=email],
[data-theme="dark"] input[type=password], [data-theme="dark"] input[type=number],
[data-theme="dark"] input[type=date], [data-theme="dark"] select, [data-theme="dark"] textarea {
    background: #0d1320;
    border-color: #263248;
    color: var(--ink);
}
[data-theme="dark"] .btn-outline { background: #0d1320; border-color: #263248; color: var(--ink); }
[data-theme="dark"] .btn-outline:hover { background: #131c2c; }
[data-theme="dark"] table.data-table tr:hover td { background: #101826; }
[data-theme="dark"] .ticket-row:hover { background: #101826; }
[data-theme="dark"] .chat-messages, [data-theme="dark"] .chat-window, [data-theme="dark"] .chat-presence,
[data-theme="dark"] .ticket-list { background: var(--panel); }
[data-theme="dark"] .chat-msg.other .bubble { background: #16202e; color: var(--ink); }
[data-theme="dark"] .chat-presence { background: #0a0f18; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: flex; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: flex; }

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 650; letter-spacing: -0.01em; margin: 0 0 0.4em 0; color: var(--ink); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: 0.98rem; }
p { margin: 0 0 0.75em 0; color: var(--ink-soft); }

.eyebrow {
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--brand);
}

/* ---- App shell ---- */

.impersonation-banner {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 9px 16px;
    background: var(--warning-soft);
    color: var(--warning);
    border-bottom: 1px solid var(--warning);
    font-size: 0.85rem;
    font-weight: 600;
}
.impersonation-banner span { display: inline-flex; align-items: center; gap: 7px; }
.impersonation-banner a { color: var(--warning); text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: 254px;
    flex-shrink: 0;
    background: var(--navy);
    background-image: radial-gradient(circle at 15% 0%, rgba(47, 127, 224, 0.16), transparent 55%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.app-sidebar .brand {
    padding: 22px 20px 18px 20px;
    border-bottom: 1px solid var(--navy-border);
    display: flex;
    align-items: center;
    gap: 11px;
}
.app-sidebar .brand img { width: 34px; height: 34px; object-fit: contain; flex-shrink: 0; }
.app-sidebar .brand .name { font-family: var(--font-display); color: #fff; font-weight: 650; font-size: 1.04rem; letter-spacing: -0.01em; line-height: 1.2; }
.app-sidebar .brand .sub { color: var(--navy-ink-faint); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em; margin-top: 2px; font-weight: 600; }

.app-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.app-nav .nav-group { margin-bottom: 20px; }
.app-nav .nav-label { font-family: var(--font-display); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.09em; color: #4d5c72; padding: 0 12px; margin-bottom: 8px; font-weight: 650; }
.app-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 8px;
    color: #a7b4c6;
    font-size: 0.89rem;
    font-weight: 500;
    text-decoration: none;
    margin-bottom: 2px;
    border-left: 2px solid transparent;
    transition: background-color .12s, color .12s;
}
.app-nav a:hover { background: var(--navy-elevated); color: #fff; text-decoration: none; }
.app-nav a.active { background: rgba(47, 127, 224, 0.16); color: #fff; font-weight: 620; border-left-color: var(--brand); }
.app-nav a .icon-slot { display: flex; opacity: 0.85; flex-shrink: 0; }
.app-nav a.active .icon-slot, .app-nav a:hover .icon-slot { opacity: 1; }
.app-nav a .badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 0.66rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
}

.unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand);
    margin-right: 8px;
    flex-shrink: 0;
    vertical-align: middle;
}

.app-sidebar .sidebar-foot {
    padding: 12px 16px;
    border-top: 1px solid var(--navy-border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.app-sidebar .sidebar-foot .profile-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex: 1;
    min-width: 0;
}
.app-sidebar .sidebar-foot img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1.5px solid rgba(255, 255, 255, 0.14);
}
.app-sidebar .sidebar-foot .profile-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
}
.app-sidebar .sidebar-foot .who {
    font-size: 0.82rem;
    color: #e2e8f2;
    font-weight: 600;
    line-height: 1.2;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-sidebar .sidebar-foot .role {
    font-size: 0.71rem;
    color: var(--navy-ink-faint);
    line-height: 1.2;
    display: block;
}
.app-sidebar .sidebar-foot a.logout { margin-left: auto; color: #7c8ba1; display: flex; flex-shrink: 0; }
.app-sidebar .sidebar-foot a.logout:hover { color: #fff; }

.app-main { flex: 1; min-width: 0; }
.app-topbar {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 16px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.app-topbar h1 { font-size: 1.22rem; margin: 0; }
.app-content { padding: 26px 30px 64px 30px; max-width: 1180px; }

/* ---- Cards / panels ---- */

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 22px 24px;
    margin-bottom: 18px;
    overflow-x: auto;
}
.panel-tight { padding: 14px 16px; }

/* ---- Service catalog / checkout ---- */
.service-hero {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 26px 30px;
    border-radius: var(--radius);
    background: var(--navy);
    background-image:
        radial-gradient(circle at 15% 20%, rgba(47, 127, 224, 0.28), transparent 45%),
        radial-gradient(circle at 90% 90%, rgba(79, 209, 224, 0.14), transparent 40%);
    border: 1px solid var(--navy-border);
    margin-bottom: 22px;
}
.service-hero-logo { width: 54px; height: 54px; flex-shrink: 0; }
.service-hero h2 { color: #fff; }
.service-hero p { color: #a8b4c9; }

.service-block { margin-bottom: 26px; }
.service-block-head { display: flex; align-items: flex-start; gap: 16px; }
.service-icon-badge {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-soft);
    color: var(--brand-dark);
}
[data-theme="dark"] .service-icon-badge { color: var(--brand); }

.plan-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 18px 18px 16px 18px;
}
.plan-card-head h3 { font-size: 1rem; margin-bottom: 2px; }
.plan-card-head p { font-size: 0.78rem; min-height: 32px; }
.plan-price { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; margin: 6px 0 12px 0; }
.plan-price span { font-family: var(--font-body); font-size: 0.72rem; font-weight: 500; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.03em; }
.plan-features { list-style: none; padding: 0; margin: 0 0 16px 0; flex: 1; }
.plan-features li { display: flex; align-items: flex-start; gap: 8px; font-size: 0.8rem; color: var(--ink-soft); padding: 5px 0; line-height: 1.4; }
.plan-check { color: var(--success, #1a8f5e); flex-shrink: 0; margin-top: 2px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.btn.sidebar-toggle-btn { display: none; }
@media (max-width: 860px) {
    .grid-2, .grid-3, .grid-4, .app-content > .grid { grid-template-columns: 1fr !important; }
    .app-sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
    .app-sidebar.open { transform: translateX(0); }
    .btn.sidebar-toggle-btn { display: inline-flex; }
}

.stat-card { display: flex; align-items: flex-start; gap: 14px; }
.stat-card .stat-icon {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--brand-soft); color: var(--brand-dark);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-card .stat-value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; color: var(--ink); line-height: 1.1; }
.stat-card .stat-label { font-size: 0.78rem; color: var(--ink-faint); margin-top: 3px; }

/* ---- Forms ---- */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
.field-hint { font-size: 0.76rem; color: var(--ink-faint); margin-top: 4px; }

/* ---- Checkboxes / radios ---- */

input[type="checkbox"], input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 1.5px solid var(--steel);
    background: var(--panel);
    display: inline-block;
    vertical-align: middle;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
    transition: background-color .12s, border-color .12s, box-shadow .12s;
}
input[type="checkbox"] { border-radius: 5px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:hover, input[type="radio"]:hover { border-color: var(--brand); }
input[type="checkbox"]:checked, input[type="radio"]:checked {
    background: var(--brand);
    border-color: var(--brand);
}
input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px; top: 1px;
    width: 5px; height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    left: 50%; top: 50%;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #fff;
    transform: translate(-50%, -50%);
}
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: .45; cursor: not-allowed; }

.check-row {
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    font-size: 0.86rem;
    color: var(--ink);
}
.check-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    cursor: pointer;
    transition: border-color .12s, background-color .12s;
}
.check-card:hover { border-color: var(--brand); }
.check-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.check-card .check-card-icon {
    width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
    background: var(--brand-soft); color: var(--brand-dark);
    display: flex; align-items: center; justify-content: center;
}
.check-card .check-card-body { flex: 1; }
.check-card .check-card-title { font-size: 0.86rem; font-weight: 600; color: var(--ink); }
.check-card .check-card-desc { font-size: 0.78rem; color: var(--ink-faint); margin-top: 1px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #d6dce4;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; min-height: 90px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 0.86rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    font-family: var(--font-body);
}
.btn-solid { background: var(--brand); color: #fff; }
.btn-solid:hover { background: var(--brand-dark); text-decoration: none; }
.btn-outline { background: #fff; color: var(--ink); border-color: #d6dce4; }
.btn-outline:hover { background: #f2f4f7; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b12f27; text-decoration: none; }
.btn-sm { padding: 5px 11px; font-size: 0.78rem; }

/* password strength meter */
.pw-meter { height: 5px; border-radius: 4px; background: #e4e7ec; overflow: hidden; margin-top: 6px; }
.pw-meter-fill { height: 100%; width: 0%; transition: width .15s, background-color .15s; }
.pw-label { font-size: 0.75rem; font-weight: 600; margin-top: 4px; }

/* ---- Alerts / flash ---- */
.alert { padding: 11px 14px; border-radius: 8px; font-size: 0.86rem; margin-bottom: 14px; }
.alert-error { background: var(--danger-soft); color: #8c231b; }
.alert-success { background: var(--success-soft); color: #145c31; }
.alert-info { background: var(--info-soft); color: #1a4586; }
.alert-warning { background: var(--warning-soft); color: #7a4d05; }

/* ---- Confirmation modal (replaces window.confirm()) ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 10, 16, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease;
    padding: 20px;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    max-width: 400px;
    width: 100%;
    transform: translateY(6px);
    transition: transform 0.15s ease;
}
.modal-overlay.open .modal-box { transform: translateY(0); }
.modal-message { font-size: 0.92rem; color: var(--ink); line-height: 1.5; margin: 0 0 18px 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---- Tables ---- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
table.data-table th { text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); padding: 9px 10px; border-bottom: 1px solid var(--border); font-weight: 650; }
table.data-table td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:hover td { background: #fafbfd; }
table.data-table tr.clickable { cursor: pointer; }

/* ---- Badges / dots (severity + status, kept as small symbols not full blocks) ---- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; flex-shrink: 0; }
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.pill-severity-low { background: #eaf1fc; color: #2464c9; }
.pill-severity-normal { background: var(--brand-soft); color: var(--brand-dark); }
.pill-severity-high { background: var(--warning-soft); color: #a1620a; }
.pill-severity-critical { background: var(--danger-soft); color: #b12f27; }
.pill-status-open { background: var(--brand-soft); color: var(--brand-dark); }
.pill-status-pending { background: var(--warning-soft); color: #a1620a; }
.pill-status-resolved { background: var(--success-soft); color: #145c31; }
.pill-status-closed { background: #eef0f3; color: #64707e; }
.pill-tag { background: var(--surface); color: var(--ink-soft); border: 1px solid var(--border); }

/* ---- Sidebar list (ticket list panel) ---- */
.ticket-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.ticket-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 15px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}
.ticket-row:last-child { border-bottom: none; }
.ticket-row:hover { background: #fafbfd; text-decoration: none; }
.ticket-row.active { background: var(--brand-soft); }
.ticket-row .subject { font-weight: 600; font-size: 0.88rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-row .meta { font-size: 0.72rem; color: var(--ink-faint); }

/* ---- Ticket cards (main client ticket list, one box per ticket) ---- */
.ticket-cards { display: flex; flex-direction: column; gap: 10px; }
.ticket-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: border-color .15s ease, transform .1s ease;
}
.ticket-card:hover { border-color: var(--brand); text-decoration: none; }
.ticket-card:active { transform: scale(0.997); }
.ticket-card .ticket-card-main { flex: 1; min-width: 0; }
.ticket-card .subject { font-weight: 650; font-size: 0.94rem; margin-bottom: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-card .tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ticket-card .meta { font-size: 0.76rem; color: var(--ink-faint); white-space: nowrap; flex-shrink: 0; }
.ticket-card.active { border-color: var(--brand); background: var(--brand-soft); }

.ticket-cards-compact { gap: 8px; }
.ticket-card-compact { padding: 11px 13px; gap: 0; }
.ticket-card-compact .subject { font-size: 0.85rem; margin-bottom: 6px; white-space: normal; }
.ticket-card-compact .tags { gap: 5px; }
.ticket-card-compact .pill { font-size: 0.62rem; padding: 2px 7px; }

/* ---- Chat ---- */
.chat-window { display: flex; flex-direction: column; height: 560px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; overflow: hidden; }
.chat-presence { padding: 10px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--ink-soft); background: #fbfcfd; min-height: 20px; }
.chat-presence img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.chat-messages {
    flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--steel) transparent;
}
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background-color: var(--steel); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
.chat-messages::-webkit-scrollbar-thumb:hover { background-color: var(--ink-faint); }

/* ---- Bar chart (render_bar_chart_svg) ---- */
.bar-chart-grad-top { stop-color: var(--brand); stop-opacity: 1; }
.bar-chart-grad-bottom { stop-color: var(--brand); stop-opacity: 0.55; }
.bar-chart-bar { transition: opacity 0.15s ease; }
.bar-chart-bar-group:hover .bar-chart-bar { opacity: 0.82; }
.bar-chart-baseline { stroke: var(--border); stroke-width: 1; }
.bar-chart-value { font-size: 11px; font-weight: 650; fill: var(--ink); font-family: var(--font-body); }
.bar-chart-label { font-size: 10px; fill: var(--ink-faint); font-family: var(--font-body); }
.chat-msg { max-width: 78%; display: flex; align-items: flex-end; gap: 8px; }
.chat-msg-body { min-width: 0; }
.chat-msg .avatar-slot { flex-shrink: 0; }
.chat-msg .avatar-slot img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; display: block; }
.avatar-initials { display: flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; letter-spacing: -0.02em; }
.chat-msg .bubble { padding: 9px 13px; border-radius: 12px; font-size: 0.87rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.chat-msg .who { font-size: 0.7rem; color: var(--ink-faint); margin-bottom: 3px; }
.chat-msg.other { align-self: flex-start; }
.chat-msg.self { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.self .bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 3px; }
.chat-msg.self .who { text-align: right; }
.chat-msg.other .bubble { background: #f0f2f5; color: var(--ink); border-bottom-left-radius: 3px; }
.typing-indicator { font-size: 0.76rem; color: var(--ink-faint); font-style: italic; padding: 0 16px 8px 16px; height: 18px; }
.typing-dots span { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--ink-faint); margin-right: 2px; animation: typingBounce 1s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }
.chat-compose { border-top: 1px solid var(--border); padding: 10px; display: flex; gap: 8px; align-items: flex-end; }
.chat-compose textarea { flex: 1; min-height: 40px; max-height: 160px; height: 40px; resize: none; overflow-y: auto; line-height: 1.4; }
.chat-compose .btn { flex-shrink: 0; }
.chat-attach-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid #d6dce4;
    background: #fff;
    color: var(--ink-soft);
    cursor: pointer;
}
.chat-attach-btn:hover { background: var(--surface); color: var(--ink); }
[data-theme="dark"] .chat-attach-btn { background: #0d1320; border-color: #263248; }
.chat-attach-preview { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 10px 10px 10px; }
.chat-attach-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px 9px;
    font-size: 0.78rem;
    color: var(--ink-soft);
}
.chat-attach-chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; }
.chat-attach-chip .remove { cursor: pointer; color: var(--ink-faint); font-weight: 700; }
.chat-attach-chip .remove:hover { color: var(--danger); }
.chat-upload-spinner {
    width: 13px;
    height: 13px;
    border: 2px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    display: inline-block;
    animation: chatUploadSpin 0.7s linear infinite;
}
@keyframes chatUploadSpin { to { transform: rotate(360deg); } }
.chat-msg .attachment { display: block; margin-top: 6px; }
.chat-msg .attachment img { max-width: 220px; max-height: 220px; border-radius: 8px; display: block; }
.chat-msg .attachment-file {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.06);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.82rem;
    text-decoration: none;
    color: inherit;
    margin-top: 6px;
}
.chat-msg.self .attachment-file { background: rgba(255,255,255,0.16); }

/* ---- Misc ---- */
.avatar-lg { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.muted { color: var(--ink-faint); }
.text-sm { font-size: 0.82rem; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: none; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chip-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.empty-state { text-align: center; padding: 52px 20px; color: var(--ink-faint); }
.empty-state .icon-wrap { display: flex; justify-content: center; margin-bottom: 12px; color: var(--steel); }

/* ---- Login shell ---- */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--ink-soft);
    cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); background: var(--surface); }

.login-shell {
    min-height: 100vh;
    display: flex;
}
.login-form-pane {
    flex: 1 1 50%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    padding: 40px 24px;
}
.login-card {
    width: 100%;
    max-width: 380px;
}
.login-card .brand-mark { color: var(--brand); font-family: var(--font-display); font-weight: 700; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.11em; margin-bottom: 8px; }
.login-card h1 { font-size: 1.5rem; }
.login-card .alert { margin-top: 4px; }

.login-brand-pane {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: var(--navy);
    background-image:
        radial-gradient(circle at 20% 15%, rgba(47, 127, 224, 0.28), transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(79, 209, 224, 0.14), transparent 40%),
        linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
    background-size: auto, auto, 28px 28px, 28px 28px;
    padding: 40px;
}
.login-brand-pane .brand-logo { width: 92px; height: 92px; margin-bottom: 22px; }
.login-brand-pane .brand-name { font-family: var(--font-display); font-size: 2rem; font-weight: 700; color: #fff; letter-spacing: -0.01em; }
.login-brand-pane .brand-slogan { color: #93a1b8; margin-top: 10px; font-size: 1.02rem; max-width: 360px; line-height: 1.5; }

@media (max-width: 860px) {
    .login-brand-pane { display: none; }
    .login-form-pane { flex: 1 1 100%; }
}

.legal-shell { min-height: 100vh; }
.legal-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    border-bottom: 1px solid var(--border);
}
.legal-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; color: var(--ink); }
.legal-brand img { width: 26px; height: 26px; }
.legal-body { max-width: 760px; margin: 0 auto; padding: 48px 24px 80px 24px; }
.legal-body h1 { font-size: 1.7rem; margin-bottom: 4px; }
.legal-body .updated { color: var(--ink-faint); font-size: 0.82rem; margin-bottom: 28px; }
.legal-body h2 { font-size: 1.08rem; margin-top: 30px; margin-bottom: 6px; }
.legal-body h3 { font-size: 0.94rem; margin-top: 18px; margin-bottom: 4px; color: var(--ink); }
.legal-body p, .legal-body li { color: var(--ink-soft); font-size: 0.92rem; line-height: 1.7; }
.legal-body ul, .legal-body ol { padding-left: 20px; margin: 0 0 0.75em 0; }
.legal-body strong { color: var(--ink); }
.legal-nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--border); font-size: 0.85rem; }
.legal-nav strong { color: var(--ink); }
.app-footer { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.78rem; }
.app-footer a, .app-footer span { color: var(--ink-faint); }
