:root {
  --bg: #f6f7f9; --card: #fff; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --accent: #4f46e5; --accent-soft: #eef2ff; --ok: #059669; --warn: #d97706; --bad: #dc2626;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b0d12; --card: #151821; --text: #e5e7eb; --muted: #9ca3af; --line: #262a36;
    --accent: #818cf8; --accent-soft: #1e1b4b; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }

.layout { display: flex; min-height: 100vh; }
nav { width: 210px; padding: 20px 12px; border-right: 1px solid var(--line); background: var(--card); flex-shrink: 0; }
nav .brand { font-weight: 700; font-size: 18px; padding: 0 10px 18px; }
nav .brand span { color: var(--accent); }
nav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; margin-bottom: 2px; }
nav a.on, nav a:hover { background: var(--accent-soft); color: var(--accent); }
nav .out { margin-top: 18px; }
main { flex: 1; padding: 28px; max-width: 1100px; min-width: 0; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  nav { width: auto; border-right: 0; border-bottom: 1px solid var(--line); display: flex; overflow-x: auto; padding: 10px; gap: 4px; }
  nav .brand { padding: 8px 10px; }
  nav a { white-space: nowrap; margin: 0; }
  nav .out { margin: 0; }
  main { padding: 16px; }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat b { display: block; font-size: 26px; font-weight: 650; }
.stat small { color: var(--muted); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > label { flex: 1 1 150px; }
label { display: block; font-size: 13px; color: var(--muted); }
input, select, textarea { width: 100%; margin-top: 4px; padding: 9px 11px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: auto; margin: 0 6px 0 0; }
.check { display: flex; align-items: center; color: var(--text); font-size: 14px; }

button { font: inherit; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
button.ghost { background: transparent; color: var(--accent); }
button.small { padding: 4px 10px; font-size: 13px; }
button.danger { border-color: var(--bad); background: transparent; color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }

.table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 13px; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .5px; }
.muted { color: var(--muted); }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: #d1fae5; color: #065f46; } .pill.bad { background: #fee2e2; color: #991b1b; } .pill.warn { background: #fef3c7; color: #92400e; }
@media (prefers-color-scheme: dark) { .pill.ok { background: #064e3b; color: #a7f3d0; } .pill.bad { background: #450a0a; color: #fecaca; } .pill.warn { background: #451a03; color: #fde68a; } }
.note { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--text); font-size: 14px; margin-bottom: 12px; }
.err { color: var(--bad); font-size: 14px; min-height: 1em; }
.spacer { height: 10px; }

.login { max-width: 340px; margin: 12vh auto; }
.login .brand { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 18px; }
.login .brand span { color: var(--accent); }
.login label { margin-bottom: 12px; }
.login button { width: 100%; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: 14px; }

@media print {
  nav, .noprint { display: none !important; }
  main { padding: 0; }
  .print-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .print-grid div { border: 1px dashed #999; padding: 10px; text-align: center; break-inside: avoid; }
}
.print-grid { display: none; }
@media print { .print-grid { display: grid; } .card { border: 0; padding: 0; } }
