/* Base: tokens, layout, typography. Swiss Ops Console.
   Flat colours only. Hairline borders are the only elevation.
   Palette: paper, ink, hairline, muted, Swiss red, success green. */

:root {
  /* Primitive */
  --c-paper: #fafafa;
  --c-surface: #ffffff;
  --c-sidebar: #fafafa;
  --c-ink: #111111;
  --c-muted: #666666;
  --c-hairline: #e5e5e5;
  --c-hover: #f5f5f5;
  --c-red: #da291c;
  --c-red-dark: #b31f14;
  --c-green: #1a7f37;
  --c-amber: #9a6700;
  --c-grey: #999999;

  /* Semantic */
  --bg: var(--c-paper);
  --surface: var(--c-surface);
  --border: var(--c-hairline);
  --text: var(--c-ink);
  --text-muted: var(--c-muted);
  --accent: var(--c-red);
  --ok: var(--c-green);
  --warn: var(--c-amber);
  --bad: var(--c-red);

  /* Component */
  --radius-sm: 6px;
  --gap: 16px;
  --max: 1440px;
  --control-h: 32px;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Helvetica Neue", Helvetica, Inter, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-tap-highlight-color: rgba(218, 41, 28, 0.2);
  touch-action: manipulation;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 8px; text-align: left; }
h2 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0 0 12px; }
a { color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }
input, select { min-height: var(--control-h); }

:focus-visible {
  outline: 2px solid var(--c-red);
  outline-offset: 2px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -100px; z-index: 50;
  background: var(--surface); border: 2px solid var(--accent); padding: 8px 12px;
}
.skip-link:focus { top: 12px; }

/* Shell: sidebar + main column */
.shell { display: flex; min-height: 100vh; align-items: stretch; }

/* Sidebar: dimmer than the content column, quiet chrome */
.sidebar {
  width: var(--sidebar-w); flex: none;
  background: var(--c-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 0 16px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 16px 16px; }
.brand-mark { flex: none; display: block; }
.sidebar-brand h1 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }

.mainnav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.mainnav a {
  text-decoration: none; color: var(--text-muted); font-weight: 500; font-size: 14px;
  padding: 7px 8px; border-radius: var(--radius-sm); border: 1px solid transparent;
  min-height: 32px; display: flex; align-items: center;
}
.mainnav a:hover { color: var(--text); background: var(--c-hover); }
.mainnav a[aria-current="page"] { color: var(--text); background: var(--c-hover); font-weight: 600; }
.mainnav a[aria-current="page"]::before {
  content: ""; width: 6px; height: 6px; background: var(--c-red); flex: none; margin-right: 8px;
}

.search-form { display: flex; gap: 6px; padding: 16px 16px 0; }
.search-form input {
  flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
.search-form button { padding: 6px 10px; }

/* Keys: quiet collapsible in the sidebar footer, same hairline style */
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding: 12px 16px 0; }
.keys summary { cursor: pointer; font-weight: 600; font-size: 13px; padding: 4px 0; }
.keys-hint { font-weight: 400; color: var(--text-muted); font-size: 12px; }
.keys-fields { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }
.keys-fields label { display: block; font-weight: 600; font-size: 12px; }
.keys-fields input {
  display: block; width: 100%; margin-top: 4px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.keys-actions { display: flex; gap: 8px; }
.key-note { font-size: 12px; color: var(--text-muted); margin: 10px 0 0; }
.muted { font-weight: 400; color: var(--text-muted); }

/* Content column */
.content { flex: 1; min-width: 0; background: var(--surface); display: flex; flex-direction: column; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
}
.page-head h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 2px; }
.page-sub { color: var(--text-muted); margin: 0; font-size: 13px; }
.statusline {
  flex: none; padding-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; letter-spacing: 0.04em; color: var(--text-muted);
  font-variant-numeric: tabular-nums; text-align: right;
}
.statusline.stale { color: var(--bad); font-weight: 600; }

/* Buttons */
button, .btn {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 12px; font-weight: 600; font-size: 13px;
  min-height: var(--control-h);
}
button:hover, .btn:hover { border-color: var(--text); }
button.btn-primary, .btn-primary {
  background: var(--c-ink); color: #ffffff; border-color: var(--c-ink);
}
button.btn-primary:hover, .btn-primary:hover { background: #000000; border-color: #000000; }
button.btn-quiet, .btn-quiet {
  background: transparent; color: var(--text-muted); border-color: transparent;
}
button.btn-quiet:hover, .btn-quiet:hover { color: var(--text); border-color: transparent; }
button.btn-danger, .btn-danger {
  background: var(--surface); color: var(--c-red); border-color: var(--border);
}
button.btn-danger:hover, .btn-danger:hover { border-color: var(--c-red); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }

/* Main — --max (1440px) was declared but never used, so at 1920px the
   tables / KPI strip stretched the full viewport width and the reading
   line got very long (Vercel-style consoles cap the content column).
   Centred max-width on the content column, header and footer alike. */
main { padding: 20px 24px 40px; flex: 1 0 auto; width: 100%; max-width: var(--max); margin-left: auto; margin-right: auto; display: flex; flex-direction: column; }
.page-head { max-width: var(--max); width: 100%; margin-left: auto; margin-right: auto; }
.pagefoot { max-width: var(--max); width: 100%; margin-left: auto; margin-right: auto; }
#view { flex: 1 0 auto; display: flex; flex-direction: column; }
.breadcrumbs { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; min-height: 20px; }
.breadcrumbs a { color: var(--text-muted); }
.toast {
  border: 1px solid var(--text); background: var(--surface);
  padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px;
}
.toast.error { border-color: var(--bad); color: var(--bad); }
.pagefoot {
  width: 100%; padding: 12px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}
.foot-status {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.foot-credit {
  margin: 6px 0 0;
  font-size: 12px; color: var(--text-muted);
}
.foot-credit a { color: inherit; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--border); padding: 12px 0; }
  .mainnav { flex-direction: row; flex-wrap: wrap; padding: 0 12px; }
  .search-form { padding: 12px 16px 0; }
  .sidebar-foot { margin-top: 12px; }
  .page-head { padding: 16px; flex-wrap: wrap; }
  .statusline { text-align: left; }
  main { padding: 16px; }
  .pagefoot { padding: 12px 16px; }
}

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