:root {
  --ink: #1b1f24; --muted: #667080; --line: #d9dee5; --bg: #f5f7fa; --card: #fff;
  --accent: #1f3a5f; --accent-soft: #e6edf6; --bad: #b42318; --good: #067647;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; }
header { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--accent); color: #fff; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
header .brand { margin-right: 8px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav a { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 6px; }
nav a.on, nav a:hover { background: rgba(255,255,255,.18); }
#who { font-size: 13px; opacity: .85; }
.ghost-select { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); min-height: 34px; padding: 4px 8px; }
.ghost-select option { color: var(--ink); }
main { padding: 16px; max-width: 1280px; margin: 0 auto; }
h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 16px; margin: 18px 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 110px; }
.row > label.grow { flex: 1; min-width: 200px; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); min-height: 38px; }
input[type=number] { width: 110px; }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
button { font: inherit; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; min-height: 38px; }
button.ghost { background: transparent; border-color: currentColor; color: inherit; }
button.light { background: #fff; color: var(--accent); }
button.danger { background: #fff; color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; position: sticky; top: 52px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.zero { color: #c3c9d1; }
td.neg { color: var(--bad); font-weight: 600; }
tr.total td { font-weight: 700; background: #fafbfc; }
.muted { color: var(--muted); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { background: #fff; color: var(--accent); }
.tabs button.on { background: var(--accent); color: #fff; }
.picker { position: relative; }
.picker ul { position: absolute; z-index: 10; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 0; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 6px; max-height: 280px; overflow: auto; box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.picker li { padding: 8px 10px; cursor: pointer; }
.picker li:hover, .picker li.on { background: var(--accent-soft); }
.rx { display: grid; grid-template-columns: 40px repeat(3, minmax(70px, 110px)); gap: 6px; align-items: center; }
.rx input { width: 100%; }
.sum { font-size: 18px; font-weight: 700; }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--bad); }
.print-only { display: none; }
.scroll { overflow-x: auto; }

@media (max-width: 640px) {
  main { padding: 10px; }
  th { top: 0; }
  .row > label { min-width: calc(50% - 6px); }
}

@media print {
  header, .no-print, #toast { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
  th { position: static; background: #fff; }
  .print-only { display: table-cell; }
  h1.print-only { display: block; }
}
