:root {
  --bg: #f6f7f9; --surface: #fff; --text: #1d2330; --muted: #5d6678; --line: #dde1e8; --line-strong: #c4cad5;
  --accent: #1f4e79; --accent-ink: #fff; --accent-soft: #e6eef6;
  --ok: #1e6b3a; --ok-soft: #e3f3e8; --warn: #8a5a00; --warn-soft: #fdf3dc; --err: #a32020; --err-soft: #fbe6e6;
  --ot: #6b3fa0; --ot-soft: #efe8f8; --weekend: #f1f2f5;
  --radius: 6px; --gap: 16px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --surface: #1c2027; --text: #e6e9ef; --muted: #9aa3b2; --line: #2c323c; --line-strong: #3a414d;
    --accent: #6ea8dc; --accent-ink: #0d1520; --accent-soft: #1f2d3b;
    --ok: #6fcf8f; --ok-soft: #173023; --warn: #e3b552; --warn-soft: #33290f; --err: #f08a8a; --err-soft: #3a1919;
    --ot: #b99ae6; --ot-soft: #2a2238; --weekend: #181b21;
  }
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hidden { display: none !important; }

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; gap: 4px; padding: 0 16px;
  min-height: 52px; flex-wrap: wrap; }
.brand { font-weight: 700; margin-right: 16px; text-decoration: none; color: var(--text); }
.nav a { text-decoration: none; color: var(--muted); padding: 8px 10px; border-radius: var(--radius); display: inline-block; }
.nav a:hover, .nav a.on { color: var(--text); background: var(--accent-soft); }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: .9rem; margin-right: 8px; }
.env-badge { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--warn-soft); color: var(--warn);
  margin-right: 8px; }

main { max-width: 1400px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* cards & grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: var(--gap); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--gap); }
.card h3 { margin-top: 0; }
.stat { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
th { font-size: .82rem; text-transform: none; color: var(--muted); font-weight: 600; background: var(--surface);
  position: sticky; top: 0; z-index: 1; }
tr:last-child td { border-bottom: none; }
tr.group-row td { background: var(--accent-soft); font-weight: 600; }
tr.archived td { color: var(--muted); text-decoration: line-through; }
tr.attention td { background: var(--warn-soft); }
tr.error td { background: var(--err-soft); }
tr.dim td { color: var(--muted); }
tfoot td { font-weight: 600; border-top: 2px solid var(--line-strong); }

/* forms */
form.stack { display: grid; gap: 12px; max-width: 720px; }
.field { display: grid; gap: 4px; }
.field label, .lbl { font-weight: 600; font-size: .9rem; }
.field .hint { font-size: .82rem; color: var(--muted); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 200px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search],
select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 7px 9px; width: 100%; min-height: 36px; }
textarea { min-height: 80px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: normal; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; }
legend { font-weight: 600; padding: 0 4px; }

/* buttons */
.btn { font: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none;
  min-height: 36px; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.danger.solid { background: var(--err); color: #fff; }
.btn.small { padding: 3px 9px; min-height: 28px; font-size: .87rem; }
.btn.link { border: none; background: none; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; }
form.inline { display: inline; }

/* alerts / badges */
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid transparent; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.alert-error { background: var(--err-soft); color: var(--err); border-color: var(--err); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.alert-info { background: var(--accent-soft); color: var(--text); border-color: var(--line-strong); }
.badge { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft);
  color: var(--text); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.ot { background: var(--ot-soft); color: var(--ot); }
.badge.muted { background: var(--weekend); color: var(--muted); }
ul.msgs { margin: 2px 0 0; padding-left: 18px; font-size: .85rem; }
ul.msgs li.err { color: var(--err); }
ul.msgs li.warn { color: var(--warn); }

/* filter bar */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.filters .field { min-width: 160px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 8px 0; }

/* progress bar */
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.warn > span { background: var(--warn); }
.bar.over > span { background: var(--err); }
.w-0 { width: 0 } .w-10 { width: 10% } .w-20 { width: 20% } .w-30 { width: 30% } .w-40 { width: 40% } .w-50 { width: 50% }
.w-60 { width: 60% } .w-70 { width: 70% } .w-80 { width: 80% } .w-90 { width: 90% } .w-100 { width: 100% }

/* login */
.login { max-width: 420px; margin: 8vh auto; }
.login .card { padding: 24px; }
.or { text-align: center; color: var(--muted); margin: 18px 0; font-size: .9rem; }
details summary { cursor: pointer; color: var(--accent); }

/* timesheet grid (M2) */
.ts-grid th.day, .ts-grid td.day { text-align: center; min-width: 74px; }
.ts-grid td.day input { width: 64px; text-align: right; padding: 5px 6px; min-height: 32px; }
.ts-grid .weekend { background: var(--weekend); }
.ts-grid .holiday { background: var(--ot-soft); }
.ts-grid td.flagged { box-shadow: inset 3px 0 0 var(--err); }
.ts-grid td.split { font-size: .78rem; color: var(--muted); }
.ts-grid .ot { color: var(--ot); font-weight: 600; }
.ts-grid .leave, .leave { color: var(--muted); white-space: nowrap; }
.ts-grid td.act { min-width: 320px; }
.ts-grid td.act .ts-wrapper { min-width: 300px; }
.cellnote { font-size: .72rem; color: var(--ot); display: block; }
.dayhead small { display: block; color: var(--muted); font-weight: normal; }
.changed { background: var(--warn-soft); }

/* tom-select tweaks */
.ts-control { border-color: var(--line-strong) !important; background: var(--surface) !important; color: var(--text) !important; min-height: 36px; }
.ts-dropdown { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.ts-dropdown .active { background: var(--accent-soft); color: var(--text); }
.ts-control input { color: var(--text) !important; }

@media (max-width: 640px) {
  .topbar-inner { padding: 6px 16px; }
  .nav a { padding: 6px 8px; }
  main { padding: 14px 16px 40px; }
  th, td { padding: 6px 7px; }
}
