:root {
  --blue: #18569C;
  --blue-dark: #12437A;
  --blue-soft: #E8EFF7;
  --red: #D51920;
  --ink: #1B1D21;
  --muted: #5C6370;
  --line: #E3E5E8;
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --ok: #1E7F45;
  --ok-soft: #E6F4EC;
  --bad: #B3261E;
  --bad-soft: #FBEAEA;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--bg); }
a { color: var(--blue); }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* top bar and tabs */
.topbar { display: flex; align-items: center; gap: 14px; background: #fff; border-bottom: 1px solid var(--line); padding: 0 16px; height: 56px; position: sticky; top: 0; z-index: 20; }
.topbar img { height: 44px; }
.topbar .spacer { flex: 1; }
.who { font-size: 13px; color: var(--muted); white-space: nowrap; }
.tabbar { display: flex; gap: 2px; background: #fff; border-bottom: 1px solid var(--line); padding: 0 8px; overflow-x: auto; position: sticky; top: 56px; z-index: 19; }
.tabbar button { border: 0; background: none; font: inherit; color: var(--muted); padding: 12px 14px; border-bottom: 3px solid transparent; cursor: pointer; font-weight: 600; white-space: nowrap; }
.tabbar button.active { color: var(--ink); border-bottom-color: var(--blue); }

/* layout */
.page { max-width: 1280px; margin: 0 auto; padding: 18px 16px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.card + .card, .card + .grid2, .grid2 + .card { margin-top: 16px; }
.grid2 > .card { margin-top: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid2, .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) { .who { display: none; } .topbar img { height: 34px; } .page { padding: 12px 10px 40px; } .card { padding: 14px; } }
.head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

/* forms */
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(24,86,156,.14); }
input[type=checkbox] { width: auto; }
.field { margin-bottom: 12px; }
.inline-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; align-items: end; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; border-radius: 6px; padding: 8px 14px; border: 1px solid var(--blue); background: var(--blue); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--blue-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.light { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.light:hover { background: var(--bg); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.linkbtn { border: 0; background: none; color: var(--blue); font: inherit; cursor: pointer; padding: 0; }
.linkbtn.danger { color: var(--bad); }

.alert { padding: 10px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; }
.alert.error { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; background: #fafbfc; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 600; background: #fafbfc; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--blue-soft); }
tr.picked td { background: var(--blue-soft); }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
table.entry td { padding: 4px 5px; }
table.entry input, table.entry select { padding: 6px 7px; }
table.entry input.num { text-align: right; }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--blue); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }

.daylist { list-style: none; margin: 0; padding: 0; }
.daylist li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.daylist li:hover { background: var(--blue-soft); }
.daylist li.missing { color: var(--bad); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 6px; z-index: 50; font-size: 13px; }

/* login */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-head img { width: 100%; max-width: 300px; }
.auth-head h1 { margin-top: 10px; }
