/* ==========================================================================
   Facezio v4 — admin design system
   Self-hosted only: no external fonts, icons or CDNs (CSP default-src 'self').
   Every visual style lives in this file; no inline styles or scripts anywhere.
   ========================================================================== */

/* --- Tokens -------------------------------------------------------------- */
:root {
    color-scheme: dark;

    --bg: #080d0b;
    --bg-soft: #0d1512;
    --surface: #121b16;
    --surface-2: #17221c;
    --surface-3: #1c2a22;
    --line: #24372b;
    --line-soft: #1a2820;

    --text: #e9f3ec;
    --text-dim: #bccdc0;
    --muted: #8ba193;

    --accent: #b5ef8d;
    --accent-ink: #0f210e;
    --accent-soft: rgba(181, 239, 141, .12);
    --accent-line: rgba(181, 239, 141, .28);

    --ok: #6fe0a0;
    --ok-bg: rgba(111, 224, 160, .14);
    --warn: #f2cc60;
    --warn-bg: rgba(242, 204, 96, .14);
    --danger: #ff9a9a;
    --danger-bg: rgba(255, 154, 154, .14);
    --info: #93c8ff;
    --info-bg: rgba(147, 200, 255, .13);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 18px 44px rgba(0, 0, 0, .42);

    --radius: 14px;
    --radius-sm: 9px;
    --radius-xs: 6px;

    --sidebar-w: 264px;
    --topbar-h: 68px;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

html[data-theme="light"] {
    color-scheme: light;

    --bg: #f2f6f3;
    --bg-soft: #e9f0ea;
    --surface: #ffffff;
    --surface-2: #f6faf7;
    --surface-3: #eef4ef;
    --line: #dbe6dc;
    --line-soft: #e7efe8;

    --text: #10201a;
    --text-dim: #33473c;
    --muted: #5f7268;

    --accent: #2f7d3a;
    --accent-ink: #ffffff;
    --accent-soft: rgba(47, 125, 58, .09);
    --accent-line: rgba(47, 125, 58, .3);

    --ok: #1d7a48;
    --ok-bg: rgba(29, 122, 72, .1);
    --warn: #8a6400;
    --warn-bg: rgba(180, 132, 0, .12);
    --danger: #b3261e;
    --danger-bg: rgba(179, 38, 30, .1);
    --info: #14548f;
    --info-bg: rgba(20, 84, 143, .1);

    --shadow-1: 0 1px 2px rgba(16, 32, 26, .06);
    --shadow-2: 0 16px 36px rgba(16, 32, 26, .1);
}

/* --- Base ---------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 640; letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: .98rem; }
h4 { font-size: .9rem; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0 0 12px; padding-left: 20px; }
li { margin: 2px 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

code {
    font-family: var(--mono);
    font-size: .84em;
    background: var(--surface-3);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-xs);
    padding: 1px 5px;
    overflow-wrap: anywhere;
}

pre {
    margin: 0 0 12px;
    padding: 12px 14px;
    background: var(--bg-soft);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: .82rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .82rem; overflow-wrap: anywhere; }
.mono a { overflow-wrap: anywhere; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: 12px; top: -60px; z-index: 90;
    background: var(--accent); color: var(--accent-ink);
    padding: 10px 16px; border-radius: var(--radius-xs); font-weight: 650;
}
.skip-link:focus { top: 12px; }

/* --- App shell ----------------------------------------------------------- */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}
html[data-sidebar="collapsed"] .app { --sidebar-w: 78px; }

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 14px 14px;
    background: var(--bg-soft);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 40;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 4px 6px 14px;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 10px;
    min-height: 58px;
}
.sidebar-brand .mark {
    flex: 0 0 auto;
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 800; font-size: 17px;
}
.sidebar-brand .brand-text { min-width: 0; }
.sidebar-brand strong { display: block; font-size: 15px; font-weight: 700; letter-spacing: -.3px; }
.sidebar-brand small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav .group {
    margin: 14px 0 4px;
    padding: 0 10px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 520;
    border: 1px solid transparent;
    position: relative;
}
.sidebar-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar-nav a[aria-current="page"] {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--text);
    font-weight: 650;
}
.sidebar-nav a[aria-current="page"]::before {
    content: "";
    position: absolute;
    left: -14px; top: 8px; bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}
.sidebar-nav .ico {
    flex: 0 0 auto;
    width: 26px; height: 26px;
    display: grid; place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    background: var(--surface);
}
.sidebar-nav .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav .tag {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--muted);
    border: 1px solid var(--line);
}
.sidebar-foot {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sidebar-note {
    font-size: 11px;
    color: var(--muted);
    padding: 8px 10px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: var(--surface-2);
    color: var(--text-dim);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}
.sidebar-toggle:hover { color: var(--text); background: var(--surface-3); }

html[data-sidebar="collapsed"] .sidebar-brand .brand-text,
html[data-sidebar="collapsed"] .sidebar-nav .label,
html[data-sidebar="collapsed"] .sidebar-nav .tag,
html[data-sidebar="collapsed"] .sidebar-note,
html[data-sidebar="collapsed"] .sidebar-nav .group,
html[data-sidebar="collapsed"] .sidebar-toggle .toggle-text { display: none; }
html[data-sidebar="collapsed"] .sidebar { padding-left: 12px; padding-right: 12px; }
html[data-sidebar="collapsed"] .sidebar-nav a { justify-content: center; padding: 9px 6px; }
html[data-sidebar="collapsed"] .sidebar-nav a[aria-current="page"]::before { left: -12px; }
html[data-sidebar="collapsed"] .sidebar-brand { justify-content: center; }

.main { display: flex; flex-direction: column; min-width: 0; }

/* --- Topbar -------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: var(--topbar-h);
    padding: 10px 26px;
    background: var(--bg-soft);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.nav-toggle {
    display: none;
    width: 40px; height: 40px;
    align-items: center; justify-content: center;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
}
.nav-toggle .bars { display: grid; gap: 4px; }
.nav-toggle .bars span { display: block; width: 17px; height: 2px; border-radius: 2px; background: currentColor; }

.crumbs { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { opacity: .5; }
.crumbs [aria-current="page"] { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.icon-button:hover { color: var(--text); background: var(--surface-3); }
.icon-button .glyph { font-size: 14px; line-height: 1; }

.dropdown { position: relative; }
.menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 224px;
    padding: 7px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    z-index: 60;
}
.menu[hidden] { display: none; }
.menu-head { padding: 9px 11px 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.menu-head strong { display: block; font-size: 13.5px; }
.menu-head small { color: var(--muted); font-size: 11.5px; }
.menu a, .menu button {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 11px;
    background: none;
    border: 0;
    border-radius: var(--radius-xs);
    color: var(--text-dim);
    font: inherit;
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

/* --- Page header + content ---------------------------------------------- */
.content { padding: 24px 26px 60px; max-width: 1420px; width: 100%; }

.page-head {
    display: flex;
    align-items: flex-end;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-head .titles { min-width: 0; }
.page-head h1 { margin-bottom: 3px; }
.page-head .subtitle { color: var(--muted); font-size: 13.5px; margin: 0; }
.page-head .page-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.page-context {
    display: flex;
    gap: 6px 16px;
    flex-wrap: wrap;
    font-size: 12.5px;
    color: var(--muted);
    margin-bottom: 16px;
}
.page-context a { color: var(--text-dim); }

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.tight { gap: 10px; }

/* --- Cards --------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 22px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-1);
    min-width: 0;
}
.card > *:last-child { margin-bottom: 0; }
.card > h2 { margin-bottom: 12px; }
.card > h2 + .muted, .card > h3 + .muted { margin-top: -6px; }
.card-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.card-head .titles { min-width: 0; }
.card-head h2, .card-head h3 { margin: 0 0 3px; }
.card-head .muted { font-size: 13px; margin: 0; }
.card-head .head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card.plain { background: var(--surface-2); box-shadow: none; }
.card.danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

.card.narrow {
    max-width: 420px;
    margin: 0 auto;
    padding: 28px 26px;
}

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }

/* --- Stat tiles ---------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-1);
    min-width: 0;
}
.stat .stat-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}
.stat .stat-value { font-size: 1.9rem; font-weight: 680; letter-spacing: -.03em; line-height: 1.1; }
.stat .stat-value small { font-size: .8rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat .stat-foot { margin-top: 8px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stat.accent { background: linear-gradient(150deg, var(--accent-soft), transparent 70%), var(--surface); border-color: var(--accent-line); }

/* --- Buttons ------------------------------------------------------------- */
button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    margin: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-size: 13.5px;
    font-weight: 680;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
button:hover, .button:hover { filter: brightness(1.06); text-decoration: none; }
button:disabled, .button[aria-disabled="true"] { opacity: .55; cursor: not-allowed; filter: none; }
button.secondary, .button.secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--line);
}
button.secondary:hover, .button.secondary:hover { background: var(--surface-3); }
button.ghost, .button.ghost { background: transparent; color: var(--accent); border-color: var(--accent-line); }
button.danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
button.small, .button.small { padding: 7px 12px; font-size: 12.5px; }
button.linkish {
    background: none;
    border: 0;
    padding: 0;
    color: var(--accent);
    font-weight: 600;
}
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* --- Forms --------------------------------------------------------------- */
label { display: block; margin: 14px 0 5px; font-size: 12.5px; font-weight: 640; color: var(--text-dim); }
label:first-child { margin-top: 0; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="search"], input[type="date"], input[type="url"], input[type="tel"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-soft);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 14px;
}
html[data-theme="light"] input, html[data-theme="light"] select, html[data-theme="light"] textarea { background: var(--surface); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); vertical-align: -3px; }
select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 34px;
}
textarea { min-height: 82px; resize: vertical; font-family: inherit; }

form > button[type="submit"] { margin-top: 16px; }
form.inline-form { display: inline; }
form.inline-form button { margin-top: 0; }

.field { margin-bottom: 6px; }
.field > label { margin-top: 14px; }
.field:first-child > label:first-child { margin-top: 0; }
.field-check { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0; }
.field-check label { margin: 0; font-weight: 500; font-size: 13.5px; color: var(--text); }

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 12px;
    align-items: end;
}
.filters label { margin-top: 0; }
.filters .filter-actions { display: flex; gap: 10px; align-items: center; }
.filters .filter-actions button { margin-top: 0; }
.filter-bar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filter-bar > * { flex: 0 1 auto; }
.filter-bar label { margin-top: 0; }

.checklist {
    max-height: 340px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    background: var(--bg-soft);
}
html[data-theme="light"] .checklist { background: var(--surface-2); }
.checklist label { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0; font-weight: 500; font-size: 13.5px; color: var(--text); }

.inline { display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline button, .inline input, .inline select { width: auto; margin-top: 0; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
    gap: 4px 20px;
    align-items: start;
    margin-top: 6px;
}
.form-grid .field-wide { grid-column: 1 / -1; }
.form-grid .field { margin-bottom: 0; }
.form-grid .field-check { margin: 8px 0; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }

/* --- Tables -------------------------------------------------------------- */
.table-wrap, .scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table-wrap { margin: 4px -4px 0; padding: 0 4px; }

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13.5px;
}
th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: top;
}
thead th {
    position: sticky;
    top: 0;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
    z-index: 1;
}
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td, tbody tr:hover th { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tbody th {
    font-weight: 600;
    color: var(--muted);
    font-size: 12.5px;
    white-space: nowrap;
    width: 1%;
}
td.empty-cell, td.muted[colspan] { text-align: center; color: var(--muted); padding: 22px 12px; }
table.kv tbody th { color: var(--muted); }
td .badge + .badge { margin-left: 4px; }

/* --- Badges -------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-3);
    color: var(--text-dim);
    font-size: 11.5px;
    font-weight: 650;
    white-space: nowrap;
    line-height: 1.5;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.badge.off { background: var(--surface-3); color: var(--muted); }
.badge.info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.badge.danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* --- Alerts / notices ---------------------------------------------------- */
.alert, .notice {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--info) 35%, transparent);
    background: var(--info-bg);
    color: var(--text);
    font-size: 13.5px;
    margin-bottom: 16px;
}
.alert { border-color: color-mix(in srgb, var(--danger) 38%, transparent); background: var(--danger-bg); }
.notice.error, .notice.alert-error { border-color: color-mix(in srgb, var(--danger) 38%, transparent); background: var(--danger-bg); }
.alert ul, .notice ul { margin: 0; padding-left: 18px; }
.alert strong, .notice strong { font-weight: 700; }

/* --- Tabs / inline nav --------------------------------------------------- */
.nav { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.nav a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 600;
}
.nav a:hover { color: var(--text); background: var(--surface-3); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }

/* --- Pager --------------------------------------------------------------- */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; font-size: 13px; }
.pager .muted { font-size: 13px; }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }

/* --- Empty states -------------------------------------------------------- */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    padding: 30px 20px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--muted);
}
.empty .empty-mark {
    width: 42px; height: 42px;
    display: grid; place-items: center;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--accent);
    font-size: 17px;
    font-weight: 700;
}
.empty strong { color: var(--text); font-size: 14.5px; font-weight: 650; }
.empty p { font-size: 13px; max-width: 460px; margin: 0; }

/* --- Charts (server-rendered SVG, no scripts) ---------------------------- */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 9.5px; font-family: var(--font); }
.chart .bar { fill: var(--accent); opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart .bar-muted { fill: var(--line); }
.chart .line { stroke: var(--accent); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: .13; }
.chart .point { fill: var(--accent); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); display: inline-block; }
.chart-legend i.muted { background: var(--line); }
.chart-legend i.ok { background: var(--ok); }
.chart-legend i.warn { background: var(--warn); }
.chart-legend i.info { background: var(--info); }
.chart-legend i.danger { background: var(--danger); }
.chart-empty { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; }

.meter { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter > span, .meter .meter-fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter .meter-fill.ok { background: var(--ok); }
.meter .meter-fill.warn { background: var(--warn); }
.meter .meter-fill.danger { background: var(--danger); }
.meter .meter-fill.info { background: var(--info); }
.meter .meter-fill.off { background: var(--line); }
.meter-0 { width: 0; }
.meter-10 { width: 10%; }
.meter-20 { width: 20%; }
.meter-30 { width: 30%; }
.meter-40 { width: 40%; }
.meter-50 { width: 50%; }
.meter-60 { width: 60%; }
.meter-70 { width: 70%; }
.meter-80 { width: 80%; }
.meter-90 { width: 90%; }
.meter-100 { width: 100%; }
.meter-list { display: flex; flex-direction: column; gap: 12px; }
.meter-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; font-size: 13px; }
.meter-row .meter { grid-column: 1 / -1; }

/* --- Detail list --------------------------------------------------------- */
.kv-list { display: grid; gap: 0; }
.kv-list > div {
    display: flex;
    gap: 14px;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid var(--line-soft);
    font-size: 13.5px;
}
.kv-list > div:last-child { border-bottom: 0; }
.kv-list dt { color: var(--muted); font-weight: 600; }
.kv-list dd { margin: 0; text-align: right; }

/* --- Mobile drawer ------------------------------------------------------- */
.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(4, 8, 6, .6);
    backdrop-filter: blur(2px);
    border: 0;
    padding: 0;
    cursor: pointer;
}

@media (max-width: 1080px) {
    .content { padding: 20px 18px 56px; }
    .topbar { padding: 10px 18px; }
}

@media (max-width: 900px) {
    .app { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 284px;
        transform: translateX(-104%);
        transition: transform .22s ease;
        box-shadow: var(--shadow-2);
    }
    html[data-nav="open"] .sidebar { transform: none; }
    html[data-nav="open"] .nav-overlay { display: block; }
    html[data-sidebar="collapsed"] .sidebar { padding: 18px 14px 14px; }
    html[data-sidebar="collapsed"] .sidebar-brand .brand-text,
    html[data-sidebar="collapsed"] .sidebar-nav .label,
    html[data-sidebar="collapsed"] .sidebar-nav .tag,
    html[data-sidebar="collapsed"] .sidebar-note,
    html[data-sidebar="collapsed"] .sidebar-nav .group,
    html[data-sidebar="collapsed"] .sidebar-toggle .toggle-text { display: block; }
    html[data-sidebar="collapsed"] .sidebar-nav a { justify-content: flex-start; padding: 9px 10px; }
    .nav-toggle { display: inline-flex; }
    .sidebar-toggle { display: none; }
    .crumbs { display: none; }
    .content { padding: 18px 16px 52px; }
    .page-head h1 { font-size: 1.35rem; }
}

@media (max-width: 640px) {
    body { font-size: 14.5px; }
    .content { padding: 16px 13px 48px; }
    .topbar { padding: 9px 13px; gap: 10px; }
    .topbar-right { gap: 7px; }
    .icon-button { padding: 0 10px; }
    .icon-button .button-text { display: none; }
    .card { padding: 16px 15px; border-radius: var(--radius-sm); }
    .card.narrow { padding: 22px 18px; }
    .grid2 { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
    .stat { padding: 13px 14px; }
    .stat .stat-value { font-size: 1.55rem; }
    .page-head { align-items: flex-start; gap: 12px; }
    .page-head .page-actions { margin-left: 0; width: 100%; }
    .filters { grid-template-columns: 1fr; }
    th, td { padding: 9px 10px; }
    .table-wrap { margin-left: -15px; margin-right: -15px; padding-left: 15px; padding-right: 15px; }
    form > button[type="submit"], form > .button { width: 100%; }
    .menu form button { width: 100%; }
    .menu { right: -6px; min-width: 200px; }
}

@media (max-width: 400px) {
    .stats { grid-template-columns: 1fr; }
}

/* --- Motion / print ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
    .sidebar, .topbar, .nav-toggle, .page-actions, .nav-overlay { display: none !important; }
    body { background: #fff; color: #000; }
    .card { box-shadow: none; border-color: #ccc; }
    a { color: #000; }
}

/* --- Auth shell (login / 2FA / re-auth) --------------------------------- */
body.auth {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background:
        radial-gradient(900px 480px at 12% -10%, var(--accent-soft), transparent 65%),
        var(--bg);
}
.auth-top {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 26px;
}
.auth-top .brand { display: flex; align-items: center; gap: 11px; font-weight: 720; font-size: 15px; letter-spacing: -.3px; color: var(--text); }
.auth-top .brand .mark {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 800;
}
.auth-top .auth-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.auth-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 20px 70px;
}
.auth-card {
    width: 100%;
    max-width: 430px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 30px 30px 26px;
    box-shadow: var(--shadow-2);
}
.auth-card h1 { font-size: 1.4rem; margin-bottom: 4px; }
.auth-card .auth-lead { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
.auth-card form > button[type="submit"] { width: 100%; margin-top: 20px; padding: 12px 16px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 12.5px; color: var(--muted); }
.auth-foot a { color: var(--text-dim); }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; font-size: 12.5px; color: var(--muted); }

/* Facezio integrations — independent owner-save cards, no inline CSP exceptions. */
.settings-intro { display:flex; align-items:center; justify-content:space-between; gap:18px; flex-wrap:wrap; background:linear-gradient(120deg, var(--surface), var(--surface-2)); }
.settings-intro h2 { margin:0 0 6px; }
.settings-intro p { margin:0; color:var(--muted); max-width:680px; }
.settings-intro-status { display:flex; gap:9px; flex-wrap:wrap; }
.settings-tabs { display:flex; gap:8px; overflow-x:auto; padding:3px 0 13px; margin-bottom:6px; scrollbar-width:thin; }
.settings-tabs a { flex:none; border:1px solid var(--line); background:var(--surface); border-radius:50px; color:var(--text); font-size:13px; font-weight:600; padding:10px 14px; text-decoration:none; }
.settings-tabs a:hover, .settings-tabs a:focus-visible { border-color:var(--accent); color:var(--accent); }
.settings-grid { display:grid; grid-template-columns:minmax(0,1fr); gap:14px; }
.settings-card { margin:0; scroll-margin-top:84px; }
.settings-card .card-head { border-bottom:1px solid var(--line); padding-bottom:14px; margin-bottom:18px; }
.settings-card .form-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr)); gap:6px 18px; }
.settings-card .field-check { font-size:13px; }
.settings-card-footer { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:16px; border-top:1px solid var(--line); padding-top:16px; margin-top:21px; }
.settings-card-footer p { font-size:12.5px; color:var(--muted); margin:0; max-width:600px; }
.settings-card-footer button, .settings-action-row button { width:auto; }
.settings-card-utilities { border-top:1px solid var(--line); margin-top:16px; padding-top:16px; }
.settings-card-utilities h3 { font-size:14px; margin:0 0 5px; }
.settings-action-row { display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin-top:10px; }
.settings-action-row button { margin-top:0; }
.settings-provider-status { display:flex; flex-wrap:wrap; gap:9px 20px; margin:0 0 15px; padding:10px 12px; border:1px solid var(--line); border-radius:var(--radius-sm); background:var(--surface-2); font-size:12.5px; color:var(--muted); }
.settings-provider-status strong { color:var(--text); }
.settings-field-error { font-size:12.5px; color:var(--danger); margin:5px 0 0; }
.settings-warning { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; border-color:var(--warn); }
.settings-warning p { margin:5px 0 0; font-size:12.5px; }
.settings-action-link { color:var(--text); border:1px solid var(--line); background:var(--surface-2); padding:10px 13px; border-radius:var(--radius-sm); font-size:13px; font-weight:700; white-space:nowrap; }
.settings-ready { font-size:13px; }
@media(max-width:620px) { .settings-card-footer { align-items:stretch; } .settings-card-footer button { width:100%; } .settings-action-row button { width:100%; } .settings-intro-status { width:100%; } }

/* Per-card destructive settings reset. External stylesheet respects Facezio CSP. */
.settings-reset-strip {
    margin-top: 18px; padding: 16px; background: var(--danger-bg);
    border: 1px solid var(--danger); border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px 18px;
}
.settings-reset-strip strong { font-size: 13px; color: var(--danger); }
.settings-reset-strip p { margin: 3px 0 0; max-width: 680px; color: var(--muted); font-size: 12px; }
.settings-reset-strip form { margin: 0; }
.settings-reset-button {
    display: inline-flex; align-items: center; justify-content: center;
    width: auto; margin: 0; border: 1px solid var(--danger);
    background: transparent; color: var(--danger); font-weight: 700;
}
.settings-reset-button:hover, .settings-reset-button:focus-visible { background: var(--danger-bg); }
@media (max-width:620px) {
    .settings-reset-strip { align-items: stretch; }
    .settings-reset-strip form, .settings-reset-strip button { width: 100%; }
}
