:root {
    color-scheme: light;
    --bg: #f8f7fa;
    --surface: rgba(255, 255, 255, .9);
    --surface-2: #f0f9f8;
    --line: #e1e0e5;
    --text: #5d596c;
    --muted: #6f6b7d;
    --accent: #5ab2ae;
    --accent-strong: #479e9a;
    --accent-ink: #2f7773;
    --accent-button: #347d79;
    --info-bg: #1669b2;
    --info-fg: #fff;
    --danger: #df626b;
    --warning: #c48a2d;
    --radius: 22px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 9% 4%, rgba(90, 178, 174, .16), transparent 28rem),
        radial-gradient(circle at 92% 12%, rgba(214, 211, 255, .52), transparent 30rem),
        linear-gradient(180deg, #fbfafd 0%, var(--bg) 100%);
    color: var(--text);
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { color: #255f5c; }
a:focus-visible,
.button:focus-visible { outline: 0; box-shadow: 0 0 0 4px rgba(90, 178, 174, .18); }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 72px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    gap: 32px;
    background: rgba(255, 255, 255, .78);
    border-bottom: 1px solid rgba(219, 218, 222, .78);
    box-shadow: 0 8px 28px rgba(75, 70, 92, .07);
    backdrop-filter: blur(22px) saturate(150%);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
}

.brand { display: flex; align-items: center; gap: 11px; flex: 0 0 auto; color: var(--text); font-weight: 750; }
.brand:hover { color: var(--text); }
.brand-logo { display: block; width: 156px; height: 50px; object-fit: contain; filter: drop-shadow(0 5px 12px rgba(71, 158, 154, .12)); }
.brand-copy { display: grid; gap: 1px; line-height: 1.1; }
.brand-copy small { color: var(--muted); font-size: .66rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }

.nav { display: flex; gap: 8px; flex: 1; }
.nav a { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; border-radius: 11px; color: var(--muted); font-weight: 650; transition: color .16s ease, background .16s ease, box-shadow .16s ease; }
.nav a:hover { background: rgba(90, 178, 174, .11); color: var(--accent-strong); }
.nav a.is-active {
    color: var(--accent-ink);
    background: linear-gradient(135deg, rgba(90, 178, 174, .18), rgba(90, 178, 174, .07));
    box-shadow: inset 0 0 0 1px rgba(90, 178, 174, .14), 0 7px 18px rgba(71, 158, 154, .09);
}
.nav-badge {
    display: inline-grid;
    place-items: center;
    min-width: 19px;
    height: 19px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--info-bg);
    box-shadow: 0 4px 10px rgba(22, 105, 178, .22);
    color: var(--info-fg);
    font-size: .64rem;
    font-weight: 850;
    line-height: 1;
}
.logout-form { margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 9px; margin-left: auto; }

.theme-toggle {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 42px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(255, 255, 255, .7);
    box-shadow: 0 3px 12px rgba(75, 70, 92, .09), inset 0 1px 0 rgba(255,255,255,.65);
    color: var(--muted);
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease;
}
.theme-toggle:hover { border-color: rgba(71, 158, 154, .5); box-shadow: 0 7px 18px rgba(75, 70, 92, .12); transform: translateY(-1px); }
.theme-toggle:focus-visible { outline: 0; box-shadow: 0 0 0 4px rgba(90, 178, 174, .16); }
.theme-symbol { width: 14px; font-size: .86rem; line-height: 1; text-align: center; }
.theme-switch { position: relative; width: 32px; height: 18px; border-radius: 999px; background: #d7ddde; box-shadow: inset 0 1px 3px rgba(75,70,92,.18); }
.theme-switch i { position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(75,70,92,.28); transition: transform .22s cubic-bezier(.2,.8,.2,1), background .18s ease; }
.theme-toggle-floating { position: fixed; top: 20px; right: 22px; z-index: 30; }

.page { width: min(1320px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 80px; }
.page-auth { width: 100%; min-height: 100vh; margin: 0; padding: 0; display: grid; place-items: center; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 3vw, 3.4rem); line-height: 1.02; letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: 1.25rem; }
.eyebrow { margin-bottom: 8px; color: var(--accent-ink); font-size: .76rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.muted { margin-bottom: 0; color: var(--muted); line-height: 1.6; }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric-card, .panel, .login-card {
    border: 1px solid rgba(255, 255, 255, .92);
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(255, 255, 255, .96), rgba(252, 252, 253, .88));
    box-shadow: 0 18px 50px rgba(75, 70, 92, .09), 0 2px 8px rgba(75, 70, 92, .05);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
.metric-card { padding: 22px; min-height: 128px; display: flex; flex-direction: column; justify-content: space-between; }
.metric-card span { color: var(--muted); font-size: .88rem; }
.metric-card strong { font-size: 2.5rem; letter-spacing: -.05em; }

.panel { padding: 24px; margin-bottom: 20px; }
.panel-table { padding: 0; overflow: hidden; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.table-wrap { overflow-x: auto; overscroll-behavior-inline: contain; }
.table-scroll-hint { display: none; }
.users-table { min-width: 960px; }
.menu-table { min-width: 900px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 18px; border-bottom: 1px solid rgba(219, 218, 222, .82); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
tbody tr:hover { background: rgba(90, 178, 174, .055); }
tbody tr:last-child td { border-bottom: 0; }
code { color: var(--accent-ink); font-family: "SFMono-Regular", Consolas, monospace; font-size: .84em; overflow-wrap: anywhere; }
td code { white-space: nowrap; }

.status { display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 999px; border: 1px solid var(--line); font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.status-active, .status-done, .status-safe { color: #2f7773; border-color: #b7e1df; background: #eaf7f6; }
.status-blocked, .status-failed, .status-invalid { color: var(--danger); border-color: #f0c3c6; background: #fff1f2; }
.status-draft, .status-queued, .status-running, .status-partial { color: var(--warning); border-color: #ecd7ac; background: #fff8e9; }
.counter { display: grid; place-items: center; min-width: 54px; height: 42px; padding: 0 14px; border-radius: 12px; background: var(--surface-2); color: var(--accent-ink); font-weight: 800; }

.button {
    appearance: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: linear-gradient(180deg, #fff, #f7f7f9);
    color: var(--text);
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}
.button { box-shadow: 0 2px 7px rgba(75, 70, 92, .08); transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.button:hover { border-color: rgba(71, 158, 154, .55); color: var(--accent-strong); box-shadow: 0 6px 16px rgba(75, 70, 92, .12); transform: translateY(-1px); }
.button-primary { background: linear-gradient(135deg, var(--accent-button), #2b6f6c); border-color: #2b6f6c; color: #fff; box-shadow: 0 8px 20px rgba(47, 119, 115, .24); }
.button-primary:hover { background: linear-gradient(135deg, #387f7b, #286864); color: #fff; }
.button-danger { border-color: #efc2c5; color: var(--danger); background: #fff4f4; }
.button-danger:hover { border-color: #df8e94; color: #c94e58; }
.button-ghost { background: transparent; }
.button-small { min-height: 34px; padding: 0 11px; font-size: .78rem; }
.button-full { width: 100%; }
.inline-form { margin: 0; }

.login-shell { width: 100%; min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.login-shell::before, .login-shell::after { content: ""; position: absolute; border-radius: 32px; pointer-events: none; }
.login-shell::before { width: 360px; height: 360px; top: 6%; left: 12%; background: rgba(90, 178, 174, .11); transform: rotate(11deg); }
.login-shell::after { width: 300px; height: 300px; right: 9%; bottom: 4%; border: 2px solid rgba(201, 199, 252, .45); transform: rotate(-8deg); }
.login-card { position: relative; z-index: 1; width: min(480px, 100%); padding: 44px; box-shadow: 0 28px 80px rgba(75, 70, 92, .15), 0 3px 10px rgba(75, 70, 92, .06); }
.login-logo { display: block; width: min(238px, 72%); height: auto; margin-bottom: 30px; filter: drop-shadow(0 9px 20px rgba(71, 158, 154, .15)); }
.login-card h1 { font-size: 2.25rem; }

.form-stack { display: grid; gap: 18px; margin-top: 28px; }
.field { display: grid; gap: 8px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { color: var(--text); font-size: .86rem; font-weight: 700; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(255, 255, 255, .92);
    color: var(--text);
    padding: 12px 14px;
    font: inherit;
    outline: none;
}
input[type="checkbox"] { accent-color: var(--accent-button); }
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(90, 178, 174, .13); }
.field-error { color: var(--danger); font-size: .78rem; }
.checkbox { display: flex; align-items: center; gap: 9px; }
.checkbox input { width: 18px; height: 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.form-panel { max-width: 780px; }
.file-control { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(90, 178, 174, .055); }
.file-control[hidden] { display: none; }
.file-control h2 { margin: 0; font-size: 1rem; }
.file-control p { margin: 0; }
.current-file, .attachment-name { color: var(--accent-ink); }
.field-help { margin: 0; color: var(--muted); font-size: .76rem; line-height: 1.5; }
.system-note { display: grid; gap: 4px; padding: 14px 16px; border: 1px solid rgba(90, 178, 174, .25); border-radius: 13px; background: rgba(90, 178, 174, .07); }
.system-note strong { color: var(--accent-ink); }
.system-note span { color: var(--muted); font-size: .8rem; line-height: 1.5; }
.field input[type="file"] { padding: 6px; color: var(--muted); cursor: pointer; }
.field input[type="file"]::file-selector-button {
    min-height: 36px;
    margin-right: 12px;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--accent-ink);
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}

.filter-bar { display: grid; grid-template-columns: minmax(240px, 1fr) 190px 190px auto; gap: 10px; margin-bottom: 16px; }
.filter-bar-simple { grid-template-columns: minmax(240px, 1fr) auto; }
.bulk-actions { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.table-actions { display: flex; align-items: center; gap: 8px; min-width: 290px; }
.table-actions form { margin: 0; }
.menu-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 190px; }
.panel-table input[type="checkbox"] { width: 18px; height: 18px; }
.role-form { display: flex; align-items: center; gap: 8px; min-width: 230px; }
.role-toggle { display: inline-flex; align-items: center; gap: 7px; color: var(--text); white-space: nowrap; }
.role-toggle input { width: 17px; height: 17px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 22px; color: var(--muted); }
.split-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 20px; align-items: start; }
.split-grid .panel { max-width: none; }
.broadcast-grid { grid-template-columns: minmax(0, 1.35fr) minmax(360px, .65fr); }
.broadcast-compose textarea { min-height: 300px; }
.broadcast-history-panel { max-height: 760px; overflow: auto; }

.broadcast-list { display: grid; }
.broadcast-item { display: flex; justify-content: space-between; gap: 20px; min-width: 0; padding: 16px 0; border-bottom: 1px solid var(--line); }
.broadcast-item:first-child { padding-top: 0; }
.broadcast-item:last-child { border-bottom: 0; }
.broadcast-item p { max-width: 580px; margin: 6px 0 0; color: var(--muted); white-space: pre-wrap; }
.broadcast-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; color: var(--muted); font-size: .78rem; }
.attachment-name { overflow-wrap: anywhere; }
.delivery-summary { color: var(--text) !important; font-size: .82rem; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .55fr); gap: 20px; align-items: stretch; margin-bottom: 20px; }
.dashboard-grid > * { min-width: 0; }
.dashboard-grid .panel { margin-bottom: 0; }
.activity-panel .panel-heading { align-items: flex-start; }
.chart-total { color: var(--accent-ink); font-size: 2.2rem; letter-spacing: -.05em; }
.activity-chart { display: grid; grid-template-columns: repeat(14, minmax(22px, 1fr)); align-items: end; gap: 8px; min-height: 240px; padding-top: 18px; }
.activity-column { display: grid; grid-template-rows: 20px 1fr 22px; gap: 7px; min-width: 0; text-align: center; }
.activity-value { color: var(--text); font-size: .75rem; font-weight: 800; }
.activity-track { display: flex; align-items: end; height: 170px; border-radius: 8px; background: rgba(90, 178, 174, .08); overflow: hidden; }
.activity-bar { width: 100%; min-height: 8px; border-radius: 8px 8px 0 0; background: linear-gradient(180deg, #78cac6, #479e9a); box-shadow: 0 -5px 18px rgba(71,158,154,.18); }
.activity-bar[style="height: 0%"] { min-height: 0; box-shadow: none; }
.activity-label { color: var(--muted); font-size: .65rem; white-space: nowrap; transform: rotate(-45deg); transform-origin: center; }
.delivery-stats { display: grid; gap: 14px; margin: 0 0 24px; }
.delivery-stats div { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.delivery-stats dt { color: var(--muted); font-size: .8rem; }
.delivery-stats dd { margin: 4px 0 0; color: var(--text); font-size: 1.7rem; font-weight: 800; letter-spacing: -.04em; }
.audit-panel { padding-block: 18px; }
.audit-panel .panel-heading { margin-bottom: 12px; }
.audit-heading { align-items: flex-start; }
.audit-filter { display: grid; grid-template-columns: auto minmax(180px, 240px) auto; align-items: end; justify-content: start; gap: 10px; margin-bottom: 14px; }
.audit-filter label { grid-column: 1 / -1; color: var(--muted); font-size: .78rem; font-weight: 700; }
.audit-scroll { max-height: 460px; padding-right: 8px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.audit-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
.audit-list { display: grid; }
.audit-item { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.audit-item:last-child { border-bottom: 0; }
.audit-item strong { font-size: .9rem; }
.audit-item p { margin: 3px 0 0; color: var(--muted); font-size: .8rem; }
.audit-item time { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.audit-pagination { margin-top: 14px; }

.alerts { display: grid; gap: 8px; margin-bottom: 18px; }
.page-auth .alerts { position: fixed; top: 20px; width: min(460px, calc(100% - 48px)); z-index: 20; }
.alert { padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.alert-error { border-color: #efc2c5; color: #c94e58; background: #fff4f4; }
.alert-success { border-color: #b7e1df; color: #378d88; background: #edf8f7; }
.alert-warning { border-color: #ecd7ac; color: #a76f18; background: #fff8e9; }

.empty { padding: 24px; color: var(--muted); text-align: center; }
.empty-state, .error-card { padding: 56px 24px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--text); font-size: 1.1rem; }
.error-card { min-height: 60vh; display: grid; place-items: center; align-content: center; }
.error-card span { color: var(--accent-ink); font-size: 4rem; font-weight: 850; }
.error-card h1 { color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Support inbox */
.support-page-heading { margin-bottom: 20px; }
.support-filter-bar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 190px auto;
    gap: 10px;
    margin-bottom: 16px;
}
.support-bulk-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -4px 0 14px; }
.support-bulk-actions form { margin: 0; }
.support-select-all { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .78rem; }
.support-select-all input,
.support-conversation-select { width: 17px; height: 17px; flex: 0 0 auto; padding: 0; }
.support-layout {
    display: grid;
    grid-template-columns: minmax(300px, 340px) minmax(430px, 1fr) minmax(220px, 250px);
    min-height: 650px;
    height: calc(100vh - 285px);
    max-height: 860px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .82);
    box-shadow: 0 24px 70px rgba(75, 70, 92, .13);
}
.support-conversations,
.support-thread,
.support-details {
    min-width: 0;
    min-height: 0;
    background: linear-gradient(160deg, rgba(255, 255, 255, .98), rgba(249, 249, 251, .96));
}
.support-conversations {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line);
}
.support-thread {
    display: flex;
    flex-direction: column;
    scroll-margin-top: 84px;
    background:
        radial-gradient(circle at 50% 0%, rgba(90, 178, 174, .10), transparent 26rem),
        #fbfbfc;
}
.support-details {
    overflow-y: auto;
    border-left: 1px solid var(--line);
}
.support-panel-header,
.support-thread-header {
    min-height: 82px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .84);
    backdrop-filter: blur(16px);
}
.support-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.support-panel-header .eyebrow { margin-bottom: 4px; }
.support-panel-header h2 { font-size: 1.05rem; }
.support-filter-label {
    max-width: 108px;
    padding: 5px 8px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: .66rem;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.support-conversation-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.support-conversation {
    position: relative;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) 30px;
    align-items: center;
    gap: 9px;
    padding: 13px 12px;
    border-bottom: 1px solid rgba(219, 218, 222, .76);
    color: var(--text);
    transition: background .16s ease, box-shadow .16s ease;
}
.support-conversation:hover { color: var(--text); background: rgba(90, 178, 174, .065); }
.support-conversation.is-active {
    background: linear-gradient(90deg, rgba(90, 178, 174, .16), rgba(90, 178, 174, .04));
    box-shadow: inset 3px 0 0 var(--accent-strong);
}
.support-conversation-link { display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; min-width: 0; gap: 12px; color: var(--text); }
.support-conversation-link:hover { color: var(--text); }
.support-delete-form { margin: 0; }
.support-delete-button {
    appearance: none;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 1.1rem;
    cursor: pointer;
    transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.support-delete-button:hover { border-color: #efc2c5; background: #fff1f2; color: #c94e58; }
.support-delete-button:focus-visible { outline: 0; box-shadow: 0 0 0 4px rgba(223, 98, 107, .14); }
.support-avatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border: 1px solid rgba(90, 178, 174, .32);
    border-radius: 14px;
    background: linear-gradient(145deg, #daf1f0, #bfe4e2);
    color: #397f7c;
    font-size: .9rem;
    font-weight: 850;
}
.support-avatar-large { width: 46px; height: 46px; border-radius: 15px; font-size: 1rem; }
.support-conversation-main { min-width: 0; }
.support-conversation-topline,
.support-conversation-meta { display: flex; align-items: center; justify-content: space-between; min-width: 0; gap: 8px; }
.support-conversation-topline strong {
    overflow: hidden;
    color: var(--text);
    font-size: .9rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.support-conversation-topline time { color: var(--muted); font-size: .66rem; white-space: nowrap; }
.support-conversation-meta { margin-top: 6px; color: var(--muted); font-size: .72rem; }
.support-conversation-meta > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.support-conversation.has-unread { box-shadow: inset 3px 0 0 #5aa7ff; }
.support-new-marker {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #256fbd;
    font-size: .66rem;
    font-weight: 850;
    white-space: nowrap;
}
.support-new-marker i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #5aa7ff;
    box-shadow: 0 0 0 3px rgba(90, 167, 255, .12);
}
.support-pagination {
    display: grid;
    grid-template-columns: 36px 1fr 36px;
    align-items: center;
    gap: 6px;
    min-height: 54px;
    padding: 8px 14px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .78rem;
    text-align: center;
}
.support-pagination a,
.support-pagination > span:first-child,
.support-pagination > span:last-child { display: grid; place-items: center; height: 32px; border-radius: 9px; }
.support-pagination a { background: var(--surface-2); color: var(--text); }
.support-pagination > span:first-child,
.support-pagination > span:last-child { color: #aaa7b1; }
.support-list-empty,
.support-no-selection,
.support-thread-empty {
    display: grid;
    place-items: center;
    align-content: center;
    min-height: 100%;
    padding: 32px;
    color: var(--muted);
    text-align: center;
}
.support-list-empty > span {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    margin-bottom: 14px;
    border-radius: 15px;
    background: rgba(90, 178, 174, .09);
    color: var(--accent-ink);
    font-size: 1.25rem;
}
.support-list-empty strong,
.support-no-selection strong { margin-bottom: 7px; color: var(--text); }
.support-list-empty p,
.support-no-selection p { max-width: 340px; margin: 0; font-size: .84rem; line-height: 1.55; }
.support-thread-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.support-thread-person { display: flex; align-items: center; min-width: 0; gap: 12px; }
.support-thread-person > div { min-width: 0; }
.support-thread-person h2 { overflow: hidden; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.support-thread-person p { margin: 4px 0 0; overflow: hidden; color: var(--muted); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.support-mobile-back { display: none; }
.support-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}
.support-message-row { display: flex; margin-bottom: 12px; }
.support-message-row:last-child { margin-bottom: 0; }
.support-message-row-outbound { justify-content: flex-end; }
.support-message {
    width: fit-content;
    max-width: min(78%, 640px);
    padding: 10px 13px 8px;
    border: 1px solid var(--line);
    border-radius: 5px 16px 16px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(75, 70, 92, .09);
}
.support-message-outbound {
    border-color: #a9d9d6;
    border-radius: 16px 5px 16px 16px;
    background: linear-gradient(145deg, #e6f6f5, #d7efed);
}
.support-message-author { display: block; margin-bottom: 4px; color: var(--accent-ink); font-size: .68rem; font-weight: 800; }
.support-message p { margin: 0 0 5px; color: var(--text); font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.support-message > time { display: block; color: #9692a0; font-size: .63rem; text-align: right; white-space: nowrap; }
.support-history-note { align-self: center; margin: 0 auto 8px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .68rem; }
.support-delivery { display: block; margin-top: 5px; color: var(--muted); font-size: .64rem; text-align: right; }
.support-delivery-failed { color: var(--danger); font-weight: 700; }
.support-attachment {
    display: flex;
    align-items: center;
    min-width: min(280px, 100%);
    gap: 10px;
    margin: 7px 0;
    padding: 10px;
    border: 1px solid rgba(90, 178, 174, .22);
    border-radius: 11px;
    background: rgba(90, 178, 174, .055);
    color: var(--text);
}
.support-attachment:hover { background: rgba(90, 178, 174, .10); color: var(--text); }
.support-attachment-icon { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; border-radius: 9px; background: rgba(90, 178, 174, .14); color: var(--accent-strong); }
.support-attachment > span:last-child { min-width: 0; }
.support-attachment strong { display: block; overflow: hidden; font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.support-attachment small { display: block; margin-top: 2px; color: var(--muted); font-size: .66rem; }
.support-composer {
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .94);
}
.support-compose-field textarea { min-height: 72px; max-height: 160px; padding: 11px 12px; background: #fff; }
.support-composer-actions { display: flex; align-items: center; gap: 10px; margin-top: 9px; }
.support-file-button {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    gap: 7px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--muted);
    cursor: pointer;
    font-size: .76rem;
}
.support-file-button:hover { border-color: rgba(71, 158, 154, .55); color: var(--text); }
.support-file-button:focus-within { border-color: var(--accent-strong); box-shadow: 0 0 0 3px rgba(90, 178, 174, .14); color: var(--text); }
.support-file-button > span:first-child { color: var(--accent-ink); font-size: 1.25rem; font-weight: 400; line-height: 1; }
.support-file-button input { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.support-selected-file { flex: 1; min-width: 0; overflow: hidden; color: var(--accent-ink); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.support-composer-actions .button { flex: 0 0 auto; }
.support-no-selection { height: 100%; }
.support-no-selection-icon {
    display: grid;
    place-items: center;
    width: 68px;
    height: 68px;
    margin-bottom: 18px;
    border: 1px solid rgba(90, 178, 174, .28);
    border-radius: 22px;
    background: rgba(90, 178, 174, .08);
    color: var(--accent-ink);
    font-size: 1.5rem;
}
.support-detail-section { padding: 22px 18px; border-bottom: 1px solid var(--line); }
.support-detail-section:last-child { border-bottom: 0; }
.support-detail-identity { display: flex; align-items: center; gap: 11px; margin: 15px 0 22px; }
.support-detail-identity > div { min-width: 0; }
.support-detail-identity strong,
.support-detail-identity span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.support-detail-identity strong { font-size: .88rem; }
.support-detail-identity span { margin-top: 4px; color: var(--muted); font-size: .72rem; }
.support-detail-list { display: grid; gap: 0; margin: 0; }
.support-detail-list > div { padding: 11px 0; border-top: 1px solid rgba(219, 218, 222, .76); }
.support-detail-list dt { margin-bottom: 4px; color: var(--muted); font-size: .7rem; }
.support-detail-list dd { margin: 0; color: var(--text); font-size: .78rem; overflow-wrap: anywhere; }
.support-details-placeholder { display: grid; place-items: center; min-height: 100%; padding: 25px; color: var(--muted); font-size: .8rem; line-height: 1.55; text-align: center; }

.confirm-dialog {
    width: min(440px, calc(100% - 32px));
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 24px;
    background: transparent;
    color: var(--text);
}
.confirm-dialog::backdrop {
    background: rgba(25, 24, 31, .36);
    backdrop-filter: blur(10px) saturate(115%);
    -webkit-backdrop-filter: blur(10px) saturate(115%);
}
.confirm-card {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 18px;
    padding: 26px;
    border: 1px solid rgba(255, 255, 255, .92);
    border-radius: 24px;
    background: linear-gradient(145deg, rgba(255, 255, 255, .98), rgba(248, 248, 250, .96));
    box-shadow: 0 32px 90px rgba(46, 42, 60, .24), 0 4px 12px rgba(46, 42, 60, .1);
}
.confirm-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 1px solid #f0c3c6;
    border-radius: 16px;
    background: #fff1f2;
    color: #c94e58;
    font-size: 1.2rem;
    font-weight: 850;
}
.confirm-copy { min-width: 0; }
.confirm-copy .eyebrow { margin-bottom: 6px; }
.confirm-copy h2 { margin-bottom: 8px; }
.confirm-copy .muted { font-size: .9rem; }
.confirm-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #080a0b;
    --surface: rgba(24, 27, 29, .88);
    --surface-2: #171c1e;
    --line: #2b3335;
    --text: #f2f5f5;
    --muted: #9da6a8;
    --accent: #69cbc6;
    --accent-strong: #50b6b1;
    --accent-ink: #86ddd8;
    --accent-button: #4eb4af;
    --info-bg: #5aa7ff;
    --info-fg: #071421;
    --danger: #ff858c;
    --warning: #e8b45d;
}

html[data-theme="dark"] body {
    background:
        radial-gradient(circle at 8% 0%, rgba(72, 176, 169, .20), transparent 31rem),
        radial-gradient(circle at 94% 10%, rgba(89, 78, 145, .18), transparent 34rem),
        linear-gradient(180deg, #0b0e0f 0%, #07090a 100%);
}
html[data-theme="dark"] .topbar {
    background: rgba(13, 16, 17, .76);
    border-bottom-color: rgba(54, 64, 66, .72);
    box-shadow: 0 10px 34px rgba(0, 0, 0, .28);
}
html[data-theme="dark"] .brand-logo,
html[data-theme="dark"] .login-logo { filter: drop-shadow(0 8px 22px rgba(44, 181, 173, .16)); }
html[data-theme="dark"] .nav a:hover { background: rgba(105, 203, 198, .10); color: #85ddd8; }
html[data-theme="dark"] .nav a.is-active {
    color: #a1e7e3;
    background: linear-gradient(135deg, rgba(105, 203, 198, .16), rgba(105, 203, 198, .055));
    box-shadow: inset 0 0 0 1px rgba(105, 203, 198, .13), 0 8px 22px rgba(0, 0, 0, .18);
}
html[data-theme="dark"] .theme-toggle {
    border-color: #313a3c;
    background: rgba(29, 34, 36, .82);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .24), inset 0 1px 0 rgba(255,255,255,.05);
    color: #b5bdbf;
}
html[data-theme="dark"] .theme-switch { background: #2e7471; box-shadow: inset 0 1px 4px rgba(0,0,0,.45), 0 0 14px rgba(105,203,198,.12); }
html[data-theme="dark"] .theme-switch i { background: #dff9f7; transform: translateX(14px); }
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .login-card {
    border-color: rgba(255, 255, 255, .065);
    background: linear-gradient(145deg, rgba(29, 33, 35, .94), rgba(17, 20, 22, .92));
    box-shadow: 0 22px 62px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255,255,255,.035);
}
html[data-theme="dark"] th,
html[data-theme="dark"] td { border-bottom-color: rgba(61, 72, 74, .72); }
html[data-theme="dark"] tbody tr:hover { background: rgba(105, 203, 198, .045); }
html[data-theme="dark"] .button {
    border-color: #30383a;
    background: linear-gradient(180deg, #24292b, #1a1e20);
    color: var(--text);
    box-shadow: 0 3px 10px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.035);
}
html[data-theme="dark"] .button:hover { border-color: rgba(105,203,198,.45); color: #8de2dd; box-shadow: 0 8px 20px rgba(0,0,0,.3); }
html[data-theme="dark"] .button-primary { border-color: #3e9e99; background: linear-gradient(135deg, #5fc5c0, #3d9894); color: #07100f; box-shadow: 0 9px 24px rgba(39,145,139,.25); }
html[data-theme="dark"] .button-primary:hover { color: #050b0b; background: linear-gradient(135deg, #76d4cf, #49aaa5); }
html[data-theme="dark"] .button-danger { border-color: #643a3f; color: #ff9ba1; background: #2b191c; }
html[data-theme="dark"] .button-danger:hover { border-color: #8b4d54; color: #ffb0b5; background: #341c20; }
html[data-theme="dark"] .button-ghost { background: transparent; box-shadow: none; }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { border-color: #313a3c; background: rgba(10, 13, 14, .88); color: var(--text); }
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus { border-color: #59bdb8; box-shadow: 0 0 0 4px rgba(105,203,198,.12), 0 0 24px rgba(80,182,177,.08); }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #737d7f; }
html[data-theme="dark"] .file-control { background: rgba(105,203,198,.045); }
html[data-theme="dark"] .system-note { border-color: rgba(105,203,198,.18); background: rgba(105,203,198,.045); }
html[data-theme="dark"] .field input[type="file"]::file-selector-button { background: #202729; color: var(--accent-ink); }
html[data-theme="dark"] .activity-track { background: rgba(105,203,198,.065); }
html[data-theme="dark"] .activity-bar { background: linear-gradient(180deg, #75d4cf, #3d9894); box-shadow: 0 -6px 20px rgba(76,190,184,.16); }
html[data-theme="dark"] .status-active,
html[data-theme="dark"] .status-done,
html[data-theme="dark"] .status-safe { color: #82ddd8; border-color: #346d6a; background: #132a29; }
html[data-theme="dark"] .status-blocked,
html[data-theme="dark"] .status-failed,
html[data-theme="dark"] .status-invalid { color: #ff9ba1; border-color: #663b40; background: #2b191c; }
html[data-theme="dark"] .status-draft,
html[data-theme="dark"] .status-queued,
html[data-theme="dark"] .status-running,
html[data-theme="dark"] .status-partial { color: #f0c675; border-color: #665333; background: #292317; }
html[data-theme="dark"] .alert { background: #1b2022; }
html[data-theme="dark"] .alert-error { border-color: #663b40; color: #ff9ba1; background: #2b191c; }
html[data-theme="dark"] .alert-success { border-color: #346d6a; color: #82ddd8; background: #132a29; }
html[data-theme="dark"] .alert-warning { border-color: #665333; color: #f0c675; background: #292317; }
html[data-theme="dark"] .login-shell::before { background: rgba(76, 184, 178, .10); }
html[data-theme="dark"] .login-shell::after { border-color: rgba(106, 94, 167, .24); }
html[data-theme="dark"] .support-layout {
    border-color: #30383a;
    background: rgba(17, 20, 22, .86);
    box-shadow: 0 26px 76px rgba(0,0,0,.36), inset 0 1px 0 rgba(255,255,255,.025);
}
html[data-theme="dark"] .support-conversations,
html[data-theme="dark"] .support-thread,
html[data-theme="dark"] .support-details { background: linear-gradient(160deg, rgba(27,31,33,.98), rgba(14,17,18,.98)); }
html[data-theme="dark"] .support-thread { background: radial-gradient(circle at 50% 0%, rgba(105,203,198,.07), transparent 26rem), #0e1112; }
html[data-theme="dark"] .support-panel-header,
html[data-theme="dark"] .support-thread-header,
html[data-theme="dark"] .support-composer { background: rgba(22, 26, 28, .91); }
html[data-theme="dark"] .support-conversation { border-bottom-color: rgba(57,67,69,.7); }
html[data-theme="dark"] .support-conversation:hover { background: rgba(105,203,198,.05); }
html[data-theme="dark"] .support-conversation.is-active { background: linear-gradient(90deg, rgba(80,182,177,.18), rgba(80,182,177,.035)); }
html[data-theme="dark"] .support-delete-button:hover { border-color: #663b40; background: #2b191c; color: #ff9ba1; }
html[data-theme="dark"] .support-new-marker { color: #82bfff; }
html[data-theme="dark"] .support-avatar { border-color: #315e5c; background: linear-gradient(145deg, #244b49, #173432); color: #a0e6e2; }
html[data-theme="dark"] .support-pagination > span:first-child,
html[data-theme="dark"] .support-pagination > span:last-child { color: #5d686a; }
html[data-theme="dark"] .support-message { border-color: #313a3c; background: #1d2224; box-shadow: 0 9px 28px rgba(0,0,0,.25); }
html[data-theme="dark"] .support-message-outbound { border-color: #356e6b; background: linear-gradient(145deg, #183b39, #142f2e); }
html[data-theme="dark"] .support-message > time { color: #7f898b; }
html[data-theme="dark"] .support-attachment { border-color: rgba(105,203,198,.16); background: rgba(6,10,10,.28); }
html[data-theme="dark"] .support-attachment:hover { background: rgba(105,203,198,.06); }
html[data-theme="dark"] .support-attachment-icon { background: rgba(105,203,198,.11); color: #82ddd8; }
html[data-theme="dark"] .support-compose-field textarea { background: #0c0f10; }
html[data-theme="dark"] .support-no-selection-icon { border-color: #315e5c; background: rgba(105,203,198,.055); }
html[data-theme="dark"] .support-detail-list > div { border-top-color: rgba(57,67,69,.7); }
html[data-theme="dark"] .confirm-dialog::backdrop { background: rgba(0, 0, 0, .58); }
html[data-theme="dark"] .confirm-card {
    border-color: rgba(255, 255, 255, .075);
    background: linear-gradient(145deg, rgba(31, 36, 38, .99), rgba(15, 18, 20, .99));
    box-shadow: 0 36px 100px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255,255,255,.035);
}
html[data-theme="dark"] .confirm-icon { border-color: #663b40; background: #2b191c; color: #ff9ba1; }

@media (prefers-reduced-motion: no-preference) {
    body, .topbar, .metric-card, .panel, .login-card, input, select, textarea, .button, .support-layout { transition: background .22s ease, border-color .22s ease, color .22s ease, box-shadow .22s ease; }
}

@media (max-width: 1180px) {
    .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
    .topbar { padding: 12px 20px; flex-wrap: wrap; gap: 10px; }
    .nav { order: 3; flex: 1 0 100%; width: 100%; overflow-x: auto; scrollbar-width: none; }
    .nav::-webkit-scrollbar { display: none; }
    .topbar-actions { margin-left: auto; }
    .support-thread { scroll-margin-top: 132px; }
}

@media (max-width: 980px) {
    .topbar { padding: 12px 20px; flex-wrap: wrap; gap: 10px; }
    .nav { order: 3; flex: 1 0 100%; width: 100%; overflow-x: auto; scrollbar-width: none; }
    .nav::-webkit-scrollbar { display: none; }
    .topbar-actions { margin-left: auto; }
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .split-grid { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .support-layout { grid-template-columns: minmax(260px, 310px) minmax(0, 1fr); height: calc(100vh - 305px); }
    .support-details { display: none; }
}

@media (max-width: 640px) {
    .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 10px 12px 12px; }
    .brand { grid-column: 1; grid-row: 1; }
    .brand-logo { width: 130px; height: 42px; }
    .brand-copy { display: none; }
    .topbar-actions { grid-column: 2; grid-row: 1; margin: 0; }
    .logout-form { margin: 0; }
    .theme-toggle { min-height: 44px; gap: 5px; padding-inline: 8px; }
    .theme-symbol { display: none; }
    .theme-symbol:last-child { display: block; }
    html[data-theme="dark"] .theme-symbol:first-child { display: block; }
    html[data-theme="dark"] .theme-symbol:last-child { display: none; }
    .nav { grid-column: 1 / -1; grid-row: 2; width: 100%; min-width: 0; gap: 4px; padding-bottom: 2px; }
    .nav a { min-height: 44px; padding: 8px 10px; font-size: .82rem; white-space: nowrap; }
    .page { width: min(calc(100% - 24px), 1320px); padding-top: 28px; }
    .page-heading { align-items: flex-start; }
    .menu-page-heading { align-items: stretch; flex-direction: column; }
    .menu-page-heading > .button { width: 100%; }
    .metric-grid { grid-template-columns: 1fr; }
    .filter-bar { grid-template-columns: 1fr; }
    .field-row { grid-template-columns: 1fr; }
    .broadcast-history-panel { max-height: none; }
    .activity-chart { grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 3px; }
    .activity-label { font-size: .52rem; }
    .audit-filter { grid-template-columns: 1fr; }
    .audit-filter label { grid-column: auto; }
    .audit-filter .button { width: 100%; }
    .audit-scroll { max-height: 420px; padding-right: 4px; }
    .audit-item { align-items: flex-start; gap: 10px; }
    .audit-item time { font-size: .7rem; }
    .role-form { min-width: 0; }
    .login-card { padding: 28px; }
    .login-logo { width: min(218px, 76%); }
    .button { min-height: 44px; }
    .button-small { min-height: 44px; }
    .topbar-actions .button { min-height: 44px; }
    .table-scroll-hint { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: .72rem; line-height: 1.4; }
    th, td { padding: 13px 14px; }
    .support-page-heading { align-items: flex-end; }
    .support-page-heading h1 { font-size: 2.15rem; }
    .support-page-heading .muted { font-size: .84rem; }
    .support-filter-bar { grid-template-columns: 1fr 1fr; }
    .support-filter-bar input { grid-column: 1 / -1; }
    .support-bulk-actions { align-items: stretch; flex-direction: column; }
    .support-bulk-actions form,
    .support-bulk-actions .button { width: 100%; }
    .support-layout {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 560px;
        max-height: none;
        overflow: visible;
    }
    .support-conversations { min-height: 560px; border-right: 0; }
    .support-conversation-list { max-height: 620px; }
    .support-conversation { grid-template-columns: 18px minmax(0, 1fr) 44px; padding-right: 8px; }
    .support-delete-button { width: 44px; height: 44px; border-radius: 12px; }
    .support-thread { min-height: min(720px, calc(100vh - 24px)); border-top: 1px solid var(--line); }
    .support-layout-selected .support-thread { order: -1; }
    .support-thread-header { min-height: 90px; padding: 13px 14px; flex-wrap: wrap; }
    .support-mobile-back { display: block; width: 100%; color: var(--muted); font-size: .72rem; }
    .support-thread-person { max-width: 100%; }
    .support-thread-person .support-avatar { width: 39px; height: 39px; border-radius: 12px; }
    .support-messages { min-height: 360px; padding: 16px 12px; }
    .support-message { max-width: 88%; }
    .support-message p { font-size: .86rem; }
    .support-composer { padding: 12px; }
    .support-composer-actions { flex-wrap: wrap; }
    .support-file-button > span:nth-child(2) { display: none; }
    .support-file-button { width: 44px; min-height: 44px; padding: 0; justify-content: center; }
    .support-selected-file { max-width: calc(100% - 140px); }
    .support-no-selection { min-height: 560px; }
    .confirm-card { grid-template-columns: 42px minmax(0, 1fr); gap: 14px; padding: 22px; }
    .confirm-icon { width: 42px; height: 42px; border-radius: 14px; }
    .confirm-actions { display: grid; grid-template-columns: 1fr 1fr; }
}
