/* Такси-СПб — общие стили трёх приложений */
:root {
  --bg: #0e1116;
  --panel: #171c24;
  --panel2: #1d2430;
  --line: #262e3a;
  --text: #e8ecf1;
  --muted: #8b96a5;
  --accent: #ffd54a;
  --green: #22c55e;
  --red: #ef4444;
  --blue: #3b82f6;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px; line-height: 1.45;
}
#map { position: absolute; inset: 0; z-index: 0; background: #10151c; }

/* листлет в тёмной теме */
.leaflet-container { background: #10151c; font-family: inherit; }
.leaflet-bar, .leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); }
.leaflet-control-attribution { background: rgba(14,17,22,.7) !important; color: #556 !important; }
.leaflet-control-attribution a { color: #667 !important; }
.marker-a, .marker-b {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; font-weight: 800; font-size: 13px;
  border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.marker-a { background: var(--green); color: #04140a; }
.marker-b { background: var(--red); color: #fff; }

/* нижняя панель-лист */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  max-height: 78vh; overflow-y: auto;
}
.grip { width: 44px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }

h1 { font-size: 19px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

.field { position: relative; margin-bottom: 10px; }
.field input, .field select {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font-size: 15px; outline: none;
}
.field input:focus { border-color: var(--accent); }
.field .tag {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-weight: 800; pointer-events: none; color: var(--muted);
}
.field input.has-tag { padding-left: 40px; }

.ac-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  max-height: 240px; overflow-y: auto; box-shadow: 0 12px 32px rgba(0,0,0,.5); display: none; }
.ac-list.open { display: block; }
.ac-item { padding: 10px 14px; cursor: pointer; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover, .ac-item.active { background: #232c3b; }

.btn {
  display: block; width: 100%; padding: 15px; border: 0; border-radius: 14px;
  font-size: 16px; font-weight: 700; cursor: pointer; text-align: center; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #1c1500; }
.btn-green { background: var(--green); color: #04140a; }
.btn-ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn + .btn { margin-top: 8px; }

.tariffs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0 14px; }
.tariff {
  padding: 10px 6px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel2); text-align: center; cursor: pointer; user-select: none;
}
.tariff.sel { border-color: var(--accent); background: #2a2410; }
.tariff .t-name { font-size: 11.5px; color: var(--muted); }
.tariff .t-price { font-size: 14px; font-weight: 700; margin-top: 3px; }
.tariff .t-price.pending { color: var(--muted); font-size: 12px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.gray  { background: #2b3444; color: #aab6c6; }
.badge.yellow{ background: #4a3d0e; color: var(--accent); }
.badge.green { background: #0e3d22; color: #4ade80; }
.badge.blue  { background: #122c52; color: #60a5fa; }
.badge.red   { background: #4a1414; color: #f87171; }

.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.error-box { background: #4a1414; color: #fca5a5; padding: 10px 14px; border-radius: 10px; margin-bottom: 10px; font-size: 14px; display: none; }
.error-box.show { display: block; }

/* ---------- меню-шторка (пассажир) ---------- */
#menu-btn {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 12px; z-index: 30;
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 20px; cursor: pointer;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font-size: 15px; cursor: pointer;
}
#menu-overlay { position: absolute; inset: 0; z-index: 40; background: rgba(6,8,12,.6); display: none; }
#menu-overlay.open { display: block; }
#menu-drawer {
  position: absolute; top: 0; bottom: 0; left: 0; z-index: 41; width: min(88vw, 360px);
  background: var(--panel); border-right: 1px solid var(--line);
  padding: calc(14px + env(safe-area-inset-top)) 16px 20px; overflow-y: auto;
  transform: translateX(-100%); transition: transform .22s ease;
}
#menu-drawer.open { transform: none; }
.hist-item {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  margin-top: 10px; cursor: pointer; background: var(--panel2);
}
.hist-item:active { background: #232c3b; }
.hist-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.hist-route { font-size: 12.5px; color: var(--muted); margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stars { display: flex; gap: 6px; margin: 10px 0 2px; }
.stars .star { font-size: 30px; cursor: pointer; color: #3a4352; user-select: none; line-height: 1; }
.stars .star.on { color: var(--accent); }

/* ---------- водитель ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: linear-gradient(rgba(14,17,22,.92), rgba(14,17,22,.55));
}
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--panel2);
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.switch { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.switch .knob { width: 46px; height: 26px; border-radius: 999px; background: #2b3444; position: relative; cursor: pointer; transition: background .2s; }
.switch .knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #e8ecf1; transition: left .2s; }
.switch.on { color: #4ade80; }
.switch.on .knob { background: var(--green); }
.switch.on .knob::after { left: 23px; }

.offer-modal {
  position: absolute; inset: 0; z-index: 50; display: none;
  background: rgba(6,8,12,.78); backdrop-filter: blur(3px);
}
.offer-modal.open { display: flex; align-items: flex-end; justify-content: center; }
.offer-card {
  width: 100%; max-width: 560px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.offer-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.count-ring { position: relative; width: 54px; height: 54px; flex: none; }
.count-ring svg { transform: rotate(-90deg); }
.count-ring .val { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; }
.offer-map { height: 180px; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 10px; }
.pt-line { display: flex; gap: 10px; margin-bottom: 8px; font-size: 14px; }
.pt-line .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; }
.pt-line .dot.a { background: var(--green); } .pt-line .dot.b { background: var(--red); }
#ac-sub a { color: var(--accent); text-decoration: none; font-weight: 600; }

.action-steps { display: flex; flex-direction: column; gap: 8px; }

/* ---------- админка ---------- */
.admin { display: flex; height: 100vh; overflow: hidden; }
.admin-side { width: 340px; flex: none; border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; }
.admin-tabs { display: flex; border-bottom: 1px solid var(--line); }
.admin-tabs button { flex: 1; padding: 12px; background: none; border: 0; color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; }
.admin-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.admin-body { flex: 1; overflow-y: auto; overflow-x: auto; padding: 12px; }
.admin-main { flex: 1; position: relative; }
table.grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.grid th { text-align: left; color: var(--muted); font-weight: 600; padding: 7px 6px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); white-space: nowrap; }
table.grid td { padding: 6px; border-bottom: 1px solid #1b222d; vertical-align: top; }
table.grid td:nth-child(4) { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat .n { font-size: 22px; font-weight: 800; }
.stat .l { font-size: 12px; color: var(--muted); }

/* карточки водителей */
.driver-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.dcard { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.dcard .head { display: flex; gap: 10px; align-items: center; }
.dcard .avatar2 { width: 42px; height: 42px; border-radius: 50%; background: #232c3b;
  display: flex; align-items: center; justify-content: center; font-size: 19px; flex: none; }
.dcard .car { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.dcard .badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.dcard .acts { display: flex; gap: 8px; margin-top: 10px; }
.dcard .acts button { flex: 1; padding: 8px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 12.5px; cursor: pointer; }
.dcard .acts button:hover { border-color: var(--accent); }

/* модалки */
#modal-root { position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(6,8,12,.7); align-items: center; justify-content: center; padding: 16px; }
#modal-root.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; width: min(560px, 96vw); max-height: 86vh; overflow-y: auto; }
.modal h3 { margin: 0 0 10px; font-size: 16px; }
.modal .close { float: right; }
.assign-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 10px; margin-top: 8px; cursor: pointer; background: var(--panel2); }
.assign-row:hover { border-color: var(--accent); }
.modal select { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font-size: 14px; }

@media (max-width: 640px) {
  .tariffs { grid-template-columns: repeat(2, 1fr); }
  .admin { flex-direction: column; }
  .admin-side { width: auto; height: 55vh; border-right: 0; border-bottom: 1px solid var(--line); }
}
