:root {
  --paper: #E9ECEF;
  --panel: #FFFFFF;
  --ink: #17202A;
  --muted: #5B6672;
  --line: #D3D8DE;
  --soft: #F5F6F8;
  --brass: #9C7F45;
  --ok: #1E9B57;    --ok-bg: #E3F3EA;   --ok-ink: #14693B;
  --warn: #C98410;  --warn-bg: #FBEFD9; --warn-ink: #85560A;
  --bad: #BE3A31;   --bad-bg: #F7E7E5;  --bad-ink: #8E2A23;
  --nav-h: 64px;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0F1419; --panel: #182028; --ink: #E6EAEE; --muted: #97A2AE; --line: #2A3540; --soft: #1F2933;
    --ok-bg: #173527; --ok-ink: #7FD8A6; --warn-bg: #3A2C12; --warn-ink: #F1C26B; --bad-bg: #3B1C1A; --bad-ink: #F2A39C;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 16px/1.45 var(--ui); color: var(--ink); background: var(--paper); -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.boot { padding: 40vh 0 0; text-align: center; color: var(--muted); }

.btn { border: 1px solid var(--line); background: var(--panel); padding: 10px 16px; border-radius: 10px; cursor: pointer; min-height: 44px; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: 14px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--panel); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.link { border: 0; background: none; color: var(--brass); padding: 0; font-size: 14px; cursor: pointer; }
.x { border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; padding: 6px 10px; border-radius: 8px; cursor: pointer; }

/* ---------- login ---------- */
.auth { max-width: 420px; margin: 0 auto; padding: max(48px, env(safe-area-inset-top)) 16px 24px; }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.brand img { border-radius: 14px; }
.brand h1 { font-size: 28px; }

/* ---------- screen + bottom nav ---------- */
.screen { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); max-width: 760px; margin: 0 auto; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 12px) 16px 12px; background: var(--paper); border-bottom: 1px solid var(--line); }
.top .title { flex: 1; min-width: 0; text-align: center; display: flex; flex-direction: column; align-items: center; }
.top h1 { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--panel); font-size: 24px; line-height: 1; cursor: pointer; }
.icon-btn:disabled { opacity: .35; }
.pad { padding: 14px 16px; }

nav.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.bottom button { flex: 1; max-width: 200px; height: var(--nav-h); border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 12px; cursor: pointer; }
nav.bottom svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav.bottom [aria-current="page"] { color: var(--ink); font-weight: 600; }
nav.bottom [aria-current="page"] svg { stroke: var(--brass); }

/* ---------- cards + forms ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; display: grid; gap: 12px; }
.card h2 { font-size: 17px; }
.card h3 { font-size: 15px; margin-top: 4px; }
.card p { margin: 0; }
.card label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.card input, .card select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); min-height: 44px; }
.hint { color: var(--muted); font-size: 14px; }
.err-text { color: var(--bad); margin: 0; min-height: 1.2em; font-size: 14px; }
.copy { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--soft); border-radius: 10px; padding: 10px 12px; }
.copy span { display: grid; gap: 2px; min-width: 0; }
.copy small { color: var(--muted); font-size: 13px; }
.copy code { font: 15px/1.35 ui-monospace, Consolas, monospace; word-break: break-all; }
.steps ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.row-btns .btn { flex: 1 1 150px; }

.banner { margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner.bad { background: var(--bad-bg); color: var(--bad-ink); }
.status-line { margin: 0 0 14px; font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px rgba(30, 155, 87, .6); }

/* ---------- today ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px; display: flex; flex-direction: column; align-items: center; }
.tile b { font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { font-size: 12.5px; color: var(--muted); }
.tile.ok b { color: var(--ok); }
.tile.warn b { color: var(--warn); }
.tile.bad b { color: var(--bad); }

.people, .punches, .devices { list-style: none; margin: 0; padding: 0; }
.person { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; display: grid; gap: 8px; }
.person.is-warn { border-left-color: var(--warn); }
.person.is-bad { border-left-color: var(--bad); }
.person .who { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.shift { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.shift .when { color: var(--muted); min-width: 92px; }
.shift .tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.tag { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12.5px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok-ink); }
.tag.warn { background: var(--warn-bg); color: var(--warn-ink); }
.tag.bad { background: var(--bad-bg); color: var(--bad-ink); }

.section { font-size: 16px; margin: 22px 0 8px; }
.punches { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.punches li { display: flex; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 15px; }
.punches li:last-child { border-bottom: 0; }
.punches time { font-variant-numeric: tabular-nums; font-weight: 600; }
.punches li span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); padding: 18px 4px; margin: 0; }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }

/* ---------- alerts ---------- */
.modes { display: grid; gap: 8px; }
.mode { display: flex !important; grid-template-columns: none; gap: 12px !important; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--ink) !important; }
.mode input { width: 20px !important; height: 20px; min-height: 0 !important; margin: 2px 0 0; accent-color: var(--ink); flex: none; }
.mode span { display: grid; gap: 2px; }
.mode b { font-size: 15px; }
.mode small { color: var(--muted); font-size: 13px; }
.mode:has(input:checked) { border-color: var(--brass); background: var(--soft); }
.times { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.time-chip { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding-left: 4px; background: var(--panel); }
.time-chip input { border: 0 !important; width: auto !important; min-height: 40px !important; padding: 6px !important; background: none !important; }
.inline-label { margin-top: 4px; }

.devices li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.devices li:last-child { border-bottom: 0; }
.devices small { display: block; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); max-width: 460px; margin: 0 auto; background: var(--ink); color: var(--panel); padding: 12px 16px; border-radius: 12px; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none; z-index: 20; text-align: center; }
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--bad); color: #fff; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

@media (min-width: 700px) {
  .top h1 { font-size: 22px; }
  .tile b { font-size: 30px; }
}
