:root {
  color-scheme: dark;
  --ink: #f5f0e6;
  --muted: #9e9d91;
  --ground: #111511;
  --surface: #1a1f1a;
  --surface-2: #222820;
  --line: #343c31;
  --green: #b5c96d;
  --green-soft: #82954c;
  --bronze: #c98a3b;
  --bronze-soft: #8d5b2a;
  --bronze-pale: #e2b873;
  --copper: #a55525;
  --cream: #e8ddc5;
  --danger: #e58b72;
  --shadow: 0 30px 80px rgb(0 0 0 / 30%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--ground); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--ground); }
button, input { font: inherit; }
a { color: inherit; }

.eyebrow, .step {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .18em;
}

.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid #8a984b;
  border-radius: 18px 4px 18px 4px;
  color: #c9d76f;
  font-family: Georgia, serif;
  font-size: 34px;
  line-height: 1;
}

.brand-mark.small { width: 42px; height: 42px; border-radius: 13px 3px 13px 3px; font-size: 24px; }
.auth-page { background: radial-gradient(circle at 17% 20%, #273021 0, var(--ground) 36%); }
.auth-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(320px, 1fr) minmax(420px, 600px); }
.auth-brand { display: flex; max-width: 680px; padding: 9vw 6vw; flex-direction: column; justify-content: center; }
.auth-brand .eyebrow { margin-top: 36px; }
.auth-brand h1 { max-width: 580px; margin: 0 0 24px; font-family: Georgia, serif; font-size: clamp(40px, 5.5vw, 76px); font-weight: 400; line-height: .98; }
.auth-brand > p:not(.eyebrow) { max-width: 590px; color: #bab9ae; font-size: 17px; line-height: 1.7; }
.safety-note { display: flex; margin-top: 40px; align-items: center; gap: 10px; color: var(--cream); font-size: 13px; }
.safety-note span, .status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 99px; background: var(--green); box-shadow: 0 0 0 5px rgb(181 201 109 / 12%); }
.auth-card { align-self: center; margin: 40px; padding: clamp(30px, 4vw, 58px); border: 1px solid var(--line); border-radius: 6px; background: rgb(26 31 26 / 92%); box-shadow: var(--shadow); }
.auth-card h2 { margin: 0 0 14px; font-family: Georgia, serif; font-size: 34px; font-weight: 400; }
.muted { margin: 0 0 30px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.form-stack { display: grid; gap: 18px; }
.form-stack label { display: grid; gap: 8px; color: var(--cream); font-size: 13px; font-weight: 700; }
.form-stack input, .form-stack select, .form-stack textarea, .form-grid input, .form-grid select, .form-grid textarea, .search-form input, .schedule-row input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 3px; outline: none; color: var(--ink); background: #121612; transition: border .2s, box-shadow .2s; }
.form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus, .form-grid input:focus, .form-grid textarea:focus, .search-form input:focus { border-color: var(--green-soft); box-shadow: 0 0 0 3px rgb(181 201 109 / 10%); }
.form-stack textarea, .form-grid textarea { min-height: 88px; resize: vertical; }
.vpn-profile-list { gap: 8px; }
.vpn-profile-card { margin-bottom: 0; }
.vpn-profile-actions { display: flex; flex-wrap: wrap; gap: 12px; padding: 0 12px 10px; }
.vpn-replace-form { padding: 8px 12px 16px; border-bottom: 1px solid var(--line); }
.vpn-replace-form summary { cursor: pointer; color: var(--muted); font-size: 10px; }
.vpn-replace-form form { margin-top: 12px; }
.danger-link { color: #e9a18d; }
.password-hint { margin: -8px 0 0; color: var(--muted); font-size: 12px; }
.primary-button { padding: 15px 20px; border: 0; border-radius: 3px; color: #151914; background: var(--green); cursor: pointer; font-weight: 800; }
.primary-button:hover { background: #c7da80; }
.secondary-button { padding: 11px 15px; border: 1px solid #4b5741; border-radius: 3px; color: var(--cream); background: #20261e; cursor: pointer; font-weight: 700; }
.secondary-button:hover { border-color: var(--green-soft); }
.danger-button { padding: 13px 16px; border: 1px solid #8e4f42; border-radius: 3px; color: #ffd9d0; background: #49271f; cursor: pointer; font-weight: 800; }
.alert { margin-bottom: 20px; padding: 12px 14px; border-left: 3px solid var(--danger); color: #ffd6cb; background: rgb(229 139 114 / 10%); font-size: 13px; line-height: 1.5; }

.app-shell { display: grid; min-height: 100vh; grid-template-columns: 242px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; padding: 28px 20px; border-right: 1px solid var(--line); flex-direction: column; background: #131713; }
.sidebar-brand { display: flex; margin: 0 8px 46px; align-items: center; gap: 13px; text-decoration: none; }
.brand-wordmark { display: grid; gap: 5px; color: #f3eee4; font-family: Georgia, serif; font-size: 25px; letter-spacing: .01em; line-height: .75; }
.brand-wordmark small { color: var(--cream); font-family: Inter, sans-serif; font-size: 10px; font-weight: 700; letter-spacing: .18em; line-height: 1; text-transform: uppercase; }
.sidebar-brand .brand-mark {
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: #7d4b2b;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
}
.sidebar nav { display: grid; gap: 4px; }
.nav-item { display: grid; min-height: 46px; padding: 0 12px; border-radius: 3px; grid-template-columns: 28px 1fr auto; align-items: center; gap: 7px; color: #a7aa9f; text-decoration: none; font-size: 13px; font-weight: 650; }
.nav-item > span { color: #5d6657; font-size: 10px; }
.nav-item.active { color: var(--ink); background: var(--surface-2); }
.nav-item.active > span { color: var(--green); }
.nav-item.analytics-nav > span { color: var(--bronze-soft); }
.nav-item.analytics-nav.active { background: linear-gradient(90deg, rgb(201 138 59 / 14%), var(--surface-2)); box-shadow: inset 2px 0 var(--bronze); }
.nav-item.analytics-nav.active > span { color: var(--bronze); }
.nav-group { margin: 0; color: inherit; font-size: inherit; }
.nav-group-toggle { cursor: pointer; list-style: none; user-select: none; }
.nav-group-toggle::-webkit-details-marker { display: none; }
.nav-group-toggle b { font: inherit; }
.nav-group-toggle:focus-visible { outline: 1px solid var(--bronze-soft); outline-offset: 2px; }
.nav-caret { color: #697064; font-size: 13px; font-style: normal; transition: transform .18s ease; }
.nav-group[open] .nav-caret { transform: rotate(180deg); }
.subnav { display: grid; padding: 3px 5px 7px 34px; gap: 2px; }
.subnav-link { display: grid; min-height: 34px; padding: 0 9px; border-radius: 3px; grid-template-columns: 27px minmax(0, 1fr); align-items: center; gap: 5px; color: #878d83; text-decoration: none; font-size: 11px; font-weight: 620; }
.subnav-link > span { color: #565e53; font-family: ui-monospace, monospace; font-size: 8px; }
.subnav-link:hover { color: var(--cream); background: rgb(255 255 255 / 3%); }
.subnav-link.active { color: var(--ink); background: #20261f; }
.analytics-group .subnav-link.active { box-shadow: inset 2px 0 var(--bronze); }
.analytics-group .subnav-link.active > span { color: var(--bronze); }
.settings-group .subnav-link.active { box-shadow: inset 2px 0 var(--green-soft); }
.settings-group .subnav-link.active > span { color: var(--green); }
.nav-item.disabled { opacity: .56; }
.nav-item em { color: #71786d; font-size: 9px; font-style: normal; letter-spacing: .1em; text-transform: uppercase; }
.sidebar-foot { display: flex; margin-top: auto; padding: 16px 10px 4px; border-top: 1px solid var(--line); align-items: center; gap: 12px; }
.sidebar-foot strong, .sidebar-foot small { display: block; font-size: 11px; }
.sidebar-foot small { margin-top: 4px; color: var(--muted); font-family: ui-monospace, monospace; }
.sidebar-health { margin-top: auto; padding: 14px 8px 2px; border-top: 1px solid var(--line); }
.sidebar-health-title { margin: 0 0 10px; color: #626a5e; font-size: 8px; font-weight: 800; letter-spacing: .16em; }
.health-row { display: grid; padding: 5px 0; grid-template-columns: 12px 1fr; align-items: center; gap: 7px; }
.health-row strong, .health-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-row strong { color: #c7c9bf; font-size: 10px; }
.health-row small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.health-dot { width: 7px; height: 7px; border-radius: 50%; background: #70766d; box-shadow: 0 0 0 3px rgb(112 118 109 / 10%); }
.health-row.online .health-dot { background: var(--green); box-shadow: 0 0 0 3px rgb(181 201 109 / 12%); }
.health-row.offline .health-dot { background: var(--danger); box-shadow: 0 0 0 3px rgb(229 139 114 / 12%); }
.health-row.degraded .health-dot { background: #dfb765; box-shadow: 0 0 0 3px rgb(223 183 101 / 12%); }
.health-row.offline small { color: #e9a18d; }
.health-row.health-parent { margin-top: 5px; }
.health-row.health-child { margin-left: 17px; padding-left: 10px; border-left: 1px solid #44503d; }
.health-row.health-child .health-dot { margin-left: -14px; }
.incident-link { display: block; margin-top: 8px; color: #858b81; font-size: 8px; text-decoration: none; }
.incident-link:hover { color: var(--green); }

.content { min-width: 0; padding: 34px clamp(24px, 4vw, 62px) 28px; }
.topbar { display: flex; margin-bottom: 28px; justify-content: space-between; align-items: center; gap: 30px; }
.topbar h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(32px, 4vw, 48px); font-weight: 400; }
.account { display: flex; align-items: center; gap: 11px; }
.account strong, .account small { display: block; font-size: 12px; }
.account small { margin-top: 3px; color: var(--muted); }
.avatar { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 50%; color: #1b2018; background: var(--green); font-weight: 900; }
.link-button { padding: 8px; border: 0; color: var(--muted); background: none; cursor: pointer; font-size: 12px; }
.link-button:hover { color: var(--ink); }

.system-banner { display: flex; margin-bottom: 20px; padding: 17px 20px; border: 1px solid #3f4938; border-radius: 4px; justify-content: space-between; align-items: center; background: linear-gradient(90deg, #20271c, #171c17); }
.system-banner > div:first-child { display: flex; align-items: center; gap: 14px; }
.system-banner strong { font-size: 13px; }
.system-banner p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.status-dot.large { width: 11px; height: 11px; }
.guard-badge { padding: 8px 11px; border: 1px solid #4b5741; border-radius: 99px; color: var(--green); font-family: ui-monospace, monospace; font-size: 10px; font-weight: 700; letter-spacing: .06em; }

.metrics { display: grid; margin-bottom: 20px; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card, .panel { border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.metric-card { position: relative; min-height: 145px; padding: 22px; overflow: hidden; }
.metric-card::after { position: absolute; right: -18px; bottom: -36px; width: 90px; height: 90px; border: 1px solid #30382d; border-radius: 50%; content: ""; }
.metric-card p { margin: 0 0 18px; color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin-bottom: 7px; font-family: Georgia, serif; font-size: clamp(25px, 2.7vw, 39px); font-weight: 400; white-space: nowrap; }
.metric-card span { color: #777d74; font-size: 10px; }
.metric-card.accent { border-color: #536144; background: linear-gradient(145deg, #27301f, #1b2119); }
.metric-card.accent strong { color: var(--green); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, .8fr); gap: 14px; }
.panel { min-width: 0; padding: 22px; }
.panel.wide { min-height: 315px; }
.panel-head { display: flex; margin-bottom: 20px; justify-content: space-between; align-items: flex-start; }
.panel h2 { margin: 0; font-family: Georgia, serif; font-size: 25px; font-weight: 400; }
.panel-count { color: var(--muted); font-family: ui-monospace, monospace; font-size: 10px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 10px 9px; border-bottom: 1px solid var(--line); color: #747a71; text-align: left; font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
td { padding: 14px 9px; border-bottom: 1px solid #2a3028; color: #c8c8bf; }
td small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
td a { color: var(--cream); font-weight: 700; text-decoration: none; }
td a:hover { color: var(--green); }
tr:last-child td { border-bottom: 0; }
.pill { padding: 5px 8px; border-radius: 99px; color: var(--green); background: rgb(181 201 109 / 10%); font-size: 9px; }
.backup-panel { text-align: center; }
.backup-panel .panel-head { text-align: left; }
.backup-icon { display: grid; width: 48px; height: 48px; margin: 4px auto 15px; place-items: center; border: 1px solid #4b5940; border-radius: 50%; color: var(--green); font-size: 20px; }
.backup-panel > strong { font-family: Georgia, serif; font-size: 20px; font-weight: 400; }
.backup-panel > p { overflow: hidden; color: var(--muted); font-family: ui-monospace, monospace; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.backup-panel dl { display: grid; margin: 22px 0 0; gap: 9px; text-align: left; }
.backup-panel dl div { display: flex; padding-top: 9px; border-top: 1px solid #2b3129; justify-content: space-between; gap: 10px; }
.backup-panel dt, .backup-panel dd { margin: 0; font-size: 10px; }
.backup-panel dt { color: var(--muted); }
.backup-panel dd { font-family: ui-monospace, monospace; }
.event-list { display: grid; }
.event { display: grid; padding: 12px 2px; border-bottom: 1px solid #2b3129; grid-template-columns: 18px 1fr auto; align-items: center; gap: 7px; }
.event:last-child { border-bottom: 0; }
.event-mark { width: 6px; height: 6px; border-radius: 50%; background: var(--green-soft); }
.event strong { font-family: ui-monospace, monospace; font-size: 10px; font-weight: 500; }
.event p, .event time { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.roadmap-panel > p:not(.eyebrow) { color: var(--muted); font-size: 13px; line-height: 1.7; }
.roadmap-tags { display: flex; margin-top: 24px; flex-wrap: wrap; gap: 7px; }
.roadmap-tags span { padding: 7px 9px; border: 1px solid var(--line); border-radius: 2px; color: #aeb1a8; font-size: 10px; }
.empty-state { display: grid; min-height: 160px; place-items: center; color: var(--muted); font-size: 12px; }
footer { padding: 28px 0 0; color: #62685f; font-size: 10px; text-align: center; }

.page-panel { min-height: 340px; }
.toolbar { display: flex; margin-bottom: 24px; justify-content: space-between; align-items: end; gap: 24px; }
.toolbar h2 { margin: 0; }
.search-form { display: flex; width: min(440px, 100%); gap: 8px; }
.search-form input { min-width: 0; }
.empty-cell { height: 160px; color: var(--muted); text-align: center; }
.back-link { display: inline-block; margin: -8px 0 18px; color: var(--muted); font-size: 12px; text-decoration: none; }
.back-link:hover { color: var(--green); }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.full-span { grid-column: 1 / -1; }
.detail-list { display: grid; margin: 22px 0 0; gap: 0; }
.detail-list div { display: grid; padding: 12px 0; border-bottom: 1px solid #2b3129; grid-template-columns: minmax(100px, .7fr) 1.5fr; gap: 18px; }
.detail-list dt, .detail-list dd { margin: 0; font-size: 12px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { overflow-wrap: anywhere; }
.spaced { display: inline-block; margin-top: 22px; }
.notice { margin-bottom: 16px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 3px; font-size: 12px; line-height: 1.5; }
.notice.success { border-color: #536144; color: #d8e8a3; background: #20271c; }
.notice.error { border-color: #74483e; color: #ffd2c6; background: #2b1d19; }
.notice.info { border-color: #455567; color: #cad8e6; background: #19222a; }
.danger-zone { border-color: #674139; }
.danger-zone > p:not(.eyebrow) { color: var(--muted); font-size: 12px; line-height: 1.6; }
.form-stack.compact { margin-top: 22px; }
.positive { color: var(--green); }
.negative { color: var(--danger); }
.settings-grid { display: grid; grid-template-columns: minmax(280px, .7fr) minmax(0, 1.5fr); gap: 14px; }
.wide-settings { grid-column: 2; grid-row: 1 / span 2; }
.full-settings { grid-column: 1 / -1; }
.form-grid { display: grid; margin-top: 22px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid label { display: grid; gap: 7px; color: var(--cream); font-size: 12px; font-weight: 700; }
.check-label { display: flex !important; align-items: center; gap: 8px !important; }
.check-label input { width: auto !important; accent-color: var(--green); }
.schedule-list { display: grid; margin-top: 20px; }
.schedule-row { display: grid; padding: 11px 0; border-bottom: 1px solid #2b3129; grid-template-columns: minmax(130px, 1fr) 90px 120px 15px 120px 110px; align-items: center; gap: 10px; }
.schedule-row strong { font-size: 12px; }
.stack { display: grid; gap: 14px; }
.event-list.detailed .event { grid-template-columns: 18px 1fr 110px; align-items: start; }
.diagnostic-event { padding: 16px 2px; }
.diagnostic-event strong { font-size: 11px; }
.diagnostic-event p { color: #c3c5bc; font-size: 12px; }
.severity { display: block; width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: #858b82; }
.severity.error, .severity.critical { background: var(--danger); }
.severity.warning { background: #dfb765; }
.severity.info { background: #79a9c9; }
.event-meta { display: grid; justify-items: end; color: var(--muted); font-size: 10px; gap: 5px; }
details { margin-top: 8px; color: var(--muted); font-size: 10px; }
pre { max-width: 100%; overflow: auto; padding: 10px; color: #afb5aa; background: #121612; white-space: pre-wrap; }
.admin-list-panel { min-height: 400px; }
.admin-cards { display: grid; margin-top: 20px; gap: 8px; }
.admin-card { display: grid; padding: 13px; border: 1px solid #2f362d; border-radius: 3px; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; }
.admin-card p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.pill.inactive { color: #aaa; background: #292d28; }
.pill.incident-open { color: #ffd0c4; background: rgb(229 139 114 / 12%); }
.incident-panel { margin-bottom: 14px; }
.details-cell { max-width: 330px; overflow-wrap: anywhere; color: var(--muted); font-size: 10px; }
code { color: var(--green); font-family: ui-monospace, monospace; font-size: 10px; }
.inline-action { display: inline-block; text-decoration: none; }

.analytics-toolbar { display: flex; margin-bottom: 14px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 4px; justify-content: space-between; align-items: center; gap: 24px; background: #171c18; }
.period-summary { display: grid; min-width: 220px; gap: 4px; }
.period-summary .eyebrow { margin-bottom: 1px; color: var(--bronze); }
.period-summary strong { font-family: Georgia, serif; font-size: 19px; font-weight: 400; }
.period-summary > span { color: var(--muted); font-size: 10px; }
.period-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 9px; }
.period-presets { display: flex; padding: 3px; border: 1px solid #30372e; border-radius: 3px; background: #111511; }
.period-presets a { padding: 8px 10px; border-radius: 2px; color: var(--muted); text-decoration: none; font-size: 10px; font-weight: 750; }
.period-presets a:hover { color: var(--ink); }
.period-presets a.active { color: #17130e; background: var(--bronze-pale); }
.date-range-form { display: flex; align-items: center; gap: 7px; }
.date-range-form label { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 9px; font-weight: 750; text-transform: uppercase; }
.date-range-form input { width: 124px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 3px; outline: none; color: var(--ink); background: #111511; font-size: 10px; color-scheme: dark; }
.date-range-form input:focus { border-color: var(--bronze-soft); box-shadow: 0 0 0 3px rgb(201 138 59 / 10%); }
.date-range-form .secondary-button { padding: 8px 11px; font-size: 10px; }
.export-button { padding: 9px 11px; border: 1px solid var(--bronze-soft); border-radius: 3px; color: var(--bronze-pale); text-decoration: none; font-family: ui-monospace, monospace; font-size: 10px; font-weight: 700; }
.export-button:hover { border-color: var(--bronze); background: rgb(201 138 59 / 7%); }

.analytics-kpis { display: grid; margin-bottom: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.analytics-kpi { min-width: 0; min-height: 142px; padding: 19px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.analytics-kpi.primary { border-color: #6f4d2a; background: linear-gradient(145deg, #271e15, #1b1d18 70%); box-shadow: inset 0 1px rgb(226 184 115 / 7%); }
.analytics-kpi > div { display: flex; min-height: 24px; justify-content: space-between; align-items: flex-start; gap: 8px; }
.analytics-kpi p { margin: 0; color: #aaa99e; font-size: 11px; font-weight: 650; }
.analytics-kpi strong { display: block; margin: 15px 0 6px; overflow: hidden; color: var(--cream); font-family: Georgia, serif; font-size: clamp(24px, 2.4vw, 35px); font-weight: 400; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
.analytics-kpi.primary strong { color: var(--bronze-pale); }
.analytics-kpi > span { color: #777d74; font-size: 9px; }
.analytics-kpi.compact { min-height: 106px; padding-top: 16px; }
.analytics-kpi.compact strong { margin-top: 9px; font-size: 28px; }
.metric-delta, .metric-note { flex: 0 0 auto; padding: 3px 5px; border-radius: 2px; font-family: ui-monospace, monospace; font-size: 8px; font-weight: 700; white-space: nowrap; }
.metric-delta.up { color: #cfe58a; background: rgb(181 201 109 / 10%); }
.metric-delta.down { color: #f1a691; background: rgb(229 139 114 / 9%); }
.metric-delta.neutral, .metric-note { color: #737a70; background: #242a22; }

.analytics-main-grid { display: grid; margin-bottom: 14px; grid-template-columns: minmax(0, 2fr) minmax(300px, .72fr); gap: 14px; }
.analytics-panel-head { align-items: center; }
.analytics-chart-panel { min-height: 352px; }
.chart-legend { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; }
.chart-legend span { width: 18px; height: 2px; background: var(--bronze); }
.line-chart { position: relative; height: 260px; }
.line-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-grid-line { stroke: #31372f; stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-area { fill: url(#revenue-area); }
.chart-line { fill: none; stroke: var(--bronze); stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.4; vector-effect: non-scaling-stroke; }
.chart-axis-label, .chart-date-label { fill: #686f65; font-family: ui-monospace, monospace; font-size: 11px; }
.chart-date-label { font-size: 10px; }
.chart-empty { min-height: 250px; }
.insight-panel { min-height: 352px; }
.insight-list { display: grid; gap: 3px; }
.insight { display: grid; padding: 13px 0; border-bottom: 1px solid #2b3129; grid-template-columns: 9px 1fr; gap: 9px; }
.insight:last-child { border-bottom: 0; }
.insight > span { width: 6px; height: 6px; margin-top: 5px; border-radius: 50%; background: #70776e; }
.insight.positive > span { background: var(--green); }
.insight.warning > span { background: var(--bronze); }
.insight strong { font-size: 11px; }
.insight p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }

.analytics-secondary-grid { display: grid; margin-bottom: 14px; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr); gap: 14px; }
.definition-hint, .period-chip { color: var(--muted); font-size: 9px; }
.lifecycle-list { display: grid; gap: 4px; }
.lifecycle-row { display: grid; min-height: 48px; grid-template-columns: minmax(160px, 1fr) minmax(100px, 1.1fr) 36px; align-items: center; gap: 16px; }
.lifecycle-row strong, .lifecycle-row span { display: block; }
.lifecycle-row strong { font-size: 11px; }
.lifecycle-row > div:first-child span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.lifecycle-bar { width: 100%; height: 5px; overflow: hidden; border: 0; border-radius: 99px; appearance: none; background: #2a3028; }
.lifecycle-bar::-webkit-progress-bar { border-radius: inherit; background: #2a3028; }
.lifecycle-bar::-webkit-progress-value { border-radius: inherit; background: linear-gradient(90deg, var(--bronze-soft), var(--bronze)); }
.lifecycle-bar::-moz-progress-bar { border-radius: inherit; background: linear-gradient(90deg, var(--bronze-soft), var(--bronze)); }
.lifecycle-row b { color: var(--cream); font-family: ui-monospace, monospace; font-size: 11px; text-align: right; }
.status-breakdown { display: grid; gap: 2px; }
.status-breakdown > div { display: grid; padding: 11px 0; border-bottom: 1px solid #2b3129; grid-template-columns: 8px 1fr 30px 38px; align-items: center; gap: 8px; }
.status-breakdown > div:last-child { border-bottom: 0; }
.status-breakdown strong, .status-breakdown b, .status-breakdown small { font-size: 9px; }
.status-breakdown strong { overflow: hidden; color: #bfc0b8; text-overflow: ellipsis; white-space: nowrap; }
.status-breakdown b { font-family: ui-monospace, monospace; text-align: right; }
.status-breakdown small { color: var(--muted); text-align: right; }
.status-swatch { width: 6px; height: 6px; border-radius: 50%; background: var(--bronze); }
.swatch-2 { background: var(--green-soft); }.swatch-3 { background: #668ca5; }.swatch-4 { background: #995b4b; }.swatch-5 { background: #7e718b; }
.small-empty { min-height: 190px; }

.campaign-panel { margin-bottom: 14px; }
.period-chip { padding: 6px 8px; border: 1px solid var(--line); border-radius: 99px; }
.analytics-table th { white-space: nowrap; }
.analytics-table td { vertical-align: top; }
.analytics-table td > strong { color: var(--cream); font-size: 11px; }
.table-footnote { margin: 14px 0 0; color: #737970; font-size: 9px; line-height: 1.5; }

.analytics-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.rank-list { display: grid; }
.rank-list > div { display: grid; min-height: 47px; border-bottom: 1px solid #2b3129; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; }
.rank-list > div:last-child { border-bottom: 0; }
.rank-list span { color: var(--bronze); font-family: ui-monospace, monospace; font-size: 9px; }
.rank-list strong { font-size: 10px; }
.rank-list small { grid-column: 2; margin-top: -14px; color: var(--muted); font-size: 8px; }
.rank-list b { grid-column: 3; grid-row: 1 / span 2; color: var(--cream); font-family: ui-monospace, monospace; font-size: 10px; }
.compact-stats { display: grid; margin: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.compact-stats > div { min-height: 92px; padding: 14px; border: 1px solid #2f362d; border-radius: 3px; background: #171b17; }
.compact-stats dt { color: var(--muted); font-size: 9px; }
.compact-stats dd { margin: 14px 0 0; color: var(--bronze-pale); font-family: Georgia, serif; font-size: 24px; }
.compact-stats dd small { color: var(--muted); font-family: Inter, sans-serif; font-size: 8px; }
.source-list { display: grid; }
.source-list > div { display: grid; min-height: 47px; padding: 8px 0; border-bottom: 1px solid #2b3129; grid-template-columns: 10px 1fr auto; align-items: center; gap: 7px; }
.source-list > div:last-child { border-bottom: 0; }
.source-state { width: 6px; height: 6px; border-radius: 50%; background: #6d746a; }
.source-state.connected { background: var(--green); box-shadow: 0 0 0 3px rgb(181 201 109 / 8%); }
.source-state.waiting { background: var(--bronze-soft); }
.source-list strong { font-size: 10px; }
.source-list small { grid-column: 2; margin-top: -8px; color: var(--muted); font-size: 8px; }
.source-list b { grid-column: 3; grid-row: 1 / span 2; color: #737a70; font-size: 8px; font-weight: 650; text-transform: uppercase; }
.source-list .connected + strong ~ b { color: var(--green-soft); }
.analytics-methodology { display: flex; margin-top: 14px; padding: 15px 18px; border-left: 2px solid var(--bronze-soft); color: #858b81; background: #161a16; gap: 8px; font-size: 9px; line-height: 1.6; }
.analytics-methodology strong { flex: 0 0 auto; color: #aaa99e; }
.staff-filter select { min-width: 150px; }
.staff-management-grid { display: grid; margin-bottom: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.staff-create-form { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(110px, .55fr) auto; align-items: end; gap: 8px; }
.staff-create-form label, .staff-editor-list label, .inline-editor label { display: grid; color: var(--muted); font-size: 9px; gap: 4px; }
.staff-create-form input, .staff-create-form select, .staff-editor-list input, .inline-editor input, .inline-editor select, .inline-editor textarea { width: 100%; }
.staff-editor-list { display: grid; margin-top: 16px; gap: 6px; }
.staff-editor-list details { padding: 10px 12px; border: 1px solid var(--line); background: #171b17; }
.staff-editor-list summary { display: flex; cursor: pointer; justify-content: space-between; gap: 12px; }
.staff-editor-list summary span { color: var(--muted); font-size: 9px; }
.staff-editor-list form { display: grid; margin-top: 10px; grid-template-columns: 1fr 130px auto auto; align-items: end; gap: 8px; }
.check-label { display: flex !important; align-items: center; flex-direction: row; white-space: nowrap; }
.check-label input { width: auto; }
.staff-card-list { display: grid; margin-top: 16px; gap: 5px; }
.staff-card-list > div { display: flex; padding: 9px 11px; border: 1px solid var(--line); justify-content: space-between; align-items: center; gap: 10px; background: #171b17; }
.staff-card-list span { display: grid; gap: 3px; }
.staff-card-list small { color: var(--muted); font-family: ui-monospace, monospace; font-size: 9px; }
.staff-card-list .inactive { opacity: .55; }
.staff-card-list b { color: var(--muted); font-size: 9px; }
.staff-overview-grid { grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); }
.staff-days-panel, .staff-sessions-panel { margin-top: 14px; }
.staff-incidents-panel { margin-top: 14px; }
.inline-editor { position: relative; }
.inline-editor > summary { cursor: pointer; color: var(--bronze-pale); font-size: 9px; white-space: nowrap; }
.inline-editor > form { display: grid; position: absolute; z-index: 5; right: 0; width: 280px; margin-top: 6px; padding: 12px; border: 1px solid #5a4326; box-shadow: 0 12px 30px #0009; background: #181c18; gap: 8px; }
.staff-hour-chart { display: grid; gap: 5px; }
.staff-hour-chart > div { display: grid; grid-template-columns: 42px 1fr 34px; align-items: center; gap: 8px; color: var(--muted); font-size: 9px; }
.staff-hour-chart i { height: 7px; border-radius: 1px; background: linear-gradient(90deg, var(--bronze) calc(var(--hour-share) * 100%), #292f28 calc(var(--hour-share) * 100%)); }
.staff-hour-chart b { color: #aaa99e; font-family: ui-monospace, monospace; font-weight: 500; text-align: right; }
.attendance-status { display: inline-flex; padding: 4px 7px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.attendance-status.status-open { border-color: #80612f; color: var(--bronze-pale); background: #2a2116; }
.attendance-status.status-auto_closed { border-color: #75423c; color: #e7aaa0; background: #281918; }
.attendance-status.status-corrected { border-color: #485f70; color: #a9c4d8; background: #182129; }
.attendance-status.iiko-succeeded { border-color: #3f6c53; color: #a8d8b8; background: #16241c; }
.attendance-status.iiko-pending { border-color: #80612f; color: var(--bronze-pale); background: #2a2116; }
.attendance-status.iiko-failed { border-color: #75423c; color: #e7aaa0; background: #281918; }
.attendance-status.iiko-not_linked { border-color: #555; color: var(--muted); background: #202020; }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .wide-settings, .full-settings { grid-column: auto; grid-row: auto; }
  .schedule-row { grid-template-columns: 1fr 85px 105px 12px 105px 100px; }
  .analytics-toolbar { align-items: flex-start; flex-direction: column; }
  .period-controls { justify-content: flex-start; }
  .analytics-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-main-grid, .analytics-secondary-grid { grid-template-columns: 1fr; }
  .staff-management-grid { grid-template-columns: 1fr; }
  .staff-create-form, .staff-editor-list form { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { min-height: 44vh; padding: 52px 28px 34px; }
  .auth-brand h1 { font-size: 43px; }
  .auth-card { margin: 0 16px 32px; padding: 28px 22px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-brand { margin: 0; }
  .sidebar nav, .sidebar-foot, .sidebar-health { display: none; }
  .content { padding: 24px 16px; }
  .topbar { align-items: flex-start; }
  .account > div:not(.avatar) { display: none; }
  .system-banner { align-items: flex-start; gap: 16px; }
  .guard-badge { max-width: 145px; text-align: center; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-form { width: 100%; }
  .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .full-span { grid-column: auto; }
  .schedule-row { grid-template-columns: 1fr 80px 1fr 12px 1fr; }
  .schedule-row button { grid-column: 1 / -1; }
  .period-controls, .date-range-form { width: 100%; }
  .period-controls { display: grid; }
  .period-presets { overflow-x: auto; }
  .period-presets a { flex: 1 0 auto; text-align: center; }
  .date-range-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .date-range-form label { align-items: stretch; flex-direction: column; }
  .date-range-form input { width: 100%; }
  .date-range-form .secondary-button { grid-column: 1 / -1; }
  .export-button { text-align: center; }
  .analytics-detail-grid { grid-template-columns: 1fr; }
  .analytics-methodology { flex-direction: column; }
}

@media (max-width: 500px) {
  .metrics { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 34px; }
  .system-banner { display: grid; }
  .account { gap: 4px; }
  .analytics-kpis { grid-template-columns: 1fr; }
  .analytics-kpi, .analytics-kpi.compact { min-height: 112px; }
  .lifecycle-row { grid-template-columns: 1fr 36px; gap: 7px; }
  .lifecycle-bar { grid-column: 1; }
  .lifecycle-row b { grid-column: 2; grid-row: 1 / span 2; }
  .compact-stats { grid-template-columns: 1fr; }
}
