/* BikeShopCrm dashboard — clean and light.
   Palette: paper, ink, muted, hairline, one accent (workshop-enamel green). Spacing on a 4px scale. */
:root {
  --paper: #fbfcfc;
  --panel: #ffffff;
  --ink: #1c2a33;
  --muted: #5f6f78;
  --line: #e3e8ea;
  --wash: #f1f5f5;
  --accent: #0e7c66;
  --accent-soft: #e3f2ee;
  --warn: #b5525a;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --radius: 10px;
  --font: "Avenir Next", "Segoe UI", "Helvetica Neue", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 var(--s3); }
.lead { color: var(--muted); margin: var(--s1) 0 0; max-width: 64ch; }
.num { font-variant-numeric: tabular-nums; }

.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr) 280px; min-height: 100vh; }

/* left rail */
.rail { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); padding: var(--s5) var(--s3);
  display: flex; flex-direction: column; gap: 2px; background: var(--panel); }
.brand { display: flex; align-items: center; gap: var(--s2); font-weight: 650; color: var(--ink); text-decoration: none;
  padding: 0 var(--s3) var(--s5); font-size: 16px; }
.mark { width: 22px; height: 22px; border-radius: 50%; border: 5px solid var(--accent); display: inline-block;
  box-shadow: inset 0 0 0 2px var(--panel), inset 0 0 0 4px var(--accent); }
.nav-link { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 500; }
.nav-link:hover { background: var(--wash); color: var(--ink); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }

.main { padding: var(--s6) var(--s6) var(--s7); min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s4); margin-bottom: var(--s5); }
.status { display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: 13px; white-space: nowrap;
  padding: var(--s1) var(--s3); border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: #b8c3c8; }
.status.live .dot { background: var(--accent); }
.status.fresh { border-color: var(--accent); color: var(--accent); }

/* event feed: the one place with personality — a running log of the shop */
.feed { border-left: 1px solid var(--line); padding: var(--s6) var(--s4); background: var(--panel); position: sticky; top: 0;
  height: 100vh; overflow: auto; }
.feed ol { list-style: none; margin: 0; padding: 0; }
.feed li { padding: var(--s3) 0 var(--s3) var(--s4); border-left: 2px solid var(--line); position: relative; font-size: 13.5px; }
.feed li::before { content: ""; position: absolute; left: -5px; top: 17px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--panel); border: 2px solid var(--line); }
.feed li.op-created::before { border-color: var(--accent); }
.feed li.op-updated::before { border-color: #3f6ea8; }
.feed li.op-deleted::before { border-color: var(--warn); }
.feed li.new { animation: arrive .6s ease-out; }
.feed .when { color: var(--muted); font-size: 12px; display: block; }
.feed .chg { color: var(--muted); font-size: 12.5px; }
.feed-empty { color: var(--muted); border-left: none !important; padding-left: 0 !important; }
.feed-empty::before { display: none; }
@keyframes arrive { from { background: var(--accent-soft); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .feed li.new { animation: none; } }

/* KPI strip: figures with plain labels, no cards-on-cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--panel); margin-bottom: var(--s5); }
.kpi { padding: var(--s4) var(--s5); border-right: 1px solid var(--line); }
.kpi:last-child { border-right: none; }
.kpi .v { display: block; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4) var(--s5); min-width: 0; }
.panel.wide { grid-column: 1 / -1; }
.panel .sub { color: var(--muted); font-size: 13px; margin: calc(var(--s2) * -1) 0 var(--s3); }
.chart-box { position: relative; height: 220px; }
.empty, .loading, .error { color: var(--muted); font-size: 14px; padding: var(--s5) 0; text-align: center; }
.error { color: var(--warn); }

/* HTML bars (block elements, never spans) */
.bars { display: flex; flex-direction: column; gap: var(--s2); }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: var(--s3); align-items: center; font-size: 14px; }
.bar-track { display: block; height: 10px; background: var(--wash); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 5px; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 13px; padding: var(--s2) var(--s2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: var(--s2); border-bottom: 1px solid var(--wash); vertical-align: top; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td:first-child { white-space: nowrap; }
td .sub { color: var(--muted); font-size: 12.5px; white-space: normal; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.pill { display: inline-block; padding: 1px var(--s2); border-radius: 999px; background: var(--wash); font-size: 12.5px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: var(--s3); color: var(--muted); font-size: 13px; }

/* search, facets, chips */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-start; margin-bottom: var(--s4); }
.search { flex: 1 1 280px; position: relative; }
.search input, .facet input, select { width: 100%; font: inherit; padding: var(--s2) var(--s3); border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel); color: var(--ink); }
.search input { padding-left: 34px; background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235f6f78' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E") no-repeat 11px center; }
.facet { position: relative; flex: 0 1 190px; }
.facet ul { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: var(--s1); list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(28, 42, 51, .08); }
.facet li { display: flex; justify-content: space-between; gap: var(--s2); padding: 6px var(--s2); border-radius: 6px; cursor: pointer; font-size: 14px; }
.facet li:hover, .facet li.on { background: var(--accent-soft); }
.facet li .c { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s4); }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: var(--s2); padding: 3px 4px 3px var(--s3); border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; }
.chip button { border: none; background: transparent; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 6px; border-radius: 999px; }
.chip button:hover { background: rgba(14, 124, 102, .15); }
button.btn { font: inherit; font-size: 14px; padding: var(--s2) var(--s3); border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); cursor: pointer; }
button.btn:hover { border-color: var(--accent); }
button.btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
button.btn:disabled { opacity: .5; cursor: default; }

/* maps */
.map-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--s4); margin-bottom: var(--s5); }
.map-panel { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.map-tools { display: flex; gap: var(--s2); padding: var(--s3); border-bottom: 1px solid var(--line); align-items: center; flex-wrap: wrap; }
.map-tools .hint { color: var(--muted); font-size: 13px; margin-left: auto; }
.map { height: 520px; }
.list-panel { height: 590px; display: flex; flex-direction: column; overflow: hidden; }
.list-panel #list { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.list-panel .table-wrap { overflow: auto; flex: 1; }
.area-del { font: inherit; font-size: 12.5px; padding: 2px var(--s2); border-radius: 999px; border: 1px solid var(--accent);
  background: var(--panel); color: var(--accent); cursor: pointer; white-space: nowrap; }
.store-pin { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: pointer; }
.drawing .maplibregl-marker, .drawing .maplibregl-popup, .drawing .store-pin { pointer-events: none !important; }
.drawing .area-del { pointer-events: none !important; }
.drawing .maplibregl-canvas-container { touch-action: none; }

@media (max-width: 1280px) { .shell { grid-template-columns: 200px minmax(0, 1fr); } .feed { display: none; } }
@media (max-width: 1000px) { .map-layout { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: var(--s2); border-right: none; border-bottom: 1px solid var(--line); }
  .rail .brand { padding: var(--s2); }
  .nav-link span { display: none; }
  .main { padding: var(--s4); }
  .top { flex-direction: column; }
}
