:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #16191f;
  --muted: #5f6672;
  --line: #e3e6eb;
  --brand: #0f6b5c;
  --brand-ink: #ffffff;
  --brand-soft: #e3f2ef;
  --ok: #157f3b;
  --ok-soft: #e4f4ea;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --info: #1d4ed8;
  --info-soft: #e5edfd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --surface: #1a1e24; --ink: #e8eaed; --muted: #9aa1ac; --line: #2c323b;
    --brand: #3fb59f; --brand-ink: #0b1513; --brand-soft: #173430;
    --ok: #4cc27a; --ok-soft: #173322; --warn: #e3a948; --warn-soft: #3a2c12;
    --bad: #f07167; --bad-soft: #3d1c1a; --info: #7aa2f7; --info-soft: #1b2640;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
p { margin: .4rem 0 .9rem; }
small, .muted { color: var(--muted); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }

/* Layout */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem; padding: 0 16px; min-height: 56px; flex-wrap: wrap;
}
.topbar .brand { font-weight: 700; color: var(--ink); white-space: nowrap; }
.topbar .brand span { color: var(--brand); }
.topbar nav { display: flex; gap: .15rem; flex-wrap: wrap; flex: 1; }
.topbar nav a {
  color: var(--muted); padding: .4rem .65rem; border-radius: 6px; font-size: .92rem; white-space: nowrap;
}
.topbar nav a:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.topbar nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.topbar .user { display: flex; align-items: center; gap: .6rem; font-size: .9rem; color: var(--muted); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }
.narrow { max-width: 560px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; background: var(--bg); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.voided td { color: var(--muted); text-decoration: line-through; }

/* Badges */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); 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(--info-soft); color: var(--info); border-color: transparent; }

/* Forms */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3rem; }
.field { margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
textarea { min-height: 90px; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.check input { width: auto; }
.inline { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline .field { margin-bottom: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: .3rem .6rem; font-size: .85rem; }
.btn.block { width: 100%; }
.error { color: var(--bad); font-size: .85rem; margin-top: .25rem; }

/* Alerts */
.alert { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid transparent; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert ul { margin: .3rem 0 0 1.1rem; padding: 0; }

details summary { cursor: pointer; font-weight: 600; }
.pre { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px; font-size: .9rem; max-height: 420px; overflow: auto; }
.pagination { margin-top: 14px; }
.pagination nav { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* Kiosk & self-service */
.kiosk { min-height: 100vh; display: flex; flex-direction: column; }
.kiosk header { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); background: var(--surface); }
.kiosk main { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 24px; align-items: start; }
@media (max-width: 760px) { .kiosk main { grid-template-columns: 1fr; } }
.clock-big { font-size: clamp(3rem, 9vw, 5.5rem); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button { font-size: 1.6rem; padding: 18px 0; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.keypad button:active { background: var(--brand-soft); }
.result { padding: 20px; border-radius: 14px; font-size: 1.3rem; font-weight: 700; text-align: center; }
.result.ok { background: var(--ok-soft); color: var(--ok); }
.result.bad { background: var(--bad-soft); color: var(--bad); }
video.scanner { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 4/3; object-fit: cover; }
.big-action { font-size: 1.25rem; padding: 1.1rem; border-radius: 14px; }

@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
