:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #17202b;
  --muted: #687385;
  --line: #e2e6ec;
  --accent: #0f5fa8;
  --accent-soft: #e3eefa;
  --pos: #1b7f4b;
  --neg: #c0392b;
  --warn: #b26a00;
  --vac: #2f80c4;
  --sick: #c0392b;
  --tele: #7a4fc4;
  --hol: #1b7f4b;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141a;
    --surface: #18202a;
    --text: #e8edf3;
    --muted: #93a0b2;
    --line: #2a3542;
    --accent: #5aa7ec;
    --accent-soft: #1b2e44;
    --pos: #4cc38a;
    --neg: #ef6b5e;
    --warn: #f0a640;
    --vac: #5aa7ec;
    --sick: #ef6b5e;
    --tele: #a98bf0;
    --hol: #4cc38a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }

.top {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 1.15rem; }
.sync { border: 0; border-radius: 999px; padding: 4px 10px; font-size: .78rem; background: var(--accent-soft); color: var(--muted); }
.sync.ok::before { content: "● "; color: var(--pos); }
.sync.busy::before { content: "↻ "; }
.sync.warn { color: var(--warn); }

.view { max-width: 640px; margin: 0 auto; padding: 12px 16px calc(84px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 2;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { display: grid; justify-items: center; padding: 8px 0 10px; font-size: .75rem; color: var(--muted); }
.tabs .ico { font-size: 1.25rem; line-height: 1.2; }
.tabs a.active { color: var(--accent); font-weight: 600; }

.pager { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; text-align: center; }
.pager > a { font-size: 1.8rem; line-height: 44px; height: 44px; border-radius: 50%; }
.pager > a:active { background: var(--accent-soft); }
.pager strong { display: block; font-size: 1.05rem; }
.pager small { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card h2 { margin: 0 0 10px; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.muted { color: var(--muted); font-size: .88rem; margin: 6px 0 0; }
.notice { background: var(--accent-soft); border-radius: var(--radius); padding: 10px 14px; margin: 0; }

.clock { display: grid; justify-items: center; gap: 6px; }
.clockbtn {
  width: 100%; border: 0; border-radius: var(--radius); padding: 22px; font-size: 1.35rem; font-weight: 700;
  color: #fff; background: var(--accent); box-shadow: 0 2px 8px rgb(0 0 0 / .12);
}
.clockbtn.out { background: var(--neg); }
.clockbtn:active { transform: scale(.98); }
.running { margin: 0; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 520px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 2px; min-width: 0; }
.tile .label { font-size: .75rem; color: var(--muted); }
.tile .value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: .75rem; color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

.slots { display: grid; gap: 8px; margin-bottom: 10px; }
.slot { display: grid; grid-template-columns: 1fr auto 1fr 3.2em 36px; gap: 6px; align-items: center; }
.slot .dash { color: var(--muted); }
.slot .dur { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }

input, textarea {
  width: 100%; font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; min-height: 42px;
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn { display: inline-block; border: 0; border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600; background: var(--accent); color: #fff; text-align: center; cursor: pointer; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.small { padding: 9px 10px; min-height: 42px; }
.btn.wide { width: 100%; }
.icon { border: 0; background: none; color: var(--muted); font-size: 1rem; width: 36px; height: 36px; border-radius: 50%; }
.icon:active { background: var(--accent-soft); }

.flags { display: grid; grid-template-columns: 1fr auto auto; gap: 8px 6px; align-items: center; }
.flags > :last-child { grid-column: span 2; }
.chip { border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: .9rem; min-width: 64px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.list { padding: 4px 0; }
.row { display: grid; grid-template-columns: 3.4em 1fr auto; gap: 10px; align-items: center; padding: 10px 14px; color: inherit; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row.current { background: var(--accent-soft); }
.row.weekend .d, .row.future { opacity: .55; }
.row .d strong { display: block; }
.row small { display: block; color: var(--muted); font-size: .75rem; }
.row .info { display: flex; flex-wrap: wrap; gap: 4px 6px; min-width: 0; font-size: .88rem; }
.row .times { font-variant-numeric: tabular-nums; width: 100%; }
.row .rem { color: var(--muted); font-size: .8rem; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.row .num small { font-weight: 500; }
.row.head { font-size: .75rem; color: var(--muted); padding-top: 6px; padding-bottom: 6px; }

.badge { font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; color: #fff; }
.badge.vac { background: var(--vac); }
.badge.sick { background: var(--sick); }
.badge.tele { background: var(--tele); }
.badge.hol { background: var(--hol); }

.weeks .row { grid-template-columns: 3.4em 1fr 5.5em; }
.bar { position: relative; height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; display: flex; }
.bar .fill { background: var(--accent); }
.bar .credit { background: var(--accent); opacity: .35; }
.bar .target { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); opacity: .6; }

.form { display: grid; gap: 10px; }
label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
.card > label + .btn { margin-top: 10px; }
.buttons { display: grid; gap: 8px; }
.file { cursor: pointer; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
