/* Pier – web UI. Calm, technical, dense; tokens and approach from Werkbank's docs/DESIGN.md (dark theme, marigold accent). */

:root {
  --bg: #1A1F29;
  --bg-sidebar: #151A22;
  --surface: #222835;
  --surface-raised: #2A3140;
  --hover: #232A37;
  --border: #333B4C;
  --border-strong: #48526A;
  --text: #E7EAF0;
  --text-muted: #8E97AA;
  --text-faint: #5E6779;
  --accent: #F5B83D;
  --accent-hover: #F8C55E;
  --accent-pressed: #E3A62C;
  --on-accent: #1A1F29;
  --blue: #6FA8F5;
  --violet: #C38FF0;
  --teal: #4FD1C5;
  --orange: #F59E4C;
  --success: #7FCB6E;
  --danger: #F2727F;
  --series-1: #5A93E3;
  --series-2: #5BA64C;

  --font-text: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, monospace;
  --r: 6px;
  --r-pop: 10px;
  --sidebar-w: 236px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.45 var(--font-text); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; }
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 15px; line-height: 1.3; }
h3 { font-size: 13px; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
code, kbd, pre, .mono { font-family: var(--font-mono); }
.mono { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.danger { color: var(--danger); }
.ok { color: var(--success); }
.hint { color: var(--text-muted); font-size: 12px; }
.small { font-size: 12px; }
.grow { flex: 1 1 auto; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
.icon { display: block; flex: none; }

/* ------------------------------------------------------------------ shell */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100vh; }
.main { overflow-y: auto; overflow-x: hidden; min-width: 0; outline: none;
  background: radial-gradient(900px 600px at 12% 0, color-mix(in srgb, var(--accent) 5%, transparent), transparent 72%), var(--bg); }
.boot { padding: 40px; color: var(--text-muted); }

.sidebar { background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; padding: 14px 10px 12px; }
.brand { display: flex; align-items: center; gap: 10px; font: 600 15px var(--font-display); padding: 2px 8px 16px; text-decoration: none; }
.brand-mark { color: var(--accent); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 8px; border-radius: var(--r); color: var(--text-muted); text-decoration: none; position: relative; }
.nav-item > .icon { color: var(--sec, var(--text-muted)); }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: color-mix(in srgb, var(--sec, var(--accent)) 14%, transparent); color: var(--text); }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--sec, var(--accent)); }
.nav-count { margin-left: auto; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.nav-count.alert { color: var(--danger); }
.nav-gap { height: 14px; }

/* Signature: the server gauge at the bottom of the sidebar */
.gauge { margin-top: auto; border-top: 1px solid var(--border); padding: 14px 8px 2px; display: flex; flex-direction: column; gap: 9px; text-decoration: none; }
.gauge-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.gauge-title { font-weight: 600; font-size: 12px; color: var(--text); display: flex; align-items: center; gap: 7px; }
.gauge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.gauge-dot.off { background: var(--text-faint); }
.gauge-up { font-size: 11px; color: var(--text-faint); }
.gauge-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 46px; align-items: center; gap: 8px; font-size: 11px; color: var(--text-muted); }
.gauge-row .mono { text-align: right; color: var(--text); }
.meter { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 2px; background: var(--accent); transition: width .5s linear; }
.meter.warn > span { background: var(--orange); }
.meter.crit > span { background: var(--danger); }
.sidebar-foot { display: flex; align-items: center; gap: 6px; padding: 10px 4px 0; color: var(--text-faint); font-size: 12px; }
.sidebar-foot .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-toggle { display: none; position: fixed; top: 10px; left: 10px; z-index: 30; background: var(--surface); border: 1px solid var(--border); }
.nav-scrim { display: none; }

/* ------------------------------------------------------------------ controls */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid transparent; background: transparent; color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none; font-weight: 500; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-pressed); }
.btn-secondary { background: var(--surface-raised); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--border-strong); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.btn-danger { background: var(--danger); color: var(--on-accent); font-weight: 600; }
.btn-ghost-danger { color: var(--danger); }
.btn-ghost-danger:hover:not(:disabled) { background: rgba(242, 114, 127, .1); }
.btn-small { height: 26px; padding: 0 9px; font-size: 12px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: var(--r); border: 0; background: transparent; color: var(--text-muted); cursor: pointer; flex: none; }
.table .show-sm { display: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }

input[type=text], input[type=password], input[type=number], input[type=url], input[type=search], input[type=email], input[type=datetime-local], input:not([type]), select, textarea {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); color: var(--text); padding: 0 9px; height: 32px; min-width: 0; width: 100%; }
textarea { padding: 7px 9px; height: auto; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; flex: none; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span:first-child { color: var(--text-muted); font-size: 12px; }
.field .hint { margin-top: 1px; }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; padding: 3px 0; }
.check input { margin-top: 2px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.mono-input { font-family: var(--font-mono); font-size: 12px; }

.segments { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.seg { border: 0; background: transparent; color: var(--text-muted); padding: 0 11px; height: 28px; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; }
.seg + .seg { border-left: 1px solid var(--border); }
.seg:hover { color: var(--text); background: var(--hover); }
.seg.active { background: var(--surface-raised); color: var(--text); font-weight: 600; }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 12px; white-space: nowrap;
  background: color-mix(in srgb, var(--c, var(--text-muted)) 14%, transparent); color: var(--c, var(--text-muted)); font-weight: 500; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.st-running, .st-ok, .st-active { --c: var(--success); }
.st-installing, .st-pending, .st-unchecked, .st-unknown, .st-superseded { --c: var(--text-muted); }
.st-partial, .st-soon, .st-rolled_back { --c: var(--orange); }
.st-problem, .st-failed, .st-error, .st-expired, .st-missing { --c: var(--danger); }
.st-stopped { --c: var(--text-faint); }
.st-progress { --c: var(--violet); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--text-faint)); flex: none; display: inline-block; }

.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; background: var(--surface-raised); font-size: 12px; white-space: nowrap; color: var(--text); text-decoration: none; }
a.chip:hover { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
kbd { font-size: 11px; color: var(--text-faint); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; }

/* ------------------------------------------------------------------ views */

.view { padding: 28px 32px 72px; }
.view-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.view-head .titles { flex: 1 1 320px; min-width: 0; }
.view-sub { color: var(--text-muted); padding-top: 8px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.app-icon { width: 36px; height: 36px; border-radius: 8px; flex: none; object-fit: contain; background: var(--surface-raised); }
.app-icon.small { width: 24px; height: 24px; border-radius: 6px; }
.app-letter { display: inline-grid; place-items: center; font: 600 15px var(--font-display); color: var(--text-muted); }
.app-letter.small { font-size: 12px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pop); padding: 18px 20px; margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18), inset 0 1px 0 rgba(255, 255, 255, .03); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { flex: 1; }
.cards-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 16px; }
.cards-2.wide { grid-template-columns: repeat(auto-fit, minmax(min(100%, 640px), 1fr)); }
.cards-2 { align-items: start; }
.cards-2 > .card { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pop); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile-label { color: var(--text-muted); font-size: 12px; }
.tile-value { font: 600 22px var(--font-display); font-variant-numeric: tabular-nums; }
.tile-value small { font-size: 13px; color: var(--text-muted); font-weight: 400; margin-left: 4px; }
.tile-sub { color: var(--text-faint); font-size: 12px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px 9px; color: var(--text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab-count { color: var(--text-faint); font-weight: 400; font-size: 12px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-weight: 600; color: var(--text-muted); font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 8px 10px; border-bottom: 1px solid rgba(51, 59, 76, .55); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table tbody tr:hover { background: var(--hover); }
.table a { text-decoration: none; }
.table a:hover { color: var(--accent); }

/* App list */
.app-list { display: flex; flex-direction: column; gap: 8px; }
.app-row { display: grid; grid-template-columns: 36px minmax(0, 1.4fr) minmax(0, 1.2fr) 120px 110px; align-items: center; gap: 14px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pop); text-decoration: none; transition: border-color .15s ease-out, transform .15s ease-out; }
.app-row:hover { border-color: #3D4659; transform: translateY(-1px); }
.app-row .name { font-weight: 600; font-size: 14px; }
.app-row .meta { color: var(--text-muted); font-size: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.app-row .usage { color: var(--text-muted); font-size: 12px; text-align: right; }
.app-row .domain { color: var(--text-muted); font-size: 12px; }

/* Recent operations (overview) */
.recent { display: flex; flex-direction: column; }
.recent-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid rgba(51, 59, 76, .55); text-decoration: none; }
.recent-row:last-child { border-bottom: 0; }
.recent-row:hover .recent-title { color: var(--accent); }
.recent-title { min-width: 0; overflow-wrap: anywhere; }
.recent-time { color: var(--text-faint); font-size: 12px; white-space: nowrap; }
@media (max-width: 520px) { .recent-row { grid-template-columns: auto minmax(0, 1fr); } .recent-time { grid-column: 2; } }

/* Empty states: centered (DESIGN.md) */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; max-width: 520px; margin: 48px auto 0; padding: 0 16px; color: var(--text-muted); }
.empty-state.compact { margin: 18px auto 10px; gap: 6px; }
.empty-icon { color: var(--text-faint); }
.empty-title { color: var(--text); font-weight: 600; font-size: 15px; }
.empty-text { line-height: 1.5; }
.empty-action { margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* Drop zone */
.drop { border: 1.5px dashed var(--border-strong); border-radius: var(--r-pop); padding: 28px 20px; text-align: center; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 10px; cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 5%, transparent); }
.drop .icon { color: var(--accent); }
body.dragging::after { content: "Paket hier ablegen"; position: fixed; inset: 12px; border: 2px dashed var(--accent); border-radius: 14px; background: rgba(21, 26, 34, .82);
  display: grid; place-items: center; color: var(--text); font: 600 20px var(--font-display); z-index: 80; pointer-events: none; }
.progress { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .2s linear; }

/* Plan & risks */
.plan { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 0; padding: 0; list-style: none; }
.plan li { display: flex; gap: 9px; align-items: flex-start; }
.plan li .icon { color: var(--text-faint); margin-top: 1px; }
.risk { border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); background: color-mix(in srgb, var(--danger) 7%, transparent); border-radius: var(--r); padding: 10px 12px; }
.warnbox { border: 1px solid color-mix(in srgb, var(--orange) 40%, var(--border)); background: color-mix(in srgb, var(--orange) 7%, transparent); border-radius: var(--r); padding: 10px 12px; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.facts dt { color: var(--text-muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Logs */
.log-search { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 10px; }
.log-search input[type=search] { flex: 1 1 220px; min-width: 0; }
.log-search select { flex: 0 1 auto; width: auto; }
.log-custom input { width: auto; }
.log-custom { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.log-custom[hidden] { display: none; }
.log-info { margin: 0 0 8px; }
.log mark { background: rgba(245, 184, 61, .28); color: var(--text); border-radius: 2px; padding: 0 1px; }
/* "Nur ansehen": no buttons that change something (the server refuses them anyway) */
body.viewer .view-actions, body.viewer td.actions > *, body.viewer .card-head .btn:not(.keep-viewer), body.viewer .btn-primary:not(.keep-viewer),
body.viewer .btn-danger, body.viewer .btn-ghost-danger, body.viewer [data-admin] { display: none !important; }
.schedule-row { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; }
.schedule-row input[type=datetime-local] { width: auto; }
.changelog { display: flex; flex-direction: column; gap: 8px; }
.changelog-text { white-space: pre-line; color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.notes.diff li { font-family: var(--font-mono); font-size: 12px; }
.chip-plan { background: rgba(111, 168, 245, .14); }
.chip-warn { background: rgba(245, 158, 76, .16); }
.chip-x { border: 0; background: transparent; color: var(--text-muted); cursor: pointer; padding: 0 0 0 2px; display: inline-flex; }
.chip-x:hover { color: var(--text); }
.backup-files { max-height: 50vh; overflow: auto; }
.odd-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.odd-list li { display: flex; flex-direction: column; gap: 2px; }
.odd-list a { color: var(--text); text-decoration: none; font-weight: 600; }
.odd-list a:hover { color: var(--accent); }
.sub-head { font-size: 13px; font-weight: 600; margin: 18px 0 8px; color: var(--text-muted); }
.callout { border: 1px solid var(--border); background: var(--surface-raised); border-radius: var(--r); padding: 10px 12px; font-size: 12.5px; }
.callout-danger { border-color: rgba(242, 114, 127, .55); }
.notes { margin: 6px 0 0; padding-left: 18px; }
.notes li { margin: 3px 0; color: var(--text-muted); }
.files-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 10px; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 12px; min-width: 0; }
.crumbs a { color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.crumbs a:hover { color: var(--accent); }
.file-name { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; overflow-wrap: anywhere; min-width: 0; }
a.file-name:hover { color: var(--accent); }
.file-name svg { flex: none; color: var(--text-muted); }
.file-text { width: 100%; min-height: 50vh; resize: vertical; font: 12px/1.55 var(--font-mono); white-space: pre; tab-size: 4; }
.console-start { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 18px; }
.console-start .field { min-width: 180px; }
.console-start .check { padding-bottom: 7px; }
.console-term { background: #12161D; border: 1px solid var(--border); border-radius: var(--r); padding: 8px; height: min(66vh, 640px); min-height: 280px; }
.console-term .xterm { height: 100%; }
.log { background: #12161D; border: 1px solid var(--border); border-radius: var(--r); font: 12px/1.55 var(--font-mono); padding: 10px 12px; overflow: auto; max-height: 60vh; min-height: 160px; white-space: pre-wrap; overflow-wrap: anywhere; }
.log.tall { height: calc(100vh - 260px); max-height: none; min-height: 320px; }
.log .l { display: block; }
.log .l-step { color: var(--text); font-weight: 600; margin-top: 6px; }
.log .l-step::before { content: "› "; color: var(--accent); }
.log .l-ok { color: var(--success); }
.log .l-warn { color: var(--orange); }
.log .l-error { color: var(--danger); }
.log .l-err { color: #D9959C; }
.log .l-out { color: var(--text-muted); }
.log .l-info { color: #C5CBD6; }
.log .ts { color: var(--text-faint); margin-right: 8px; }
.op-status { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.spinner { width: 14px; height: 14px; border: 2px solid color-mix(in srgb, var(--violet) 30%, transparent); border-top-color: var(--violet); border-radius: 50%; animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* Key/value editor */
.kv { display: flex; flex-direction: column; gap: 6px; }
.kv-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; gap: 6px; }

/* ------------------------------------------------------------------ charts (no library; validated colors) */

.chart { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.ch-head { display: flex; align-items: baseline; gap: 10px; }
.ch-title { font-weight: 600; }
.ch-now { margin-left: auto; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ch-legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-muted); font-size: 12px; }
.ch-key { display: inline-flex; align-items: center; gap: 6px; }
.ch-key i, .ch-tip i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; }
.ch-area { padding: 6px 8px 22px 52px; }
.ch-plot { position: relative; height: clamp(150px, 9vw, 260px); }
.ch-gl { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.ch-yl { position: absolute; left: -52px; width: 44px; transform: translateY(-50%); text-align: right; color: var(--text-faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.ch-xl { position: absolute; bottom: -20px; transform: translateX(-50%); color: var(--text-faint); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ch-xl.first { transform: none; }
.ch-xl.last { transform: translateX(-100%); }
.ch-dot { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); pointer-events: none; }
.ch-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ch-svg polyline { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.ch-bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.ch-barslot { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.ch-bar { width: min(16px, 70%); border-radius: 4px 4px 0 0; background: var(--series-1); }
.ch-cross { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed var(--text-faint); pointer-events: none; }
.ch-tip { position: absolute; top: 4px; z-index: 5; display: flex; flex-direction: column; gap: 2px; padding: 7px 10px; pointer-events: none;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r); box-shadow: 0 8px 24px rgba(0, 0, 0, .28); font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.ch-tip b { color: var(--text); }
.ch-tip span { display: inline-flex; align-items: center; gap: 6px; }
.ch-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-faint); font-size: 12px; }
.ch-table summary { color: var(--text-faint); font-size: 12px; cursor: pointer; width: max-content; }
.ch-table summary:hover { color: var(--text-muted); }
.ch-table .table-wrap { max-height: 220px; overflow-y: auto; margin-top: 6px; }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 64px; align-items: center; gap: 10px; }
.hbar-label { color: var(--text-muted); font-size: 12px; }
.hbar-track { height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--border) 60%, transparent); overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 4px; background: var(--series-1); min-width: 2px; }
.hbar-value { text-align: right; font-size: 12px; }

/* ------------------------------------------------------------------ modal, toast, menu */

.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 13, 18, .6); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; z-index: 50; }
.modal { width: 100%; max-width: 480px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pop); display: flex; flex-direction: column; max-height: 86vh;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .04); }
.modal-wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 14px 6px 20px; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 10px 20px 18px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); justify-content: flex-end; flex-wrap: wrap; }
.modal-foot .grow { flex: 1; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 90; width: min(400px, calc(100vw - 32px)); pointer-events: none; }
.toast { --kind: var(--blue); position: relative; overflow: hidden; display: flex; gap: 10px; align-items: flex-start; pointer-events: auto; background: var(--surface-raised);
  border: 1px solid var(--border); border-radius: var(--r-pop); padding: 12px 10px 12px 16px; box-shadow: 0 8px 24px rgba(0, 0, 0, .28); white-space: pre-line; }
.toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--kind); }
.toast-error { --kind: var(--danger); }
.toast-ok { --kind: var(--success); }
.toast-msg { flex: 1; min-width: 0; line-height: 1.45; overflow-wrap: anywhere; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) { .toast { animation: toast-in 160ms ease-out; } }

.menu { position: fixed; z-index: 70; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pop); padding: 5px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.menu button { display: flex; width: 100%; align-items: center; gap: 9px; height: 30px; padding: 0 10px; border: 0; background: transparent; border-radius: var(--r); cursor: pointer; text-align: left; color: var(--text); }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 2px; }

.offline { position: fixed; top: 0; left: 50%; transform: translateX(-50%); background: var(--danger); color: var(--on-accent); padding: 6px 14px; border-radius: 0 0 var(--r) var(--r); z-index: 95; font-weight: 600; }

/* ------------------------------------------------------------------ login */

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px;
  background: radial-gradient(900px 600px at 30% 0, color-mix(in srgb, var(--accent) 7%, transparent), transparent 72%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pop); padding: 28px 26px 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .04); }
.login-card .brand { padding: 0 0 18px; font-size: 18px; }
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card .lead { color: var(--text-muted); margin-bottom: 18px; line-height: 1.5; }
.login-card .btn-primary { width: 100%; height: 36px; margin-top: 4px; }
.form-error { color: var(--danger); min-height: 18px; white-space: pre-line; }

/* ------------------------------------------------------------------ narrow windows and phones */

@media (max-width: 1100px) {
  .app-row { grid-template-columns: 36px minmax(0, 1fr) 110px; }
  .app-row .domain-col, .app-row .usage { display: none; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: inline-flex; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-w); z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(10, 13, 18, .5); z-index: 35; }
  .view { padding: 58px 16px 64px; }
  h1 { font-size: 24px; }
  .card { padding: 16px; }
  .modal-backdrop { padding: 16px 10px; }
  .modal { max-height: calc(100vh - 32px); }
  .kv-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .table .hide-sm { display: none; }
  .table .show-sm { display: block; }
  .table .wrap-sm { white-space: normal; word-break: break-all; }
}

@media (max-width: 520px) {
  .tiles { gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { padding: 12px; }
  .tile-value { font-size: 18px; }
  .app-row { grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; padding: 10px 12px; }
  .view-actions .btn .label { display: none; }
}

/* ------------------------------------------------------------------ monitoring */

/* status timeline: one segment per slice, status colors + percentage in the tooltip */
.tl { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tl-bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; height: 22px; }
.tl.compact .tl-bars { height: 14px; gap: 1px; }
.tl-bars > span { border-radius: 2px; background: color-mix(in srgb, var(--border) 80%, transparent); }
.tl-bars > .tl-up { background: color-mix(in srgb, var(--success) 70%, var(--surface)); }
.tl-bars > .tl-part { background: var(--orange); }
.tl-bars > .tl-down { background: var(--danger); }
.tl-bars > span:hover { outline: 1px solid var(--text-muted); outline-offset: 1px; }
.tl-legend { display: flex; justify-content: space-between; color: var(--text-faint); font-size: 11px; }

/* "is everything fine?" banner and the problem list */
.health { display: flex; align-items: center; gap: 14px; padding: 16px 20px; }
.health-mark { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.health-mark.bad { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.health-mark.info { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
.health-mark.warn { background: color-mix(in srgb, var(--orange) 14%, transparent); color: var(--orange); }
.health h2 { font-size: 17px; }
.health p { color: var(--text-muted); margin-top: 2px; }
.problems { display: flex; flex-direction: column; }
.problem { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: start; padding: 12px 0; border-top: 1px solid rgba(51, 59, 76, .55); }
.problem:first-child { border-top: 0; }
.problem .sev { margin-top: 1px; }
.problem-title { font-weight: 600; overflow-wrap: anywhere; }
.problem-detail { color: var(--text-muted); grid-column: 2 / 4; overflow-wrap: anywhere; }
.problem details { grid-column: 2 / 4; }
.problem summary { color: var(--accent); cursor: pointer; width: max-content; font-size: 12px; }
.problem .todo { margin-top: 6px; padding: 8px 10px; border-radius: var(--r); background: var(--bg); color: var(--text); line-height: 1.5; }
.problem-time { color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.sev-critical { --c: var(--danger); }
.sev-warning { --c: var(--orange); }
.sev-info { --c: var(--blue); }

/* app rows with a timeline */
.mon-rows { display: flex; flex-direction: column; }
.mon-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr) 70px 70px; gap: 14px; align-items: center; padding: 10px 4px;
  border-top: 1px solid rgba(51, 59, 76, .55); text-decoration: none; }
.mon-row:first-child { border-top: 0; }
.mon-row:hover .mon-name { color: var(--accent); }
.mon-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.mon-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 12px; }
.mon-num strong { color: var(--text); font-weight: 600; font-size: 13px; }
.mon-head { color: var(--text-faint); font-size: 11px; padding-top: 0; border-top: 0; }
@media (max-width: 860px) { .mon-row { grid-template-columns: minmax(0, 1fr) 64px; } .mon-row .tl, .mon-row .hide-sm { display: none; } }

/* per-core CPU and per-mount usage */
.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.core { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-muted); }
.core b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.usage-rows { display: flex; flex-direction: column; gap: 12px; }
.usage-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
.usage-row .meter { grid-column: 1 / 3; height: 6px; border-radius: 3px; }
.usage-row .meter > span { border-radius: 3px; }
.kv-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; }
.kv-list dt { color: var(--text-muted); }
.kv-list dd { margin: 0; overflow-wrap: anywhere; }

/* bell */
.bell { position: relative; }
.bell-count { position: absolute; top: 2px; right: 1px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: var(--on-accent);
  font: 600 10px/15px var(--font-text); text-align: center; }
.bell-count.calm { background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); line-height: 13px; }
.brand-row { display: flex; align-items: center; gap: 4px; }
.brand-row .brand { flex: 1; }
.bell-top { display: none; position: fixed; top: 10px; right: 10px; z-index: 30; background: var(--surface); border: 1px solid var(--border); }
.notif { position: fixed; z-index: 75; width: min(380px, calc(100vw - 20px)); max-height: min(520px, calc(100vh - 80px)); overflow: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-pop); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); padding: 6px; }
.notif-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 6px; }
.notif-head h3 { flex: 1; }
.notif-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; padding: 9px 10px; border-radius: var(--r); text-decoration: none; }
.notif-item:hover { background: var(--hover); }
.notif-item .dot { margin-top: 5px; }
.notif-item .t { font-weight: 600; overflow-wrap: anywhere; }
.notif-item .s { grid-column: 2; color: var(--text-faint); font-size: 12px; }
.notif-item.done .t { font-weight: 400; color: var(--text-muted); }

/* forms in the alert settings */
.rule-group { margin-bottom: 18px; }
.rule-group h3 { color: var(--text-muted); font-size: 12px; text-transform: none; margin: 0 0 6px; }
.rule { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 10px 0; border-top: 1px solid rgba(51, 59, 76, .55); }
.rule:first-of-type { border-top: 0; }
.rule-title { font-weight: 600; }
.rule-desc { color: var(--text-muted); font-size: 12px; }
.rule-params { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; grid-column: 1 / 3; color: var(--text-muted); font-size: 12px; }
.rule-params input { width: 84px; height: 28px; }
.rule-switches { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; font-size: 12px; color: var(--text-muted); }
@media (max-width: 520px) { .rule { grid-template-columns: minmax(0, 1fr); } .rule-switches { justify-content: flex-start; } }
@media (max-width: 860px) { .bell-top { display: inline-flex; } }
.scope-pick { border: 1px solid var(--border); border-radius: var(--r); padding: 6px 12px 8px; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.scope-pick legend { padding: 0 4px; }

/* catalog */
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.catalog-card { margin-bottom: 0; display: flex; flex-direction: column; }
.catalog-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.catalog-head h2 { font-size: 15px; }
.catalog-text { color: var(--text-muted); line-height: 1.5; flex: 1; margin-bottom: 8px; }
.catalog-images { margin-bottom: 12px; overflow-wrap: anywhere; }
.catalog-actions { display: flex; gap: 6px; flex-wrap: wrap; }
