:root {
  --bg: #f3f5f8;
  --card: #fff;
  --text: #1c2430;
  --muted: #6b7686;
  --border: #d9dee6;
  --primary: #1f5fa8;
  --go: #1e9e4a;
  --stop: #d23c3c;
  --warn: #c98a00;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[hidden] { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
}
.topbar .brand { font-weight: 600; margin-right: auto; }
.topbar .link { color: #fff; }
#whoami { opacity: .9; font-size: 14px; }

.container { max-width: 520px; margin: 0 auto; padding: 16px; }
.container.wide { max-width: 1200px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  padding: 16px;
  margin-bottom: 16px;
}

h1, h2 { margin: 0 0 12px; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }

label { display: block; margin-bottom: 12px; font-weight: 500; }

input, textarea, select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  font: inherit;
  font-size: 18px;
  color: inherit;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
input:disabled, textarea:disabled { background: #eef1f5; color: var(--text); -webkit-text-fill-color: var(--text); opacity: 1; }
textarea { resize: vertical; }

.btn {
  display: inline-block;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { color: var(--stop); }
.btn.small { padding: 6px 10px; font-size: 14px; }

.btn.big {
  display: block;
  width: 100%;
  min-height: 68px;
  font-size: 24px;
  border: none;
  color: #fff;
  margin-top: 8px;
}
.btn.big.go { background: var(--go); }
.btn.big.stop { background: var(--stop); }
.btn.big.primary { background: var(--primary); }

.link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
}

.error { color: var(--stop); min-height: 1.4em; margin: 10px 0 0; }
.success { color: var(--go); }
.hint, .muted { color: var(--muted); font-size: 14px; }
.hint { margin: -6px 0 12px; }

.banner {
  background: #fff4d6;
  color: #6a4b00;
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

/* таймер */
.timer {
  text-align: center;
  font-size: 56px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  margin: 8px 0 0;
  color: #b7bfca;
}
.timer.driving { color: var(--go); }
.timer.arrived { color: var(--text); }
.status { text-align: center; color: var(--muted); min-height: 1.4em; margin-bottom: 8px; }

#finishBlock { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); }
#resumeBtn { display: block; margin: 14px auto 0; font-size: 14px; }

.done { text-align: center; }
.done .big-check { font-size: 48px; color: var(--go); line-height: 1; }
.summary { text-align: left; margin: 16px 0; border-collapse: collapse; width: 100%; }
.summary td { padding: 6px 0; border-bottom: 1px solid #eef1f5; }
.summary td:first-child { color: var(--muted); padding-right: 12px; }
.summary td:last-child { font-weight: 600; }

.hist-item { padding: 10px 0; border-bottom: 1px solid #eef1f5; }
.hist-item:last-child { border-bottom: none; }
.hist-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--muted); }
.hist-route { margin-top: 2px; word-break: break-word; }

/* админка */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs button {
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: #e3e8ef;
  color: var(--text);
  cursor: pointer;
}
.tabs button.active { background: var(--primary); color: #fff; }

.filters, .form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  align-items: end;
}
.filters label, .form-row label { margin: 0; }
.filters input, .filters select, .form-row input { font-size: 16px; padding: 10px; }
.filter-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.input-with-btn { display: flex; gap: 6px; align-items: stretch; }
.input-with-btn input { flex: 1; min-width: 0; }
.input-with-btn .btn { margin-top: 6px; }

.totals { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 0 0 12px; font-size: 15px; }
.totals b { font-size: 18px; }

.table-wrap { overflow-x: auto; padding: 0; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eef1f5; vertical-align: top; }
table.data th { background: #f7f9fb; font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data td.nowrap { white-space: nowrap; }
table.data td.route { min-width: 200px; word-break: break-word; }
table.data tr.inactive td { color: var(--muted); }
table.data .actions { display: flex; gap: 6px; flex-wrap: wrap; }
table.data .empty { text-align: center; color: var(--muted); padding: 24px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.driving { background: #dff3e6; color: #16723a; }
.badge.arrived { background: #fff1cc; color: #7a5600; }
.badge.completed { background: #e7ecf3; color: #3b4757; }
.badge.off { background: #f7dede; color: #9b2525; }
