:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e8;
  --text: #14181d;
  --muted: #667085;
  --accent: #8a6d1f;
  --accent-soft: #f6efd9;
  --good: #1a7f4b;
  --bad: #b42318;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1114;
    --surface: #161a1f;
    --surface-2: #1d222a;
    --border: #2a313a;
    --text: #e6e9ee;
    --muted: #9aa4b2;
    --accent: #d9bc63;
    --accent-soft: #2a2517;
    --good: #4ec98a;
    --bad: #f28b82;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */

header.top {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
header.top .brand { font-weight: 700; letter-spacing: -.01em; color: var(--text); }
header.top .brand span { color: var(--accent); }
header.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
header.top nav a {
  padding: 6px 11px; border-radius: 7px; color: var(--muted); font-weight: 500;
}
header.top nav a:hover { background: var(--surface-2); text-decoration: none; }
header.top nav a.on { background: var(--accent-soft); color: var(--accent); }
header.top .spacer { margin-left: auto; }
header.top .who { color: var(--muted); font-size: 13px; }

main { max-width: 1240px; margin: 0 auto; padding: 22px 20px 80px; }

h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0 0 10px; letter-spacing: -.01em; }
h3 { font-size: 14px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p.lede { color: var(--muted); margin: 0 0 18px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
.card > h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head .spacer { margin-left: auto; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { font-weight: 650; border-top: 2px solid var(--border); border-bottom: none; }
tr.sub td { background: var(--surface-2); font-size: 13px; }

/* ---------- forms ---------- */

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 7px 9px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 7px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { min-height: 62px; resize: vertical; }
input.qty { width: 78px; text-align: right; font-variant-numeric: tabular-nums; }
input.price { width: 96px; text-align: right; font-variant-numeric: tabular-nums; }
.field { margin-bottom: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 150px; margin-bottom: 0; }
.check { display: flex; align-items: center; gap: 7px; font-size: 14px; color: var(--text); }
.check input { width: auto; }

button, .btn {
  display: inline-block; padding: 7px 14px; font: inherit; font-weight: 550;
  border-radius: 7px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { button.primary, .btn.primary { color: #14181d; } }
button.danger { color: var(--bad); }
button.link { background: none; border: none; padding: 2px 4px; color: var(--muted); text-decoration: underline; }
.btn.sm, button.sm { padding: 4px 9px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

/* ---------- misc ---------- */

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.flash.ok { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); }
.flash.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); border: 1px solid var(--bad); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
        background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.pill.collecting { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.pill.allocated, .pill.good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); border-color: var(--good); }
.pill.submitted { background: color-mix(in srgb, #3b82f6 14%, transparent); color: #3b82f6; border-color: #3b82f6; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 0; }
details[open] summary { margin-bottom: 8px; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.inline-form { display: inline; }
.warn { color: var(--bad); }
.over { color: var(--bad); font-weight: 650; }

/* ---------- login ---------- */

.login-wrap { max-width: 380px; margin: 12vh auto; padding: 0 20px; }
.login-wrap .brand { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 4px; }
.login-wrap .brand span { color: var(--accent); }

@media print {
  header.top, .noprint { display: none !important; }
  body { background: #fff; }
  .card { border: none; box-shadow: none; padding: 0; }
  main { max-width: none; padding: 0; }
}
