/* CaptivEye Hub: a plain operations console.
   Neutral greys, light or dark as the system is set, one accent: the server colour
   (--accent, set per server on the Settings page) so it's clear which server this is. */

:root {
  --accent: #2563eb;
  --accent-tint: color-mix(in srgb, var(--accent) 12%, transparent);
  --bg: #f5f6f8;
  --side: #ffffff;
  --surface: #ffffff;
  --raised: #f0f2f5;
  --border: #e2e5ea;
  --ink: #171a21;
  --muted: #5b6371;
  --link: #1d4ed8;
  --track: #e6e9ee;
  --ok: #127a4c;
  --ok-tint: #e3f5ec;
  --warn: #8a5a00;
  --warn-tint: #fdf6e3;
  --warn-line: #f1d999;
  --bad: #c62828;
  --bad-tint: #fde7e7;
  --bad-line: #f0b4b4;
  --on-bad: #ffffff;  /* text on a solid --bad button */
  --info: #2754c5;
  --info-tint: #e6edfc;
  --neutral: #eef0f3;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent-tint: color-mix(in srgb, var(--accent) 22%, transparent);
    --bg: #0e1014;
    --side: #12151b;
    --surface: #161a21;
    --raised: #1e232c;
    --border: #272d38;
    --ink: #e7e9ee;
    --muted: #9ba2ae;
    --link: #8fb3ff;
    --track: #2a303b;
    --ok: #3ecf8e;
    --ok-tint: rgba(62, 207, 142, .14);
    --warn: #f0b429;
    --warn-tint: rgba(240, 180, 41, .10);
    --warn-line: rgba(240, 180, 41, .35);
    --bad: #ff7a7a;
    --bad-tint: rgba(255, 107, 107, .14);
    --bad-line: rgba(255, 122, 122, .45);
    --on-bad: #1f0808;
    --info: #9db8ff;
    --info-tint: rgba(122, 167, 255, .16);
    --neutral: rgba(155, 162, 174, .14);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--bg); }
body { margin: 0; color: var(--ink); font: 14px/1.45 var(--font); min-height: 100vh;
  border-top: 4px solid var(--accent); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); }
code { font-size: 12px; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.red { color: var(--bad); }
.amber { color: var(--warn); }

/* ---- the shell: sidebar beside the page; the sidebar stacks on top on a phone -------- */

.shell { display: flex; flex-wrap: wrap; min-height: calc(100vh - 4px); }
.side { flex: 1 1 232px; max-width: 100%; background: var(--side); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.logo { display: block; width: 40px; height: 40px; flex: none; }
.brand b { display: block; font-size: 15px; font-weight: 600; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px;
  color: var(--muted); min-height: 44px; }
.nav a:hover { background: var(--raised); color: var(--ink); text-decoration: none; }
.nav a.on { background: var(--accent-tint); color: var(--ink); font-weight: 600; }
.nav a.on .ico { background: var(--accent); }
.nav a .lock { margin-left: auto; width: 14px; height: 14px; opacity: .7; }
/* icons: single-colour SVGs used as masks, so they take the colour of the text around them */
.ico { display: inline-block; width: 18px; height: 18px; flex: none; background: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
.ico-server { --ico: url("/static/icons/icons8-menu-48.svg"); }
.ico-ssl, .lock { --ico: url("/static/icons/icons8-lock-48.svg"); }
.ico-audit { --ico: url("/static/icons/icons8-document-48.svg"); }
.ico-maintenance { --ico: url("/static/icons/icons8-wrench-48.svg"); }
.ico-config { --ico: url("/static/icons/icons8-settings-48.svg"); }
.side-fill { flex: 1; }
.who { border-top: 1px solid var(--border); padding: 14px 8px 0; display: flex; flex-direction: column; gap: 10px; }
.who span { font-weight: 500; }
.who small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.who form { margin: 0; }
.who button { width: 100%; }

.page { flex: 999 1 560px; min-width: 0; padding: 28px 32px 40px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); }
.page-head .tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head form { margin: 0; }
.page > p { margin: 0; }

/* ---- building blocks ----------------------------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-head .note { color: var(--muted); font-size: 13px; }
.card-body { padding: 16px; }
.card-body > :first-child { margin-top: 0; }
.card-body > :last-child { margin-bottom: 0; }

/* status pills: a dot and a word, so the state never rests on colour alone */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral); color: var(--muted); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge.green, .badge.ok { background: var(--ok-tint); color: var(--ok); }
.badge.amber, .badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.red, .badge.bad { background: var(--bad-tint); color: var(--bad); }
.badge.big { font-size: 13px; padding: 6px 12px; }
.badge.plain::before { display: none; }

/* host tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px;
  display: flex; flex-direction: column; gap: 8px; }
.tile .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.tile .value { font-size: 28px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 16px; color: var(--muted); font-weight: 500; }

/* meter: a thin bar, amber or red past its thresholds */
.meter { display: inline-block; width: 120px; height: 6px; border-radius: 3px; background: var(--track);
  overflow: hidden; vertical-align: middle; margin-right: 10px; }
.meter i { display: block; height: 100%; border-radius: 3px; background: var(--ok); }
.meter.amber i { background: var(--warn); }
.meter.red i { background: var(--bad); }
.tile .meter { width: 100%; margin: 0; }

/* alerts box */
.alerts { padding: 14px 16px; border-radius: 10px; background: var(--warn-tint); border: 1px solid var(--warn-line); }
.alerts .head { font-weight: 600; color: var(--warn); }
.alerts ul { margin: 6px 0 0; padding-left: 20px; }
.alerts.red { background: var(--bad-tint); border-color: var(--bad-line); }
.alerts.red .head { color: var(--bad); }

/* shared services: a strip of cells */
.cells { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.cell { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 0 -1px -1px 0; }
.cell .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cell .label { font-weight: 600; }
.cell .note { color: var(--muted); font-size: 13px; }
/* maintenance */
.plain-list { margin: 0 0 12px; padding-left: 20px; }
.df { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 12px; margin: 16px 0; }
.df > div { display: flex; flex-direction: column; gap: 2px; padding: 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--raised); }
.df .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.df b { font-size: 20px; font-weight: 600; }
details summary { cursor: pointer; color: var(--link); margin: 4px 0; }
details pre.logs { margin-top: 8px; }
.card-foot form { margin: 0; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 6px;
  background: var(--neutral); color: var(--ink); font: 12px var(--mono); white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.chip.warn { background: var(--warn-tint); color: var(--warn); }
.chip.warn::before { background: var(--warn); }
.chip.bad { background: var(--bad-tint); color: var(--bad); }
.chip.bad::before { background: var(--bad); }

/* portals: grid rows (not a table, so a restart's progress can stand in for the chips) */
.rows-scroll { overflow-x: auto; }
.rows { min-width: 1000px; }
.row, .rows-head { display: grid; align-items: center; gap: 12px; padding: 12px 16px;
  grid-template-columns: 110px minmax(160px, 1.2fr) 90px 170px minmax(0, 2fr) 250px; }
.rows-head { color: var(--muted); font-size: 12px; font-weight: 500; padding-top: 10px; padding-bottom: 10px; }
.row { border-top: 1px solid var(--border); }
.row .name b { display: block; font-weight: 600; }
.row .name a { font-size: 13px; }
.row .num { font: 13px var(--mono); white-space: nowrap; }
.row .ver { font: 13px var(--mono); }
.row .ver small { display: block; font: 12px var(--font); color: var(--muted); }
.row .ver .rel { font: normal 600 11px var(--font); padding: 2px 8px; border-radius: 999px; margin-left: 6px;
  background: var(--neutral); color: var(--muted); }
.row .ver .rel.current { background: var(--ok-tint); color: var(--ok); }
.row .ver .rel.update { background: var(--warn-tint); color: var(--warn); }
.row .ver .rel.shakedown { background: var(--info-tint); color: var(--info); }
.row .svc { display: flex; flex-wrap: wrap; gap: 6px; }
.row .act { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.row .act form { display: flex; gap: 8px; margin: 0; }
.row .act > a { font-weight: 500; padding: 0 6px; }
.row.busy { background: var(--accent-tint); }

/* a restart running live under its row */
.progress { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.progress .track { position: relative; height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; }
.progress .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent);
  transition: width .4s ease-out; }
.progress .ptext { font-size: 12px; color: var(--muted); }
.progress.done .fill { background: var(--ok); }
.progress.done .ptext { color: var(--ok); }
.progress.failed .fill { background: var(--bad); }
.progress.failed .ptext { color: var(--bad); }
.live { padding: 0 16px 14px; }
.live-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.live pre { margin: 0; }

.flash, .error { padding: 12px 16px; border-radius: 10px; margin: 0; white-space: pre-wrap;
  background: var(--info-tint); border: 1px solid var(--border); }
.error { background: var(--bad-tint); border-color: var(--bad-line); color: var(--bad); }

/* the confirm (base.html's hubConfirm) */
.modal { padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  color: var(--ink); width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.modal::backdrop { background: rgba(0, 0, 0, .5); }
.modal form { margin: 0; }
.modal-bar { padding: 20px 20px 0; font-size: 16px; font-weight: 600; }
.modal-msg { margin: 0; padding: 8px 20px 0; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 20px; }

/* settings: unlock, and the server colour beside its preview */
.settings { display: flex; flex-direction: column; gap: 20px; max-width: 640px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.swatches button { width: 44px; height: 44px; min-height: 0; padding: 0; border: 0; border-radius: 10px;
  background: var(--c); }
.swatches button:hover { background: var(--c); outline: 2px solid var(--muted); outline-offset: 3px; }
.swatches button.on { outline: 2px solid var(--ink); outline-offset: 3px; }
.custom { display: flex; align-items: center; gap: 10px; }
.custom input[type=color] { width: 44px; height: 36px; padding: 2px; }
.preview { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg);
  border-top: 4px solid var(--accent); margin-top: 16px; }
.preview .brand { padding: 12px; }
.preview .brand .logo { width: 32px; height: 32px; }
.preview .brand button { margin-left: auto; pointer-events: none; }
.card-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 16px;
  border-top: 1px solid var(--border); background: var(--raised); }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dt { color: var(--muted); font-size: 13px; }
dd { margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 16px; border-top: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; font-weight: 500; color: var(--muted); border-top: 0; }
tr:hover td { background: var(--raised); }
.clip { max-height: 4.5em; overflow: hidden; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }

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

button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 14px/1 var(--font); color: var(--ink); background: transparent;
  border: 1px solid var(--border); border-radius: 8px; padding: 0 14px; min-height: 40px; cursor: pointer; }
button:hover, .button:hover { background: var(--raised); text-decoration: none; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .button.primary:hover { background: color-mix(in srgb, var(--accent) 85%, #000); }
button.danger { color: var(--bad); border-color: var(--bad-line); }
button.danger:hover { background: var(--bad-tint); }
button.danger.solid { background: var(--bad); border-color: var(--bad); color: var(--on-bad); }
button.danger.solid:hover { background: color-mix(in srgb, var(--bad) 85%, var(--ink)); }
button.link { border: 0; background: none; color: var(--link); padding: 0; min-height: 0; font-weight: 500; }
button.link:hover { text-decoration: underline; }
button:disabled { opacity: .45; cursor: wait; }
.row .act button, .row .act select { min-height: 36px; font-size: 13px; }

form label { display: block; margin: 0 0 14px; font-size: 13px; font-weight: 500; }
form label.check { display: flex; gap: 10px; align-items: center; font-weight: 400; font-size: 14px; }
form.inline { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin: 0; }
form.inline label { margin: 0; }
input, select { font: 14px var(--font); color: var(--ink); background: var(--raised);
  border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; min-height: 40px; }
input[type=file] { padding: 8px 10px; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=checkbox] { accent-color: var(--accent); width: 17px; height: 17px; min-height: 0; }
form label > input:not([type=checkbox]), form label > select { display: block; width: 100%; margin-top: 6px; }
form.inline label > input, form.inline label > select { width: auto; }
.code-input { letter-spacing: .2em; font-size: 16px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }

pre.logs, .live pre { background: var(--raised); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; overflow: auto; max-height: 70vh; font-size: 12px; white-space: pre; }

.login { max-width: 480px; display: flex; flex-direction: column; gap: 20px; }
.login .brand { padding: 0; }
.login .brand .logo { width: 56px; height: 56px; }
.login .brand b { font-size: 22px; }

/* a phone: the sidebar sits on top, the page keeps a 16px gutter */
@media (max-width: 600px) {
  .side { border-right: 0; border-bottom: 1px solid var(--border); }
  .page { padding: 20px 16px 32px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
