:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --topbar-bg: rgba(255, 255, 255, 0.92);
    --auth-bg: #eef3f9;
    --sidebar: #0f172a;
    --text: #152033;
    --text-strong: #0f172a;
    --muted: #64748b;
    --muted-2: #94a3b8;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --brand: #2563eb;
    --brand-strong: #1d4ed8;
    --brand-soft: #eff6ff;
    --good: #059669;
    --good-soft: #ecfdf5;
    --warn: #d97706;
    --warn-soft: #fffbeb;
    --bad: #dc2626;
    --bad-soft: #fef2f2;
    --violet: #7c3aed;
    --violet-soft: #f5f3ff;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow: 0 16px 42px rgba(15, 23, 42, 0.09);
    --radius: 14px;
    --font:
        Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI",
        "Microsoft YaHei", sans-serif;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #090f1d;
    --panel: #10192b;
    --panel-soft: #121e32;
    --topbar-bg: rgba(16, 25, 43, 0.92);
    --auth-bg: #080e1a;
    --text: #dce6f5;
    --text-strong: #f8fafc;
    --muted: #93a4bd;
    --muted-2: #6f829f;
    --line: #24334c;
    --line-strong: #354866;
    --brand: #4d7ecf;
    --brand-strong: #6f9ce6;
    --brand-soft: #15284b;
    --good: #34d399;
    --good-soft: #10362f;
    --warn: #fbbf24;
    --warn-soft: #3b2b10;
    --bad: #ef8398;
    --bad-soft: #3a202a;
    --violet: #a78bfa;
    --violet-soft: #2d2150;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.22);
    --shadow: 0 18px 44px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}
html {
    min-width: 320px;
}
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.55 var(--font);
    -webkit-font-smoothing: antialiased;
}
[hidden] {
    display: none !important;
}
a {
    color: inherit;
    text-decoration: none;
}
button,
input,
select,
textarea {
    font: inherit;
}
button,
a {
    -webkit-tap-highlight-color: transparent;
}
button {
    color: inherit;
}
button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}
input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    outline: 0;
    background: var(--panel);
    color: var(--text);
    transition:
        border-color 0.15s,
        box-shadow 0.15s,
        background 0.15s;
}
input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
    outline: 0;
}
input::placeholder,
textarea::placeholder {
    color: var(--muted-2);
}
textarea {
    min-height: 90px;
    resize: vertical;
}
label {
    color: var(--text-strong);
    font-size: 12px;
    font-weight: 750;
}
p {
    line-height: 1.65;
}
.skip-link {
    position: fixed;
    left: 18px;
    top: -60px;
    z-index: 100;
    padding: 9px 14px;
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}
.skip-link:focus {
    top: 14px;
}
.notice {
    position: fixed;
    z-index: 90;
    top: 84px;
    right: 24px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 15px;
    border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line));
    border-radius: 10px;
    background: var(--brand-soft);
    color: var(--brand-strong);
    box-shadow: var(--shadow);
    font-size: 12px;
    font-weight: 650;
}
.notice-error {
    border-color: color-mix(in srgb, var(--bad) 30%, var(--line));
    background: var(--bad-soft);
    color: var(--bad);
}
.notice-success {
    border-color: color-mix(in srgb, var(--good) 30%, var(--line));
    background: var(--good-soft);
    color: var(--good);
}
.loader {
    width: 18px;
    height: 18px;
    border: 2px solid #dbeafe;
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background: var(--auth-bg);
}
.boot-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-width: 250px;
    min-height: 110px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow-sm);
    color: var(--muted);
}
.auth-shell {
    width: min(960px, 100%);
    min-height: 570px;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--panel);
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.16);
}
.auth-visual {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 42px;
    background: linear-gradient(145deg, #0f172a, #172554 62%, #1e3a8a);
    color: #fff;
}
.auth-visual h1 {
    max-width: 410px;
    margin: 0 0 14px;
    font-size: 34px;
    line-height: 1.18;
    letter-spacing: 0;
}
.auth-visual p {
    max-width: 390px;
    margin: 0;
    color: #b7c5db;
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: 11px;
    background: linear-gradient(145deg, #3b82f6, #1d4ed8);
    color: #fff;
    font-size: 18px;
    font-weight: 900;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.32);
}
.auth-brand strong,
.brand-copy strong {
    display: block;
    color: #fff;
    font-size: 16px;
}
.auth-brand small,
.brand-copy span {
    display: block;
    color: #8298b6;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.auth-kicker,
.eyebrow {
    margin: 0 0 10px;
    color: var(--brand);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
}
.auth-kicker {
    color: #93c5fd;
}
.auth-points {
    display: grid;
    gap: 11px;
    margin-top: 28px;
}
.auth-points span {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #d6e2f2;
    font-size: 12px;
}
.auth-points i {
    display: grid;
    place-items: center;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    background: rgba(52, 211, 153, 0.16);
    color: #6ee7b7;
    font-style: normal;
}
.auth-footnote {
    color: #7f93b1;
}
.auth-form-wrap {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px;
}
.auth-form-wrap h2 {
    margin: 0;
    color: var(--text-strong);
    font-size: 26px;
}
.auth-form-wrap > p {
    margin: 7px 0 25px;
    color: var(--muted);
}
.auth-form-wrap form {
    display: grid;
    gap: 10px;
}
.field-help {
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}
.auth-security {
    margin-top: 24px !important;
    color: var(--muted) !important;
    text-align: center;
    font-size: 10px;
}

.app-shell {
    min-height: 100vh;
}
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: 248px;
    display: flex;
    flex-direction: column;
    padding: 24px 16px 18px;
    background: linear-gradient(180deg, #0f172a, #0a1120 72%);
    color: #dbe7f7;
    border-right: 1px solid rgba(148, 163, 184, 0.12);
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 10px 24px;
}
.brand-copy span {
    margin-top: 1px;
}
.nav-label {
    padding: 10px 12px 8px;
    color: #6f829f;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
}
.nav {
    display: grid;
    gap: 5px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    min-height: 43px;
    padding: 9px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #9fb0c8;
    text-align: left;
    font-weight: 650;
    cursor: pointer;
    transition: 0.18s ease;
}
.nav-link:hover {
    color: #fff;
    background: rgba(148, 163, 184, 0.1);
}
.nav-link.active {
    color: #fff;
    background: linear-gradient(
        90deg,
        rgba(59, 130, 246, 0.28),
        rgba(59, 130, 246, 0.12)
    );
    box-shadow: inset 3px 0 #60a5fa;
}
.nav-icon {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    font-size: 16px;
}
.sidebar-footer {
    margin-top: auto;
    padding: 14px 10px 2px;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
}
.server-mini {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #91a4bf;
    font-size: 11px;
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.11);
}
.sidebar-site-link {
    display: block;
    margin-top: 14px;
    color: #8298b6;
    font-size: 11px;
}
.main-wrap {
    min-height: 100vh;
    margin-left: 248px;
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: 72px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: var(--topbar-bg);
    backdrop-filter: blur(18px);
}
.page-identity {
    min-width: 0;
}
.page-identity strong {
    display: block;
    color: var(--text-strong);
    font-size: 16px;
}
.page-identity span {
    display: block;
    color: var(--muted);
    font-size: 11px;
}
.top-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}
.session-chip {
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    color: var(--muted);
    font-size: 11px;
}
.session-chip b {
    color: var(--text-strong);
}
.account-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 10px 5px 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    color: var(--text-strong);
    font-weight: 700;
}
.avatar {
    display: grid;
    place-items: center;
    width: 29px;
    height: 29px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 850;
}
.icon-button {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    cursor: pointer;
    transition: 0.16s ease;
}
.icon-button:hover {
    border-color: var(--line-strong);
    background: var(--panel-soft);
}
.mobile-menu {
    display: none;
}
.content {
    width: min(1480px, 100%);
    margin: 0 auto;
    padding: 28px;
}
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}
.page-head h1 {
    margin: 0;
    color: var(--text-strong);
    font-size: clamp(24px, 2.4vw, 32px);
    line-height: 1.15;
    letter-spacing: 0;
}
.page-head p:last-child {
    max-width: 780px;
    margin: 7px 0 0;
    color: var(--muted);
}
.head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    padding: 8px 14px;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: 9px;
    background: var(--brand);
    color: #fff;
    font-weight: 750;
    cursor: pointer;
    transition: 0.16s ease;
}
.button:hover:not(:disabled) {
    background: var(--brand-strong);
}
.button.secondary {
    border-color: var(--line);
    background: var(--panel);
    color: var(--text);
}
.button.secondary:hover:not(:disabled) {
    border-color: var(--line-strong);
    background: var(--panel-soft);
}
.button.ghost {
    background: transparent;
    color: var(--muted);
}
.button.ghost:hover:not(:disabled) {
    background: var(--panel-soft);
    color: var(--text);
}
.button.small {
    min-height: 32px;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 12px;
}
.button.is-loading {
    cursor: default;
    opacity: 0.75;
}
.danger-action {
    color: var(--bad);
}
.button-quiet.danger-action {
    border-color: color-mix(in srgb, var(--bad) 38%, var(--line));
    background: var(--bad-soft);
    color: var(--bad);
}
.button-quiet.danger-action:hover:not(:disabled) {
    border-color: var(--bad);
    background: color-mix(in srgb, var(--bad) 18%, var(--panel));
    color: var(--bad);
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.overview-metrics {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}
.metric {
    min-height: 125px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: var(--shadow-sm);
}
.metric-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-weight: 700;
}
.metric-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--brand-soft);
    color: var(--brand);
}
.metric-value {
    display: block;
    margin-top: 13px;
    color: var(--text-strong);
    font-size: 30px;
    line-height: 1;
    font-weight: 850;
    font-variant-numeric: tabular-nums;
}
.metric-note {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
}
.metric.good .metric-icon {
    background: var(--good-soft);
    color: var(--good);
}
.metric.warn .metric-icon {
    background: var(--warn-soft);
    color: var(--warn);
}
.metric.bad .metric-icon {
    background: var(--bad-soft);
    color: var(--bad);
}
.metric.violet .metric-icon {
    background: var(--violet-soft);
    color: var(--violet);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: 18px;
}
.stack {
    display: grid;
    gap: 18px;
    align-content: start;
}
.panel {
    margin-bottom: 18px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow-sm);
}
.panel.flush {
    padding: 0;
    overflow: hidden;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}
.panel-head h2 {
    margin: 0;
    color: var(--text-strong);
    font-size: 16px;
}
.panel-head p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 11px;
}
.progress-item {
    margin: 17px 0;
}
.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 11px;
}
.progress-label strong {
    color: var(--text-strong);
}
.progress-track {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--panel-soft);
}
.progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--brand);
    transition: width 0.25s ease;
}
.progress-bar.good {
    background: var(--good);
}
.progress-bar.bad {
    background: var(--bad);
}
.quick-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.quick-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--panel-soft);
    color: inherit;
    text-align: left;
    cursor: pointer;
}
.quick-link:hover {
    border-color: var(--brand);
}
.quick-link-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    border-radius: 10px;
    background: var(--brand-soft);
    color: var(--brand);
}
.quick-link strong,
.quick-link span span {
    display: block;
}
.quick-link strong {
    color: var(--text-strong);
    font-size: 12px;
}
.quick-link span span {
    color: var(--muted);
    font-size: 10px;
}
.health-list {
    display: grid;
}
.health-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
}
.health-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}
.health-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 10px;
    background: var(--good-soft);
    color: var(--good);
}
.health-row.service-unavailable .health-icon {
    background: var(--bad-soft);
    color: var(--bad);
}
.health-copy {
    min-width: 0;
}
.health-copy strong {
    display: block;
    color: var(--text-strong);
    font-size: 12px;
}
.health-copy span {
    display: block;
    color: var(--muted);
    font-size: 10px;
}
.health-value {
    margin-left: auto;
    color: var(--good);
    font-size: 11px;
    font-weight: 800;
    overflow-wrap: anywhere;
}
.service-unavailable .health-value {
    color: var(--bad);
}

.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 64px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--panel-soft);
}
.toolbar-title {
    color: var(--text-strong);
    font-weight: 800;
}
.toolbar-status {
    margin-left: auto;
    color: var(--muted);
    font-size: 11px;
}
.toolbar-status.error-text,
.error-text {
    color: var(--bad);
}
.filter-form {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}
.audit-toolbar {
    align-items: flex-end;
}
.audit-toolbar .filter-form {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
}
.audit-toolbar > #audit-export-button {
    flex: 0 0 auto;
}
.inline-field {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    white-space: nowrap;
}
.inline-field select {
    width: auto;
    min-width: 120px;
    min-height: 36px;
    padding-block: 6px;
}
.inline-field input {
    width: min(230px, 100%);
    min-height: 36px;
    padding-block: 6px;
}
.task-counts {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--line);
}
.task-counts span {
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 10px;
}

.list-table {
    overflow: hidden;
}
.list-head {
    display: grid;
    align-items: center;
    gap: 14px;
    padding: 11px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.03em;
}
.account-table .list-head,
.account-table .ops-row {
    grid-template-columns: minmax(180px, 1.4fr) 130px 165px 70px;
}
.task-table .list-head,
.task-table .ops-row {
    grid-template-columns: minmax(190px, 1.5fr) 90px 165px 100px;
}
.audit-table .list-head,
.audit-table .audit-row {
    grid-template-columns: minmax(170px, 1.1fr) 90px minmax(130px, 0.8fr) 155px;
}
.ops-list {
    max-height: clamp(320px, calc(100vh - 360px), 620px);
    overflow-y: auto;
}
.ops-row {
    display: grid;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-width: 0;
    padding: 12px 18px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    color: inherit;
    text-align: left;
    cursor: pointer;
}
.ops-row:hover {
    background: var(--brand-soft);
}
.ops-row.is-selected {
    background: var(--brand-soft);
    box-shadow: inset 3px 0 var(--brand);
}
.ops-row.is-selected .row-action {
    color: var(--brand-strong);
}
.ops-row:last-child {
    border-bottom: 0;
}
.row-identity {
    min-width: 0;
}
.row-identity strong,
.row-identity small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.row-identity strong {
    color: var(--text-strong);
    font-size: 12px;
}
.row-identity small,
.subtext {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}
.row-status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}
.row-action {
    color: var(--brand);
    font-size: 11px;
    font-weight: 750;
    text-align: right;
}
.panel-foot {
    padding: 10px 18px;
    border-top: 1px solid var(--line);
    background: var(--panel-soft);
}
.panel-status {
    min-height: 18px;
    margin: 0;
    padding: 10px 18px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
}
.pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 18px;
    border-top: 1px solid var(--line);
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 11px;
}
.pager-label {
    min-width: 72px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.detail-panel {
    margin-bottom: 18px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow-sm);
    scroll-margin-top: 88px;
}
.detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}
.detail-head h3 {
    margin: 0;
    color: var(--text-strong);
    font-size: 16px;
}
.detail-panel > .subtext {
    margin: 10px 0 0;
}
.ops-pager {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 11px;
}
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}
.badge.active {
    background: var(--good-soft);
    color: var(--good);
}
.badge.expiring {
    background: var(--warn-soft);
    color: var(--warn);
}
.badge.disabled,
.badge.revoked {
    background: var(--bad-soft);
    color: var(--bad);
}
.badge.info {
    background: var(--brand-soft);
    color: var(--brand);
}
.empty-state {
    padding: 44px 20px;
    color: var(--muted);
    text-align: center;
}
.empty-state.compact {
    padding: 24px 16px;
}
.mono {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 11px;
    overflow-wrap: anywhere;
}
.small-label {
    color: var(--muted);
    font-size: 11px;
}

.dialog-inline {
    margin-bottom: 18px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow-sm);
}
.dialog-inline-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}
.dialog-inline-head h2 {
    margin: 0;
    font-size: 16px;
}
.dialog-inline-head p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 11px;
}
.dialog-inline-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px;
}
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-error {
    color: var(--bad);
    font-size: 11px;
}
.credential-panel {
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid color-mix(in srgb, var(--warn) 28%, var(--line));
    border-radius: var(--radius);
    background: var(--warn-soft);
}
.credential-panel strong {
    font-size: 13px;
}
.credential-panel p {
    margin: 3px 0 0;
    color: var(--warn);
    font-size: 11px;
}
.credential-panel textarea {
    margin: 12px 0;
    font:
        12px/1.5 Consolas,
        monospace;
}
.inline-form-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.record-detail {
    padding: 20px;
}
.accounts-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
.accounts-workspace.has-detail {
    grid-template-columns: minmax(0, 1.25fr) minmax(420px, 0.75fr);
}
.accounts-workspace > .panel {
    margin-bottom: 0;
}
#account-detail {
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 112px);
    overflow: auto;
    scroll-margin-top: 88px;
}
#account-detail .record-detail-heading {
    position: sticky;
    top: -20px;
    z-index: 1;
    margin: -20px -20px 0;
    padding: 20px 20px 15px;
    background: var(--panel);
}
.record-detail-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--line);
}
.record-detail-heading-main {
    min-width: 0;
    flex: 1 1 auto;
}
.record-detail-eyebrow {
    margin: 0 0 6px;
    color: var(--muted-2);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
}
.record-detail-title-row {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}
.record-detail-heading strong {
    min-width: 0;
    max-width: 100%;
    color: var(--text-strong);
    font-size: 18px;
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.record-detail-heading small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}
.record-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 15px 0;
}
.record-section {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}
.record-section h4 {
    margin: 0 0 9px;
    color: var(--text-strong);
    font-size: 13px;
}
.record-section > .subtext {
    margin: 0 0 12px;
}
.record-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.record-row:last-child {
    border-bottom: 0;
}
.record-row > span:first-child {
    min-width: 0;
}
.record-row strong,
.record-row small {
    display: block;
    overflow-wrap: anywhere;
}
.record-row strong {
    font-size: 12px;
}
.record-row small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
}
.record-badge {
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}
.record-badge.is-active {
    background: var(--good-soft);
    color: var(--good);
}
.record-badge.is-disabled {
    background: var(--bad-soft);
    color: var(--bad);
}
.record-badge.is-pending {
    background: var(--warn-soft);
    color: var(--warn);
}
.record-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin: 14px 0;
}
.record-facts > div {
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--panel-soft);
}
.record-facts dt {
    color: var(--muted);
    font-size: 11px;
}
.record-facts dd {
    margin: 4px 0 0;
    color: var(--text);
    font-size: 12px;
    overflow-wrap: anywhere;
}
.password-value {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}
.password-value .mono {
    min-width: 0;
    white-space: nowrap;
}

.record-status {
    min-height: 17px;
    margin: 0 0 2px;
    color: var(--muted);
    font-size: 11px;
}
.record-status.error-text {
    color: var(--bad);
}
.record-danger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px dashed color-mix(in srgb, var(--bad) 32%, var(--line));
}
.record-danger-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}
.token-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.token-row:last-child {
    border-bottom: 0;
}
.token-main {
    min-width: 0;
}
.token-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.token-head strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}
.token-meta {
    display: block;
    margin-top: 4px;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.id-text {
    overflow-wrap: anywhere;
}
.button.copy-button {
    min-height: 32px;
    padding: 5px 10px;
    font-family: var(--font);
    font-size: 11px;
}
.account-main-actions {
    margin: 16px 0 2px;
}
.account-main-actions .button {
    min-height: 36px;
}
.current-device-facts {
    margin-top: 12px;
}
.account-editor {
    display: grid;
    gap: 0;
}
.account-edit-section {
    min-width: 0;
}
.detail-form-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
    margin: 12px 0;
}
.account-policy-section .detail-form-fields {
    display: block;
    margin: 14px 0;
}
.detail-field-group + .detail-field-group {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.detail-field-group-title {
    margin: 0 0 8px;
    color: var(--text-strong);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0;
}
.detail-field-group-fields {
    display: grid;
    gap: 0;
}
.account-policy-section .form-field-check {
    display: flex;
    align-items: center;
    min-height: 38px;
    padding: 6px 2px;
    cursor: pointer;
    border-bottom: 1px solid var(--line);
}
.account-policy-section .form-field-check:last-child {
    border-bottom: 0;
}
.account-policy-section .form-field-check > span {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
    color: var(--text);
    font-size: 13px;
    line-height: 1.35;
    white-space: nowrap;
}
.account-policy-section .form-field-check input[type="checkbox"] {
    order: 2;
    width: 16px;
    min-width: 16px;
    height: 16px;
    min-height: 16px;
    margin: 0 2px 0 12px;
}
.account-policy-section .form-field-check .form-field-error {
    order: 3;
    flex-basis: 100%;
}
.account-policy-section .detail-field-group:last-child .form-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(84px, 112px);
    align-items: center;
    column-gap: 12px;
    row-gap: 2px;
}
.account-policy-section .detail-field-group:last-child .form-field > span {
    grid-column: 1;
    grid-row: 1;
    font-size: 12px;
    font-weight: 600;
}
.account-policy-section .detail-field-group:last-child .form-field > input[type="number"] {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
}
.account-policy-section .detail-field-group:last-child .form-help,
.account-policy-section .detail-field-group:last-child .form-field-error {
    grid-column: 1 / -1;
}
.account-policy-section .form-help {
    color: var(--muted);
    font-size: 11px;
}
.account-policy-section .detail-field-group:last-child .detail-field-group-fields {
    gap: 12px;
}
.account-policy-section .form-field-error:empty {
    display: none;
}
.detail-form-fields .form-field {
    min-width: 0;
}
#account-detail .form-field > span {
    font-size: 11px;
}
#account-detail .detail-form-fields input[type="text"],
#account-detail .detail-form-fields input[type="date"],
#account-detail .detail-form-fields input[type="number"],
#account-detail .detail-form-fields select {
    min-height: 36px;
    padding: 7px 9px;
    border-radius: 8px;
    font-size: 12px;
}
.detail-save-button {
    min-height: 34px;
    padding-inline: 13px;
    font-size: 12px;
}
.device-list {
    border-top: 1px solid var(--line);
}
.device-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.device-row:last-child {
    border-bottom: 0;
}
.device-main,
.device-heading {
    min-width: 0;
}
.device-heading {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.device-heading strong {
    min-width: 0;
    font-size: 12px;
}
.device-meta {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
}
.device-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
}
.device-actions .button {
    min-height: 30px;
    padding: 4px 9px;
    font-size: 11px;
}
.token-section .record-badge {
    flex: 0 0 auto;
}
.record-facts .copy-button {
    min-height: 26px;
    padding: 3px 8px;
}
.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.inline-form label {
    min-width: min(280px, 100%);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.task-detail-event {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 10px;
}
.task-detail-event strong {
    color: var(--text);
}

.audit-list {
    max-height: 590px;
    overflow-y: auto;
}
.audit-row {
    display: grid;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}
.audit-row:hover {
    background: var(--brand-soft);
}
.audit-row:last-child {
    border-bottom: 0;
}
.audit-row > strong {
    color: var(--text-strong);
    font-size: 11px;
}
.audit-row time {
    color: var(--muted);
    font-size: 10px;
    text-align: right;
}
.audit-details {
    grid-column: 1 / -1;
    margin: -4px 0 0;
    color: var(--muted);
    font-size: 9px;
    overflow-wrap: anywhere;
}

@media (max-width: 1320px) {
    .overview-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
@media (max-width: 1180px) {
    .accounts-workspace.has-detail {
        grid-template-columns: 1fr;
    }
    #account-detail {
        position: static;
        max-height: none;
        overflow: visible;
    }
    #account-detail .record-detail-heading {
        position: static;
        margin: 0;
        padding: 0 0 15px;
    }
}
@media (max-width: 1120px) {
    .metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .overview-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 0 28px 80px rgba(15, 23, 42, 0.42);
    }
    body.nav-open .sidebar {
        transform: translateX(0);
    }
    .main-wrap {
        margin-left: 0;
    }
    .mobile-menu {
        display: inline-grid;
    }
    .content,
    .topbar {
        padding-inline: 20px;
    }
}
@media (max-width: 720px) {
    .auth-shell {
        grid-template-columns: 1fr;
        min-height: auto;
    }
    .auth-visual {
        display: none;
    }
    .auth-form-wrap {
        padding: 34px 25px;
    }
    .page-head {
        align-items: flex-start;
        flex-direction: column;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .session-chip,
    .account-chip span:last-child {
        display: none;
    }
    .list-head {
        display: none;
    }
    .account-table .ops-row,
    .task-table .ops-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .account-table .ops-row {
        grid-template-areas:
            "identity status"
            "identity action";
    }
    .account-table .ops-row > .row-identity {
        grid-area: identity;
    }
    .account-table .ops-row > .row-status {
        grid-area: status;
        justify-content: flex-end;
    }
    .account-table .ops-row > .subtext {
        display: none;
    }
    .account-table .ops-row > .row-action {
        grid-area: action;
    }
    .task-table .ops-row {
        grid-template-areas:
            "identity badge"
            "meta badge";
    }
    .task-table .ops-row > .row-identity {
        grid-area: identity;
    }
    .task-table .ops-row > .subtext:nth-child(2),
    .task-table .ops-row > .subtext:nth-child(3) {
        display: none;
    }
    .task-table .ops-row > .subtext:nth-child(4) {
        display: block;
        grid-area: meta;
    }
    .task-table .ops-row > .badge {
        grid-area: badge;
        align-self: center;
    }
    .audit-table .audit-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .accounts-workspace {
        grid-template-columns: 1fr;
    }
    #account-detail {
        position: static;
        max-height: none;
        overflow: visible;
    }
}
@media (max-width: 520px) {
    .content {
        padding: 18px 14px;
    }
    .topbar {
        padding-inline: 14px;
    }
    .metrics,
    .overview-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .metric {
        min-height: 108px;
        padding: 13px;
        border-radius: 10px;
    }
    .metric-top {
        gap: 6px;
        font-size: 11px;
    }
    .metric-icon {
        width: 28px;
        height: 28px;
        border-radius: 8px;
        font-size: 11px;
    }
    .metric-value {
        margin-top: 10px;
        font-size: 24px;
    }
    .metric-note {
        margin-top: 6px;
        font-size: 10px;
        line-height: 1.4;
    }
    .quick-links {
        grid-template-columns: 1fr;
    }
    .toolbar,
    .filter-form {
        align-items: stretch;
        flex-direction: column;
    }
    .inline-field,
    .inline-field select,
    .inline-field input {
        width: 100%;
    }
    .toolbar-status {
        margin-left: 0;
    }
    .audit-toolbar {
        align-items: stretch;
    }
    .audit-toolbar .filter-form {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: end;
        gap: 9px;
    }
    .audit-toolbar .filter-form .inline-field:first-child {
        grid-column: 1 / -1;
    }
    .audit-toolbar .filter-form .inline-field,
    .audit-toolbar .filter-form .inline-field input,
    .audit-toolbar .filter-form .inline-field select {
        width: 100%;
    }
    .audit-toolbar > #audit-export-button {
        align-self: flex-start;
    }
    .record-facts {
        grid-template-columns: 1fr;
    }
    .record-detail {
        padding: 16px;
    }
    #account-detail .record-detail-heading {
        margin: -16px -16px 0;
        padding: 16px 16px 14px;
    }
    .record-detail-heading strong {
        font-size: 16px;
    }
    .detail-form-fields {
        grid-template-columns: 1fr;
    }
    .device-row {
        grid-template-columns: 1fr;
        align-items: start;
        gap: 9px;
    }
    .device-actions {
        justify-content: flex-start;
    }
    .device-actions .button {
        flex: 1 1 125px;
    }
    .account-main-actions .button {
        width: 100%;
    }
    .dialog-inline-foot {
        align-items: stretch;
        flex-direction: column;
    }
}
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important;
    }
}

.task-diagnostics {
    display: grid;
    gap: 14px;
    margin-top: 12px;
}

.task-diagnostic-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.diagnostic-message {
    display: grid;
    gap: 6px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
}

.diagnostic-message pre,
.diagnostic-json {
    max-height: 360px;
    margin: 0;
    overflow: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-soft);
    color: var(--text);
    font: 12px/1.6 Consolas, "Courier New", monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.warn-badge {
    color: var(--warn);
}

/* Notices that stack and dismiss themselves. The single banner they replace was overwritten by the next action,
   so the answer to "did that work" could disappear while it was still being read. */
.toasts {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 380px;
}

.toast {
    position: relative;
    padding: 10px 34px 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--line, #2a2f3a);
    background: var(--panel, #161a22);
    color: inherit;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 6px 20px rgb(0 0 0 / 35%);
}

.toast-success { border-color: #2f7d53; }
.toast-error { border-color: #a2444a; }

.toast-close {
    position: absolute;
    top: 4px;
    right: 6px;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
}

.toast-close:hover { opacity: 1; }

/* One form for every account edit. The prompts it replaces asked one question at a time, could not be reviewed
   before saving, and used the OK/Cancel buttons of a confirmation to mean on and off. */
.form-dialog {
    border: 1px solid var(--line, #2a2f3a);
    border-radius: 10px;
    background: var(--panel, #161a22);
    color: inherit;
    min-width: 420px;
    max-width: min(560px, 92vw);
    padding: 18px 20px;
}

.form-dialog::backdrop { background: rgb(0 0 0 / 55%); }

.form-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 14px 0;
}

.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field > span { font-size: 13px; }
.form-field input[type="text"],
.form-field input[type="date"],
.form-field input[type="number"],
.form-field select {
    padding: 7px 9px;
    border-radius: 6px;
    border: 1px solid var(--line, #2a2f3a);
    background: var(--bg, #0f1218);
    color: inherit;
    font-size: 13px;
}

.form-field-check {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-height: 36px;
}
.form-field-check input[type="checkbox"] {
    width: 16px;
    min-width: 16px;
    height: 16px;
    min-height: 16px;
    margin: 0;
    padding: 0;
    accent-color: var(--brand);
    flex: 0 0 auto;
}
.form-field-check > span {
    flex: 0 1 auto;
}
.form-help { font-size: 12px; opacity: 0.7; }
.form-field-error { color: #e08a90; font-size: 12px; min-height: 14px; }
.form-error {
    color: #e08a90;
    font-size: 13px;
    margin: 6px 0;
    white-space: pre-wrap;
}
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
