:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #1d4ed8;
  --brand-ink: #ffffff;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --bad: #b91c1c;
  --bad-bg: #fef2f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17;
    --card: #151b26;
    --ink: #f3f4f6;
    --muted: #9ca3af;
    --line: #263043;
    --brand: #3b82f6;
    --ok: #34d399;
    --ok-bg: #062b22;
    --warn: #fbbf24;
    --warn-bg: #2b2108;
    --bad: #f87171;
    --bad-bg: #2d1212;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.top .who { min-width: 0; }
.top .biz { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .sub { color: var(--muted); font-size: 0.85rem; }
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 96px); display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.center { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.hero { width: 100%; max-width: 420px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; text-align: center; }
.logo { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto; display: block; }
.muted { color: var(--muted); }
.small { font-size: 0.87rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card > h2 { margin-bottom: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 11px 16px; border-radius: 12px; font-weight: 600; cursor: pointer; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn:focus-visible, .row:focus-visible, .tab:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand); padding-inline: 8px; }
.btn.block { width: 100%; }
.btn.big { width: 100%; min-height: 64px; font-size: 1.2rem; border-radius: 16px; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row.end { justify-content: flex-end; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: #fff transparent #fff transparent; animation: spin 0.8s linear infinite;
}
.btn.busy:not(.primary):not(.danger)::after { border-color: var(--ink) transparent var(--ink) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.status { text-align: center; display: grid; gap: 10px; padding: 22px 16px; }
.status-label { font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.8rem; color: var(--muted); }
.status.on { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.status.on .status-label { color: var(--ok); }
.timer { font-size: 3.2rem; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.timer.dim { color: var(--muted); }
.loc { font-size: 0.92rem; color: var(--muted); min-height: 1.4em; }
.loc.ok { color: var(--ok); }
.loc.warn { color: var(--warn); }
.loc.bad { color: var(--bad); }

.note { border-radius: 12px; padding: 12px 14px; border: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.note.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.note.bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.note.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }

.list { display: grid; }
.row {
  appearance: none; background: none; border: 0; border-top: 1px solid var(--line); width: 100%; text-align: left;
  padding: 12px 2px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: inherit;
}
button.row { cursor: pointer; }
.list > .row:first-child { border-top: 0; }
.row .main { min-width: 0; display: grid; gap: 2px; }
.row .name { font-weight: 600; overflow-wrap: anywhere; }
.row .sub { color: var(--muted); font-size: 0.88rem; }
.row .num { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.day { font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 14px 2px 4px; }
.badge { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--ink); vertical-align: middle; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.empty { color: var(--muted); padding: 10px 2px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs-inner { display: flex; width: 100%; max-width: 760px; }
.tab { flex: 1; appearance: none; background: none; border: 0; padding: 10px 2px 9px; font-size: 0.78rem; font-weight: 600; color: var(--muted); cursor: pointer; display: grid; gap: 2px; justify-items: center; position: relative; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--brand); }
.tab .dot { position: absolute; top: 6px; left: calc(50% + 8px); min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; background: var(--bad); color: #fff; font-size: 0.7rem; line-height: 18px; }

form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
label { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; font-weight: 600; font-size: 0.9rem; }
label .hint { font-weight: 400; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 16px; min-height: 44px;
}
input, select, textarea { min-width: 0; max-width: 100%; }
input[type="date"], input[type="datetime-local"] { -webkit-appearance: none; appearance: none; }
input::-webkit-date-and-time-value { text-align: left; }
textarea { min-height: 72px; resize: vertical; }
input[type="range"] { padding: 0; border: 0; min-height: 32px; accent-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.filters .wide { grid-column: 1 / -1; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 6px; border-top: 1px solid var(--line); }
thead th { border-top: 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; border-top: 2px solid var(--ink); }
.table-scroll { overflow-x: auto; }

#map { height: 300px; border-radius: 12px; border: 1px solid var(--line); overflow: hidden; background: var(--line); display: grid; place-items: center; color: var(--muted); text-align: center; padding: 0; z-index: 0; }

.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.45); display: grid; align-items: end; justify-items: center; }
.sheet { background: var(--card); width: 100%; max-width: 520px; max-height: 92dvh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px); display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 640px) { .overlay { align-items: center; } .sheet { border-radius: 18px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

#toast { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 10px); z-index: 30; display: grid; justify-items: center; pointer-events: none; padding: 0 16px; }
.toast { background: #111827; color: #fff; padding: 12px 16px; border-radius: 12px; max-width: 520px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); font-weight: 500; }
.toast.bad { background: #991b1b; }

.print-only { display: none; }
@media print {
  .top, .tabs, .no-print, #toast, #modal { display: none !important; }
  body { background: #fff; color: #000; }
  .wrap { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .print-only { display: block; }
}
