/* Hermes control centre — 2026-11-20 design refresh */
:root {
  --bg: #f3f5f8;
  --bg-accent: #e8edf5;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #12151c;
  --muted: #5c6573;
  --line: #e2e6ee;
  --line-strong: #cfd6e0;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #e8effc;
  --accent-ink: #ffffff;
  --ok: #047857;
  --ok-hover: #065f46;
  --ok-bg: #ecfdf5;
  --ok-line: #a7f3d0;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-line: #fde68a;
  --bad: #b91c1c;
  --bad-hover: #991b1b;
  --bad-bg: #fef2f2;
  --bad-line: #fecaca;
  --client: #5b21b6;
  --client-bg: #f5f3ff;
  --client-line: #ddd6fe;
  --sidebar-bg: #111827;
  --sidebar-ink: #e5e7eb;
  --sidebar-muted: #9ca3af;
  --sidebar-hover: #1f2937;
  --sidebar-active: #1e3a5f;
  --sidebar-active-ink: #93c5fd;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.05), 0 8px 24px rgba(17, 24, 39, 0.04);
  --shadow-lg: 0 16px 40px rgba(17, 24, 39, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0f14;
    --bg-accent: #151a24;
    --surface: #161b24;
    --surface-2: #1c232f;
    --ink: #e8eaef;
    --muted: #9aa3b2;
    --line: #2a3342;
    --line-strong: #3b4658;
    --accent: #6ea8fe;
    --accent-hover: #93c5fd;
    --accent-soft: #152033;
    --accent-ink: #0c0f14;
    --ok: #34d399;
    --ok-hover: #6ee7b7;
    --ok-bg: #052e22;
    --ok-line: #065f46;
    --warn: #fbbf24;
    --warn-bg: #2a1e06;
    --warn-line: #854d0e;
    --bad: #f87171;
    --bad-hover: #fca5a5;
    --bad-bg: #2a1010;
    --bad-line: #7f1d1d;
    --client: #c4b5fd;
    --client-bg: #1e1533;
    --client-line: #4c1d95;
    --sidebar-bg: #080b10;
    --sidebar-ink: #e5e7eb;
    --sidebar-muted: #8b93a1;
    --sidebar-hover: #151b26;
    --sidebar-active: #13233c;
    --sidebar-active-ink: #93c5fd;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  font: 15px/1.5 var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.9em; }

/* ---- Sidebar ---- */
.nav-toggle { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  z-index: 40;
  border-right: 1px solid rgba(255,255,255,0.04);
}
.brand { padding: 1.15rem 1.1rem 1rem; }
.brand a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.03em;
  display: grid;
  place-items: center;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 0.95rem; font-weight: 650; letter-spacing: -0.01em; }
.brand-text span { font-size: 0.72rem; color: var(--muted); font-weight: 500; }
.sidebar .brand-text span { color: var(--sidebar-muted); }

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.25rem 0.7rem;
  flex: 1;
  overflow-y: auto;
}
.side-nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--sidebar-ink);
  text-decoration: none;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 0.92rem;
  font-weight: 500;
  min-height: 40px;
}
.side-nav a:hover { background: var(--sidebar-hover); text-decoration: none; }
.side-nav a.active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-ink);
}
.side-nav a svg {
  width: 18px; height: 18px;
  flex: 0 0 auto;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
}

.sidebar-foot {
  padding: 0.8rem 0.9rem 1.1rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-foot .who {
  display: block;
  font-size: 0.75rem;
  color: var(--sidebar-muted);
  margin: 0 0 0.45rem 0.15rem;
}
button.signout {
  width: 100%;
  background: transparent;
  color: var(--sidebar-ink);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  min-height: 40px;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}
button.signout:hover { background: var(--sidebar-hover); }

/* ---- Shell / topbar ---- */
.shell {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 25;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  align-items: center;
  gap: 0.7rem;
  padding: 0 0.9rem;
}
.topbar-title { font-weight: 650; font-size: 0.98rem; letter-spacing: -0.01em; }
.menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}
.menu-btn:hover { background: var(--surface-2); }
.menu-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.nav-backdrop { display: none; }

main.app-main { max-width: 1180px; margin: 0 auto; padding: 1.6rem 1.5rem 4rem; }

.page-head { margin: 0 0 1.15rem; }
.page-head h1 {
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  font-weight: 700;
  margin: 0 0 0.3rem;
  line-height: 1.25;
}
.page-head p { margin: 0; color: var(--muted); max-width: 70ch; }
.page-head h2 { /* fallback if used */ font-size: 1.45rem; margin: 0 0 0.3rem; letter-spacing: -0.03em; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.05rem 1.15rem;
  margin: 0 0 0.9rem;
  box-shadow: var(--shadow);
}
.card > h2, .card-head h2 {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  font-weight: 650;
  margin: 0;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.9rem;
  margin: 0 0 0.9rem;
}
.card-grid > .card { margin: 0; }
.card.status-ok { border-left: 3px solid var(--ok); }
.card.status-warn { border-left: 3px solid var(--warn); }
.card.status-bad { border-left: 3px solid var(--bad); background: linear-gradient(90deg, var(--bad-bg), var(--surface) 28%); }
.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.7rem;
  align-items: center;
  margin: 0 0 0.7rem;
}
.card-head .btn.chat-btn {
  margin-left: auto;
  padding: 0.35rem 0.8rem;
  min-height: 36px;
  font-size: 0.82rem;
}
.muted { color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; align-items: center; }

/* ---- Stats ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.65rem 1rem;
  margin: 0.7rem 0 0;
}
.stats div { min-width: 0; }
.stats dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 0.15rem;
}
.stats dd { margin: 0; font-weight: 550; font-variant-numeric: tabular-nums; }
.meta-line { margin: 0.15rem 0 0.55rem; color: var(--muted); font-size: 0.88rem; word-break: break-word; }
.error-list { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.error-list li { margin: 0.2rem 0; font-size: 0.88rem; color: var(--muted); }

/* ---- Buttons & forms ---- */
.btn, button, input[type=submit] {
  appearance: none;
  border: 0;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  line-height: 1.2;
  transition: background 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.btn:hover, button:hover, input[type=submit]:hover { background: var(--accent-hover); text-decoration: none; }
.btn:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, .menu-btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn.secondary, button.secondary, input[type=submit].secondary, a.btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn.secondary:hover, button.secondary:hover { background: var(--surface-2); }
.btn.approve, button.approve {
  background: var(--ok);
  color: #fff;
}
.btn.approve:hover, button.approve:hover { background: var(--ok-hover); }
@media (prefers-color-scheme: dark) {
  .btn.approve, button.approve { color: #042f22; }
}
.btn.danger, button.danger, .btn.danger:hover, button.danger:hover { color: #fff; }
.btn.danger, button.danger { background: var(--bad); }
.btn.danger:hover, button.danger:hover { background: var(--bad-hover); }
@media (prefers-color-scheme: dark) {
  .btn.danger, button.danger { color: #2a1010; font-weight: 700; }
}
.btn[disabled], button[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

input[type=text], input[type=password], input:not([type]), input[type=search], input[type=email], input[type=number], textarea {
  width: 100%;
  font: inherit;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  min-height: 44px;
}
textarea { min-height: 5.5rem; resize: vertical; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
label { display: block; margin: 0.85rem 0 0.3rem; font-weight: 600; font-size: 0.88rem; }
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0.9rem 0 0.4rem;
  font-weight: 550;
}
.check-row input[type=checkbox] {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin-top: 0.15rem;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

/* ---- Flash / chips ---- */
.flash { padding: 0.7rem 0.9rem; border-radius: var(--radius-sm); margin: 0 0 1rem; border: 1px solid transparent; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.flash.err { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
  margin-right: 0.15rem;
  text-transform: lowercase;
}
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.chip.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.chip.client { background: var(--client-bg); color: var(--client); border-color: var(--client-line); }

/* ---- Tables ---- */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card > .table-wrap, .table-wrap.plain {
  border: 0;
  box-shadow: none;
  border-radius: 0;
  margin: 0.4rem -0.2rem 0;
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.num-up { color: var(--bad); }
.num-down { color: var(--ok); }
.preview { white-space: pre-wrap; word-break: break-word; margin: 0.35rem 0 0.5rem; }
.source-line { font-size: 0.85rem; color: var(--muted); margin: 0; }
.closed-list { list-style: none; margin: 0; padding: 0; }
.closed-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}
.closed-list li:last-child { border-bottom: 0; }
.job-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.job-actions form, .job-actions a.btn { margin: 0; }
.job-actions .btn { padding: 0.35rem 0.7rem; min-height: 36px; font-size: 0.82rem; }
.id-meta { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.hero-metric {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin: 0 0 0.2rem;
}
.hero-metric span { font-size: 0.95rem; font-weight: 550; color: var(--muted); letter-spacing: 0; }
.empty { margin: 0; color: var(--muted); }

/* ---- Login ---- */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--bg-accent), transparent 60%),
    var(--bg);
}
body.login-page .shell {
  margin-left: 0;
  min-height: 0;
  width: 100%;
  max-width: 28rem;
}
body.login-page main.app-main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 1.15rem;
  justify-content: center;
  color: var(--ink);
  text-decoration: none;
}
.login-brand:hover { text-decoration: none; }
.login.card { margin: 0; padding: 1.5rem 1.5rem 1.6rem; }
.login h2 { margin: 0 0 0.35rem; font-size: 1.3rem; letter-spacing: -0.03em; }
.login .muted { margin: 0 0 0.5rem; }
.login .btn-row { margin-top: 1.15rem; }
.login .btn-row button { width: 100%; }
#totp { letter-spacing: 0.28em; font-variant-numeric: tabular-nums; font-size: 1.1rem; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  .nav-toggle:checked ~ .sidebar { transform: translateX(0); }
  .nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(8, 11, 16, 0.5);
    z-index: 35;
    border: 0;
  }
  .nav-toggle:checked ~ .nav-backdrop { display: block; }
  .shell { margin-left: 0; padding-top: 0; }
  .topbar { display: flex; }
  main.app-main { padding: 1.15rem 1rem 3rem; }
  th, td { padding: 0.65rem 0.75rem; }
  .page-head h1 { font-size: 1.28rem; }
  .hero-metric { font-size: 1.5rem; }
}
@media (max-width: 720px) {
  table { font-size: 0.88rem; }
  .job-actions .btn { min-height: 40px; }
  .card { padding: 0.95rem 0.95rem; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .btn, button { transition: none; }
}
