:root {
  --bg: #f5f7fa; --panel: #fff; --ink: #172234; --muted: #627083; --line: #e1e6ed; --line2: #eef1f5;
  --brand: #1f5fbf; --brand-soft: #e8f0fb; --ok: #127a49; --ok-soft: #e3f4ea; --warn: #9a5200; --warn-soft: #fdf1e2;
  --bad: #b3261e; --bad-soft: #fbe9e7; --info: #3c4e9e; --info-soft: #eceffb;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
[x-cloak] { display: none !important; }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 19px; margin: 0 0 12px; } h3 { font-size: 15px; margin: 20px 0 10px; }
input, select, button { font: inherit; color: inherit; }
input, select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
input:focus, select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
label.inline { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Menlo, monospace; }
.err { color: var(--bad); min-height: 18px; margin-top: 8px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 14px; line-height: 1.5; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { border-color: #c9d1dc; }
label.btn { flex-direction: row; color: var(--ink); font-size: 14px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: #f0c9c5; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.block { width: 100%; padding: 11px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 18px; }
.row.gap { margin-top: 18px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(360px, 100%); background: var(--panel); padding: 32px; border-radius: 14px; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin-bottom: 6px; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #142033; color: #c8d2e0; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.logo { color: #fff; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; }
.nav { display: flex; justify-content: space-between; align-items: center; color: inherit; text-decoration: none; padding: 9px 10px; border-radius: 8px; margin-bottom: 2px; }
.nav:hover { background: rgba(255,255,255,.06); }
.nav.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.badge { background: #e5484d; color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 10px; font-size: 13px; }
.side-foot a { color: #9fb0c6; text-decoration: none; } .side-foot a:hover { color: #fff; }
.who { color: #fff; margin-bottom: 4px; }

.main { padding: 26px 30px 60px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.sub { color: var(--muted); margin-top: 4px; }
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; background: var(--panel); padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.search { min-width: 260px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; color: var(--muted); text-decoration: none; }
.tile .n { font-size: 30px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.tile.ok .n { color: var(--ok); } .tile.warn .n { color: var(--warn); } .tile.bad .n { color: var(--bad); } .tile.link .n { color: var(--brand); }
.devices { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

table.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.grid th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #fafbfc; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.grid tbody tr:last-child td { border-bottom: none; }
.grid tfoot td { font-weight: 700; border-top: 1px solid var(--line); background: #fafbfc; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid tr.click { cursor: pointer; } .grid tr.click:hover td { background: #f7f9fc; }
.grid tr.voided td { color: #9aa5b3; text-decoration: line-through; text-decoration-color: #c5ccd6; }
.grid tr.voided td .btn { text-decoration: none; }
.grid .actions { white-space: nowrap; text-align: right; }
.grid .actions .btn { margin-left: 4px; }
.empty { text-align: center; color: var(--muted); padding: 30px !important; }
.scroll-x { overflow-x: auto; }
.roster td.cell { cursor: pointer; text-align: center; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 110px; }
.roster td.cell:hover { background: var(--brand-soft); }

.pill, .flag { display: inline-block; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: var(--line2); color: var(--muted); margin: 0 4px 4px 0; }
.pill.ok, .flag.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn, .flag.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad, .flag.bad { background: var(--bad-soft); color: var(--bad); }
.flag.info { background: var(--info-soft); color: var(--info); }

.export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.export { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.export h3 { margin: 0 0 6px; } .export p { color: var(--muted); line-height: 1.5; min-height: 60px; }

.drawer { position: fixed; inset: 0; background: rgba(20, 32, 51, .35); display: flex; justify-content: flex-end; z-index: 20; }
.drawer-body { width: min(560px, 100%); background: var(--panel); height: 100%; overflow: auto; padding: 24px; box-shadow: -20px 0 50px rgba(20, 32, 51, .2); }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.kv div { background: var(--bg); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.kv span { color: var(--muted); font-size: 12px; } .kv b { font-size: 18px; font-variant-numeric: tabular-nums; }
.punch-list { display: flex; flex-direction: column; gap: 10px; }
.punch { display: flex; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.punch.voided { opacity: .55; }
.ph { width: 96px; height: 72px; border-radius: 8px; background: var(--bg); display: grid; place-items: center; overflow: hidden; flex: none; cursor: zoom-in; }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.pinfo { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.modal-bg { position: fixed; inset: 0; background: rgba(20, 32, 51, .45); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; padding: 24px; width: min(520px, 100%); max-height: 90vh; overflow: auto; }
.modal form > label, .modal > div > label { margin-top: 12px; }
.modal .row label { flex: 1; margin-top: 12px; }
.big-code { font-size: 40px; font-weight: 800; letter-spacing: 6px; text-align: center; padding: 18px; background: var(--bg); border-radius: 12px; margin: 10px 0; font-variant-numeric: tabular-nums; }
.small-code { font-size: 15px; letter-spacing: 0; word-break: break-all; font-weight: 600; }
.photo { width: 100%; border-radius: 10px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #142033; color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.2); }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 10px; }
  .logo { width: 100%; padding-bottom: 6px; }
  .side-foot { flex-direction: row; width: 100%; margin-top: 6px; }
  .main { padding: 18px 14px 40px; }
  .grid { display: block; overflow-x: auto; }
  .kv { grid-template-columns: repeat(2, 1fr); }
}

.pair { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.pair-qr { width: 200px; height: 200px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; flex: none; }
.pair-qr img { width: 100%; height: 100%; display: block; }
.pair-info { flex: 1; min-width: 220px; }
.pair-info p { margin: 0 0 10px; line-height: 1.5; }
.modal { width: min(600px, 100%); }
