:root {
  color-scheme: light;
  --bg: oklch(0.985 0.012 85);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.965 0.018 100);
  --ink: oklch(0.18 0.025 240);
  --muted: oklch(0.48 0.025 245);
  --line: oklch(0.88 0.018 95);
  --primary: oklch(0.42 0.13 165);
  --primary-dark: oklch(0.34 0.11 165);
  --accent: oklch(0.62 0.16 55);
  --danger: oklch(0.56 0.19 28);
  --warn: oklch(0.68 0.14 70);
  --info: oklch(0.58 0.1 230);
  --ok: oklch(0.52 0.13 155);
  --shadow: 0 12px 32px oklch(0.2 0.04 250 / 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 72px;
  padding: 12px clamp(16px, 3vw, 32px);
  background: oklch(0.995 0.005 100 / 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  text-decoration: none;
}
.brand small, .muted, .help { color: var(--muted); }
.mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  font-weight: 800;
}
.nav {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
}
.nav a {
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }

.shell {
  width: min(1380px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 32px) 48px;
}
.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 10px 0 22px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.75rem, 3vw, 2.65rem); letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 1.05rem; }
.eyebrow {
  margin-bottom: 6px;
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.rule-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.rule-strip span, .status, .count {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.metric, .panel, .form-card, .receipt {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.metric {
  min-height: 132px;
  padding: 16px;
}
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong {
  display: block;
  margin: 10px 0 6px;
  font-size: 1.42rem;
  line-height: 1.1;
}
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 16px;
  margin-bottom: 18px;
}
.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.6fr); }
.panel { padding: 16px; margin-bottom: 18px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.text-link { color: var(--primary-dark); font-weight: 700; text-decoration: none; }
.alert-list { display: grid; gap: 10px; }
.alert {
  border-left: 4px solid var(--info);
  border-radius: 6px;
  padding: 12px;
  background: var(--surface-2);
}
.alert.critical { border-color: var(--danger); }
.alert.warning { border-color: var(--warn); }
.alert p { margin: 6px 0; color: var(--muted); }
.empty { color: var(--muted); margin: 0; }

.facts {
  display: grid;
  gap: 10px;
  margin: 0;
}
.facts div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 800; text-align: right; }
.compact div { padding-bottom: 8px; }

.table-wrap { width: 100%; overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
th, td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0;
}
.status.ok { color: white; background: var(--ok); }
.status.warn { color: var(--ink); background: oklch(0.91 0.08 85); }

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}
.full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; min-height: 42px; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: white;
  color: var(--ink);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid oklch(0.78 0.11 165);
  outline-offset: 1px;
}
button, .primary {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 9px 14px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  cursor: pointer;
}
button:hover, .primary:hover { background: var(--primary-dark); }
.icon-button {
  width: 42px;
  padding: 0;
  background: var(--surface-2);
  color: var(--ink);
}
.filters, .inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.inline-form { margin: 0; }
.inline-form input { min-width: 120px; }
.login-panel {
  min-height: calc(100vh - 140px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  align-items: center;
  gap: 32px;
}
.login-panel h1 { font-size: clamp(2rem, 5vw, 4rem); max-width: 760px; }
.secure-login {
  min-height: calc(100vh - 96px);
  grid-template-columns: minmax(280px, 380px);
  justify-content: center;
}
.login-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 4px;
  border-radius: 8px;
  color: white;
  background: var(--ink);
  font-weight: 900;
}
.form-card { padding: 20px; display: grid; gap: 14px; }
.alert-text { color: var(--danger); font-weight: 800; margin-bottom: 0; }
.receipt-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.receipt { padding: 14px; display: grid; gap: 8px; }
.receipt span { color: var(--primary-dark); font-size: 1.2rem; font-weight: 900; }
.receipt small { color: var(--muted); }
.receipt a { color: var(--primary-dark); font-weight: 800; text-decoration: none; }
.prose {
  max-width: 880px;
  line-height: 1.65;
}
.prose h2 { margin-top: 24px; margin-bottom: 8px; }

@media (max-width: 1080px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .receipt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col, .wide-left, .login-panel { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .brand { min-width: 100%; }
  .page-head { align-items: start; flex-direction: column; }
  .metric-grid, .receipt-grid, .grid-form { grid-template-columns: 1fr; }
  .filters, .inline-form { align-items: stretch; flex-direction: column; }
  .shell { padding-top: 16px; }
}
