/* Inter, self-hosted (SIL Open Font License). */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('/fonts/InterVariable.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: italic; font-weight: 100 900; font-display: swap; src: url('/fonts/InterVariable-Italic.woff2') format('woff2'); }
:root {
  --brand: #00a86b;
  --brand-dark: #008a58;
  --brand-soft: #e6f7f0;
  --bg: #f5f7f9;
  --surface: #ffffff;
  --border: #e3e8ee;
  --text: #1a2330;
  --muted: #6b7785;
  --danger: #d93b3b;
  --danger-soft: #fdecec;
  --warn: #c98200;
  --warn-soft: #fff5e0;
  --info: #2f6fdd;
  --info-soft: #e8f0fd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1419;
    --surface: #182029;
    --border: #2a3440;
    --text: #e6edf3;
    --muted: #8b98a5;
    --brand-soft: #0f3326;
    --danger-soft: #3a1717;
    --warn-soft: #3a2c0f;
    --info-soft: #14243f;
  }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 20px; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 14px; margin: 16px 0 8px; font-weight: 600; }

/* layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: flex-end; gap: 8px; padding: 4px 10px 20px; }
.logo img { height: 34px; display: block; }
.logo-sub { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding-bottom: 3px; }
.money { white-space: nowrap; }
img.currency { height: 1.1em; vertical-align: -0.2em; margin-left: .15em; }
.nav a { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: 8px; color: var(--text); margin-bottom: 2px; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
:root[data-theme="dark"] .nav a.active { color: #5fe0ad; }

.nav .count { background: var(--danger); color: #fff; font-size: 11px; border-radius: 10px; padding: 1px 7px; font-weight: 600; }
.sidebar-footer { margin-top: 24px; padding: 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.main { padding: 28px 32px; min-width: 0; }
.mobile-bar, .nav-backdrop { display: none; }

/* components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 28px; font-weight: 650; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; }
.two-col { grid-template-columns: 2fr 1fr; }
.half-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .two-col, .half-col { grid-template-columns: 1fr; } }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { width: 100%; min-height: 80px; resize: vertical; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
label.field input, label.field select { width: 100%; }
.check { display: inline-flex; gap: 6px; align-items: center; }

button, .btn { font: inherit; font-weight: 550; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 14px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
button:hover { background: var(--bg); }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--danger-soft); }
button.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 10px 14px; color: var(--muted); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; background: var(--bg); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--brand-soft); color: var(--brand-dark); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.yellow { background: var(--warn-soft); color: var(--warn); }
.badge.blue { background: var(--info-soft); color: var(--info); }
:root[data-theme="dark"] .badge.green { color: #5fe0ad; }


.stars { color: #f5a623; letter-spacing: 1px; }
.route { font-weight: 600; }
.route .arrow { color: var(--muted); margin: 0 4px; }

/* chart */
.chart svg { width: 100%; height: 220px; display: block; }
.chart .bar { fill: var(--brand); }
.chart .bar:hover { fill: var(--brand-dark); }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .gridline { stroke: var(--border); }
.legend { display: flex; gap: 8px; margin-bottom: 8px; }

/* modal & drawer */
.overlay { position: fixed; inset: 0; background: rgba(10, 15, 20, .45); z-index: 50; display: flex; justify-content: flex-end; }
.overlay.center { justify-content: center; align-items: center; padding: 16px; }
.drawer { background: var(--surface); width: min(720px, 100%); height: 100%; overflow-y: auto; padding: 24px; box-shadow: -8px 0 30px rgba(0,0,0,.15); }
.modal { background: var(--surface); width: min(520px, 100%); max-height: 90vh; overflow-y: auto; border-radius: 14px; padding: 24px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h2 { margin: 0; }
.close { border: none; background: none; font-size: 22px; line-height: 1; padding: 4px 8px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; }
.kv .k { color: var(--muted); }

.app-card { display: grid; grid-template-columns: 1fr auto; gap: 12px; margin-bottom: 12px; }
.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 12px; background: var(--bg); }
.msg.right { align-self: flex-end; background: var(--brand-soft); }
.msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); }
.login .logo { justify-content: center; padding-bottom: 24px; }
.login .logo img { height: 48px; }
.error { color: var(--danger); margin: 8px 0; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; }
#toast .t { background: var(--text); color: var(--surface); padding: 10px 18px; border-radius: 8px; margin-top: 8px; box-shadow: var(--shadow); }
#toast .t.err { background: var(--danger); color: #fff; }

/* ---------- live map ---------- */
.map-wrap { display: grid; grid-template-columns: 1fr 260px; gap: 16px; margin-top: 12px; }
@media (max-width: 1000px) { .map-wrap { grid-template-columns: 1fr; } }
.live-map { height: 480px; border-radius: var(--radius); border: 1px solid var(--border); z-index: 0; background: var(--bg); }
@media (max-width: 600px) { .live-map { height: 360px; } }


.map-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.map-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 4px 10px; font-size: 13px; cursor: pointer; }
.map-chip.on { color: var(--text); border-color: var(--brand); background: var(--brand-soft); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); margin-right: 4px; vertical-align: middle; }
.dot.driver { background: #2f6fdd; }
.dot.passenger { background: var(--brand); }
.dot.ride { background: #fff; border-color: var(--brand); }
.line { display: inline-block; width: 22px; height: 0; margin-right: 4px; vertical-align: middle; }
.line.planned { border-top: 3px dashed #8b98a5; }
.line.actual { border-top: 4px solid var(--brand); }
.map-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.ride-list { display: flex; flex-direction: column; gap: 8px; max-height: 440px; overflow: auto; }
.ride-row { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.ride-row:hover { border-color: var(--brand); }
.car-marker { width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 3px solid var(--brand); box-shadow: 0 0 0 6px rgba(0,168,107,.25), 0 2px 6px rgba(0,0,0,.35); display: grid; place-items: center; }
.car-marker.stale { border-color: #8b98a5; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.car-arrow { color: var(--brand); font-size: 16px; line-height: 1; }
.car-marker.stale .car-arrow { color: #8b98a5; }
.map-pop { display: grid; gap: 3px; min-width: 180px; }
.live-map .leaflet-popup-content-wrapper, .live-map .leaflet-popup-tip { background: var(--surface); color: var(--text); }

/* ---------- document / car photo thumbnails ---------- */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { display: flex; flex-direction: column; gap: 3px; width: 120px; font-size: 11px; color: var(--muted); }
.thumb img { width: 120px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); }
.thumb:hover img { border-color: var(--brand); }

.pos { color: var(--brand); font-weight: 600; }
.neg { color: var(--danger); font-weight: 600; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 4px; }

.dup-warn { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.dup-warn a { color: var(--danger); font-weight: 600; text-decoration: underline; }
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 12px; margin: 8px auto; width: fit-content; }
.sos-banner { display: block; background: var(--danger); color: #fff; font-weight: 700; margin-bottom: 16px; }

/* ---------- horizontal bars (dashboard audience) ---------- */
.three-col { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) { .three-col { grid-template-columns: 1fr; } }
.hbars { display: grid; gap: 8px; margin-top: 12px; }
.hbar { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.hbar:hover .hbar-fill { filter: brightness(1.12); }
.hbar-label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 12px; }
.hbar-fill { display: block; height: 100%; min-width: 2px; background: var(--brand); border-radius: 0 4px 4px 0; }
.hbar-value { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 64px; text-align: right; }

.counts { display: inline-flex; gap: 4px; }
.nav .count.green { background: var(--brand); }
.nav .count.blue { background: var(--info); }
.tab-count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 700; text-align: center; }
.tab-count.green { background: var(--brand-soft); color: var(--brand); }
.tab-count.blue { background: var(--info-soft); color: var(--info); }
.tab-count.yellow { background: var(--warn-soft); color: var(--warn); }

/* ---------- settings ---------- */
.settings-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; padding-bottom: 80px; }
@media (max-width: 1000px) { .settings-layout { grid-template-columns: 1fr; } .set-nav { position: static !important; flex-direction: row !important; flex-wrap: wrap; } }
.set-nav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; }
.set-nav a { color: var(--text); padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.set-nav a:hover { background: var(--brand-soft); color: var(--brand); }
.set-main { display: grid; gap: 16px; min-width: 0; }
.set-section { scroll-margin-top: 16px; }
.set-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.set-head h2 { margin: 0 0 2px; }
.set-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--brand-soft); display: grid; place-items: center; font-size: 18px; flex: none; }
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
@media (max-width: 700px) { .set-grid { grid-template-columns: 1fr; } }
.set-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.set-field.wide { grid-column: 1 / -1; }
.set-field.changed .set-label::after { content: ' •'; color: var(--warn); }
.set-label { font-size: 13px; font-weight: 600; }
.set-hint { font-size: 12px; color: var(--muted); }
.with-unit { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); overflow: hidden; }
.with-unit input { border: 0; flex: 1; min-width: 0; box-shadow: none; }
.with-unit .unit { padding: 0 10px; color: var(--muted); font-size: 13px; white-space: nowrap; display: inline-flex; align-items: center; gap: 2px; }
.with-unit .unit img.currency { height: 14px; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); width: fit-content; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 7px 12px; font-size: 13px; color: var(--text); box-shadow: none; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--brand); color: #fff; font-weight: 600; }
.fuel-now { background: var(--bg); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.save-bar { position: fixed; left: 50%; bottom: 16px; transform: translate(-50%, 150%); display: flex; align-items: center; gap: 10px; width: min(640px, calc(100% - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.18); transition: transform .2s; z-index: 50; }
.save-bar.show { transform: translate(-50%, 0); }

.hbar-fill { position: relative; overflow: hidden; }
.hbar-both { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--brand) 60%, #000); }
.both-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; background: color-mix(in srgb, var(--brand) 60%, #000); }

/* ================= responsive: tablet & phone ================= */
.main > * { min-width: 0; }
.nav .counts { margin-left: auto; }

/* Tablet (portrait / small laptop): keep the menu, make it narrower. */
@media (max-width: 1180px) and (min-width: 861px) {
  .layout { grid-template-columns: 200px minmax(0, 1fr); }
  .sidebar { padding: 14px 8px; }
  .nav a { padding: 8px 10px; font-size: 14px; }
  .main { padding: 22px 20px; }
  .kv { grid-template-columns: 140px 1fr; }
  .settings-layout { grid-template-columns: 180px minmax(0, 1fr); }
}

/* Phone & narrow tablet: the menu slides in from the left over a backdrop; a sticky bar holds the button. */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; width: min(280px, 85vw); height: 100dvh; transform: translateX(-105%); transition: transform .22s ease; box-shadow: 8px 0 30px rgba(0,0,0,.2); }
  .layout.nav-open .sidebar { transform: none; }
  .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(10,15,20,.45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .layout.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  .main { padding: 0 16px 24px; }
  .main > h1 { display: none; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 40; margin: 0 -16px 14px; padding: 10px 12px;
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
  .menu-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; font-size: 20px; border-radius: 10px; }
  .mobile-title { font-size: 18px; font-weight: 800; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mobile-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
  .two-col, .half-col, .three-col, .map-wrap { grid-template-columns: minmax(0, 1fr) !important; }
  .app-card { grid-template-columns: minmax(0, 1fr); }
  .app-card > .actions { flex-direction: row !important; flex-wrap: wrap; }
  .tabs { overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { white-space: nowrap; flex: none; }
  .toolbar input, .toolbar select { min-width: 0 !important; flex: 1 1 160px; }
  .drawer { width: 100%; padding: 16px; }
  .overlay.center { padding: 0; align-items: flex-end; }
  .modal { width: 100%; max-height: 92dvh; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .set-nav { position: sticky !important; top: 60px; z-index: 30; flex-direction: row !important; flex-wrap: nowrap !important; overflow-x: auto; gap: 6px;
    background: var(--bg); padding: 6px 0; margin: 0 -16px; padding-left: 16px; scrollbar-width: none; }
  .set-nav::-webkit-scrollbar { display: none; }
  .set-nav a { white-space: nowrap; border: 1px solid var(--border); background: var(--surface); padding: 6px 12px; border-radius: 999px; font-size: 13px; }
  .set-section { scroll-margin-top: 110px; }
  .save-bar { bottom: calc(10px + env(safe-area-inset-bottom)); }
  .hbar { grid-template-columns: 72px 1fr auto; }
  .hbar-value { min-width: 52px; }
}

/* Phone: 2 KPI tiles per row, label above value in key-value lists, tables become cards. */
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 22px; }
  .kpi .label { font-size: 11px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv .k { margin-top: 8px; font-size: 12px; }
  .card { padding: 14px; }
  .set-grid { grid-template-columns: minmax(0, 1fr); }
  .seg { width: 100%; }
  .seg button { flex: 1; }
  .live-map { height: 320px; }
  .login { padding: 20px; }

  .table-wrap { background: none; border: 0; box-shadow: none; overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 10px; padding: 6px 12px; }
  .table-wrap tr.clickable:active { background: var(--bg); }
  .table-wrap td { display: flex; gap: 12px; justify-content: space-between; align-items: baseline; border: 0; border-bottom: 1px dashed var(--border); padding: 7px 0; text-align: right; }
  .table-wrap td:last-child { border-bottom: 0; }
  .table-wrap td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex: none; max-width: 45%; }
  .table-wrap td:not([data-label])::before { content: none; }
  .table-wrap td > * { min-width: 0; }
  .table-wrap td.actions-cell { justify-content: flex-end; }
  .table-wrap td.num { text-align: right; }
  .table-wrap .empty { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
  .pager { justify-content: center; }
}

/* Tablet widths: tighter tables, long ids wrap instead of pushing columns off screen. */
@media (max-width: 1180px) and (min-width: 641px) {
  th, td { padding: 8px 10px; font-size: 14px; }
  th { font-size: 11px; }
  td:first-child { word-break: break-all; max-width: 130px; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

/* ---------- photo viewer ---------- */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(8, 12, 16, .92); display: grid; grid-template-rows: auto 1fr; }
.lb-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: #fff; }
.lb-top .spacer { flex: 1; }
.lb-caption { font-weight: 600; }
.lb-counter { color: rgba(255,255,255,.6); font-variant-numeric: tabular-nums; }
.lb-btn { background: rgba(255,255,255,.12); color: #fff; border: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 24px; line-height: 1; }
.lb-stage { display: grid; place-items: center; padding: 0 16px 16px; min-height: 0; }
.lb-img { max-width: 100%; max-height: calc(100dvh - 90px); object-fit: contain; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.5); cursor: default; }
.lb-nav { position: fixed; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.14); color: #fff; border: 0; width: 48px; height: 64px; font-size: 36px; border-radius: 12px; }
.lb-nav:hover, .lb-btn:hover { background: rgba(255,255,255,.25); }
.lb-nav.prev { left: 12px; }
.lb-nav.next { right: 12px; }
@media (max-width: 640px) { .lb-nav { width: 40px; height: 52px; font-size: 28px; } }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text); }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.drawer-app .app-card { box-shadow: none; border-color: var(--brand); }

.tg-steps { margin: 0 0 12px; padding-left: 20px; line-height: 1.7; }
#set-telegram td input[type=checkbox] { width: 18px; height: 18px; }

/* support chat */
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; color: #fff; font-weight: 700; object-fit: cover; letter-spacing: .02em; }
.sc-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px; gap: 16px; align-items: stretch; height: calc(100dvh - 130px); min-height: 520px; }
.sc-side, .sc-pane, .sc-info { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); min-height: 0; }
.sc-side { display: flex; flex-direction: column; overflow: hidden; }
.sc-side-head { display: grid; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.sc-side-head input { width: 100%; }
.sc-tabs { width: 100%; }
.sc-tabs button { flex: 1; }
.sc-list { flex: 1; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.sc-item { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; background: none; border: none; border-radius: 12px; padding: 9px 10px; color: var(--text); font-weight: 400; }
.sc-item:hover { background: var(--bg); }
.sc-item.active { background: var(--brand-soft); }
.sc-item.unread b { color: var(--brand-dark); }
:root[data-theme="dark"] .sc-item.unread b { color: #5fe0ad; }

.sc-item-main { flex: 1; min-width: 0; }
.sc-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; min-width: 0; }
.sc-row b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-row + .sc-row { margin-top: 3px; }
.sc-last { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sc-item.unread .sc-last { color: var(--text); font-weight: 600; }
.sc-item .count { flex: none; background: var(--brand); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; }

.sc-pane { display: flex; flex-direction: column; overflow: hidden; }
.sc-placeholder { margin: auto; display: grid; gap: 8px; place-items: center; }
.sc-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.sc-head .spacer { flex: 1; }
.sc-back, .sc-info-toggle { display: none; }
.sc-msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px;
  background: radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--brand) 6%, transparent), transparent 40%), var(--bg); }
.sc-day { align-self: center; margin: 10px 0 6px; }
.sc-day span { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 3px 12px; border-radius: 999px; }
.sc-msg { max-width: min(72%, 520px); padding: 8px 12px 6px; border-radius: 18px; box-shadow: 0 1px 1px rgba(16, 24, 40, .06); }
.sc-msg.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.sc-msg.out { align-self: flex-end; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; border-bottom-right-radius: 6px; }
.sc-msg.out a { color: #fff; text-decoration: underline; }
.sc-msg.media { padding: 4px 4px 6px; }
.sc-msg.media .sc-text, .sc-msg.media .sc-meta { padding: 0 8px; }
.sc-text { white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.sc-meta { font-size: 11px; opacity: .7; margin-top: 2px; text-align: right; }
.sc-photo { display: block; }
.sc-photo img { display: block; max-width: 100%; width: 320px; max-height: 360px; object-fit: cover; border-radius: 14px; background: var(--bg); min-height: 120px; }
.sc-loc { width: 320px; max-width: 100%; display: grid; gap: 6px; }
.sc-loc a { font-size: 13px; padding: 0 8px; }
.mini-map { border-radius: 12px; overflow: hidden; background: var(--bg); z-index: 0; }



.sc-composer { border-top: 1px solid var(--border); padding: 10px 12px; display: grid; gap: 8px; }
.sc-attach:empty { display: none; }
.sc-attach { display: flex; align-items: center; gap: 10px; background: var(--bg); border-radius: 10px; padding: 6px 8px; }
.sc-attach img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; }
.sc-attach .close { margin-left: auto; }
.sc-input { display: flex; gap: 8px; align-items: flex-end; }
.sc-input textarea { flex: 1; resize: none; min-height: 42px; max-height: 160px; border-radius: 21px; padding: 10px 16px; line-height: 1.35; }
.sc-clip, .sc-send { width: 42px; height: 42px; border-radius: 50%; padding: 0; justify-content: center; font-size: 18px; flex: none; }
.sc-send { font-size: 16px; }

.sc-info { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.sc-info-card { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.sc-info-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.btn.small { padding: 4px 10px; font-size: 13px; }

@media (max-width: 1300px) {
  .sc-layout { grid-template-columns: 300px minmax(0, 1fr); }
  .sc-info { display: none; }
  .sc-info-toggle { display: inline-flex; }
  .sc-layout.show-info .sc-info { display: flex; position: fixed; right: 16px; top: 80px; bottom: 16px; width: min(340px, calc(100vw - 32px)); z-index: 45; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
}
@media (max-width: 800px) {
  .sc-layout { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - 90px); }
  .sc-layout.has-chat .sc-side { display: none; }
  .sc-layout:not(.has-chat) .sc-pane { display: none; }
  .sc-back { display: inline-flex; }
  .sc-msg { max-width: 88%; }
  .sc-photo img, .sc-loc { width: 240px; }
  .sc-msgs { padding: 12px; }
}

/* legal documents editor */
.legal-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.legal-src { width: 100%; min-height: 520px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; box-sizing: border-box; }
.legal-preview { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; max-height: 640px; overflow-y: auto; background: var(--bg); line-height: 1.55; }
.legal-preview h1 { font-size: 20px; margin: 0 0 12px; }
.legal-preview h2 { font-size: 16px; margin: 18px 0 6px; }
.legal-preview ul { padding-left: 20px; }
.ph-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ph-list button { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
#set-legal .seg button { min-width: 48px; }
@media (max-width: 1100px) { .legal-edit { grid-template-columns: 1fr; } .legal-src { min-height: 360px; } }

/* ---------- dashboard ---------- */
.dash-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 12px 14px; margin-bottom: 4px;
  position: sticky; top: 8px; z-index: 20; }
.dash-period { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.dash-dates { display: flex; gap: 6px; align-items: center; }
.dash-dates input { padding: 6px 8px; }
.dash-body { transition: opacity .2s; }
.dash-body.loading { opacity: .5; pointer-events: none; }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.dash .card h2 { font-size: 15px; }

.now-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.now-item { display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; color: var(--text); box-shadow: var(--shadow); }
a.now-item:hover { border-color: var(--brand); text-decoration: none; }
.now-item .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--bg); font-size: 18px; flex: none; }
.now-item b { display: block; font-size: 19px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.now-item.warn .ic { background: var(--warn-soft); }
.now-item.warn b { color: var(--warn); }
.now-item.alert .ic { background: var(--danger-soft); }
.now-item.alert b { color: var(--danger); }
.now-item.live .ic { background: var(--brand-soft); }
.now-item.live b { color: var(--brand); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { cursor: pointer; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 0; overflow: hidden; transition: border-color .15s, box-shadow .15s, transform .15s; }
.stat:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--brand) 50%, var(--border)); }
.stat.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.stat-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; flex: none; }
.stat-value { font-size: 27px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); min-height: 20px; }
.delta { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.delta.up { background: var(--brand-soft); color: var(--brand-dark); }
.delta.down { background: var(--danger-soft); color: var(--danger); }
.delta.flat { background: var(--bg); color: var(--muted); }
:root[data-theme="dark"] .delta.up { color: #5fe0ad; }

.spark { display: block; width: calc(100% + 32px); height: 42px; margin: 4px -16px 0; }

.chart-card .metric-seg { margin-bottom: 12px; max-width: 100%; }
.area-chart svg { width: 100%; height: 260px; display: block; }
.area-chart .axis { fill: var(--muted); font-size: 10px; }
.area-chart .gridline { stroke: var(--border); }
.line-sw { height: 3px !important; width: 18px !important; border-radius: 2px !important; vertical-align: 3px !important; background: var(--brand); }
.line-sw.prev { background: none; border-top: 2px dashed var(--muted); height: 0 !important; }

.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin-top: 12px; padding: 12px; background: var(--bg); border-radius: 10px; }
.split b { display: block; font-size: 16px; margin: 2px 0; font-variant-numeric: tabular-nums; }
.hbars.wide .hbar { grid-template-columns: minmax(120px, 42%) 1fr auto; }

@media (max-width: 860px) {
  .dash-head { top: 62px; }
}
@media (max-width: 640px) {
  .dash-head { position: static; }
  .dash-period, .dash-dates { width: 100%; }
  .dash-dates input { flex: 1; min-width: 0; }
  .dash-period .seg { width: 100%; }
  .dash-period .seg button { flex: 1; padding: 7px 4px; }
  .now-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .now-item { padding: 8px 10px; }
  .now-item .ic { width: 30px; height: 30px; font-size: 15px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 12px 0; }
  .stat-value { font-size: 20px; }
  .spark { width: calc(100% + 24px); margin: 4px -12px 0; }
  .area-chart svg { height: 200px; }
  .chart-card .metric-seg { flex-wrap: nowrap; overflow-x: auto; width: 100%; scrollbar-width: none; }
  .chart-card .metric-seg button { flex: none; }
}

.leaflet-container { font-family: inherit !important; }

/* dashboard tiles → detail panel */
button.stat { text-align: left; font: inherit; font-weight: 400; color: var(--text); width: 100%; align-items: stretch; white-space: normal; background: var(--surface); }
button.stat:hover { background: var(--surface); }
.stat-more { margin-left: auto; font-size: 20px; line-height: 1; color: var(--muted); transition: transform .15s; }
.stat:hover .stat-more { transform: translateX(3px); color: var(--brand); }
.stat-pad { height: 14px; }
.stack-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--bg); gap: 2px; }
.stack-bar span { display: block; height: 100%; min-width: 3px; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 0 14px; }
.chip { font-size: 12px; font-weight: 600; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; }
.detail h3 { margin: 22px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.detail .split { margin-top: 0; }
.detail .area-chart svg { height: 240px; }
.detail-table { max-height: 420px; overflow-y: auto; }
.detail-table th { position: sticky; top: 0; z-index: 1; }
.drawer { width: min(820px, 100%); }

/* theme & language */
.prefs { display: grid; gap: 8px; margin-top: 12px; }
.theme-seg { width: 100%; }
.theme-seg button { flex: 1; justify-content: center; gap: 4px; padding: 6px 4px; font-size: 12px; }
.theme-label { font-size: 11px; }
.lang-select { width: 100%; padding: 6px 8px; font-size: 13px; }
.login-wrap .prefs { width: min(380px, 100%); margin-top: 16px; }
.login-wrap { align-content: center; justify-items: center; }

/* maps: muted OpenStreetMap (dark theme — inverted and dimmed), tiny credit, labels */
.leaflet-control-attribution { font-size: 9px !important; background: color-mix(in srgb, var(--surface) 70%, transparent) !important; color: var(--muted) !important; padding: 0 5px !important; border-radius: 6px 0 0 0; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar a { background: var(--surface); color: var(--text); border-color: var(--border); }
.map-label { background: var(--surface); color: var(--text); border: 0; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.2); padding: 2px 7px; font: 600 11px/1.3 inherit; }
.map-label.strong { background: var(--brand); color: #fff; }
.map-label::before { display: none; }

/* ================= refined look: quiet, typographic, no decoration =================
   One accent colour, hairline borders instead of shadows, compact controls, no emoji icons. */
:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --border: #e6e8eb;
  --text: #121821;
  --muted: #6a7380;
  --radius: 12px;
  --shadow: none;
  letter-spacing: -0.005em;
}
:root[data-theme="dark"] { --bg: #0e1215; --surface: #161b20; --border: #262d34; --text: #e8ecf0; --muted: #8a949e; }

h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 22px; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }

/* sidebar: plain text items, the active one marked by a bar and weight */
.sidebar { padding: 20px 12px; }
.logo { padding: 4px 12px 22px; }
.nav a { padding: 7px 12px; border-radius: 8px; font-size: 14px; color: var(--muted); position: relative; margin-bottom: 1px; }
.nav a:hover { background: var(--bg); color: var(--text); }
.nav a.active { background: var(--bg); color: var(--text); font-weight: 600; }
.nav a.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--brand); }
:root[data-theme="dark"] .nav a.active { color: var(--text); }
.nav .count { font-size: 11px; padding: 0 6px; border-radius: 6px; line-height: 18px; }

.main { padding: 32px 40px; max-width: 1440px; }

/* surfaces */
.card, .table-wrap, .sc-side, .sc-pane, .sc-info, .now-item { box-shadow: none; border-radius: var(--radius); }
.card { padding: 20px; }

/* controls */
button, .btn { font-weight: 550; border-radius: 8px; padding: 7px 13px; min-height: 34px; transition: background .12s, border-color .12s; }
button:hover, .btn:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--border)); text-decoration: none; }
button.primary:hover { border-color: var(--brand-dark); }
button.small, .btn.small { min-height: 28px; padding: 3px 10px; }
input, select, textarea { border-radius: 8px; padding: 7px 10px; }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.tabs { gap: 0; }
.tabs button { min-height: 0; padding: 10px 14px; font-weight: 550; }
.tabs button:hover { background: none; color: var(--text); }

/* tables: quiet header, comfortable rows */
th { background: none; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; color: var(--muted); padding: 11px 16px; border-bottom: 1px solid var(--border); }
td { padding: 12px 16px; }
tr.clickable:hover td { background: color-mix(in srgb, var(--bg) 70%, var(--surface)); }

/* status labels: small, square-ish, not pills */
.badge, .delta, .chip, .tab-count { border-radius: 6px; font-weight: 600; font-size: 11.5px; padding: 2px 7px; }

/* dashboard: numbers first, no icon tiles, no lift on hover */
.ic:empty, .stat-ic:empty, .set-icon:empty { display: none; }
.stat:hover { transform: none; }
.stat-top { color: var(--muted); font-weight: 550; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.now-item { padding: 12px 14px; }
.now-item b { font-size: 20px; letter-spacing: -0.01em; }
.section-title { font-size: 11.5px; letter-spacing: .06em; margin: 28px 0 10px; }
.kpi .value { letter-spacing: -0.02em; }

/* support chat: flat colours */
.sc-msgs { background: var(--bg); }
.sc-msg.out { background: var(--brand); }
.sc-msg { box-shadow: none; }

/* modals and drawers: thin edge instead of heavy shadow */
.drawer { box-shadow: -1px 0 0 var(--border), -12px 0 32px rgba(0, 0, 0, .08); }
.modal { border-radius: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, .12); }
.theme-seg button { gap: 0; }

@media (max-width: 860px) { .main { padding: 0 16px 24px; } }
