/* hostcd — a control room for fleets of plain hosts.
   Colour carries status only; everything else stays steel and ink. */

:root {
  --bg: #EEF1F4;
  --panel: #FFFFFF;
  --panel-2: #F6F8FA;
  --ink: #18212C;
  --ink-2: #485564;
  --ink-3: #758392;
  --line: #CBD3DC;
  --line-soft: #E1E6EC;
  --brand: #24426B;
  --brand-ink: #FFFFFF;
  --focus: #2E6BD6;

  --synced: #2F8A57;
  --outofsync: #B8740E;
  --degraded: #C23B33;
  --progressing: #2E6BD6;
  --missing: #7B6AA6;
  --unknown: #8A95A3;

  --synced-bg: #E5F3EA;
  --outofsync-bg: #FBF0DD;
  --degraded-bg: #FBE7E5;
  --progressing-bg: #E4EDFC;
  --missing-bg: #EEEAF6;
  --unknown-bg: #ECEFF2;

  --add: #E3F4E8;
  --add-ink: #1F6B40;
  --del: #FBE8E6;
  --del-ink: #9C2F28;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --r-sm: 4px;
  --r: 6px;
  --shadow: 0 1px 2px rgba(24, 33, 44, .06), 0 8px 24px rgba(24, 33, 44, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171D;
    --panel: #1A2129;
    --panel-2: #161C23;
    --ink: #E4E9EF;
    --ink-2: #B3BECA;
    --ink-3: #8593A2;
    --line: #34404D;
    --line-soft: #26303A;
    --brand: #8FB1E3;
    --brand-ink: #10161D;
    --focus: #8FB1E3;

    --synced: #4FBF84;
    --outofsync: #E3A33F;
    --degraded: #EF6E66;
    --progressing: #6E9CF0;
    --missing: #A796D1;
    --unknown: #8E9AA8;

    --synced-bg: #18301F;
    --outofsync-bg: #36290F;
    --degraded-bg: #3A1B19;
    --progressing-bg: #172744;
    --missing-bg: #282236;
    --unknown-bg: #232A33;

    --add: #173322;
    --add-ink: #7FD8A4;
    --del: #3A1C1A;
    --del-ink: #F29C95;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--ink-3); }
.boot { padding: 40px; color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  background: var(--panel-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px 14px;
  font-weight: 650; font-size: 16px; letter-spacing: -.01em;
  text-decoration: none;
}
.brand svg { width: 22px; height: 22px; }
.brand .ver { margin-left: auto; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.nav { padding: 4px 10px; }
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--r);
  text-decoration: none; color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--line-soft); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brand); color: var(--brand-ink); }
.nav a .count { margin-left: auto; font-size: 12px; opacity: .75; font-variant-numeric: tabular-nums; }
.count.skel { opacity: .35; }
.actbar { display: flex; align-items: center; gap: 10px; padding: 6px 10px 12px; }
.nav svg { width: 16px; height: 16px; flex: none; }

.folders { padding: 6px 10px 12px 14px; }
.folders .head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px 4px; color: var(--ink-3); font-size: 12.5px;
}
.folders ul { list-style: none; margin: 0; padding: 0; }
.folders li ul { padding-left: 14px; border-left: 1px solid var(--line-soft); margin-left: 10px; }
.folder-link {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 10px; border-radius: var(--r);
  color: var(--ink-2); text-decoration: none; font-size: 13.5px;
}
.folder-link:hover { background: var(--line-soft); color: var(--ink); }
.folder-link[aria-current="true"] { background: var(--panel); color: var(--ink); box-shadow: inset 2px 0 0 var(--brand); }
.folder-link svg { width: 15px; height: 15px; flex: none; opacity: .7; }
.folder-link .count { margin-left: auto; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.folder-link .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

.side-foot { margin-top: auto; padding: 12px 18px; border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--ink-3); display: flex; justify-content: space-between; align-items: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 28px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.bar h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 13px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.bar .spacer { flex: 1; }
.content { padding: 22px 28px 60px; }

/* ---------- controls ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel); color: var(--ink); font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--degraded); }
.btn.danger.solid { background: var(--degraded); border-color: var(--degraded); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-soft); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
td.right { text-align: right; }

.input, .select, textarea.input {
  height: 32px; padding: 0 10px; width: 100%;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel);
}
textarea.input { height: auto; padding: 8px 10px; min-height: 64px; resize: vertical; }
.input:focus, .select:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.search { position: relative; width: min(320px, 100%); }
.search svg { position: absolute; left: 10px; top: 9px; width: 14px; height: 14px; color: var(--ink-3); }
.search .input { padding-left: 30px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  font-size: 13px; cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--line-soft); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip .n { font-variant-numeric: tabular-nums; color: var(--ink-3); }

.label {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 7px; border-radius: 3px;
  background: var(--line-soft); color: var(--ink-2);
  font-family: var(--mono); font-size: 11.5px; white-space: nowrap;
}

.tag {
  display: inline-block; margin-left: 7px; padding: 1px 6px; border-radius: 3px;
  background: var(--unknown-bg, var(--line-soft)); color: var(--ink-3);
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  vertical-align: 1px;
}

#i-output { max-height: 220px; overflow: auto; white-space: pre-wrap; margin-top: 10px; }
textarea.input { resize: vertical; min-height: 92px; line-height: 1.45; }
details.manual { margin-top: 14px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
details.manual > summary { cursor: pointer; color: var(--ink-2); font-size: 13px; user-select: none; }

/* clusters */
.cluster-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 26px; align-items: start; }
@media (max-width: 860px) { .cluster-grid { grid-template-columns: 1fr; } }
pre.code.log { max-height: 440px; overflow: auto; white-space: pre-wrap; }
.nst {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
  background: var(--unknown-bg); color: var(--unknown);
}
.nst-Ready { background: var(--synced-bg); color: var(--synced); }
.nst-Failed { background: var(--degraded-bg); color: var(--degraded); }
.nst-Preparing, .nst-Initializing, .nst-Joining { background: var(--progressing-bg); color: var(--progressing); }
.tag.warn { background: var(--outofsync-bg); color: var(--outofsync); }
.tag.ok { background: var(--synced-bg); color: var(--synced); }

/* webhook event checkboxes */
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
@media (max-width: 620px) { .check-grid { grid-template-columns: 1fr; } }

/* changelog */
ul.changelog { list-style: none; margin: 0; padding: 0; }
ul.changelog li { padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
ul.changelog li:last-child { border-bottom: 0; }
.cl-head { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.cl-msg { margin-top: 3px; white-space: pre-wrap; word-break: break-word; }

/* backup / restore */
.backup { display: flex; flex-direction: column; gap: 20px; max-width: 720px; }
.backup .card { border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; background: var(--surface, var(--bg)); }
.backup .card h2 { margin: 0 0 6px; font-size: 15px; }
.backup .card p { margin: 0 0 14px; }
.backup textarea.input { width: 100%; }

/* explorer */
.content .tabs { display: flex; gap: 2px; margin: 0 0 18px; border-bottom: 1px solid var(--line); }
.content .tabs button { border: 0; background: none; padding: 9px 14px; cursor: pointer; color: var(--ink-3); border-bottom: 2px solid transparent; font-weight: 500; font-size: 14px; }
.content .tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.explore-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.explore-bar .select { max-width: 280px; }
.drawer textarea#kube-yaml { width: 100%; min-height: 60vh; resize: vertical; }
.drawer .term-body { padding: 0; }
.term { width: 100%; height: 72vh; background: #0b0e14; padding: 8px; box-sizing: border-box; }
.term .xterm { height: 100%; }
details.manual[open] > summary { margin-bottom: 10px; }

/* ---------- status ---------- */

.st { display: inline-flex; align-items: center; gap: 5px; font-weight: 550; font-size: 13px; white-space: nowrap; }
.st svg { width: 15px; height: 15px; flex: none; }
.st-Synced, .st-Healthy { color: var(--synced); }
.st-OutOfSync { color: var(--outofsync); }
.st-Degraded, .st-Failed { color: var(--degraded); }
.st-Progressing, .st-Running { color: var(--progressing); }
.st-Missing { color: var(--missing); }
.st-Unknown, .st-Terminated { color: var(--unknown); }
.st-Succeeded { color: var(--synced); }

.fill-Synced, .fill-Healthy, .fill-Succeeded { background: var(--synced); }
.fill-OutOfSync { background: var(--outofsync); }
.fill-Degraded, .fill-Failed { background: var(--degraded); }
.fill-Progressing, .fill-Running { background: var(--progressing); }
.fill-Missing { background: var(--missing); }
.fill-Unknown, .fill-Terminated { background: var(--unknown); }

.spin { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* ---------- app list ---------- */

.filters { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .sep { width: 1px; height: 22px; background: var(--line); }

.apps { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.app-row {
  display: grid;
  grid-template-columns: 4px minmax(200px, 1.3fr) minmax(220px, 1.5fr) 150px 180px 140px;
  align-items: center; gap: 0 18px;
  background: var(--panel); text-decoration: none; color: inherit;
  min-height: 64px; padding-right: 18px;
}
.app-row:hover { background: var(--panel-2); }
.app-row .rail { align-self: stretch; }
.app-row .name { font-weight: 600; font-size: 14.5px; }
.app-row .sub { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.app-row .src { min-width: 0; }
.app-row .src .mono { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.app-row .src .commit { color: var(--ink-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-row .hostbar { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--ink-2); }
.meter { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line-soft); }
.meter span { display: block; height: 100%; }
.app-row .warn { grid-column: 2 / -1; margin: -6px 0 10px; color: var(--degraded); font-size: 12.5px; }

.empty {
  border: 1px dashed var(--line); border-radius: var(--r);
  padding: 40px 28px; text-align: center; color: var(--ink-2); background: var(--panel);
}
.empty h2 { margin: 0 0 6px; font-size: 16px; color: var(--ink); }
.empty p { margin: 0 auto 16px; max-width: 52ch; }

/* ---------- app detail ---------- */

.summary {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  margin-bottom: 18px;
}
.summary > div { padding: 14px 18px; border-right: 1px solid var(--line-soft); min-width: 0; }
.summary > div:last-child { border-right: 0; }
.summary .k { color: var(--ink-3); font-size: 12.5px; margin-bottom: 6px; }
.summary .v { font-size: 15px; }
.summary .v .st { font-size: 15px; }
.summary .v .st svg { width: 18px; height: 18px; }
.summary .d { color: var(--ink-2); font-size: 12.5px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: var(--r); margin-bottom: 14px;
  border: 1px solid; font-size: 13.5px;
}
.banner.err { background: var(--degraded-bg); border-color: var(--degraded); color: var(--ink); }
.banner.run { background: var(--progressing-bg); border-color: var(--progressing); }
.banner.warn { background: var(--outofsync-bg); border-color: var(--outofsync); }
.banner.info { background: var(--progressing-bg); border-color: var(--progressing); }
.banner .grow { flex: 1; min-width: 200px; }
.banner pre { margin: 4px 0 0; white-space: pre-wrap; font-family: var(--mono); font-size: 12px; }

/* Update "what's new" modal: scrollable release notes + the apply command. */
.update-modal .body { max-height: 60vh; overflow: auto; }
.update-modal header .hint { margin-top: 2px; }
.changelog { font-size: 13.5px; line-height: 1.55; }
.changelog h4 { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.changelog h4:first-child { margin-top: 0; }
.changelog ul { margin: 4px 0 10px; padding-left: 20px; }
.changelog li { margin: 2px 0; }
.changelog p { margin: 6px 0; }
.changelog code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); padding: 1px 5px; border-radius: var(--r-sm); }
.update-modal .howto { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.update-modal .howto .lbl { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }

.view-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: transparent; height: 30px; padding: 0 12px; cursor: pointer; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }

/* resource tree: the one loud thing on the page */
.tree-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  overflow: auto; position: relative;
  background-image: radial-gradient(var(--line-soft) 1px, transparent 1px);
  background-size: 18px 18px;
}
.tree { position: relative; }
.tree svg.links { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.tree svg.links path { fill: none; stroke-width: 1.6; }
.node {
  position: absolute; display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 0 10px 0 0; height: 40px; cursor: pointer; text-align: left;
  overflow: hidden; box-shadow: 0 1px 0 rgba(24,33,44,.04);
}
.node:hover { border-color: var(--ink-3); }
.node[aria-current="true"] { outline: 2px solid var(--focus); outline-offset: 1px; }
.node .stripe { align-self: stretch; width: 4px; flex: none; }
.node .ico { width: 26px; height: 26px; border-radius: 5px; display: grid; place-items: center; flex: none; background: var(--line-soft); color: var(--ink-2); }
.node .ico svg { width: 15px; height: 15px; }
.node .txt { min-width: 0; flex: 1; line-height: 1.2; }
.node .t1 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; font-size: 13px; }
.node .t2 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-3); font-size: 11.5px; }
.node .t1.mono { font-weight: 500; font-size: 12.5px; }
.node .marks { display: flex; gap: 3px; flex: none; }
.node .marks svg { width: 15px; height: 15px; }
.node.app { height: 56px; border-width: 1.5px; border-color: var(--ink-3); }
.node.app .ico { width: 34px; height: 34px; background: var(--brand); color: var(--brand-ink); }
.node.app .ico svg { width: 19px; height: 19px; }
.node.app .t1 { font-size: 14.5px; font-weight: 650; }
.node.host .ico { background: var(--ink); color: var(--panel); }
.node.orphan { border-style: dashed; }
.node.offline { opacity: .6; }
/* Status highlight: a resource/host that is not cleanly synced stands out —
   red for a failure, amber for drift, blue while a change is being applied.
   Synced/Healthy stays neutral so problems are what catch the eye. */
.node.n-OutOfSync { border-color: var(--outofsync); background: var(--outofsync-bg); }
.node.n-Degraded, .node.n-Missing, .node.n-Failed { border-color: var(--degraded); background: var(--degraded-bg); }
.node.n-Progressing, .node.n-Running { border-color: var(--progressing); background: var(--progressing-bg); }
.node.n-Degraded .ico, .node.n-Missing .ico, .node.n-Failed .ico { background: var(--degraded); color: #fff; }
.node.n-OutOfSync .ico { background: var(--outofsync); color: #fff; }

/* resource list view */
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
table.grid th { text-align: left; font-weight: 550; color: var(--ink-3); font-size: 12.5px; padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
table.grid td { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover td { background: var(--panel-2); }
table.grid td.drift { color: var(--ink-2); font-size: 12.5px; }

/* ---------- drawer ---------- */

.scrim { position: fixed; inset: 0; background: rgba(18, 23, 29, .35); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw);
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  z-index: 41; display: flex; flex-direction: column;
  animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }
.drawer header { padding: 16px 20px 0; border-bottom: 1px solid var(--line); }
.drawer header .top { display: flex; align-items: flex-start; gap: 12px; }
.drawer header h2 { margin: 0; font-size: 16px; word-break: break-all; }
.drawer header .kind { color: var(--ink-3); font-size: 12.5px; margin-bottom: 2px; }
.drawer .tabs { display: flex; gap: 2px; margin-top: 12px; }
.drawer .tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--ink-3); border-bottom: 2px solid transparent; font-weight: 500; }
.drawer .tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.drawer .body { padding: 18px 20px 40px; overflow: auto; flex: 1; }
dl.kv { display: grid; grid-template-columns: 150px 1fr; gap: 9px 14px; margin: 0; }
dl.kv dt { color: var(--ink-3); }
dl.kv dd { margin: 0; min-width: 0; word-break: break-word; }
.drift-list { margin: 0; padding: 0; list-style: none; }
.drift-list li { padding: 6px 10px; border-left: 3px solid var(--outofsync); background: var(--outofsync-bg); margin-bottom: 4px; font-family: var(--mono); font-size: 12.5px; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.section-title { font-weight: 600; margin: 22px 0 10px; font-size: 14px; }

/* diff */
.diff { border: 1px solid var(--line); border-radius: var(--r); overflow: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; }
.diff .hdr { display: flex; gap: 16px; padding: 7px 12px; background: var(--panel-2); border-bottom: 1px solid var(--line); font-family: var(--sans); font-size: 12.5px; color: var(--ink-2); }
.diff .hdr .a { color: var(--del-ink); }
.diff .hdr .b { color: var(--add-ink); }
.diff table { border-collapse: collapse; width: 100%; }
.diff td { padding: 0 10px; white-space: pre; vertical-align: top; }
.diff td.n { width: 1%; color: var(--ink-3); text-align: right; user-select: none; padding: 0 8px; }
.diff td.s { width: 1%; user-select: none; padding: 0 4px; color: var(--ink-3); }
.diff tr.add td { background: var(--add); }
.diff tr.add td.s, .diff tr.add td:last-child { color: var(--add-ink); }
.diff tr.del td { background: var(--del); }
.diff tr.del td.s, .diff tr.del td:last-child { color: var(--del-ink); }
.diff tr.fold td { background: var(--panel-2); color: var(--ink-3); font-family: var(--sans); font-size: 12px; text-align: center; padding: 3px; }
pre.code { margin: 0; padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; }

/* ---------- modal ---------- */

.modal-scrim { position: fixed; inset: 0; background: rgba(18, 23, 29, .45); z-index: 50; display: grid; place-items: start center; padding: 8vh 16px 16px; overflow: auto; }
.modal { width: min(640px, 100%); background: var(--panel); border-radius: 8px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.modal header { padding: 18px 22px 6px; }
.modal header h2 { margin: 0; font-size: 17px; }
.modal header p { margin: 6px 0 0; color: var(--ink-2); }
.modal .body { padding: 12px 22px 6px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 18px; }
.field { margin-bottom: 14px; }
.field > label, .field > .lbl { display: block; font-weight: 550; margin-bottom: 5px; font-size: 13.5px; }
.field .hint { color: var(--ink-3); font-size: 12.5px; margin-top: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset { border: 1px solid var(--line-soft); border-radius: var(--r); padding: 10px 14px 4px; margin: 0 0 14px; }
legend { font-weight: 600; padding: 0 6px; font-size: 13.5px; }
.check { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 10px; cursor: pointer; }
.check input { margin-top: 3px; }
.check .hint { color: var(--ink-3); font-size: 12.5px; }
.picklist { border: 1px solid var(--line); border-radius: var(--r); max-height: 220px; overflow: auto; padding: 6px 10px; }
.picklist .check { margin: 4px 0; font-size: 13px; }
.picklist-tools { display: flex; gap: 6px; margin: 4px 0 6px; }
.form-error { color: var(--degraded); background: var(--degraded-bg); padding: 8px 12px; border-radius: var(--r); margin-bottom: 12px; font-size: 13.5px; }

/* history */
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: grid; grid-template-columns: 22px 1fr auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.history li:last-child { border-bottom: 0; }
.history .meta { color: var(--ink-3); font-size: 12.5px; }
.history .msg { color: var(--ink-2); font-size: 13px; grid-column: 2 / 3; }
.history .cur { font-size: 11.5px; padding: 1px 6px; border-radius: 3px; background: var(--synced-bg); color: var(--synced); margin-left: 6px; }

/* hosts */
.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.online-dot.on { background: var(--synced); box-shadow: 0 0 0 3px var(--synced-bg); }
.online-dot.off { background: var(--unknown); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(360px, 100%); }
.login .brand { padding: 0 0 24px; font-size: 22px; }
.login .brand svg { width: 30px; height: 30px; }
.login p.muted { margin: -14px 0 22px; }
.login form > a.btn { display: block; text-align: center; margin-top: 10px; }
.sso-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0 4px; }
.sso-sep::before, .sso-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* toasts */
#toasts { position: fixed; left: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--panel); padding: 10px 14px; border-radius: var(--r); box-shadow: var(--shadow); max-width: 420px; font-size: 13.5px; }
.toast.err { background: var(--degraded); color: #fff; }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .app-row { grid-template-columns: 4px 1fr 130px 120px; }
  .app-row .src, .app-row .hostbar { display: none; }
  .summary { grid-template-columns: 1fr 1fr; }
  .summary > div:nth-child(2) { border-right: 0; }
  .summary > div:nth-child(-n+2) { border-bottom: 1px solid var(--line-soft); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .folders { display: none; }
  .nav { display: flex; gap: 4px; }
  .side-foot { display: none; }
  .bar, .content { padding-left: 16px; padding-right: 16px; }
  .app-row { grid-template-columns: 4px 1fr 120px; padding: 8px 14px 8px 0; }
  .app-row .rail, .app-row > :nth-child(2) { grid-row: span 2; }
  .app-row > :nth-child(5), .app-row > :nth-child(6) { grid-column: 3; }
  .app-row .muted { display: none; }
  .filters .sep { display: none; }
  .row2 { grid-template-columns: 1fr; }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
  table.grid .hide-sm { display: none; }
}

/* tree links: quiet when fine, loud when not */
.ln { stroke: var(--line); }
.ln-OutOfSync { stroke: var(--outofsync); stroke-dasharray: 5 4; }
.ln-Degraded { stroke: var(--degraded); stroke-width: 2.2 !important; }
.ln-Missing { stroke: var(--missing); stroke-dasharray: 2 4; }
.ln-Progressing { stroke: var(--progressing); }
.ln-Unknown { stroke: var(--unknown); stroke-dasharray: 1 5; }
.tree .toggle {
  position: absolute; width: 20px; height: 20px; padding: 0; z-index: 2;
  display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--ink-3); border-radius: 50%;
  background: var(--panel); color: var(--ink-2);
  font: 600 13px/1 var(--mono);
}
.tree .toggle:hover { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.drawer header .grow, .grow { flex: 1; min-width: 0; }
.view-tools .spacer { flex: 1; }
.view-tools .check { margin: 0; }
.node.res .t2 { max-width: 100%; }
.app-row .src .commit .mono { display: inline; color: var(--ink-2); }
.summary .signed { display: flex; align-items: center; gap: 5px; color: var(--synced); }
.summary .signed svg { width: 13px; height: 13px; flex: none; }

/* cluster apps: detail header, metadata grid and section cards */
.detail-head { display: flex; align-items: flex-start; gap: 16px; margin: 4px 0 14px; }
.detail-head h1 { margin: 0; font-size: 20px; }
.detail-head .grow { flex: 1; min-width: 0; }
.detail-head p { margin: 4px 0 0; }
.st-row { display: flex; gap: 8px; flex-wrap: wrap; flex: none; }
.meta-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 20px;
  padding: 14px 16px; margin-bottom: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
}
.meta-grid .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); margin-bottom: 3px; }
.meta-grid a { text-decoration: none; color: var(--brand); }
.meta-grid a:hover { text-decoration: underline; }
section.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; margin-bottom: 16px;
}
section.card h2 { margin: 0 0 10px; font-size: 14px; color: var(--ink); }
section.card .warn { color: var(--outofsync); }

/* fleet dashboard: stat cards + status pills */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat-k { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); margin-bottom: 8px; }
.stat-k a { color: inherit; text-decoration: none; }
.stat-k a:hover { color: var(--ink); text-decoration: underline; }
.stat-parts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stat-n { font-size: 22px; font-weight: 600; color: var(--ink); }
.stat-n.ok { color: var(--synced); }
.stat-n.warn { color: var(--outofsync); }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.pill-ok { background: var(--synced-bg); color: var(--synced); }
.pill-OutOfSync { background: var(--outofsync-bg); color: var(--outofsync); }
.pill-Degraded { background: var(--degraded-bg); color: var(--degraded); }
.pill-Progressing { background: var(--progressing-bg); color: var(--progressing); }

/* ---- security & recovery centers, shared cards ---- */
.center { display: flex; flex-direction: column; gap: 18px; }
.center .summary { margin: 0; }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; background: var(--surface, var(--panel)); }
.card h2 { margin: 0 0 10px; font-size: 15px; }
.settings { display: flex; flex-direction: column; gap: 20px; max-width: 760px; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.concerns { display: flex; flex-direction: column; gap: 8px; }
.concern { display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; border: 1px solid var(--line); border-left-width: 3px; border-radius: 8px; background: var(--panel); }
.concern .t { font-weight: 550; }
.concern .sev { text-transform: uppercase; font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; flex: none; margin-top: 2px; }
.concern.lvl-high { border-left-color: var(--degraded); }
.concern.lvl-high .sev { background: var(--degraded-bg); color: var(--degraded); }
.concern.lvl-medium { border-left-color: var(--outofsync); }
.concern.lvl-medium .sev { background: var(--outofsync-bg); color: var(--outofsync); }
.concern.lvl-low { border-left-color: var(--unknown); }
.concern.lvl-low .sev { background: var(--unknown-bg); color: var(--unknown); }
.banner.ok { background: var(--synced-bg); border-color: var(--synced); }
.center .v .warn, .center .d .warn { color: var(--degraded); }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; vertical-align: top; }
table.tbl tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }
@media (max-width: 860px) { .cols2 { grid-template-columns: 1fr; } }

/* ---- sync plan (pre-flight) ---- */
.sync-plan { margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); padding: 12px 14px; }
.sync-plan .plan-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13.5px; }
.sync-plan .plan-head svg { width: 16px; height: 16px; }
.sync-plan .pl { display: grid; grid-template-columns: 92px 1fr; gap: 6px 12px; padding: 3px 0; font-size: 12.5px; align-items: baseline; }
.sync-plan .plk { color: var(--ink-3); }
.sync-plan .plv { min-width: 0; word-break: break-word; }
.sync-plan .warn { color: var(--degraded); }
.sync-plan ol.waves { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.sync-plan ol.waves li { display: flex; gap: 8px; align-items: baseline; }
.sync-plan ol.waves .wn { flex: none; font-size: 11px; font-weight: 650; color: var(--progressing); background: var(--progressing-bg); padding: 1px 7px; border-radius: 999px; }

/* ---- compact exceptions list (mobile alternative to the topology) ---- */
.detail-exceptions { display: none; }
.exc { display: flex; flex-direction: column; gap: 12px; }
.exc-host { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.exc-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 12px; background: var(--panel-2); border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.exc-head .st { font-size: 12px; }
.exc-res { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line-soft); padding: 9px 12px; cursor: pointer; color: inherit; }
.exc-res:last-child { border-bottom: 0; }
.exc-res:hover { background: var(--panel-2); }
.exc-res .ico svg { width: 16px; height: 16px; color: var(--ink-3); }
.exc-res .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.exc-res .t1 { font-size: 12.5px; }
.exc-res .t2 { font-size: 11.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }
.exc-res .marks { display: flex; gap: 6px; flex: none; }
.exc-res .marks .st { font-size: 11.5px; }
@media (max-width: 760px) {
  .detail-main, .view-tools { display: none; }
  .detail-exceptions { display: block; }
}
