:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #181b20;
  --panel-2: #20252c;
  --text: #f5f7fb;
  --muted: #9aa4b2;
  --line: #303743;
  --accent: #28d17c;
  --warn: #f2b84b;
  --bad: #ff6b6b;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif; letter-spacing: 0; }
a { color: inherit; text-decoration: none; }
.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { border-right: 1px solid var(--line); padding: 20px; position: sticky; top: 0; height: 100vh; background: #121419; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; margin-bottom: 24px; }
.brand span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #07120c; }
.brand.large { font-size: 28px; margin-bottom: 28px; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar nav a { color: var(--muted); padding: 11px 12px; border-radius: 8px; }
.sidebar nav a.active, .sidebar nav a:hover { color: var(--text); background: var(--panel-2); }
main { min-width: 0; }
.topbar { min-height: 72px; display: grid; grid-template-columns: auto minmax(240px, 620px) auto; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); padding: 14px 24px; position: sticky; top: 0; z-index: 5; background: rgba(16,17,20,.88); backdrop-filter: blur(16px); }
.topbar small { display: block; color: var(--muted); }
.quick-search { display: flex; gap: 8px; }
.quick-search input, textarea, select, input, .form-control { width: 100%; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 11px 12px; }
button, .ghost, .quick-search button { border: 0; border-radius: 8px; padding: 11px 14px; background: var(--accent); color: #07120c; font-weight: 800; white-space: nowrap; }
.ghost { background: var(--panel-2); color: var(--text); }
.page-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr); gap: 16px; padding: 16px; }
.hero-strip { grid-column: 1 / -1; min-height: 190px; display: flex; align-items: center; justify-content: space-between; overflow: hidden; padding: 30px; background: linear-gradient(135deg, #171a1f, #16251f 60%, #1f272a); border-bottom: 1px solid var(--line); }
.hero-strip p { color: var(--accent); font-weight: 800; text-transform: uppercase; margin: 0 0 8px; }
.hero-strip h1 { font-size: clamp(34px, 6vw, 72px); line-height: 1; margin: 0; }
.pulse-map { width: min(42vw, 460px); aspect-ratio: 2 / 1; position: relative; border: 1px solid var(--line); border-radius: 8px; background: repeating-linear-gradient(90deg, transparent 0 42px, rgba(255,255,255,.04) 43px 44px), repeating-linear-gradient(0deg, transparent 0 42px, rgba(255,255,255,.04) 43px 44px); }
.pulse-map span { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 8px rgba(40,209,124,.15); }
.pulse-map span:nth-child(1) { left: 18%; top: 34%; }
.pulse-map span:nth-child(2) { left: 42%; top: 58%; background: var(--warn); }
.pulse-map span:nth-child(3) { left: 70%; top: 26%; }
.pulse-map span:nth-child(4) { left: 82%; top: 70%; background: #7aa7ff; }
.metric-row { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-row.compact { grid-column: auto; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 12px; }
.metric-row article, .panel, .driver-card, .dispatch-card, .settings-grid article, .map-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.metric-row article { padding: 18px; }
.metric-row small { color: var(--muted); }
.metric-row strong { display: block; font-size: 30px; margin-top: 4px; }
.panel { padding: 18px; min-width: 0; }
.panel.full { margin: 16px; }
.panel.wide { grid-column: span 1; }
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.panel-head h1, .panel-head h2 { font-size: 22px; margin: 0; }
.panel-head a, .panel-head span { color: var(--muted); }
.route-list { display: grid; gap: 10px; }
.route-list div { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
meter { grid-column: 1 / -1; width: 100%; height: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 13px; }
.notice, .mini-row { border-top: 1px solid var(--line); padding: 12px 0; }
.notice small, .mini-row span { color: var(--muted); display: block; }
.driver-grid, .dispatch-grid, .settings-grid, .map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 18px; }
.admin-grid h2 { font-size: 18px; margin: 0; }
.driver-card, .dispatch-card, .settings-grid article, .map-card { padding: 16px; }
.driver-card div { display: flex; justify-content: space-between; gap: 10px; }
.driver-card p, .settings-grid p { color: var(--muted); }
.mini-list { display: grid; gap: 4px; margin-top: 10px; }
.mini-list small { color: var(--muted); }
.ok { color: var(--accent); }
.muted { color: var(--muted); }
.split { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(0, 1.2fr); gap: 16px; }
.booking-box { display: grid; gap: 10px; align-content: start; }
.test-notice, .settings-form, .search-panel { margin-top: 18px; max-width: 920px; }
.split-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.split-fields label, .toggle-row label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toggle-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.toggle-row label { grid-template-columns: 18px 1fr; align-items: center; color: var(--text); }
.history-head { margin-top: 22px; }
.gateway-split { margin-top: 16px; }
.gateway-conversation { display: grid; width: 100%; text-align: left; gap: 3px; margin-bottom: 8px; }
.gateway-conversation small, .message-item small { color: var(--muted); }
.message-feed { display: grid; gap: 10px; max-height: 520px; overflow: auto; }
.message-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--panel-2); }
.message-item.outgoing { border-color: var(--accent); }
.message-item p { margin: 6px 0; color: var(--text); }
pre { background: #0a0c0f; color: #d9fbe8; border: 1px solid var(--line); border-radius: 8px; padding: 12px; white-space: pre-wrap; min-height: 120px; }
.dispatch-card.shortage { border-color: var(--bad); }
.dispatch-card.surplus { border-color: var(--warn); }
.dispatch-card.balanced { border-color: var(--accent); }
.dispatch-title { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.dispatch-title span { display: inline-grid; place-items: center; min-width: 34px; height: 28px; border-radius: 8px; background: var(--panel-2); color: var(--accent); font-weight: 800; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 20%, #173626 0, transparent 34%), var(--bg); }
.login-panel { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 28px; }
.login-panel form { display: grid; gap: 12px; }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar { grid-template-columns: 1fr; }
  .page-grid, .split { grid-template-columns: 1fr; }
  .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pulse-map { display: none; }
}
@media (max-width: 520px) {
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-row { grid-template-columns: 1fr; }
  .hero-strip { padding: 22px; min-height: 150px; }
  .panel.full { margin: 10px; }
}
