:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --error: #b91c1c;
  --border: #e2e8f0;
  --brand: #2563eb;
  --ink: #0f172a;
  --line: #e2e8f0;
  --surface: #ffffff;
  --canvas: #f8fafc;
  --ready-bg: #dcfce7;    --ready-ink: #166534;
  --skipped-bg: #fef3c7;  --skipped-ink: #92400e;
  --invisible-bg: #f1f5f9; --invisible-ink: #475569;
  --warn-bg: #fff7ed;     --warn-ink: #9a3412;
}
* { box-sizing: border-box; }
/* An author-origin `display` declaration on a hidden element beats the `[hidden]` default at equal
   specificity — this rule must win regardless of what any element's own class declares, or the
   `hidden` attribute silently stops hiding anything (finding 2). */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
/* This was `#app`, and index.html has had no #app since the shell was rebuilt around #view-app --
   a dead rule, and silently so. #view-login centres itself through .login-card and #view-app is a
   full-viewport grid, so the only view that ever depended on it was #view-loading, which was left
   rendering flush into the top-left corner of the window. */
#view-loading { max-width: 880px; margin: 0 auto; padding: 24px 16px; }
.view { animation: fade 0.15s ease-in; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.muted { color: var(--muted); }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.login-card { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.login-card h1 { margin: 0 0 4px; }
/* Both login steps share one layout rather than duplicating it: the code form is the same column
   of one input and one button. The `display: flex` here is exactly the declaration the [hidden]
   rule above has to outrank — `#code-form` ships hidden until a code has been sent. */
#login-form, #code-form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
/* 6 digits in a 380px card looks like a typo'd password box at full width. */
#login-code { text-align: center; letter-spacing: 0.3em; font-size: 1.2em; }
input, button {
  font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
}
input { background: #ffffff; color: var(--text); }
button {
  background: var(--accent); color: #fff; border: none; cursor: pointer; font-weight: 600;
}
button:disabled { opacity: 0.6; cursor: default; }
.message { margin-top: 12px; }
.message.error, .error { color: var(--error); }
.dash-header { display: flex; align-items: baseline; justify-content: space-between; }
.dash-header a { color: var(--accent); text-decoration: none; font-size: 0.9rem; }
.stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; margin-top: 4px; }
.stat-sub { font-size: 0.75rem; margin-top: 2px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: none; }
.list .row-top { display: flex; justify-content: space-between; gap: 12px; }
.list .row-class { font-weight: 600; }
.list .row-time { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.list .row-body { color: var(--text); margin-top: 2px; word-break: break-word; }
.list .empty { color: var(--muted); padding: 10px 0; }

/* Request actions (CONSOLE-1). `.row-time` keeps the right edge, so the status pill sits with the
   class name on the left rather than fighting the space-between for it. */
.list .row-class { margin-right: auto; }
.list .row-status {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  align-self: center;
  white-space: nowrap;
}
.list .status-open { background: var(--ready-bg); color: var(--ready-ink); }
.list .status-acknowledged { background: #e0e7ff; color: #3730a3; }
.row-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.row-action {
  font: inherit;
  font-size: 0.8rem;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
.row-action:hover:not(:disabled) { border-color: var(--muted); }
/* Disabled is the in-flight state, and it has to READ as busy rather than as broken — the control
   comes back on every outcome. */
.row-action:disabled { opacity: 0.5; cursor: progress; }
.row-busy { opacity: 0.7; }

@media (max-width: 520px) { .stats-row { grid-template-columns: 1fr; } }

/* ── App shell ──────────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
  background: var(--canvas);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.sidebar .brand { font-weight: 700; color: var(--brand); padding: 0 10px 16px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}
.sidebar nav a:hover { background: var(--canvas); }
.sidebar nav a.active { background: #eff6ff; color: var(--brand); font-weight: 600; }
.sidebar .logout { margin-top: auto; padding: 8px 10px; color: var(--muted); font-size: 0.9rem; }

#route-outlet { padding: 24px 28px; }
.page-header h1 { margin: 0 0 16px; font-size: 1.4rem; }

/* ── Status pills — the three readiness states ──────────────────────────── */
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  white-space: nowrap;
}
.pill.ready       { background: var(--ready-bg);     color: var(--ready-ink); }
.pill.skipped     { background: var(--skipped-bg);   color: var(--skipped-ink); }
.pill.not-scanned { background: var(--invisible-bg); color: var(--invisible-ink); }
.pill.muted       { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
/* .night-row is a five-track grid and .pill is nowrap. Where the day-0 note now sits BESIDE a
   kept state pill it is a sixth child, which would otherwise land in an implicit row inside
   track 1 and stretch that track to the note's full width — throwing that one row's columns out
   of line with every other row. Span it across the row instead. */
.day0-note { grid-column: 1 / -1; justify-self: start; }

/* ── Banners ────────────────────────────────────────────────────────────── */
.banner {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  line-height: 1.45;
}
.banner-warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid #fed7aa; }

/* ── Rates page ─────────────────────────────────────────────────────────── */
.window-summary {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
}
.preset-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.preset-bar .preset {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
.night-list { list-style: none; margin: 0 0 20px; padding: 0; background: var(--surface);
              border: 1px solid var(--line); border-radius: 8px; }
.night-row {
  display: grid;
  grid-template-columns: auto 1fr 70px 90px minmax(160px, auto);
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
}
.night-row:last-child { border-bottom: 0; }
.night-date { font-variant-numeric: tabular-nums; }
.night-rate, .night-comps { color: var(--muted); font-variant-numeric: tabular-nums; }

.rate-form { background: var(--surface); border: 1px solid var(--line);
             border-radius: 8px; padding: 16px; display: grid; gap: 10px; }
.own-rate-field { display: grid; gap: 6px; font-weight: 600; }
.competitor-row, .removal-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-error, .form-error { color: #b91c1c; font-size: 0.85rem; margin: 2px 0 0; }
.landed-log { margin-top: 20px; }
.landed-log ul { list-style: none; padding: 0; display: grid; gap: 6px; }
.landed-ok { color: var(--ready-ink); }
.landed-fail { color: #b91c1c; }
