/* HGCS Console. Plain CSS, no framework. Utilitarian: a left nav, tabular numbers, four pill
   colours and a real progress bar. Both colour schemes are first-class; the dark palette is not
   an afterthought filter. */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --text: #1b1f24;
  --muted: #5f6673;
  --border: #d8dce2;
  --accent: #2456b8;
  --accent-text: #ffffff;
  --green: #1a7f4b;
  --green-bg: #e3f4ea;
  --amber: #a15c00;
  --amber-bg: #fdf0d9;
  --red: #b3261e;
  --red-bg: #fbe4e2;
  --grey: #6b7280;
  --grey-bg: #eceff3;
  --info-bg: #e6eefb;
  --nav-bg: #1b1f24;
  --nav-text: #d7dbe0;
  --nav-active: #2c333c;
  --shadow: 0 1px 2px rgba(0,0,0,.06);
  --radius: 6px;
  --mono: ui-monospace, "Cascadia Mono", "Consolas", "SF Mono", Menlo, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --panel: #171b21;
    --panel-2: #1d222a;
    --text: #e6e8eb;
    --muted: #98a1ac;
    --border: #2b323b;
    --accent: #6f9cff;
    --accent-text: #0b1220;
    --green: #4cc38a;
    --green-bg: #12301f;
    --amber: #f0b35b;
    --amber-bg: #3a2a10;
    --red: #ff6b61;
    --red-bg: #401a17;
    --grey: #9aa3ad;
    --grey-bg: #262c34;
    --info-bg: #182640;
    --nav-bg: #0b0e12;
    --nav-text: #c9ced4;
    --nav-active: #1d232b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 12px; font-weight: 650; }
h2 { font-size: 15px; margin: 18px 0 8px; font-weight: 650; }
h2:first-child { margin-top: 0; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.wide { width: 100%; }

/* ── shell ─────────────────────────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-rows: 48px 1fr; grid-template-columns: 200px 1fr; min-height: 100vh; }
.topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: var(--nav-bg); color: var(--nav-text);
  border-bottom: 1px solid #000;
}
.topbar .brand { color: #fff; font-weight: 700; letter-spacing: .2px; font-size: 15px; }
.topbar .brand:hover { text-decoration: none; }
.side { background: var(--nav-bg); color: var(--nav-text); padding: 12px 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: block; padding: 8px 12px; border-radius: 5px; color: var(--nav-text); }
.nav-link:hover { background: var(--nav-active); text-decoration: none; }
.nav-link.active { background: var(--nav-active); color: #fff; font-weight: 600; }
.side-foot { margin-top: 24px; padding: 0 12px; font-size: 11.5px; color: #7d8590; }
.content { padding: 20px 24px 40px; max-width: 1280px; }

.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; padding: 6px 10px; border-radius: 5px; color: #fff; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--nav-active); }
.user-menu .menu {
  position: absolute; right: 0; top: 36px; min-width: 200px; z-index: 20;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0,0,0,.18); padding: 6px;
}
.user-menu .menu a { display: block; padding: 7px 10px; border-radius: 4px; color: var(--text); }
.user-menu .menu a:hover { background: var(--panel-2); text-decoration: none; }
.user-menu .menu .who { padding: 6px 10px 8px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* ── auth pages ────────────────────────────────────────────────────────────────────────── */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 28px; box-shadow: var(--shadow); }
.auth-brand { font-weight: 700; font-size: 13px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin-bottom: 18px; }
.qr { background: #fff; padding: 12px; border-radius: 6px; width: 220px; margin: 12px 0; border: 1px solid var(--border); }
.qr svg { display: block; width: 196px; height: 196px; }
.key { letter-spacing: 1px; word-break: break-all; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; }
.recovery-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 12px 0 16px; }
.recovery-codes code { padding: 6px 8px; text-align: center; font-size: 13px; }

/* ── layout blocks ─────────────────────────────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.page-head h1 { margin-bottom: 2px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card + .card, section.card { margin-top: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.two-col { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .grid-2, .two-col { grid-template-columns: 1fr; }
}
.empty { padding: 32px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--border); border-radius: var(--radius); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }

/* ── pills, dots, alerts ───────────────────────────────────────────────────────────────── */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.pill.green { color: var(--green); background: var(--green-bg); }
.pill.amber { color: var(--amber); background: var(--amber-bg); }
.pill.red { color: var(--red); background: var(--red-bg); }
.pill.grey { color: var(--grey); background: var(--grey-bg); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; background: var(--grey); }
.dot.green { background: var(--green); }
.dot.amber { background: var(--amber); }
.dot.red { background: var(--red); }
.alert { padding: 9px 12px; border-radius: var(--radius); margin: 10px 0; border: 1px solid var(--border); background: var(--panel-2); }
.alert.danger { background: var(--red-bg); color: var(--red); border-color: transparent; }
.alert.warn { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.alert.ok { background: var(--green-bg); color: var(--green); border-color: transparent; }
.alert.info { background: var(--info-bg); border-color: transparent; }
ul.alert { padding-left: 28px; }
ul.alert li { margin: 2px 0; }

/* ── fleet ─────────────────────────────────────────────────────────────────────────────── */
.platform-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; padding: 10px 14px; margin-bottom: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.platform-item { display: flex; align-items: baseline; gap: 6px; }
.platform-name { font-weight: 600; }
.strip-note { margin-left: auto; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.cafe-card.attention { border-color: var(--amber); }
.cafe-card.attention.red { border-color: var(--red); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-head h2 { margin: 0; font-size: 16px; }
.hosts { list-style: none; margin: 8px 0; padding: 0; }
.hosts li { display: flex; gap: 10px; padding: 2px 0; font-size: 13px; }
.hosts li .muted { min-width: 84px; }
.hosts.big li { font-size: 15px; padding: 4px 0; }
.services { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.svc { font-size: 12.5px; color: var(--muted); }

/* ── tables, definition lists ──────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table .wrap { max-width: 420px; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 6px 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv.inline { grid-template-columns: max-content 1fr max-content 1fr; }

/* ── forms, buttons ────────────────────────────────────────────────────────────────────── */
.field, .form label { display: block; margin-bottom: 12px; }
label { font-weight: 600; font-size: 13px; }
label small, .field small { display: block; font-weight: 400; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input:not([type]), select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 7px 9px; font: inherit;
  color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 5px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 4px 16px 4px 0; }
.check input { margin: 0; }
.validation-message { color: var(--red); font-size: 12px; font-weight: 400; display: block; margin-top: 3px; }
.btn {
  display: inline-block; padding: 7px 13px; font: inherit; font-weight: 600; cursor: pointer;
  color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 5px;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--red); color: #fff; border-color: transparent; }
.btn.danger.outline { background: transparent; color: var(--red); border-color: var(--red); }
.btn.big { padding: 11px 18px; font-size: 15px; }
.btn.tiny { padding: 2px 8px; font-size: 11.5px; font-weight: 500; margin-left: 6px; }

/* ── progress, log ─────────────────────────────────────────────────────────────────────── */
.progress-block { margin: 14px 0 18px; }
.progress { height: 22px; background: var(--grey-bg); border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.progress .bar { height: 100%; background: var(--accent); transition: width .6s ease; }
.progress .bar.green { background: var(--green); }
.progress .bar.red { background: var(--red); }
.progress .bar.amber { background: var(--amber); }
.progress-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; }
.progress-meta .pct { font-weight: 700; font-size: 20px; }
.progress-meta .step { color: var(--muted); align-self: center; }
.log {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5; background: #0c0f13; color: #d6dbe1;
  border-radius: var(--radius); padding: 10px 12px; height: 380px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  border: 1px solid #000;
}
.log .line { display: block; }
.log .ts { color: #7d8590; margin-right: 10px; }
.log .empty-log { color: #7d8590; }
.finished h1 { font-size: 26px; }
.phase2 { margin: 18px 0; border-color: var(--accent); }

/* ── dialogs ───────────────────────────────────────────────────────────────────────────── */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.dialog { width: 100%; max-width: 520px; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 18px 20px; box-shadow: 0 16px 48px rgba(0,0,0,.35); }
.dialog h2 { margin: 0 0 10px; font-size: 17px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog label { display: block; margin-top: 10px; }

/* ── blazor's reconnect / error bar ────────────────────────────────────────────────────── */
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; padding: 10px 16px; background: var(--amber-bg); color: var(--amber); border-top: 1px solid var(--amber); }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }
