:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #1c2430;
  --muted: #5d6b7c;
  --border: #dde3ea;
  --primary: #1f4e79;
  --primary-hover: #173d60;
  --primary-soft: #e7eff8;
  --good: #1d7a46;
  --good-soft: #e3f4ea;
  --warn: #9a5b00;
  --warn-soft: #fff4dc;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --info-soft: #eef2ff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161d; --surface: #19202a; --surface-2: #1f2834; --text: #e6ebf1; --muted: #9aa8b8; --border: #2d3846;
    --primary: #6aa6e0; --primary-hover: #8bbbe9; --primary-soft: #1d3147;
    --good: #5cc98a; --good-soft: #15301f; --warn: #f0b350; --warn-soft: #34270f; --bad: #f2867c; --bad-soft: #3a1c19; --info-soft: #1e2440;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 15px; line-height: 1.45; }
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Layout */
.topbar { background: var(--primary); color: #fff; display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; position: sticky; top: 0; z-index: 10; }
@media (prefers-color-scheme: dark) { .topbar { background: #14304d; } }
.topbar .brand { font-weight: 700; font-size: 1.05rem; white-space: nowrap; color: #fff; text-decoration: none; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: #dbe7f3; text-decoration: none; padding: .35rem .65rem; border-radius: 6px; font-size: .92rem; }
.topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.topbar nav a.active { background: rgba(255,255,255,.2); color: #fff; }
.topbar .who { font-size: .85rem; color: #dbe7f3; white-space: nowrap; }
.topbar .who button { margin-left: .5rem; }
.menu-toggle { display: none; }
main { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  .menu-toggle { display: inline-flex; margin-left: auto; }
  .topbar nav { display: none; flex-basis: 100%; flex-direction: column; }
  .topbar nav.open { display: flex; }
  .topbar .who { flex-basis: 100%; display: none; }
  .topbar nav.open + .who { display: block; }
  main { padding: 1rem .75rem 4rem; }
}

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; }
.stat .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; }

/* Buttons & forms */
button, .btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: .5rem .9rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; line-height: 1.2; }
button:hover, .btn:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-hover); }
@media (prefers-color-scheme: dark) { button.primary, .btn.primary { color: #0d1620; } }
button.good { background: var(--good); border-color: var(--good); color: #fff; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.danger.solid { background: var(--bad); color: #fff; }
button.link { border: none; background: none; color: var(--primary); padding: .2rem .3rem; text-decoration: underline; }
button.small, .btn.small { padding: .3rem .6rem; font-size: .85rem; }
.topbar button { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); padding: .3rem .7rem; font-size: .85rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .2rem; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: .45rem .6rem; width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
input[type=checkbox] { width: auto; margin-right: .4rem; transform: scale(1.15); }
textarea { min-height: 60px; resize: vertical; }
.field { margin-bottom: .8rem; }
.check { display: flex; align-items: center; font-weight: 500; color: var(--text); font-size: .95rem; margin-bottom: .6rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.help { font-size: .8rem; color: var(--muted); margin-top: .2rem; font-weight: 400; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem .4rem; margin: 0 0 1rem; }
legend { font-weight: 650; padding: 0 .4rem; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: .5rem .65rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border); }
tr.weekend td { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--primary-soft); }

/* Badges & alerts */
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.alert { padding: .7rem .9rem; border-radius: 8px; margin: .6rem 0; font-size: .92rem; border: 1px solid transparent; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.good { background: var(--good-soft); color: var(--good); }
.alert.info { background: var(--info-soft); color: var(--text); border-color: var(--border); }
.alert ul { margin: .3rem 0 0 1.1rem; padding: 0; }

/* Clock */
.clock-card { text-align: center; padding: 1.6rem 1rem; }
.clock-time { font-size: 3rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.clock-status { font-size: 1.05rem; margin: .4rem 0 1.2rem; }
.clock-buttons { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
.clock-buttons button { font-size: 1.15rem; padding: .9rem 1.6rem; border-radius: 12px; min-width: 160px; justify-content: center; }
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; background: var(--muted); margin-right: .35rem; vertical-align: middle; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.dot.break { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }

/* Timesheet */
.day-row td { padding-top: .45rem; padding-bottom: .45rem; }
.day-name { font-weight: 600; white-space: nowrap; }
.entry-line { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.entry-notes { color: var(--muted); font-size: .85rem; white-space: pre-wrap; }
.period-nav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(10, 15, 25, .5); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 1rem; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 560px; padding: 1.2rem 1.3rem; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal.wide { max-width: 860px; }
.modal h2 { margin-top: 0; }
.modal .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }

/* Toast */
#toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .4rem; align-items: center; }
#toast .t { background: #1c2430; color: #fff; padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow); font-size: .92rem; max-width: 90vw; }
#toast .t.err { background: var(--bad); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login { width: 100%; max-width: 380px; }
.login h1 { text-align: center; margin-bottom: .2rem; }
.login .sub { text-align: center; color: var(--muted); margin-bottom: 1.2rem; }

/* Pay stub */
.stub { background: #fff; color: #111; border: 1px solid #ccc; border-radius: 6px; padding: 1.4rem; max-width: 820px; margin: 0 auto; font-size: .9rem; }
.stub h2 { margin: 0; font-size: 1.2rem; }
.stub .stub-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 2px solid #222; padding-bottom: .6rem; margin-bottom: .8rem; }
.stub table { font-size: .85rem; }
.stub th { background: #f1f1f1; color: #333; }
.stub th, .stub td { border-bottom: 1px solid #ddd; padding: .3rem .5rem; }
.stub .net-box { border: 2px solid #222; padding: .6rem .9rem; display: inline-block; font-size: 1.1rem; font-weight: 700; }
.stub .two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .stub .two { grid-template-columns: 1fr; } }
.draft-mark { color: #b42318; font-weight: 700; letter-spacing: .1em; }

.report-notes { font-size: .88rem; }
.report-notes li { margin-bottom: .3rem; }

@media print {
  .topbar, .no-print, #toast, .btn-row, .page-head .btn-row { display: none !important; }
  body, html { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  .card { border: none; box-shadow: none; padding: 0; }
  .stub { border: none; padding: 0; }
  .table-wrap { border: none; overflow: visible; }
  th { background: #eee !important; color: #000; }
  .print-break { page-break-after: always; }
  a { color: #000; text-decoration: none; }
}
.print-only { display: none; }
@media print { .print-only { display: block; } }
@media (max-width: 600px) {
  th, td { padding: .4rem .35rem; }
  table { font-size: .85rem; }
  .day-name { white-space: normal; width: 4.2rem; }
  th { font-size: .7rem; letter-spacing: 0; white-space: normal; }
  .clock-time { font-size: 2.4rem; }
}
@media (max-width: 600px) { .stub { padding: .7rem; } .stub th, .stub td { padding: .3rem .25rem; } }
