/* Parking Hunter Graz cockpit. Light, calm, generous spacing. One accent (amber), numbers in mono. */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #1b1f27;
  --muted: #5c6370;
  --faint: #8b93a1;
  --line: #e6e8ee;
  --line-strong: #cfd4dc;
  --accent: #e39a2a;
  --accent-ink: #9a5200;
  --accent-soft: #fff4e2;
  --ok: #1a7f4b;
  --warn: #c2410c;
  --warn-soft: #fff1ea;
  --btn-fg: #1b1f27;
  --toast-bg: #1b1f27;
  --toast-fg: #ffffff;
  --pin-bg: #1b1f27;
  --pin-fg: #ffffff;
  --shadow: rgba(20, 30, 50, .08);
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/* dark theme: same tokens, switched by the header button (stored in localStorage) */
[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --text: #e9ecf2;
  --muted: #a0a7b4;
  --faint: #6f7683;
  --line: #2a2f3a;
  --line-strong: #3a4150;
  --accent: #e9a93b;
  --accent-ink: #f0b955;
  --accent-soft: rgba(233, 169, 59, .14);
  --ok: #7ee2a0;
  --warn: #f28b6b;
  --warn-soft: rgba(242, 139, 107, .14);
  --toast-bg: #e9ecf2;
  --toast-fg: #1b1f27;
  --pin-bg: #e9ecf2;
  --pin-fg: #1b1f27;
  --shadow: rgba(0, 0, 0, .45);
  color-scheme: dark;
}
/* dim the grey basemap in dark mode; the aerial layer stays untouched */
[data-theme="dark"] #map:not(.ortho) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.6); }
[data-theme="dark"] #map { background: #0f1115; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.5 var(--sans); background: var(--bg); color: var(--text); display: flex; flex-direction: column; }
h1, h2, h3 { margin: 0; font-weight: 600; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* header */
.top { display: flex; align-items: center; gap: 32px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-mark { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); }
.brand h1 { font-size: 17px; letter-spacing: -.01em; }
.brand h1 span { color: var(--muted); font-weight: 500; }
.kpis { display: flex; gap: 32px; flex: 1; }
.kpi { display: flex; flex-direction: column; gap: 2px; white-space: nowrap; }
.kpi b { font: 600 18px/1.1 var(--mono); font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12px; }
.jobs { display: flex; align-items: center; gap: 10px; }
.job-state { color: var(--muted); font-size: 13px; min-width: 120px; }
.job-state.running { color: var(--accent-ink); }
.job-state.error { color: var(--warn); }
.logout { color: var(--muted); font-size: 13px; margin-left: 6px; }
.job-desc { margin: 0; padding: 8px 24px; background: var(--surface-2); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.job-desc:empty { display: none; }
.job-log { margin: 0; padding: 12px 24px; max-height: 180px; overflow: auto; background: var(--surface-2); border-bottom: 1px solid var(--line); font: 12.5px/1.6 var(--mono); color: var(--muted); white-space: pre-wrap; }

/* controls */
.btn { padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; background: var(--accent); color: var(--btn-fg); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(.96); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--surface); border-color: var(--line-strong); color: var(--text); font-weight: 500; }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn[disabled] { opacity: .5; cursor: default; }
select, input[type="search"], input[type="number"], input[type="text"], textarea {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 11px; color: var(--text); min-width: 0;
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
::placeholder { color: var(--faint); }
.chk { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); white-space: nowrap; cursor: pointer; }
.chk input { accent-color: var(--accent-ink); width: 15px; height: 15px; }
.num { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); white-space: nowrap; }
.num input { width: 68px; padding: 7px 9px; font-family: var(--mono); }

/* layout */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 420px 1fr auto; }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--line); }
.filters { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.filters .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters .row > select { flex: 1; }
.filters .sources { gap: 6px; }
.sources .chk { padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 100px; color: var(--muted); font-size: 13px; }
.sources .chk input { display: none; }
.sources .chk:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.list-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 20px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); }
.list { list-style: none; margin: 0; padding: 4px 16px 16px; overflow: auto; flex: 1; background: var(--bg); }
.item { padding: 14px 16px; border-radius: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 2px var(--shadow); transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease; }
.item + .item { margin-top: 10px; }
.item:hover { border-color: var(--line-strong); box-shadow: 0 4px 14px var(--shadow); transform: translateY(-1px); }
.item:active { transform: translateY(0); }
.item.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
.item .head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.item .label { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .score { font: 500 12.5px var(--mono); color: var(--faint); font-variant-numeric: tabular-nums; }
.item .nums { color: var(--text); font-size: 13.5px; }
.item .nums b { font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; }
.item .tags { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st, var(--faint)); flex: none; }
.sep { color: var(--line-strong); }
.ko { color: var(--warn); font-weight: 500; }
.analysed { color: var(--ok); }
.empty { padding: 40px 20px; color: var(--muted); text-align: center; line-height: 1.6; }

/* map */
.map-wrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #e9ecef; }
.map-tools { position: absolute; z-index: 800; top: 12px; right: 12px; display: flex; gap: 14px; padding: 8px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 2px 10px var(--shadow); }
.leaflet-container { font: inherit; }
.leaflet-bar { border: 1px solid var(--line) !important; box-shadow: 0 2px 10px var(--shadow) !important; }
.leaflet-bar a { background: var(--surface); color: var(--text); border-color: var(--line); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: 0 6px 24px var(--shadow); }
.leaflet-popup-content { margin: 10px 12px; font-size: 13px; }
.leaflet-tooltip { background: var(--surface); color: var(--text); border-color: var(--line); border-radius: 8px; padding: 6px 9px; }
.pin.selected { display: block; width: 26px; height: 26px; border-radius: 50%; background: #ff3b30; border: 3px solid #fff; box-shadow: 0 0 0 4px rgba(255, 59, 48, .35); animation: pulse 1.4s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 4px rgba(255, 59, 48, .45); } 100% { box-shadow: 0 0 0 18px rgba(255, 59, 48, 0); } }
@media (prefers-reduced-motion: reduce) { .pin.selected { animation: none; } }
.pin.garage { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--pin-bg); color: var(--pin-fg); border: 2px solid var(--pin-fg); box-shadow: 0 1px 4px rgba(0, 0, 0, .4); font: 700 12px/1 var(--sans); }

/* detail drawer */
.detail { width: 440px; overflow: auto; background: var(--surface); border-left: 1px solid var(--line); padding: 22px 24px 32px; display: flex; flex-direction: column; gap: 22px; }
.detail header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.detail h2 { font-size: 18px; line-height: 1.3; }
.detail .sub { color: var(--muted); font-size: 13px; margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.close { background: none; border: 0; color: var(--faint); font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px; }
.close:hover { color: var(--text); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.fact { display: flex; flex-direction: column; gap: 2px; }
.fact small { color: var(--muted); font-size: 12px; }
.fact b { font: 500 15px var(--mono); font-variant-numeric: tabular-nums; }
.fact b small { color: var(--faint); font-family: var(--sans); }
.fact b.text { font-family: var(--sans); font-size: 14px; }
.fact.wide { grid-column: 1 / -1; }
.section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.ortho { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); display: block; }
.ortho-missing { padding: 22px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); text-align: center; line-height: 1.5; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.ortho-missing p { margin: 0; }
.links { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13.5px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12.5px; }
.form textarea { min-height: 80px; resize: vertical; font-family: var(--sans); }
.form .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form .saved { color: var(--faint); font-size: 12.5px; }
.verify-note { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.ko-note { padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }

/* contract checklist + term sheet */
.checklist { display: flex; flex-direction: column; gap: 8px; }
.checklist .chk { flex-direction: row; color: var(--text); white-space: normal; align-items: flex-start; font-size: 13.5px; line-height: 1.4; }
.checklist .chk input { margin-top: 3px; }
.checklist .chk.done { color: var(--muted); }
.progress { font: 500 12.5px var(--mono); color: var(--muted); }
.progress.full { color: var(--ok); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 1200; background: rgba(0, 0, 0, .5); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { width: min(720px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 16px; padding: 22px 28px 28px; box-shadow: 0 20px 60px var(--shadow); }
.modal-box header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-box h2 { font-size: 18px; }
.modal-body h2 { font-size: 12px; margin: 20px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.modal-body p { margin: 8px 0; }
.modal-body ul { margin: 6px 0 10px; padding-left: 20px; }
.modal-body li { margin: 4px 0; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); opacity: 0; padding: 10px 16px; background: var(--toast-bg); color: var(--toast-fg); border-radius: 10px; transition: .2s ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 360px 1fr; }
  /* above Leaflet controls (z-index 1000) */
  .detail { position: fixed; right: 0; top: 0; bottom: 0; z-index: 1100; box-shadow: -8px 0 32px var(--shadow); }
  .kpis { display: none; }
}
.mobile-only { display: none; }
.sheet-handle { display: none; }
.list-actions { display: flex; gap: 8px; }

/* phone: one view at a time (tabs), filters collapsed, detail full screen */
@media (max-width: 720px) {
  body { height: 100dvh; overflow: hidden; }
  .mobile-only { display: inline-flex; }
  .top { flex-wrap: wrap; gap: 8px 12px; padding: 10px 14px; }
  .kpis { display: none; }
  .jobs { flex-wrap: wrap; gap: 8px; width: 100%; }
  .jobs select { flex: 1; min-width: 0; }
  .job-state { min-width: 0; width: 100%; }
  .layout { display: block; position: relative; padding-bottom: 56px; }
  .side, .map-wrap { position: absolute; inset: 0 0 56px 0; border: 0; }
  body[data-view="map"] .side { display: none; }
  body[data-view="list"] .map-wrap { display: none; }
  .filters { display: none; }
  .side.filters-open .filters { display: flex; }
  .list { padding: 4px 12px 16px; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; height: 56px; display: flex; background: var(--surface); border-top: 1px solid var(--line); z-index: 900; }
  .tabs button { flex: 1; border: 0; background: none; font-weight: 600; color: var(--muted); font-size: 15px; }
  .tabs button.active { color: var(--accent-ink); box-shadow: inset 0 3px 0 var(--accent); }
  .job-desc { display: none; }
  /* detail as bottom sheet above the tabs: half height, drag up for everything */
  .detail { position: fixed; left: 0; right: 0; bottom: 56px; top: auto; height: 56dvh; width: 100%; z-index: 1050; /* above Leaflet controls */
    border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 6px 16px 32px; gap: 18px;
    box-shadow: 0 -10px 30px var(--shadow); transition: height .2s ease; }
  .detail.expanded { height: calc(100dvh - 56px); border-radius: 0; }
  .sheet-handle { display: block; flex: none; width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 4px auto 0; }
  .detail header { position: sticky; top: 0; background: var(--surface); padding-top: 4px; z-index: 1; }
  .detail h2 { font-size: 17px; }
  .close { font-size: 28px; padding: 0 8px; }
  .map-tools { top: auto; bottom: 12px; left: 12px; right: auto; }
  .modal-box { padding: 18px; }
}
@media (max-width: 720px) and (display-mode: browser) { .tabs { padding-bottom: env(safe-area-inset-bottom); } }
@media (prefers-reduced-motion: reduce) { .toast, .item { transition: none; } .item:hover { transform: none; } }
