:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #11161c;
  --muted: #6b7682;
  --line: #dde1e6;
  --accent: #2f7de1;
  --danger: #d4443a;
  --ok: #1f9d55;
  --warn: #e08a00;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101418;
    --card: #1a2027;
    --text: #e9edf2;
    --muted: #93a1b0;
    --line: #2a323b;
    --accent: #4f9bf5;
    --danger: #e2574c;
    --ok: #35b26a;
    --warn: #f0a92a;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  padding: 0 0 96px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.top {
  position: sticky; top: 0; z-index: 5;
  padding: 12px 16px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.net { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); transition: background .3s; }
.net.stale { background: var(--warn); }
.net.down { background: var(--danger); }

.tabs { display: flex; gap: 8px; padding: 10px 16px; position: sticky; top: 62px; background: var(--bg); z-index: 4; }
.tab {
  flex: 1; padding: 9px 4px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--muted); font-size: 15px; cursor: pointer;
}
.tab.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.badge { font-size: 12px; opacity: .85; }

main { padding: 4px 16px 16px; }

.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.card.free { border-style: dashed; }
.card.overdue { border-color: var(--danger); }

.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.box-name { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.plate { font-size: 20px; font-weight: 700; letter-spacing: .02em; }
.row { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; }
.row.right { justify-content: flex-end; }
.timer { font-variant-numeric: tabular-nums; }
.timer.over { color: var(--danger); font-weight: 600; }
.timer.tappable { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.sum { font-weight: 700; white-space: nowrap; }

.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn {
  flex: 1; min-width: 92px; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 15px; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.wide { width: 100%; margin-top: 16px; }
.btn:active { opacity: .75; }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; }

.list { display: flex; flex-direction: column; gap: 10px; }
.section { font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 20px 0 8px; }

.fab {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 6;
  padding: 15px; border: none; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); cursor: pointer;
}

.modal {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end;
  background: rgba(0,0,0,.45);
}
.sheet {
  width: 100%; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-radius: 18px 18px 0 0; padding: 14px 16px 24px;
}
@media (min-width: 620px) {
  .modal { align-items: center; justify-content: center; }
  .sheet { max-width: 560px; border-radius: 18px; }
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sheet-foot {
  position: sticky; bottom: 0; display: flex; gap: 12px; align-items: center;
  padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--line); background: var(--bg);
}
.sheet-foot .btn { flex: 0 0 auto; min-width: 140px; }
.total { flex: 1; }
.total.big { font-size: 18px; margin: 10px 0; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select {
  width: 100%; padding: 12px; font-size: 16px; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
#f-plate { text-transform: uppercase; font-weight: 700; letter-spacing: .05em; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--text); font-size: 15px; cursor: pointer;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.services { display: flex; flex-direction: column; gap: 6px; max-height: 42vh; overflow-y: auto; }
.service {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  cursor: pointer;
}
.service.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.service .price { white-space: nowrap; color: var(--muted); font-size: 14px; }
.cat { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 8px 0 2px; }

.suggest {
  margin: -6px 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); overflow: hidden;
}
.suggest-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:active { background: var(--bg); }
.suggest-item b { letter-spacing: .03em; }

.hint { padding: 10px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--accent); margin-bottom: 12px; font-size: 14px; }

.sum-block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.sum-block h3 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.sum-big { font-size: 30px; font-weight: 700; }
.sum-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.sum-row:last-child { border-bottom: none; }

/* --- вкладка «График»: вертикальные полосы боксов --- */

.chart-head, .chart-grid {
  display: grid;
  grid-template-columns: 38px repeat(var(--lanes, 5), 1fr);
  gap: 5px;
}
.chart-head {
  position: sticky; top: 110px; z-index: 3;
  padding: 6px 0; background: var(--bg);
}
.chart-head span {
  font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); text-align: center;
}
.chart-grid { position: relative; }

.hours { position: relative; }
.hours span {
  position: absolute; right: 4px; transform: translateY(-50%);
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
}

.lane {
  position: relative; border: 1px solid var(--line); border-radius: 10px;
  background-color: var(--card);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0, transparent calc(var(--hour) - 1px),
    var(--line) calc(var(--hour) - 1px), var(--line) var(--hour)
  );
}

.slot {
  position: absolute; left: 3px; right: 3px; min-height: 18px;
  border-radius: 7px; padding: 3px 5px; overflow: hidden;
  color: #fff; font-size: 11px; line-height: 1.25; cursor: pointer;
}
.slot b { font-size: 12px; letter-spacing: .02em; }
.slot.in_progress { background: var(--accent); }
/* Запись — ещё не факт, поэтому рамкой. */
.slot.scheduled { background: transparent; border: 1px dashed var(--accent); color: var(--accent); }
.slot.done { background: var(--warn); }
.slot.paid { background: var(--ok); }
.slot.forecast { background-image: repeating-linear-gradient(
  45deg, rgba(255,255,255,.14) 0 6px, transparent 6px 12px); }

.nowline { position: absolute; left: 38px; right: 0; height: 2px; background: var(--danger); }
.nowline::before {
  content: ''; position: absolute; left: -4px; top: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
}

.legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin: 12px 0 6px; font-size: 12px; color: var(--muted); }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
.legend .dot.in_progress { background: var(--accent); }
.legend .dot.done { background: var(--warn); }
.legend .dot.paid { background: var(--ok); }
.legend .dot.booked { border: 1px dashed var(--accent); }

.login-sheet { max-width: 400px; }
@media (min-width: 620px) { .login-sheet { border-radius: 18px; } }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: 84px; z-index: 30;
  padding: 13px 16px; border-radius: 12px; background: #222; color: #fff; font-size: 15px;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.toast.err { background: var(--danger); }
