:root {
  --accent: #1a56db;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, #fff);
  --bg: #f4f5f7;
  --surface: #fff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --ok: #047857;  --ok-bg: #ecfdf5;
  --warn: #b45309; --warn-bg: #fffbeb;
  --danger: #b91c1c; --danger-bg: #fef2f2;
  --info: #1d4ed8; --info-bg: #eff6ff;
  --r: 10px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .05), 0 1px 3px rgba(17, 24, 39, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -.015em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.ic { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; }
.side-brand b { display: block; font-size: 14px; }
.side-brand small { color: #94a3b8; font-size: 12px; }
.logo-dot { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); flex: none; box-shadow: inset 0 0 0 6px rgba(255, 255, 255, .22); }
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; flex: 1; overflow-y: auto; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #cbd5e1; font-weight: 500; }
.side-nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.side-nav a.on { background: rgba(255, 255, 255, .1); color: #fff; }
.side-nav a .ic { opacity: .85; }
.side-user { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 18px; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-user b { display: block; color: #fff; font-weight: 600; }
.side-user small { color: #94a3b8; }
.side-user a { color: #94a3b8; }
.main { padding: 22px 28px 60px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head .sub { margin: 2px 0 0; color: var(--muted); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side-nav { flex-direction: row; overflow-x: auto; padding: 0 10px 10px; }
  .side-nav a { white-space: nowrap; }
  .side-nav a span { display: none; }
  .side-nav a.on span { display: inline; }
  .side-user { display: none; }
  .main { padding: 16px; }
}

/* ---------------------------------------------------------------- building blocks */
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--danger-bg); color: var(--danger); }
.flash-info { background: var(--info-bg); color: var(--info); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 550;
  cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: #f9fafb; }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(.95); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-ok { color: var(--ok); border-color: #a7f3d0; }
.btn-sm { height: 28px; padding: 0 9px; font-size: 13px; border-radius: 7px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip .ic { width: 13px; height: 13px; }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-danger { background: var(--danger-bg); color: var(--danger); }
.chip-info { background: var(--info-bg); color: var(--info); }
.chip-muted { background: #f3f4f6; color: var(--muted); }
button.chip { border: 0; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; }

/* ---------------------------------------------------------------- forms */
label.f { display: flex; flex-direction: column; gap: 4px; font-weight: 550; font-size: 13px; }
label.f > small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=datetime-local], input[type=number], input[type=search], input[type=color], select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; min-height: 36px; width: 100%;
}
input[type=color] { padding: 2px; width: 60px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters label.f { min-width: 140px; }
.filters .grow { flex: 1; min-width: 200px; }
fieldset { border: 0; padding: 0; margin: 0 0 22px; }
legend { font-weight: 700; font-size: 15px; margin-bottom: 10px; padding: 0; }
.help { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafafa; white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #fafbfc; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; }
.pg { padding: 6px 10px; border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); }
.pg-info { color: var(--muted); }

/* ---------------------------------------------------------------- today dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 12px 14px; border: 0; text-align: left; font: inherit; cursor: pointer; color: inherit; }
.stat b { display: block; font-size: 26px; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.stat.on { box-shadow: 0 0 0 2px var(--accent); }
.stat.alert b { color: var(--danger); }
.stat.attention b { color: var(--warn); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .search { flex: 1; min-width: 220px; max-width: 360px; }
.kiosk-status { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; margin-right: 5px; }
.dot.on { background: #10b981; box-shadow: 0 0 0 3px #d1fae5; }
.dot.off { background: #ef4444; }

.vlist { display: flex; flex-direction: column; gap: 8px; }
.vrow {
  display: grid; grid-template-columns: 54px minmax(180px, 1.4fr) minmax(150px, 1fr) 110px 360px;
  gap: 14px; align-items: center; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 10px 14px; cursor: pointer; border-left: 4px solid transparent;
}
.vrow:hover { box-shadow: 0 0 0 1px var(--line-strong), var(--shadow); }
.vrow.is-new { animation: newRow 2.5s ease-out; }
@keyframes newRow { from { background: #fef9c3; } }
.vrow.st-on_site { border-left-color: var(--ok); }
.vrow.st-expected { border-left-color: #93c5fd; }
.vrow.st-checked_out { opacity: .72; }
.vrow.alert { border-left-color: var(--danger); background: #fff7f7; }
.thumb { width: 54px; height: 72px; border-radius: 8px; object-fit: cover; background: #e5e7eb; display: grid; place-items: center; color: #6b7280; font-weight: 700; font-size: 15px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vname { font-weight: 650; font-size: 15px; }
.vsub { color: var(--muted); font-size: 13px; }
.vtime { font-variant-numeric: tabular-nums; font-weight: 600; }
.vactions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 1100px) {
  .vrow { grid-template-columns: 54px 1fr auto; }
  .vrow .vhost, .vrow .vtimes { display: none; }
  .vactions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ---------------------------------------------------------------- modal / drawer / toast */
.backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 40; display: flex; justify-content: center; align-items: flex-start; padding: 6vh 16px; overflow-y: auto; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 25px 60px rgba(0, 0, 0, .25); animation: rise .18s ease-out; }
.modal.wide { max-width: 760px; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.x-btn { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }

.drawer-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .3); z-index: 30; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: #fff; z-index: 31; box-shadow: -10px 0 40px rgba(0, 0, 0, .15); display: flex; flex-direction: column; animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.drawer-head .photo { width: 96px; height: 128px; border-radius: 10px; object-fit: cover; background: #e5e7eb; flex: none; display: grid; place-items: center; font-size: 26px; font-weight: 700; color: #6b7280; cursor: zoom-in; overflow: hidden; }
.drawer-head .photo img { width: 100%; height: 100%; object-fit: cover; }
.drawer-head h3 { margin: 2px 0 4px; font-size: 20px; }
.drawer-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.drawer-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0 0 18px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { padding: 0 0 12px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--line-strong); }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .what { font-weight: 600; }
.timeline .det { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.photo-zoom { max-width: min(90vw, 600px); max-height: 85vh; border-radius: 12px; display: block; margin: 0 auto; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast { background: #111827; color: #fff; padding: 12px 14px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: 380px; display: flex; gap: 12px; align-items: center; animation: rise .2s ease-out; }
.toast.ok { background: #065f46; }
.toast.error { background: #991b1b; }
.toast.arrival { background: #fff; color: var(--ink); border-left: 5px solid var(--accent); }
.toast .t-body { flex: 1; }
.toast .t-body b { display: block; }

.autocomplete { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .12); z-index: 50; max-height: 260px; overflow-y: auto; }
.ac-item { padding: 8px 10px; cursor: pointer; }
.ac-item:hover, .ac-item.on { background: var(--accent-soft); }
.ac-item small { display: block; color: var(--muted); }

/* ---------------------------------------------------------------- bars (statistics) */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 48px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 14px; border-radius: 4px; background: var(--accent); min-width: 2px; }
.bar-track { background: #f3f4f6; border-radius: 4px; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.cols { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 10px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.col .c { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.col small { color: var(--muted); font-size: 11px; }
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }

/* ---------------------------------------------------------------- evacuation list */
.roll { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.roll-item { display: flex; gap: 12px; align-items: center; background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 10px; cursor: pointer; user-select: none; }
.roll-item.ok { background: var(--ok-bg); box-shadow: 0 0 0 2px #6ee7b7; }
.roll-item .thumb { width: 48px; height: 64px; }
.roll-item .tick { margin-left: auto; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; color: transparent; flex: none; }
.roll-item.ok .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.roll-count { font-size: 15px; font-weight: 600; }
@media print {
  .side, .head-actions, .no-print { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  body { background: #fff; }
  .roll-item, .card, .table-wrap { box-shadow: none; border: 1px solid #ddd; }
}
