:root {
  --bg: #f3f5f8; --card: #fff; --text: #17202c; --muted: #647084; --line: #e1e6ee; --field: #fff;
  --accent: #0b5cad; --accent-soft: #e6f0fb; --accent-text: #fff;
  --ok: #15803d; --ok-bg: #e3f6e9; --bad: #b42318; --bad-bg: #fdeceb; --warn-bg: #fdf3d3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f141a; --card: #171d26; --text: #e7ebf1; --muted: #94a0b3; --line: #2a3340; --field: #111720;
    --accent: #5aa5ee; --accent-soft: #17293d; --accent-text: #08111c;
    --ok: #4ade80; --ok-bg: #11301f; --bad: #f97066; --bad-bg: #391613; --warn-bg: #3a2f10;
    --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- top bar ---- */
header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1.25rem; height: 56px; padding: 0 max(1rem, calc((100% - 1100px) / 2 + 1rem)); background: var(--card); border-bottom: 1px solid var(--line); }
header a:hover { text-decoration: none; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.05rem; color: var(--text); white-space: nowrap; }
.brand svg { color: var(--accent); width: 1.4em; height: 1.4em; }
nav.main { display: flex; gap: .25rem; align-self: stretch; }
nav.main a { display: flex; align-items: center; gap: .4rem; padding: 0 .75rem; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; border-top: 2px solid transparent; }
nav.main a:hover { color: var(--text); }
nav.main a.active { color: var(--accent); border-bottom-color: var(--accent); }
nav.main svg { display: none; }
header .right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.menu { position: relative; }
.menu summary { list-style: none; display: flex; align-items: center; gap: .5rem; padding: .4rem .7rem; border-radius: 8px; cursor: pointer; font-weight: 500; color: var(--muted); user-select: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: ""; width: .4em; height: .4em; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg) translateY(-2px); }
.menu summary:hover, .menu[open] summary { background: var(--bg); color: var(--text); }
.menu summary.active { color: var(--accent); }
.avatar { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .9rem; }
.pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; padding: .35rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(16, 24, 40, .14); }
.pop a, .pop button { display: block; width: 100%; padding: .5rem .7rem; border: 0; border-radius: 7px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.pop a:hover, .pop button:hover { background: var(--bg); }
.pop a.active { color: var(--accent); font-weight: 600; }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: .3rem 0; }
.pop form { margin: 0; }

/* ---- layout ---- */
main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: .95rem; margin: 1.1rem 0 .3rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.muted { color: var(--muted); font-size: .88rem; }
.small { font-size: .8rem; font-weight: 400; margin-left: .5rem; }
.flash { padding: .7rem 1rem; border-radius: 10px; background: var(--ok-bg); border-left: 4px solid var(--ok); margin: 0 0 1rem; }
.flash.error { background: var(--bad-bg); border-left-color: var(--bad); }
code { word-break: break-all; background: var(--bg); padding: .25rem .45rem; border-radius: 6px; font-size: .9em; }

/* ---- forms ---- */
label { display: block; margin: .7rem 0; font-size: .82rem; font-weight: 500; color: var(--muted); flex: 1 1 150px; }
label.check { display: flex; align-items: center; gap: .5rem; color: var(--text); font-size: .95rem; font-weight: 400; flex: 0 0 auto; }
input, select, button, .btn { font: inherit; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--text); }
input:focus, select:focus, button:focus-visible, .btn:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label > input:not([type=checkbox]), label > select { display: block; width: 100%; margin-top: .25rem; font-weight: 400; }
input[type=checkbox], input[type=radio] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); flex: none; }
button, .btn { cursor: pointer; display: inline-block; white-space: nowrap; font-weight: 500; background: var(--card); }
button:hover, .btn:hover { border-color: var(--muted); text-decoration: none; }
.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.primary:hover { filter: brightness(1.08); border-color: var(--accent); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 400; }
button.link:hover { text-decoration: underline; }
.danger { color: var(--bad) !important; }
.row { display: flex; flex-wrap: wrap; gap: .6rem .8rem; align-items: flex-end; }
.row label { margin: 0; }
.toolbar { margin: 0 0 1rem; }
.push { margin-left: auto; }

/* ---- tables ---- */
.scroll { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
th { font-size: .72rem; color: var(--muted); font-weight: 600; white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child > td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.zero { color: var(--muted); opacity: .55; }
tr.inactive td { color: var(--muted); }
tr.open td { background: var(--warn-bg); }
.actions { white-space: nowrap; text-align: right; }
.actions form { display: inline; margin-left: .7rem; }
.actions a { margin-left: .7rem; }
td input, td select { padding: .35rem .5rem; }
table.totals { width: auto; margin: 1rem 0 0 auto; }
table.totals td, table.totals th { border: 0; padding: .2rem 0 .2rem 1.5rem; text-transform: none; font-size: 1rem; letter-spacing: 0; color: var(--text); }
.tag { display: inline-block; font-size: .72rem; font-weight: 500; padding: .1rem .5rem; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.tag.approved { background: var(--ok-bg); color: var(--ok); }
.tag.rejected { background: var(--bad-bg); color: var(--bad); }
.tag.pending { background: var(--warn-bg); color: var(--text); }

/* ---- stats & punch clock ---- */
.stats { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.stats > div { flex: 1 1 110px; padding: .7rem .9rem; background: var(--bg); border-radius: 10px; }
.stats span { display: block; font-size: .75rem; color: var(--muted); font-weight: 500; }
.stats strong { font-size: 1.45rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.status { border-top: 4px solid var(--line); }
.status.in { border-top-color: var(--ok); }
.status h1 { font-size: 1.3rem; margin-bottom: .3rem; }
.big { font-size: 1.2rem; margin: .2rem 0 .6rem; }
.punch { width: 100%; padding: 1.1rem; font-size: 1.25rem; font-weight: 700; color: #fff; border: 0; border-radius: 12px; margin: .7rem 0; }
.punch.in { background: #15803d; }
.punch.out { background: #b42318; }
.punch:hover { filter: brightness(1.08); }

/* ---- kiosk ---- */
.kiosk .clock { font-size: 1.4rem; font-variant-numeric: tabular-nums; margin-right: .5rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; }
.tile { display: block; padding: 1.2rem 1rem; background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow); }
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile.in { border-left-color: var(--ok); }
.tile strong { display: block; font-size: 1.15rem; }
.tile span { color: var(--muted); font-size: .9rem; }
.pin { font-size: 1.6rem; letter-spacing: .3em; text-align: center; }

/* ---- phones: primary links become a bottom tab bar ---- */
@media (max-width: 760px) {
  header { gap: .5rem; height: 52px; }
  .brand { overflow: hidden; text-overflow: ellipsis; }
  .uname { display: none; }
  .menu.user summary::after { display: none; }
  .menu.user summary { padding: .2rem; }
  nav.main { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; gap: 0; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  nav.main a { flex: 1; flex-direction: column; justify-content: center; gap: .15rem; padding: .45rem 0 .4rem; font-size: .7rem; border-bottom: 0; }
  nav.main a.active { border-top-color: var(--accent); }
  nav.main svg { display: block; width: 1.4rem; height: 1.4rem; }
  body.has-tabs main { padding-bottom: 5.5rem; }
  main { padding-top: 1rem; }
  h1 { font-size: 1.35rem; }
  .card { padding: 1rem; }
  .scroll { margin: 0 -1rem; padding: 0 1rem; }
  .push { margin-left: 0; }
}
@media print {
  header, .noprint, .flash { display: none !important; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .card { border: 0; box-shadow: none; padding: 0; page-break-after: always; }
}
.sso { display: block; text-align: center; padding: .7rem; }
.or { display: flex; align-items: center; gap: .8rem; color: var(--muted); font-size: .8rem; margin: 1rem 0 .2rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
details.quick > summary { cursor: pointer; font-weight: 600; }
details.quick[open] > summary { margin-bottom: .8rem; }
pre { background: var(--bg); padding: .8rem 1rem; border-radius: 8px; overflow-x: auto; font-size: .85rem; }
