:root {
    --night: #15131F;
    --night-2: #1F1D2B;
    --accent: #5B4BFF;
    --accent-2: #4B3BF0;
    --lime: #D7FF4A;
    --ink: #15131F;
    --muted: #6D6A7C;
    --faint: #A6A3B5;
    --bg: #F3F3F7;
    --surface: #FFFFFF;
    --surface-2: #F7F7FA;
    --line: #E2E2EA;
    --danger: #E5484D;
    --danger-soft: #FDECEC;
    --ok: #12895A;
    --ok-soft: #E2F5EC;
    --warn: #A8650A;
    --warn-soft: #FDF1E0;
    --radius: 18px;
    --shadow: 0 1px 2px rgba(21, 19, 31, .04), 0 10px 24px -16px rgba(21, 19, 31, .14);
    --heading: 'Geologica', system-ui, sans-serif;
    --body: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: ui-monospace, 'SFMono-Regular', Consolas, monospace;
    --primary: var(--accent);
    --primary-hover: var(--accent-2);
    --on-primary: #fff;
    --sidebar: var(--night);
    --sidebar-line: transparent;
    --kpi-icon: var(--accent);
    --bar: color-mix(in srgb, var(--accent) 40%, var(--surface));
    --danger-solid-ink: #fff;
    --cal-up-bg: rgba(91, 75, 255, .10);
    --cal-up-line: var(--accent);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --accent: #7D6FFF;
        --accent-2: #9387FF;
        --ink: #F2F1F7;
        --muted: #9A97AB;
        --faint: #615E72;
        --bg: #0D0C14;
        --surface: #17161F;
        --surface-2: #1D1C27;
        --line: #2A2836;
        --danger: #FF6B70;
        --danger-soft: #3A1A1E;
        --ok: #3DD39A;
        --ok-soft: #12291F;
        --warn: #F0A43A;
        --warn-soft: #33240F;
        --shadow: none;
        --primary: var(--accent);
        --primary-hover: var(--accent-2);
        --on-primary: #fff;
        --sidebar: #0A0910;
        --sidebar-line: #2A2836;
        --kpi-icon: #A89FFF;
        --bar: color-mix(in srgb, var(--accent) 40%, var(--surface));
        --danger-solid-ink: #3A1A1E;
        --cal-up-bg: rgba(125, 111, 255, .16);
        --cal-up-line: #A89FFF;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --accent: #7D6FFF;
    --accent-2: #9387FF;
    --ink: #F2F1F7;
    --muted: #9A97AB;
    --faint: #615E72;
    --bg: #0D0C14;
    --surface: #17161F;
    --surface-2: #1D1C27;
    --line: #2A2836;
    --danger: #FF6B70;
    --danger-soft: #3A1A1E;
    --ok: #3DD39A;
    --ok-soft: #12291F;
    --warn: #F0A43A;
    --warn-soft: #33240F;
    --shadow: none;
    --primary: var(--accent);
    --primary-hover: var(--accent-2);
    --on-primary: #fff;
    --sidebar: #0A0910;
    --sidebar-line: #2A2836;
    --kpi-icon: #A89FFF;
    --bar: color-mix(in srgb, var(--accent) 40%, var(--surface));
    --danger-solid-ink: #3A1A1E;
    --cal-up-bg: rgba(125, 111, 255, .16);
    --cal-up-line: #A89FFF;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-family: var(--heading); font-weight: 600; font-size: 24px; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 15px; }
a { color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.block { display: block; }
.application-message { min-width: 220px; max-width: 380px; white-space: pre-line; color: var(--muted); font-size: 14px; line-height: 1.5; }

.shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: 24px;
    padding: 20px 14px; background: var(--sidebar); color: #fff; border-right: 1px solid var(--sidebar-line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px; font-family: var(--heading); font-weight: 600; font-size: 17px; color: #fff; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 1px rgba(255, 255, 255, .1); }
.brand-mark svg { display: block; width: 100%; height: 100%; }
.brand small { margin-left: auto; font: 600 11px var(--body); letter-spacing: .06em; text-transform: uppercase; color: rgba(255, 255, 255, .5); }

.menu { display: flex; flex-direction: column; gap: 2px; }
.menu-toggle { display: none; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer; }
.menu-toggle-close, body.menu-open .menu-toggle-open { display: none; }
body.menu-open .menu-toggle-close { display: contents; }
.menu-label { padding: 0 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .4); }
.menu a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: rgba(255, 255, 255, .72); text-decoration: none; font-weight: 600; }
.menu a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.menu a.active { background: rgba(125, 111, 255, .2); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.menu a > [data-live] { margin-left: auto; }
.menu a .count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 99px; background: rgba(255, 255, 255, .14); color: #fff; font-size: 12px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.menu a .count-warn { background: var(--lime); color: var(--night); }

.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: 10px; background: rgba(255, 255, 255, .06); }
.theme-switch button { display: grid; place-items: center; height: 30px; border: 0; border-radius: 8px; background: transparent; color: rgba(255, 255, 255, .6); cursor: pointer; }
.theme-switch button:hover { color: #fff; }
.theme-switch button[aria-pressed="true"] { background: rgba(255, 255, 255, .14); color: #fff; }
.theme-switch svg.i { width: 16px; height: 16px; }

.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: rgba(255, 255, 255, .06); }
.me .who { min-width: 0; flex: 1; }
.me .who strong, .me .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who span { font-size: 12px; color: rgba(255, 255, 255, .55); }
.me form { margin: 0; }
.me button { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: rgba(255, 255, 255, .7); cursor: pointer; }
.me button:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.main { min-width: 0; }
.header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 22px 32px; border-bottom: 1px solid var(--line); background: var(--surface); }
.header .crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.header .crumbs a { text-decoration: none; }
.header .crumbs a:hover { color: var(--ink); }
.content { padding: 28px 32px 56px; }

body.is-loading .main { opacity: .55; transition: opacity .15s .1s; pointer-events: none; }
body.is-loading::before { content: ''; position: fixed; z-index: 10; top: 0; left: 0; height: 3px; width: 100%; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: loading 1s linear infinite; }
@keyframes loading { from { background-position: -50% 0; } to { background-position: 150% 0; } }
@media (prefers-reduced-motion: reduce) { body.is-loading::before { animation: none; background: var(--accent); } }

.grid { display: grid; gap: 20px; }
.grid-kpi { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-kpi.grid-kpi-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.content > * + * { margin-top: 20px; }
.database-frame { display: block; width: 100%; height: calc(100vh - 170px); min-height: 520px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.stack > * + * { margin-top: 20px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head a { font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; }
.card-head a:hover { color: var(--ink); }
.card-body { padding: 20px; }

.kpi { padding: 18px 20px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-weight: 600; font-size: 13px; }
.kpi-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--kpi-icon); border: 1px solid var(--line); }
.kpi-value { margin-top: 10px; font-family: var(--heading); font-weight: 600; font-size: 28px; line-height: 1.1; }
.kpi-foot { margin-top: 6px; font-size: 12px; color: var(--muted); }
.kpi-foot .up { color: var(--ok); font-weight: 700; }
a.kpi-link { display: block; text-decoration: none; }
a.kpi-link:hover { border-color: var(--accent); }
.kpi-alert { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: var(--warn-soft); }
.kpi-alert .kpi-value, .kpi-alert .kpi-icon { color: var(--warn); }

.side-stack { display: grid; grid-template-rows: 1fr 1fr; gap: 20px; min-width: 0; }
.side-stack .kpi { display: flex; flex-direction: column; }
.side-stack .kpi-foot { margin-top: auto; padding-top: 10px; }
.bars-mini { height: auto; flex: 1; min-height: 44px; margin-top: 12px; padding-top: 0; gap: 4px; }
.bars-mini .bar-fill { max-width: none; border-radius: 3px; }
.mini-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.mini-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); }
.mini-list span { min-width: 0; }
.mini-list strong, .mini-list small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list small { font-size: 12px; color: var(--muted); }
.mini-list b { white-space: nowrap; color: var(--ink); }

.revenue-figures { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.revenue-figures > div { padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.revenue-figures span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.revenue-figures strong { display: block; margin-top: 4px; font-size: 18px; white-space: nowrap; }
.revenue-figures small { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.revenue-figures .revenue-main { background: var(--accent); border-color: var(--accent); color: #fff; }
.revenue-figures .revenue-main span, .revenue-figures .revenue-main small { color: rgba(255, 255, 255, .78); }
.revenue-figures .revenue-main strong { font-family: var(--heading); font-weight: 600; font-size: 26px; }
.revenue-figures .revenue-main .up, .revenue-figures .revenue-main .down { display: inline; color: #fff; font-weight: 700; }
.down { color: var(--danger); font-weight: 700; }

.bars-stacked { gap: 4px; height: 160px; }
.bars-stacked .bar-fill { display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; max-width: 22px; }
.bars-stacked .bar:last-child .bar-fill:not(.zero) { background: var(--bar); }
.bar-part { display: block; width: 100%; background: var(--accent); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 14px; font-size: 12px; font-weight: 600; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend > span.muted { margin-left: auto; font-weight: 400; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend-gross { background: var(--bar); }
.legend-fee { background: var(--accent); }
.bars-stacked .bar { cursor: default; }
.bars-stacked .bar:hover .bar-fill:not(.zero) { filter: brightness(.92); }

.tabs-sm a { padding: 5px 10px; font-size: 13px; }
.tip { position: fixed; z-index: 60; pointer-events: none; padding: 8px 10px; border-radius: 8px; background: var(--night); color: #fff; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: pre-line; box-shadow: 0 8px 24px rgba(21, 19, 31, .22); transform: translate(-50%, calc(-100% - 10px)); }
.tip[hidden] { display: none; }

.chart-totals { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-bottom: 16px; font-size: 13px; color: var(--muted); }
.chart-totals > span { display: inline-flex; align-items: center; gap: 6px; }
.chart-totals strong { color: var(--ink); font-size: 15px; }
.chart-totals i { width: 10px; height: 10px; border-radius: 3px; }
.line-chart { --axis: 64px; }
.line-chart-plot { position: relative; margin-left: var(--axis); }
.line-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.line-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.line-area { fill: var(--cal-up-bg); }
.line-gross, .line-fee { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.line-gross { stroke: color-mix(in srgb, var(--accent) 50%, var(--surface)); }
.line-fee { stroke: var(--accent); }
.line-hit { fill: transparent; }
.line-guide { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; opacity: 0; }
.line-point circle { stroke: var(--surface); stroke-width: 2; opacity: 0; }
.dot-gross { fill: color-mix(in srgb, var(--accent) 50%, var(--surface)); }
.dot-fee { fill: var(--accent); }
.line-point:hover .line-guide, .line-point:hover circle, .line-point.is-active .line-guide, .line-point.is-active circle { opacity: 1; }
.line-y { position: absolute; left: calc(-1 * var(--axis)); width: calc(var(--axis) - 10px); transform: translateY(-50%); text-align: right; font-size: 11px; color: var(--faint); white-space: nowrap; }
.line-x { position: relative; height: 18px; margin: 8px 0 0 var(--axis); }
.line-x span { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--faint); white-space: nowrap; }

.bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); align-items: end; gap: 6px; height: 180px; padding-top: 8px; }
.bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; min-width: 0; }
.bar-fill { width: 100%; max-width: 30px; min-height: 3px; border-radius: 6px 6px 3px 3px; background: var(--bar); }
.bar-fill.zero { background: var(--line); }
.bar.is-future .bar-fill { opacity: .45; }
.bar.is-future .bar-label { opacity: .6; }
.bar:last-child .bar-fill:not(.zero) { background: var(--accent); }
.bar-value { height: 14px; font-size: 11px; font-weight: 700; line-height: 14px; color: var(--muted); }
.bar-label { height: 14px; font-size: 11px; line-height: 14px; color: var(--faint); white-space: nowrap; }

.meter { display: grid; gap: 14px; }
.meter-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) 36px; align-items: center; gap: 12px; font-weight: 600; }
.meter-track { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 99px; background: var(--accent); }
.meter-row:nth-child(2) .meter-fill { background: var(--bar); }
.meter-row span:last-child { text-align: right; color: var(--muted); }

.split { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.split div { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.split strong { display: block; font-size: 18px; }
.split span { font-size: 12px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 10px 20px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr:hover td { background: var(--surface-2); }
th.right, td.right { text-align: right; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.table-compact td:first-child { width: 100%; max-width: 0; }
a.place-link { text-decoration: none; }
a.place-link:hover strong { text-decoration: underline; }
.cell-note { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.table-compact .person { min-width: 0; }
.table-compact .person-text strong, .table-compact .person-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.person { display: flex; align-items: center; gap: 12px; min-width: 200px; text-decoration: none; }
.avatar {
    flex: none; width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--primary); color: var(--on-primary); font-size: 13px; font-weight: 700; line-height: 1;
}
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar.accent { background: var(--accent); color: #fff; }
img.avatar { object-fit: cover; background: var(--surface-2); }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.photo-tile { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.photo-tile img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photo-tile figcaption { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; }
.person-text { min-width: 0; }
.person-text strong { display: block; font-weight: 700; }
.person-text small { display: block; color: var(--muted); font-size: 13px; }
a.person:hover strong { text-decoration: underline; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge + .badge { margin-left: 4px; }
.badge-administrator { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.badge-owner { background: var(--lime); border-color: var(--lime); color: var(--night); }
.badge-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.badge-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.badge-off { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.actions form { margin: 0; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; font-weight: 600; color: var(--muted); text-decoration: none; }
.tabs a:hover { background: var(--surface-2); color: var(--ink); }
.tabs a.active { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.tabs a span { font-size: 12px; color: var(--faint); }
.search { position: relative; width: 280px; max-width: 100%; }
.search svg.i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 16px; height: 16px; }
.search .input { padding-left: 36px; height: 38px; }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters select.input { width: auto; max-width: 220px; height: 38px; }
.toolbar h2 { margin-right: auto; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tiles div { padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.tiles div > span { display: block; font-size: 12px; color: var(--muted); }
.tiles strong { display: block; font-size: 17px; margin-top: 2px; }
.tiles small { display: block; font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.buttons form { margin: 0; }
.rpc { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.reply { margin-top: 18px; }
.reply-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
pre.code { margin: 10px 0 0; padding: 12px 14px; max-height: 360px; overflow: auto; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font: 12px/1.5 var(--mono); white-space: pre; }
details.raw { margin-top: 16px; }
td details.raw, dd details.raw { margin: 0; }
details.raw summary { cursor: pointer; color: var(--muted); font-weight: 600; }
td details.raw summary, dd details.raw summary { color: inherit; font-weight: 400; }
details.log-line > .mono { margin-top: 8px; color: var(--muted); font-size: 12px; }

[data-region].is-loading { opacity: .6; transition: opacity .15s; }
@keyframes live-new { from { background: rgba(91, 75, 255, .16); } to { background: transparent; } }
tr.is-new > td { animation: live-new 2.5s ease-out; }
@media (prefers-reduced-motion: reduce) { tr.is-new > td { animation: none; } }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.input, select.input {
    width: 100%; height: 42px; padding: 0 12px;
    font: inherit; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.input[readonly] { background: var(--surface-2); color: var(--muted); }
.input.code { height: 58px; text-align: center; font: 700 26px var(--mono); letter-spacing: .4em; }
.error { color: var(--danger); font-size: 13px; margin-top: 6px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.input-settings { align-items: start; gap: 16px; }
.input-settings .field { margin-bottom: 0; }
/* A form stretched to its neighbour in a grid keeps its buttons at the bottom. */
form.card { display: flex; flex-direction: column; }
form.card > .card-body { flex: 1; }
.form-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.check { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.check + .check { margin-top: 8px; }
.check input { margin: 2px 0 0; width: 16px; height: 16px; accent-color: var(--primary); }
.check strong { display: block; }
.check small { display: block; color: var(--muted); }
.check:has(input:checked) { border-color: var(--accent); background: var(--surface-2); }

.invite-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) 150px auto; gap: 12px; align-items: end; }
.invite-row .field { margin: 0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 44px; padding: 0 20px; border: 1px solid transparent; border-radius: 999px;
    font: 700 14px var(--body); cursor: pointer; text-decoration: none; white-space: nowrap;
    background: var(--primary); color: var(--on-primary);
}
.btn:hover { background: var(--primary-hover); }
.btn svg.i { width: 16px; height: 16px; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-2); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--line); }
.btn-danger:hover { background: var(--danger-soft); border-color: transparent; }
.btn-danger-solid { background: var(--danger); color: var(--danger-solid-ink); }
.btn-danger-solid:hover { background: #C4373C; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; border-radius: 999px; }
.btn-block { width: 100%; }
.btn-icon { width: 32px; padding: 0; }
.btn[disabled], .btn[aria-disabled] { opacity: .45; pointer-events: none; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: inherit; text-decoration: underline; cursor: pointer; }

.alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; font-weight: 600; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--danger-soft); color: var(--danger); }

.toasts { position: fixed; top: 20px; right: 20px; z-index: 50; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast { position: relative; overflow: hidden; display: flex; align-items: flex-start; gap: 10px; padding: 14px 44px 16px 18px; border-radius: 12px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 12px 32px rgba(21, 19, 31, .16); font-weight: 600; line-height: 1.4; animation: toast-in .22s ease-out; }
.toast > svg { flex: none; margin-top: 1px; }
.toast-ok > svg { color: var(--ok); }
.toast-error > svg { color: var(--danger); }
.toast::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--ok); }
.toast-error::before { background: var(--danger); }
.toast::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--ok); opacity: .35; transform-origin: left; animation: toast-time var(--toast-for, 0s) linear forwards; }
.toast-error::after { background: var(--danger); }
.toast.is-paused::after { animation-play-state: paused; }
.toast.is-leaving { animation: toast-out .2s ease-in forwards; }
.toast-close { position: absolute; top: 9px; right: 9px; width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.toast-close:hover { background: var(--surface-2); color: var(--ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }
@keyframes toast-time { to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) {
    .toast, .toast.is-leaving { animation: none; }
    .toast::after { display: none; }
}

.week-nav { display: flex; align-items: center; gap: 6px; }
.week-nav strong { min-width: 150px; text-align: center; font-size: 14px; }
.cal-scroll { position: relative; max-height: 560px; overflow: auto; border-bottom: 1px solid var(--line); }
.cal { display: grid; grid-template-columns: 56px repeat(7, minmax(96px, 1fr)); min-width: 760px; }
.cal-corner, .cal-day-head { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--line); }
.cal-day-head { display: flex; align-items: baseline; justify-content: center; gap: 6px; padding: 10px 4px; border-left: 1px solid var(--line); }
.cal-day-head span { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.cal-day-head strong { font-size: 16px; }
.cal-day-head.is-today strong { color: var(--accent); }
.cal { --row: 32px; }
.cal-hours div { height: var(--row); padding: 4px 8px 0; font-size: 11px; line-height: 1; color: var(--faint); text-align: right; }
.cal-day { position: relative; height: calc(var(--rows, 24) * var(--row)); border-left: 1px solid var(--line); background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% var(--row); }
.cal-day.is-today { background-color: rgba(91, 75, 255, .06); }
.cal-closed { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, transparent 6px 12px); pointer-events: none; }
.hours { display: grid; gap: 6px; margin-top: 8px; }
.field:has(input[name=always_open]:checked) .hours { display: none; }
.hours-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center; }
.hours-row span { text-transform: capitalize; font-size: 13px; }
.hours-row .error { grid-column: 2 / -1; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 1; }
.cal-event { position: absolute; left: 3px; right: 3px; overflow: hidden; padding: 3px 6px; border-radius: 6px; font-size: 11px; line-height: 1.3; border-left: 3px solid; }
.cal-event strong, .cal-event span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-upcoming { background: var(--cal-up-bg); border-color: var(--cal-up-line); color: var(--ink); }
.cal-ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.cal-past { background: var(--surface-2); border-color: var(--faint); color: var(--muted); }

pre.code.log-text { margin: 0; height: calc(100vh - 290px); min-height: 240px; max-height: none; white-space: pre-wrap; word-break: break-word; user-select: text; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); }

.profile { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.profile .actions { margin-left: auto; }
.facts { display: grid; gap: 0; }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.danger-zone .card-body, .action-card .card-body { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.stage {
    min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px 16px; position: relative; overflow: hidden; background: var(--night);
}
.stage::before {
    content: ''; position: absolute; width: 720px; height: 720px; top: -300px; right: -300px; border-radius: 50%;
    background: repeating-radial-gradient(circle, transparent 0 70px, rgba(255, 255, 255, .06) 70px 71px);
    pointer-events: none;
}
.stage::after {
    content: ''; position: absolute; width: 432px; height: 432px; top: -156px; right: -156px; border-radius: 50%;
    border: 1.5px solid rgba(168, 159, 255, .45); pointer-events: none;
}
.stage .brand { position: relative; margin-bottom: 28px; }
.panel { position: relative; width: 100%; max-width: 420px; padding: 32px 28px; border-radius: 24px; background: var(--surface); }
.panel h1 { margin-bottom: 6px; }
.panel .lead { margin: 0 0 24px; color: var(--muted); }
.templates { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
.templates-nav { display: flex; flex-direction: column; padding: 10px; position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; }
.templates-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; font-size: 14px; }
.templates-nav a .i { width: 16px; height: 16px; color: var(--muted); flex: none; }
.templates-nav a:hover { background: var(--surface-2); }
.templates-nav a.active { background: var(--surface-2); font-weight: 700; }
.templates-nav a.active .i { color: var(--accent); }
.templates-group { margin: 12px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.templates-group:first-child { margin-top: 4px; }
.templates-facts { margin-bottom: 20px; }
.mail-frame { display: block; width: 100%; height: 900px; border: 1px solid var(--line); border-radius: 14px; background: #F3F3F7; }
.lockscreen { max-width: 380px; margin: 0 auto; padding: 40px 14px 120px; border-radius: 36px; background: linear-gradient(160deg, #2B2550, #15131F 60%, #0D0C14); }
.lockscreen-time { margin-bottom: 28px; text-align: center; color: #fff; font: 600 56px/1 var(--body); letter-spacing: -.02em; }
.push-card { display: flex; gap: 12px; padding: 14px; border-radius: 22px; background: rgba(255, 255, 255, .14); backdrop-filter: blur(12px); color: #fff; }
.push-icon { display: block; flex: none; width: 38px; height: 38px; border-radius: 10px; overflow: hidden; }
.push-icon svg { display: block; width: 100%; height: 100%; }
.push-text { flex: 1; min-width: 0; }
.push-app { font-size: 12px; opacity: .75; margin-bottom: 2px; }
.push-text strong { display: block; font-size: 15px; }
.push-text p { margin: 2px 0 0; font-size: 14px; opacity: .92; }
.push-session { margin-top: 10px; }
.push-session-left { font: 600 20px/1.25 var(--body); }
.push-session-bar { display: block; width: 100%; height: 8px; margin-top: 10px; border: 0; border-radius: 4px; background: rgba(147, 135, 255, .25); overflow: hidden; appearance: none; }
.push-session-bar::-webkit-progress-bar { border-radius: 4px; background: rgba(147, 135, 255, .25); }
.push-session-bar::-webkit-progress-value { border-radius: 4px; background: #9387FF; }
.push-session-bar::-moz-progress-bar { border-radius: 4px; background: #9387FF; }
.push-session-times { display: flex; justify-content: space-between; margin-top: 4px; font-size: 12px; opacity: .7; }
.push-actions { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 10px; font-size: 13px; font-weight: 700; }
/* Wide: the page as high as the window, the list and the preview each scrolling on its own, so a shorter preview
   moves nothing (the window's scroll would otherwise shrink with the page). */
@media (min-width: 981px) {
    .main:has(.templates) { height: 100vh; display: flex; flex-direction: column; }
    .main:has(.templates) .content { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-bottom: 28px; }
    .templates { flex: 1; min-height: 0; align-items: stretch; }
    .templates-nav { position: static; max-height: none; min-height: 0; }
    .templates-preview { min-height: 0; overflow-y: auto; }
}
@media (max-width: 980px) { .templates { grid-template-columns: minmax(0, 1fr); } .templates-nav { position: static; max-height: none; } }
.chat { display: flex; flex-direction: column; gap: 10px; }
.chat-message { max-width: 70%; padding: 10px 14px; border-radius: 14px; background: var(--surface-2); }
.chat-message.chat-owner { align-self: flex-end; background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.chat-message small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.chat-message p { margin: 0; white-space: pre-line; }
.terms { max-height: 300px; overflow-y: auto; margin: 4px 0 14px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); font-size: 14px; line-height: 1.55; }
.terms h2 { margin: 0 0 4px; font-size: 16px; }
.terms h3 { margin: 14px 0 2px; font-size: 14px; }
.terms p { margin: 0; color: var(--muted); }
.terms-check { margin-bottom: 18px; }
.panel .foot { margin-top: 18px; text-align: center; color: var(--muted); }
.panel .foot form { display: inline; }
.status-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 18px; background: var(--ok-soft); color: var(--ok); }
.status-icon.off { background: var(--danger-soft); color: var(--danger); }
.status-icon svg.i { width: 24px; height: 24px; stroke-width: 2.4; }

@media (max-width: 1100px) {
    .grid-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid-kpi.grid-kpi-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .side-stack { grid-template-rows: none; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2, .grid-halves { grid-template-columns: minmax(0, 1fr); }
    .invite-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
    .shell { grid-template-columns: minmax(0, 1fr); align-content: start; }
    /* A top bar; the menu opens over the page as a drawer. */
    .sidebar { position: sticky; z-index: 30; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 16px; }
    .sidebar > .menu, .sidebar > .theme-switch, .sidebar > .me { display: none; }
    .menu-toggle { display: grid; order: -1; }
    body.menu-open { overflow: hidden; }
    body.menu-open::after { content: ''; position: fixed; inset: 0; z-index: 29; background: rgba(0, 0, 0, .45); }
    body.menu-open .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100dvh; flex-direction: column; align-items: stretch; gap: 20px; padding: 16px 14px; overflow-y: auto; }
    body.menu-open .sidebar > .brand { padding-left: 56px; }
    body.menu-open .menu-toggle { position: absolute; top: 14px; left: 14px; }
    body.menu-open .sidebar > .menu, body.menu-open .sidebar > .me { display: flex; }
    body.menu-open .sidebar > .theme-switch { display: grid; }
    .menu a { padding: 12px; }
    .header { padding: 18px 16px; }
    .content { padding: 20px 16px 48px; }
    .form-grid, .invite-row { grid-template-columns: 1fr; }
    .danger-zone .card-body, .action-card .card-body { flex-direction: column; align-items: flex-start; }
    .search { width: 100%; }
    .filters, .filters select.input { width: 100%; max-width: none; }
    .tiles { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
    h1 { font-size: 19px; overflow-wrap: anywhere; }
    .header { flex-direction: column; align-items: stretch; }
    .header .actions { justify-content: flex-start; flex-wrap: wrap; }
    .card-head { flex-wrap: wrap; }
    .week-nav { flex-wrap: wrap; }
    .week-nav strong { min-width: 0; flex: 1; }
    .toolbar .tabs { width: 100%; }

    table.is-stackable thead { display: none; }
    table.is-stackable, .is-stackable tbody, .is-stackable tr { display: block; }
    .is-stackable tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
    .is-stackable tbody tr:last-child { border-bottom: 0; }
    .is-stackable td { display: block; padding: 5px 0; border: 0; text-align: right; overflow: hidden; }
    .is-stackable td:first-child { padding-bottom: 8px; text-align: left; }
    .is-stackable td { overflow-wrap: anywhere; }
    .is-stackable td[data-label]:not(:first-child)::before { content: attr(data-label); float: left; margin-right: 12px; font: 600 12px/1.8 var(--body); color: var(--muted); }
    .is-stackable td:empty { display: none; }
    .is-stackable td.empty { text-align: center; }
    .is-stackable tbody tr:hover td { background: transparent; }
    .is-stackable .person { min-width: 0; }
    .is-stackable .actions { justify-content: flex-end; flex-wrap: wrap; }
    .is-stackable .person-text small { white-space: normal; }
}

@media (max-width: 520px) {
    .grid-kpi, .grid-kpi.grid-kpi-4 { grid-template-columns: 1fr 1fr; gap: 12px; }
    .revenue-figures { grid-template-columns: 1fr 1fr; }
    .revenue-figures .revenue-main { grid-column: 1 / -1; }
    .side-stack { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .bars-stacked .bar-label.minor, .line-x .minor { visibility: hidden; }
    .line-chart { --axis: 52px; }
    .bars:not(.bars-stacked) .bar:nth-child(even) .bar-label { visibility: hidden; }
    .table-compact .hide-sm { display: none; }
    .kpi { padding: 14px; }
    .kpi-value { font-size: 20px; white-space: nowrap; }
    .panel { padding: 26px 20px; }
    th, td { padding-left: 14px; padding-right: 14px; }
}
.panel h1 + form { margin-top: 22px; }
.panel .alert { margin-bottom: 16px; }
