:root {
  --bg: #f4f5f7; --panel: #ffffff; --ink: #14171f; --muted: #5d6470; --line: #d9dde3; --soft: #eceff3;
  --accent: #1f5fd6; --accent-ink: #ffffff; --accent-soft: #e3ecfc;
  --ok: #127a3a; --ok-soft: #e1f4e8; --warn: #9a5b00; --warn-soft: #fdf0d8; --bad: #b42318; --bad-soft: #fde7e5;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --panel: #171b23; --ink: #e8eaee; --muted: #9aa3b2; --line: #2b313d; --soft: #222833;
    --accent: #6ea0ff; --accent-ink: #0b1220; --accent-soft: #1b2a47;
    --ok: #5fd08a; --ok-soft: #133022; --warn: #f2b44a; --warn-soft: #3a2b10; --bad: #ff8278; --bad-soft: #3d1715;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --panel: #171b23; --ink: #e8eaee; --muted: #9aa3b2; --line: #2b313d; --soft: #222833;
  --accent: #6ea0ff; --accent-ink: #0b1220; --accent-soft: #1b2a47;
  --ok: #5fd08a; --ok-soft: #133022; --warn: #f2b44a; --warn-soft: #3a2b10; --bad: #ff8278; --bad-soft: #3d1715;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 18px; margin: 22px 0 10px; }
h3 { font-size: 15px; }
p { margin: 6px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Shell ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: -.01em; text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.brand img { width: 26px; height: 26px; }
.brand small { font-weight: 500; color: var(--muted); }
.top .spacer { flex: 1; }
.persona { display: flex; align-items: center; gap: 6px; }
.persona select, .top select { min-height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 0 10px; font: inherit; max-width: 290px; }
.clock { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.clock .time { font-weight: 700; }
.clock .shifted { color: var(--warn); font-size: 12px; font-weight: 600; }
.bell { position: relative; }
.bell .count { position: absolute; top: -4px; right: -4px; background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 4px; font-weight: 700; }
.demo-banner { background: var(--warn-soft); color: var(--warn); font-size: 13px; padding: 6px 16px; border-bottom: 1px solid var(--line); }
.demo-banner b { color: inherit; }

.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: calc(100vh - 90px); }
.side { border-right: 1px solid var(--line); background: var(--panel); padding: 12px; position: sticky; top: 54px; height: calc(100vh - 54px); overflow: auto; }
.side h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 14px 8px 6px; }
.side a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--ink); text-decoration: none; }
.side a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.side a:hover { background: var(--soft); }
.side .badge { margin-left: auto; }
main { padding: 20px 24px 100px; max-width: 1100px; width: 100%; }
main:focus { outline: none; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  main { padding: 14px 16px 96px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 25; background: var(--panel); border-top: 1px solid var(--line); padding: 4px 0 calc(8px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; padding: 6px 2px; min-height: 48px; }
  .tabbar a[aria-current="page"] { color: var(--accent); font-weight: 700; }
  .tabbar .ico { font-size: 20px; line-height: 1; }
  .top { padding: 8px 12px; }
  .brand small { display: none; }
  .persona select { max-width: 160px; }
  .hide-sm { display: none !important; }
}

/* ---------- Components ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; box-shadow: var(--shadow); }
.card.hl { background: var(--accent-soft); border-color: transparent; }
.card.urgent { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad) inset; }
.card.warn { border-color: var(--warn); }
.card.ok { border-color: var(--ok); }
.card.dashed { border-style: dashed; box-shadow: none; }
.card h3 { margin-bottom: 4px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.stack > * + * { margin-top: 8px; }
.grid { display: grid; gap: 12px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .grid.c2, .grid.c3 { grid-template-columns: minmax(0, 1fr); } .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.mt0 { margin-top: 0; }
.mt { margin-top: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { min-width: 40px; min-height: 40px; padding: 0 10px; }

.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
.chip[aria-pressed="true"], a.chip[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--ink); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

.avatars { display: inline-flex; align-items: center; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--soft); border: 2px solid var(--panel); display: inline-grid; place-items: center; font-size: 11px; font-weight: 800; margin-left: -7px; color: var(--ink); }
.avatar:first-child { margin-left: 0; }

.days { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.days.ten { grid-template-columns: repeat(10, minmax(64px, 1fr)); overflow-x: auto; padding-bottom: 4px; }
@media (max-width: 860px) { .days.ten { grid-template-columns: repeat(10, 64px); } }
.day { text-decoration: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 10px; padding: 8px 4px; text-align: center; font: inherit; font-size: 12px; cursor: pointer; min-height: 64px; }
.day b { display: block; font-size: 15px; }
.day[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 1px; background: var(--accent-soft); }
.day .bar { height: 5px; border-radius: 3px; background: var(--soft); margin: 5px 4px 3px; overflow: hidden; }
.day .bar i { display: block; height: 100%; background: var(--accent); }
.day .bar.full i { background: var(--bad); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-bottom: 1px solid var(--soft); }
.list > li:last-child { border-bottom: 0; }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--soft); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.table-wrap { overflow-x: auto; }

label.field, .field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.field > span { font-size: 13px; font-weight: 650; }
.field input, .field select, .field textarea, input.inline, select.inline { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; background: var(--panel); color: var(--ink); width: 100%; }
.field textarea { min-height: 80px; }
.field .hint { font-size: 12px; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; }
.check input { width: 20px; height: 20px; margin-top: 1px; flex: none; }
details > summary { cursor: pointer; font-weight: 650; padding: 6px 0; }

.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 13px; color: var(--muted); }
.meter { height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; min-width: 80px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.alt i { background: var(--ok); }
.meter.grey i { background: var(--muted); }

.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); }

/* Sheet / Dialog */
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 22, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--panel); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 18px 18px calc(22px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; box-shadow: 0 -10px 40px rgba(0, 0, 0, .25); }
@media (min-width: 861px) { .scrim { align-items: center; } .sheet { border-radius: 18px; } }
.sheet .grab { width: 44px; height: 4px; background: var(--line); border-radius: 2px; margin: 0 auto 12px; }
.sheet .big { font-size: 40px; line-height: 1; }

.toast-area { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(560px, calc(100% - 32px)); }
.toast { background: var(--ink); color: var(--panel); border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.toast .btn { min-height: 34px; background: transparent; color: var(--panel); border-color: color-mix(in srgb, var(--panel) 40%, transparent); }
@media (min-width: 861px) { .toast-area { bottom: 24px; } }

/* Plan */
.plan { width: 100%; height: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.plan .zone-rect { fill: var(--soft); stroke: var(--line); }
.plan .zone-label { fill: var(--muted); font-size: 12px; font-weight: 700; }
.plan .desk { cursor: pointer; }
.plan .desk rect { stroke-width: 2; }
.plan .desk.free rect { fill: var(--panel); stroke: var(--ok); }
.plan .desk.taken rect { fill: var(--soft); stroke: var(--line); }
.plan .desk.team rect { fill: var(--accent-soft); stroke: var(--accent); }
.plan .desk.mine rect { fill: var(--accent); stroke: var(--accent); }
.plan .desk.locked rect { fill: var(--bad-soft); stroke: var(--bad); }
.plan .desk.held rect { fill: var(--warn-soft); stroke: var(--warn); stroke-dasharray: 4 3; }
.plan .desk text { font-size: 10px; fill: var(--muted); pointer-events: none; }
.plan .desk .mark { fill: var(--ink); }
.plan .desk.mine .mark { fill: var(--accent-ink); }
.plan .desk:focus { outline: none; }
.plan .desk:focus rect, .plan .desk.sel rect { stroke: var(--ink); stroke-width: 3; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin: 8px 0; }

/* Kiosk & Gast */
body.kiosk-mode .top, body.kiosk-mode .side, body.kiosk-mode .tabbar, body.kiosk-mode .demo-banner,
body.guest-mode .top, body.guest-mode .side, body.guest-mode .tabbar, body.guest-mode .demo-banner { display: none; }
body.kiosk-mode .layout, body.guest-mode .layout { display: block; min-height: 100vh; }
body.kiosk-mode main { max-width: 980px; margin: 0 auto; padding: 32px 24px; }
body.guest-mode main { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; }
.kiosk-hero { text-align: center; padding: 20px 0; }
.kiosk-hero h1 { font-size: 34px; }
.kiosk-big { min-height: 120px; font-size: 22px; border-radius: 16px; }
.code-input { font-size: 32px !important; letter-spacing: .3em; text-transform: uppercase; text-align: center; font-variant-numeric: tabular-nums; }
.pseudo-qr { width: 168px; height: 168px; margin: 8px auto; display: grid; grid-template-columns: repeat(21, 1fr); background: #fff; padding: 8px; border-radius: 8px; border: 1px solid var(--line); }
.pseudo-qr i { background: #000; }
.pseudo-qr i.o { background: #fff; }
.guest-code { font-size: 28px; font-weight: 800; letter-spacing: .25em; text-align: center; font-variant-numeric: tabular-nums; }
.demo-note { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 28px; padding-top: 10px; }

.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { padding: 4px 0 8px 12px; position: relative; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

.clock-panel { display: grid; gap: 8px; }
.notice { font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--soft); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }

.badge-print { display: none; }
@media print {
  body * { visibility: hidden; }
  .badge-print, .badge-print * { visibility: visible; }
  .badge-print { display: block; position: fixed; left: 0; top: 0; width: 89mm; padding: 6mm; border: 1px solid #000; font-family: var(--font); color: #000; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
