/* ==========================================================================
   ACHILON Security Management System — application UI
   Same design language as the ACHILON Security website: palette "Obsidian → Bone",
   champagne accent, hairlines, Inter + IBM Plex Mono (self-hosted, SIL OFL).
   Breakpoints: ≤1100 compact · ≤1024 drawer navigation · ≤760 phone · ≤400 small phone
   ========================================================================== */

@font-face { font-family: "Inter"; src: url("fonts/inter-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --obsidian: #0a0a0b;
  --charcoal: #111316;
  --charcoal-2: #171a1e;
  --charcoal-3: #1f2328;
  --slate: #2e3338;
  --stone: #6b7278;
  --stone-light: #9aa0a6;
  --bone: #d6d7d5;
  --white: #fafaf8;
  --champagne: #c9b99a;
  --champagne-soft: rgba(201, 185, 154, 0.12);
  --ok: #7fb39a;
  --ok-soft: rgba(127, 179, 154, 0.12);
  --warn: #d9b26f;
  --warn-soft: rgba(217, 178, 111, 0.12);
  --error: #e0a395;
  --error-strong: #e0796b;
  --error-soft: rgba(224, 121, 107, 0.13);
  --orange: #e0a37a;

  --bg: var(--obsidian);
  --fg: var(--bone);
  --fg-strong: var(--white);
  --muted: var(--stone-light);
  --line: rgba(214, 215, 213, 0.1);
  --line-strong: rgba(214, 215, 213, 0.24);
  --surface: var(--charcoal);
  --surface-2: var(--charcoal-2);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --side-w: 264px;
  --top-h: 64px;
  --pad: clamp(16px, 3vw, 40px);
  --radius: 4px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}
@supports (padding: max(0px)) {
  :root { --pad: max(clamp(16px, 3vw, 40px), env(safe-area-inset-left), env(safe-area-inset-right)); }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; color-scheme: dark; }
body {
  margin: 0; min-width: 320px; background: var(--bg); color: var(--fg);
  font: 400 15px/1.55 var(--font); font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--fg-strong); text-decoration-color: var(--line-strong); text-underline-offset: 0.2em; }
a:hover { text-decoration-color: currentColor; }
p { margin: 0 0 0.9em; }
p:last-child { margin-bottom: 0; }
strong { color: var(--fg-strong); font-weight: 600; }
h1, h2, h3 { color: var(--fg-strong); margin: 0; font-weight: 400; letter-spacing: -0.015em; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--champagne); color: var(--obsidian); }
:focus-visible { outline: 1px solid var(--champagne); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -60px; z-index: 100; background: var(--bone); color: var(--obsidian); padding: 10px 16px; }
.skip:focus { top: 16px; }
html:not(.js) .js-only { display: none !important; }
.mono { font-family: var(--mono); font-size: 0.82em; letter-spacing: 0.02em; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.kicker { font-family: var(--mono); font-size: 0.7rem; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase; color: var(--champagne); margin: 0 0 0.8em; }
.hint { display: flex; gap: 8px; align-items: flex-start; font-size: 0.82rem; color: var(--muted); margin: 12px 0 0; }
.hint .icon { margin-top: 3px; }

/* ---------- Icons, brand ---------- */
.icon { width: 18px; height: 18px; flex: none; }
.icon-xs { width: 14px; height: 14px; }
.mark { width: 26px; height: 26px; flex: none; }
.mark-l { fill: var(--stone); }
.mark-r { fill: var(--bone); }
.mark-sm { width: 22px; height: 22px; }
.mark-lg { width: 56px; height: 56px; }
.logo { display: inline-flex; align-items: center; gap: 12px; color: var(--fg-strong); }
.logo-text { display: flex; flex-direction: column; line-height: 1; }
.logo-word { font-weight: 300; font-size: 1.02rem; letter-spacing: 0.4em; margin-right: -0.4em; }
.logo-sub { font-family: var(--mono); font-size: 0.5rem; letter-spacing: 0.32em; color: var(--muted); margin-top: 6px; white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 42px; padding: 10px 18px;
  border: 1px solid var(--bone); background: var(--bone); color: var(--obsidian); border-radius: var(--radius);
  font: 500 0.9rem/1.2 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn .icon { width: 17px; height: 17px; }
.btn-ghost { background: transparent; color: var(--fg-strong); border-color: var(--line-strong); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.82rem; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.btn-group form { margin: 0; }
@media (hover: hover) {
  .btn:hover { background: var(--white); border-color: var(--white); }
  .btn-ghost:hover { background: var(--surface-2); border-color: var(--bone); color: var(--fg-strong); }
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: var(--radius);
  color: var(--fg-strong); border: 1px solid var(--line); background: transparent; text-decoration: none;
}
.icon-btn .icon { width: 20px; height: 20px; }
.link-arrow { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--muted); text-decoration: none; white-space: nowrap; }
.link-arrow .icon { width: 15px; height: 15px; transition: transform 0.2s var(--ease); }
@media (hover: hover) { .link-arrow:hover { color: var(--fg-strong); } .link-arrow:hover .icon { transform: translateX(3px); } }

/* ---------- Tags ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 0.64rem; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 8px; border: 1px solid var(--line-strong);
  color: var(--fg); white-space: nowrap; border-radius: 2px; line-height: 1.4; vertical-align: middle;
}
.tag-plan, .tag-accent { border-color: var(--champagne); color: var(--champagne); }
.tag-muted { color: var(--muted); }
.tag-err, .st-open, .cat-korrektur.tag, .level-tag-error { border-color: var(--error); color: var(--error); background: var(--error-soft); }
.st-in_progress, .cat-alarm.tag, .level-tag-warn, .sev-medium { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.st-closed, .level-tag-ok { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.sev-low { color: var(--muted); }
.sev-high { border-color: var(--orange); color: var(--orange); background: rgba(224, 163, 122, 0.12); }
.sev-critical { border-color: var(--error-strong); background: var(--error-strong); color: var(--obsidian); }
.tag-row { display: inline-flex; flex-wrap: wrap; gap: 6px; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh;
  background: linear-gradient(to right, var(--charcoal) calc(var(--side-w) - 1px), var(--line) 0, var(--line) var(--side-w), transparent 0); }
.side {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  background: var(--charcoal); border-right: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain;
  padding-bottom: env(safe-area-inset-bottom);
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: var(--top-h); padding: 0 20px; border-bottom: 1px solid var(--line); flex: none; }
.side-brand { text-decoration: none; }
.side-close { display: none; }
.side-nav { padding: 12px 12px 24px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-label { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--stone); margin: 18px 10px 8px; }
.side-label:first-child { margin-top: 8px; }
.side-link {
  display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 10px; border-radius: var(--radius);
  color: var(--muted); text-decoration: none; font-size: 0.9rem; border: 0; background: none; width: 100%; text-align: left; cursor: pointer;
  position: relative;
}
.side-link .icon { color: var(--stone); }
.side-link.is-active { background: var(--charcoal-3); color: var(--fg-strong); }
.side-link.is-active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 2px; background: var(--champagne); }
.side-link.is-active .icon { color: var(--champagne); }
@media (hover: hover) { .side-link:hover { color: var(--fg-strong); background: var(--charcoal-2); } }
.side-foot { border-top: 1px solid var(--line); padding: 12px; display: grid; gap: 4px; flex: none; }
.side-foot form { margin: 0; }
.side-user { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius); text-decoration: none; min-width: 0; }
.side-user.is-active, .side-user:hover { background: var(--charcoal-2); }
.side-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.side-user-text strong { font-size: 0.86rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-text span { font-size: 0.74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex: none; border-radius: 50%;
  border: 1px solid var(--line-strong); font: 500 0.72rem/1 var(--mono); letter-spacing: 0.06em; color: var(--champagne); background: var(--obsidian);
}
.avatar-sm { width: 28px; height: 28px; font-size: 0.62rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1rem; }
.side-backdrop { display: none; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 16px; padding: 0 var(--pad);
  background: rgba(10, 10, 11, 0.86); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(140%) blur(14px); backdrop-filter: saturate(140%) blur(14px);
}
.top-menu, .top-brand { display: none; }
.top-tenant { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.top-tenant-name { font-size: 0.9rem; color: var(--fg-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-clock { display: flex; align-items: center; gap: 8px; color: var(--muted); white-space: nowrap; font-size: 0.78rem; }
.top-clock .icon { width: 15px; height: 15px; color: var(--stone); }

.content { flex: 1; width: 100%; max-width: 1440px; padding: clamp(20px, 3vw, 36px) var(--pad) 48px; outline: none; }
.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding: 18px var(--pad) calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); color: var(--stone); font-size: 0.72rem;
}
.foot-status { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--champagne); }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: clamp(20px, 2.5vw, 32px); }
.page-head-text { min-width: 0; max-width: 72ch; }
.page-head h1 { font-size: clamp(1.6rem, 1.6vw + 1rem, 2.4rem); line-height: 1.12; font-weight: 300; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.page-sub { color: var(--muted); margin: 10px 0 0; font-size: 0.92rem; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-actions form { margin: 0; }

/* ---------- Panels & layout ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(16px, 2vw, 24px); margin: 0 0 20px; min-width: 0; }
.panel-flush { padding: 0; }
.panel-flush > .panel-head { padding: 16px clamp(16px, 2vw, 24px); margin: 0; border-bottom: 1px solid var(--line); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; min-height: 28px; }
.panel-head h2 { font-size: 1.02rem; font-weight: 500; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.panel-foot { display: flex; align-items: center; gap: 10px; margin: 16px -24px -24px; padding: 14px 24px; border-top: 1px solid var(--line); text-decoration: none; }
.step { color: var(--champagne); font-size: 0.72rem; }
.split { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.split > .panel, .cols-2 > .panel, .stack > .panel { margin-bottom: 0; }
.split, .cols-2 { margin-bottom: 20px; }
.stack { display: grid; gap: 20px; min-width: 0; }
.sub-label { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin: 20px 0 8px; }
.panel-head + .sub-label { margin-top: 0; }
.entry-text { font-size: 0.98rem; line-height: 1.65; color: var(--fg-strong); }
.ref { font-size: 0.88rem; color: var(--muted); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 20px; overflow: hidden; }
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { position: relative; display: flex; flex-direction: column; gap: 4px; padding: clamp(16px, 2vw, 24px); border-right: 1px solid var(--line); text-decoration: none; color: var(--fg); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat strong { font-size: clamp(1.8rem, 1.6vw + 1.1rem, 2.6rem); font-weight: 300; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat > span:last-child { font-size: 0.8rem; color: var(--muted); }
.stat-icon { position: absolute; top: 16px; right: 16px; color: var(--stone); }
.stat.is-alert strong { color: var(--error); }
.stat.is-warn strong { color: var(--warn); }
a.stat { transition: background 0.2s var(--ease); }
@media (hover: hover) { a.stat:hover { background: var(--surface-2); } }

/* ---------- Guard log (as in the product illustration) ---------- */
.log { list-style: none; margin: 0; padding: 0; }
.log-day { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--champagne); font-weight: 500; margin: 20px 0 4px; }
.log-day:first-of-type { margin-top: 0; }
.log-line { border-bottom: 1px solid var(--line); }
.log-line:last-child { border-bottom: 0; }
.log-link {
  display: grid; grid-template-columns: 64px 176px minmax(0, 1fr); grid-template-areas: "time tag text" "time tag meta";
  column-gap: 16px; row-gap: 2px; padding: 12px 8px; margin: 0 -8px; text-decoration: none; color: var(--fg); border-radius: var(--radius);
}
@media (hover: hover) { .log-link:hover { background: var(--surface-2); } }
.log-time { grid-area: time; display: flex; flex-direction: column; font-family: var(--mono); line-height: 1.3; }
.log-hm { color: var(--fg-strong); font-size: 0.86rem; }
.log-date { color: var(--stone); font-size: 0.66rem; }
.log-tag { grid-area: tag; padding-top: 1px; min-width: 0; }
.log-tag .tag { max-width: 100%; white-space: normal; }
.log-text { grid-area: text; color: var(--fg-strong); white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.log-meta { grid-area: meta; font-size: 0.76rem; color: var(--muted); }
.log-line.cat-alarm .log-hm { color: var(--warn); }
.log-line.cat-korrektur .log-hm { color: var(--error); }
.verify-line { display: inline-flex; align-items: center; gap: 8px; color: var(--ok); font-family: var(--mono); font-size: 0.78rem; margin: 0; text-decoration: none; }
.verify-line .icon { width: 16px; height: 16px; }
a.verify-line { display: flex; }

/* Item lists (incidents on dashboard, modules in license detail) */
.item-list { list-style: none; margin: 0; padding: 0; }
.item-list > li { border-bottom: 1px solid var(--line); }
.item-list > li:last-child { border-bottom: 0; }
.item { display: grid; gap: 4px; padding: 12px 8px; margin: 0 -8px; text-decoration: none; color: var(--fg); border-radius: var(--radius); }
.item-static { margin: 0; padding: 12px 0; }
@media (hover: hover) { a.item:hover { background: var(--surface-2); } }
.item-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.item-title { font-weight: 500; color: var(--fg-strong); }
.item-meta { font-size: 0.78rem; color: var(--muted); }
.quick { display: grid; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.quick .side-label { margin: 0 0 4px; }
.quick .btn { justify-content: flex-start; }
.empty { display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 18px 0; font-size: 0.9rem; }
.empty .mark { opacity: 0.45; }
.empty p { margin: 0; }
.timeline { list-style: none; margin: 0 0 4px; padding: 0 0 0 18px; border-left: 1px solid var(--line-strong); display: grid; gap: 16px; }
.timeline li { position: relative; }
.timeline li::before { content: ""; position: absolute; left: -22px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--champagne); }
.timeline-meta { display: block; color: var(--muted); font-size: 0.74rem; margin-bottom: 4px; }

/* ---------- Facts ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 16px 24px; margin: 20px 0 0; }
.facts:first-child { margin-top: 0; }
.facts-stack { grid-template-columns: minmax(0, 1fr); gap: 14px; }
.facts-top { padding-top: 16px; border-top: 1px solid var(--line); }
.facts dt { font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.facts dd { margin: 0; color: var(--fg-strong); overflow-wrap: anywhere; }
.hash { font-family: var(--mono); font-size: 0.76rem; line-height: 1.6; word-break: break-all; }
.profile { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.profile div { display: flex; flex-direction: column; }
.user-cell { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Messages ---------- */
.flash, .notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border: 1px solid var(--ok); border-left-width: 3px;
  background: var(--ok-soft); color: var(--fg-strong); border-radius: var(--radius); margin: 0 0 20px; font-size: 0.9rem;
}
.flash .icon, .notice .icon { color: var(--ok); margin-top: 2px; }
.flash p, .notice p { margin: 0; }
.flash.error { border-color: var(--error); background: var(--error-soft); }
.flash.error .icon { color: var(--error); }
.flash ul { margin: 0; padding-left: 18px; }
.notice { border-color: var(--warn); background: var(--warn-soft); }
.notice .icon { color: var(--warn); }
.license-banner {
  display: flex; align-items: center; gap: 12px; padding: 10px var(--pad); font-size: 0.86rem; border-bottom: 1px solid var(--warn);
  background: var(--warn-soft); color: var(--fg-strong);
}
.license-banner .icon { color: var(--warn); }
.license-banner p { margin: 0; flex: 1; }
.license-banner.level-error { border-color: var(--error); background: var(--error-soft); }
.license-banner.level-error > .icon { color: var(--error); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .vendor-form label:not(.check):not(.choice) {
  font-family: var(--mono); font-size: 0.66rem; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.field > label .muted { text-transform: none; letter-spacing: 0; font-family: var(--font); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=search],
input[type=number], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--obsidian); color: var(--fg-strong); font-size: 16px; line-height: 1.4;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--stone); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--champagne); box-shadow: 0 0 0 3px var(--champagne-soft); }
input[readonly] { color: var(--muted); }
textarea { min-height: 120px; resize: vertical; }
select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='1.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
select[multiple] { min-height: 140px; padding-right: 12px; background-image: none; }
select option { background: var(--charcoal); color: var(--fg-strong); }
input[type=date]::-webkit-calendar-picker-indicator, input[type=datetime-local]::-webkit-calendar-picker-indicator { filter: invert(0.75); cursor: pointer; }
input[type=file] { font-size: 0.86rem; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button { font: inherit; margin-right: 12px; padding: 8px 14px; border: 1px solid var(--line-strong); background: transparent; color: var(--fg-strong); border-radius: var(--radius); cursor: pointer; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 0.92rem; color: var(--fg); }
.check input, .choice input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--champagne); flex: none; }
.field-check { align-content: center; }
.field-search { position: relative; }
.field-search .icon { position: absolute; left: 12px; top: 13px; color: var(--stone); pointer-events: none; }
.field-search input { padding-left: 38px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.form-actions form { margin: 0; }
.form-actions .hint { margin: 0; flex: 1 1 260px; }
.form-inline-panel { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)) auto; gap: 10px; align-items: end; margin: 0 0 20px; }
.textarea-key { min-height: 140px; font-size: 0.78rem; word-break: break-all; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; }
.secret { border-color: var(--warn); }
.secret-label { display: flex; gap: 8px; align-items: center; color: var(--warn); font-size: 0.86rem; margin-bottom: 12px; }
.code { font-family: var(--mono); font-size: 0.78rem; background: var(--obsidian); border: 1px solid var(--line); padding: 14px; border-radius: var(--radius); overflow-x: auto; margin: 16px 0 0; color: var(--fg); white-space: pre; }
.details summary { cursor: pointer; font-weight: 500; color: var(--fg-strong); }
.choice-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 10px; margin-bottom: 16px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); cursor: pointer; font-size: 0.9rem; color: var(--fg-strong); }
.choice:has(input:checked) { border-color: var(--champagne); background: var(--champagne-soft); }
.module-rows { display: grid; }
.module-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.2fr) minmax(0, 0.8fr); gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.module-row:last-child { border-bottom: 0; }
.module-row-name span { display: flex; flex-direction: column; }
.module-row-name .muted { font-size: 0.76rem; }
.model-help { margin: 16px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 0.82rem; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-family: var(--mono); font-size: 0.64rem; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); white-space: nowrap; background: var(--charcoal-2); }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td a { text-decoration: none; }
.table td a:hover { text-decoration: underline; }
@media (hover: hover) { .table tbody tr:hover td { background: rgba(255, 255, 255, 0.015); } }
.table-dense td { padding: 9px 16px; font-size: 0.84rem; }
.panel:not(.panel-flush) .table th:first-child, .panel:not(.panel-flush) .table td:first-child { padding-left: 0; }
.cell-title { color: var(--fg-strong); font-weight: 500; }
.cell-action { text-align: right; white-space: nowrap; }
.cell-action form { margin: 0; display: inline; }
.cell-note { font-size: 0.8rem; color: var(--muted); }
tr.is-inactive td { color: var(--stone); }
tr.is-inactive .cell-title, tr.is-inactive .cell-title a { color: var(--muted); }
.row-empty td { padding: 4px 16px; }
.hash-short { font-size: 0.74rem; }

/* ---------- Bars & meters ---------- */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.bars li { display: grid; grid-template-columns: 96px minmax(0, 1fr) 32px; align-items: center; gap: 12px; }
.bars-track, .meter-track { height: 6px; background: var(--charcoal-3); border-radius: 3px; overflow: hidden; }
.bars-fill, .meter-fill { display: block; height: 100%; background: var(--bone); border-radius: 3px; }
.sev-fill-critical { background: var(--error-strong); }
.sev-fill-high { background: var(--orange); }
.sev-fill-medium { background: var(--warn); }
.sev-fill-low { background: var(--stone-light); }
.meter { margin-bottom: 18px; }
.meter-head { display: flex; justify-content: space-between; gap: 12px; font-size: 0.88rem; margin-bottom: 8px; }
.meter-fill { background: var(--champagne); }
.meter-fill.is-over { background: var(--error-strong); }
.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; } .w-25 { width: 25%; }
.w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; } .w-50 { width: 50%; } .w-55 { width: 55%; }
.w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; } .w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; }
.w-90 { width: 90%; } .w-95 { width: 95%; } .w-100 { width: 100%; }

/* ---------- License ---------- */
.license-hero {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap;
  padding: clamp(18px, 2.4vw, 28px); margin-bottom: 20px; border: 1px solid var(--ok); border-left-width: 3px; border-radius: var(--radius);
  background: linear-gradient(120deg, var(--ok-soft), transparent 60%), var(--surface);
}
.license-hero.level-warn { border-color: var(--warn); background: linear-gradient(120deg, var(--warn-soft), transparent 60%), var(--surface); }
.license-hero.level-error { border-color: var(--error); background: linear-gradient(120deg, var(--error-soft), transparent 60%), var(--surface); }
.license-hero-main { display: flex; gap: 16px; align-items: flex-start; min-width: 0; flex: 1 1 420px; }
.license-hero-icon { display: inline-flex; padding: 10px; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--ok); }
.level-warn .license-hero-icon { color: var(--warn); }
.level-error .license-hero-icon { color: var(--error); }
.license-hero h2 { font-size: clamp(1.25rem, 1vw + 0.95rem, 1.6rem); font-weight: 400; margin-bottom: 8px; }
.license-hero p { color: var(--fg); max-width: 72ch; }
.license-hero .kicker { margin-bottom: 6px; }
.license-note { display: flex; gap: 8px; align-items: center; color: var(--warn) !important; margin-top: 8px; font-size: 0.88rem; }
.license-hero-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.module { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--obsidian); min-width: 0; }
.module.is-active { border-color: rgba(127, 179, 154, 0.45); }
.module.is-planned { opacity: 0.6; }
.module-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.module-cat { color: var(--stone); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; }
.module .tag { white-space: normal; text-align: right; }
.module h3 { font-size: 1rem; font-weight: 500; }
.module p { font-size: 0.84rem; color: var(--muted); margin: 0; }
.module-meta { color: var(--champagne) !important; font-size: 0.72rem !important; margin-top: auto !important; padding-top: 6px; }
.model-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); }
.model-card { padding: 18px; border-right: 1px solid var(--line); }
.model-card:last-child { border-right: 0; }
.model-card h3 { font-size: 1rem; font-weight: 500; margin-bottom: 8px; }
.model-card p { font-size: 0.86rem; color: var(--muted); }

/* ---------- Pagination, errors ---------- */
.pagination { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 8px 0 20px; flex-wrap: wrap; color: var(--muted); }
.error-page { max-width: 640px; margin: 8vh auto; text-align: left; padding: 0 var(--pad); }
.error-page .mark { margin-bottom: 28px; }
.error-page h1 { font-size: clamp(1.6rem, 2vw + 1rem, 2.4rem); font-weight: 300; letter-spacing: -0.03em; margin-bottom: 28px; }
.error-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Public pages / login ---------- */
.public { min-height: 100vh; min-height: 100dvh; outline: none; }
.public > .flash { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 30; width: min(92vw, 480px); }
.login { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr); min-height: 100vh; min-height: 100dvh; }
.login-brand {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; overflow: hidden;
  padding: clamp(32px, 5vw, 72px); border-right: 1px solid var(--line);
  background: radial-gradient(120% 90% at 0% 100%, rgba(201, 185, 154, 0.08), transparent 55%), var(--charcoal);
}
.login-mark { width: clamp(64px, 7vw, 104px); height: auto; aspect-ratio: 1; }
.login-mark .mark-l { fill: var(--slate); }
.login-claim { font-size: clamp(2.2rem, 4.2vw, 4.4rem); line-height: 1.02; font-weight: 300; letter-spacing: -0.04em; color: var(--fg-strong); margin: 0 0 32px; }
.login-claim .soft { color: var(--stone-light); }
.login-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; color: var(--muted); font-size: 0.74rem; letter-spacing: 0.06em; }
.login-points li { display: flex; align-items: center; gap: 10px; }
.login-points .icon { color: var(--champagne); width: 16px; height: 16px; }
.tagline { color: var(--stone); text-transform: uppercase; letter-spacing: 0.28em; font-size: 0.66rem; margin: 0; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: clamp(28px, 5vw, 64px) var(--pad); }
.login-box { width: min(100%, 380px); }
.login-box .logo { margin-bottom: 48px; }
.login-title { font-size: 1.9rem; font-weight: 300; letter-spacing: -0.03em; margin-bottom: 6px; }
.login-box > .muted { margin-bottom: 28px; }
.login-box .flash { margin-bottom: 20px; }
.login-note { display: flex; gap: 8px; align-items: flex-start; color: var(--stone); font-size: 0.7rem; margin: 28px 0 0; line-height: 1.6; }
.login-note .icon { margin-top: 2px; }

/* ---------- Responsive ---------- */
@media (min-width: 1800px) {
  body { font-size: 16px; }
  :root { --side-w: 288px; }
}
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats .stat:nth-child(2n) { border-right: 0; }
  .stats .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-3 .stat { border-bottom: 0 !important; border-right: 1px solid var(--line) !important; }
  .stats-3 .stat:last-child { border-right: 0 !important; }
  .module-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .module-row-name { grid-column: 1 / -1; }
}
@media (max-width: 1024px) {
  .shell { display: block; background: none; }
  .side {
    position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: min(86vw, 320px); height: auto;
    transform: translateX(-102%); transition: transform 0.3s var(--ease), visibility 0.3s; visibility: hidden;
    box-shadow: 30px 0 60px rgba(0, 0, 0, 0.5);
  }
  .side:target, .nav-open .side { transform: none; visibility: visible; }
  .side-close { display: inline-flex; }
  .side-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.6); opacity: 0; pointer-events: none; transition: opacity 0.3s var(--ease); }
  .side:target + .side-backdrop, .nav-open .side-backdrop { opacity: 1; pointer-events: auto; }
  .top-menu { display: inline-flex; }
  .top-brand { display: inline-flex; }
  .top { gap: 12px; }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-brand { min-height: 0; gap: 28px; border-right: 0; border-bottom: 1px solid var(--line); padding-bottom: 32px; }
  .login-claim { font-size: clamp(2rem, 7vw, 3.2rem); margin-bottom: 20px; }
  .login-brand .tagline { display: none; }
  .login-panel { align-items: flex-start; }
  .login-box .logo { display: none; }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .top-clock time { font-size: 0.72rem; }
  .top-tenant .tag-plan { display: none; }
  .page-head { align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions > .btn, .page-actions > form { flex: 1 1 auto; }
  .page-actions > form .btn { width: 100%; }
  .filters { grid-template-columns: minmax(0, 1fr); }
  .stats-3 { grid-template-columns: minmax(0, 1fr); }
  .stats-3 .stat { border-right: 0 !important; border-bottom: 1px solid var(--line) !important; flex-direction: row; align-items: baseline; gap: 12px; }
  .stats-3 .stat:last-child { border-bottom: 0 !important; }
  .stats-3 .stat-icon { top: 50%; transform: translateY(-50%); }
  .model-grid { grid-template-columns: minmax(0, 1fr); }
  .model-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .model-card:last-child { border-bottom: 0; }
  .log-link { grid-template-columns: 52px minmax(0, 1fr); grid-template-areas: "time tag" "time text" "time meta"; row-gap: 6px; }
  .log-tag { padding-top: 0; }
  .module-row { grid-template-columns: minmax(0, 1fr); }
  .license-banner { flex-wrap: wrap; }
  .panel-foot { margin: 16px -16px -16px; padding: 14px 16px; }

  /* Tables become stacked cards on phones. */
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .table-cards tbody tr:last-child { border-bottom: 0; }
  .table-cards td { border: 0; padding: 3px 0; text-align: left !important; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; }
  .table-cards td::before { content: attr(data-label); white-space: normal; font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--stone); padding-top: 3px; }
  .table-cards td.cell-title { display: block; font-size: 1rem; padding-bottom: 6px; }
  .table-cards td.cell-title::before, .table-cards td.cell-action::before, .table-cards .row-empty td::before { content: none; }
  .table-cards td.cell-action { display: flex; justify-content: flex-start; padding-top: 10px; }
  .table-cards td:not([data-label]):not(.cell-action) { display: block; }
  .table-cards .row-empty td { display: block; }
  .btn-group { justify-content: flex-start; }
}
@media (max-width: 400px) {
  .top-clock { display: none; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .stats .stat { border-right: 0 !important; border-bottom: 1px solid var(--line); }
  .stats .stat:last-child { border-bottom: 0; }
  .table-cards td { grid-template-columns: 92px minmax(0, 1fr); }
  .copy-row { flex-direction: column; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .login { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .login-brand { border-bottom: 0; border-right: 1px solid var(--line); }
  .login-points { display: none; }
  .login-claim { font-size: 1.8rem; }
  .top { position: static; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Print (reports, entries) ---------- */
@media print {
  :root { --bg: #fff; --fg: #111; --fg-strong: #000; --muted: #555; --line: #ccc; --line-strong: #999; --surface: #fff; --surface-2: #fff; --charcoal-2: #f2f2f2; --charcoal-3: #e5e5e5; --obsidian: #fff; }
  html { color-scheme: light; }
  body { background: #fff; color: #111; font-size: 11pt; }
  .side, .side-backdrop, .top, .foot, .no-print, .flash, .license-banner, .page-actions, .skip { display: none !important; }
  .shell { display: block; background: none; }
  .content { padding: 0; max-width: none; }
  .panel, .stats, .license-hero { border-color: #ccc; break-inside: avoid; background: #fff; }
  .tag { border-color: #999 !important; color: #000 !important; background: none !important; }
  .stat strong, .log-hm { color: #000 !important; }
  a { color: #000; text-decoration: none; }
  .mark-l { fill: #777; } .mark-r { fill: #000; }
  .table-cards thead { display: table-header-group !important; }
  .table-cards, .table-cards tbody { display: table !important; } .table-cards tr { display: table-row !important; } .table-cards td { display: table-cell !important; }
  .table-cards td::before { content: none !important; }
}

.tag-ok { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.tag-warn { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.ok-text { color: var(--ok); }
/* ---------- Updates & releases ---------- */
.license-banner.level-ok { border-color: var(--ok); background: var(--ok-soft); }
.license-banner.level-ok > .icon { color: var(--ok); }
.release.is-security { border-color: var(--error); }
.changelog { font-size: 0.9rem; color: var(--fg); line-height: 1.65; }
.changelog-entry { padding: 16px 0; border-bottom: 1px solid var(--line); }
.changelog-entry:first-of-type { padding-top: 0; }
.changelog-entry:last-child { border-bottom: 0; padding-bottom: 0; }
.changelog-entry h3 { font-size: 1rem; font-weight: 500; margin-bottom: 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.changelog-entry.is-current h3 { color: var(--ok); }
