/* Jan Awaaz public dashboard. Tokens follow the landing page (web/styles.css);
   chart colours are the validated categorical set (light and dark steps). */

:root {
  --paper: #f6f1e7;
  --card: #fffcf5;
  --sunk: #efe8d9;
  --ink: #1a1a17;
  --ink-2: #3a3933;
  --muted: #6b6658;
  --line: rgba(26, 26, 23, .12);
  --line-strong: rgba(26, 26, 23, .2);
  --marigold: #f2b231;
  --marigold-hover: #e6a51f;
  --on-marigold: #1a1a17;
  --brand-tile: #1a1a17;
  --focus: #b77800;
  --danger-bg: #fbe4df;
  --danger-ink: #8f2a1b;

  /* chart */
  --grid: #e7dfcd;
  --axis: #c9bfa8;
  --filed: #3a3933;
  --fixed: #0ca30c;
  --c-roads: #2a78d6;
  --c-sanitation: #eb6834;
  --c-water_drain: #1baf7a;
  --c-streetlight: #eda100;
  --c-unsafe_area: #e87ba4;
  --c-other: #008300;

  --radius: 14px;
  --display: "Bricolage Grotesque", "Hind", system-ui, sans-serif;
  --body: "Hind", "Nirmala UI", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #16150f;
    --card: #23211a;
    --sunk: #1c1a14;
    --ink: #f3eee2;
    --ink-2: #d8d2c3;
    --muted: #a8a191;
    --line: rgba(243, 238, 226, .1);
    --line-strong: rgba(243, 238, 226, .18);
    --brand-tile: #2c2a22;
    --focus: #f2b231;
    --danger-bg: #3a1f19;
    --danger-ink: #f3b4a7;
    --grid: #33302a;
    --axis: #4a463b;
    --filed: #d8d2c3;
    --c-roads: #3987e5;
    --c-sanitation: #d95926;
    --c-water_drain: #199e70;
    --c-streetlight: #c98500;
    --c-unsafe_area: #d55181;
    --c-other: #008300;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stack { display: grid; gap: 16px; min-width: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.55 var(--body);
  min-height: 100dvh;
}
:root[lang="hi"] body { line-height: 1.7; }
h1, h2 { font-family: var(--display); margin: 0; text-wrap: balance; }
:root[lang="hi"] h1, :root[lang="hi"] h2 { font-family: "Hind", var(--display); }
h1 { font-size: 2.25rem; line-height: 1.1; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.125rem; line-height: 1.3; font-weight: 600; }
p { margin: 0; text-wrap: pretty; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.wrap { width: min(1200px, 100% - 32px); margin-inline: auto; }
.skip { position: absolute; left: 16px; top: -48px; background: var(--card); padding: 8px 12px; border-radius: 8px; z-index: 30; }
.skip:focus { top: 8px; }

/* ---- top bar ---- */
.topbar { border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--display); font-size: 1.05rem; }
.brand-text small { color: var(--muted); font-size: .8rem; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.lang, .btn, .link-btn { font: inherit; cursor: pointer; }
.lang {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  background: transparent; color: var(--ink); border: 1px solid var(--line-strong);
  font-size: .9rem; transition: background-color .15s;
}
.mine-link { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 500; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 999px; border: 0; background: var(--marigold); color: var(--on-marigold);
  font-weight: 600; font-size: .95rem; text-decoration: none; transition: background-color .15s, transform .12s;
}
.btn:active { transform: scale(.97); }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.link-btn { background: none; border: 0; padding: 4px 2px; color: inherit; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
@media (hover: hover) and (pointer: fine) {
  .lang:hover { background: var(--sunk); }
  .btn:hover { background: var(--marigold-hover); }
}

/* ---- page ---- */
main { display: grid; gap: 16px; padding: 32px 0 48px; }
.page-head { display: grid; gap: 6px; margin-bottom: 8px; }
.facts { color: var(--muted); font-size: .95rem; font-variant-numeric: tabular-nums; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 16px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; }

.alert {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 16px;
  border-radius: 12px; background: var(--danger-bg); color: var(--danger-ink);
}
.empty { justify-items: start; padding: 32px 24px; }
.empty h2 { font-size: 1.5rem; }
.empty p { color: var(--ink-2); max-width: 60ch; }

/* ---- tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; display: grid; gap: 2px; align-content: start; min-height: 128px; }
.tile-label { color: var(--muted); font-weight: 500; font-size: .9rem; }
.tile-value { font-family: var(--display); font-weight: 700; font-size: 2.25rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile-note { color: var(--ink-2); font-size: .9rem; font-variant-numeric: tabular-nums; }
.skeleton { background: var(--sunk); border-color: transparent; }
.skeleton .bar { display: block; height: 12px; border-radius: 6px; background: var(--line); }
.skeleton .bar + .bar { margin-top: 12px; }
.skeleton .bar.big { height: 30px; width: 40%; }

/* ---- legend ---- */
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 0; list-style: none; color: var(--ink-2); font-size: .9rem; }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch-filed { background: var(--filed); }
.swatch-fixed { background: var(--fixed); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* ---- trend chart ---- */
.chart { position: relative; min-height: 220px; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart text { fill: var(--muted); font: 500 12px var(--body); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .b-filed { fill: var(--filed); }
.chart .b-fixed { fill: var(--fixed); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover, .chart .hit.on { fill: var(--line); }

/* ---- split row ---- */
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; }

/* ---- types ---- */
.types { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.type-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; }
.type-name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.type-count { font-weight: 600; font-variant-numeric: tabular-nums; }
.type-track { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--sunk); overflow: hidden; }
.type-fill { height: 100%; border-radius: 4px; }
.type-note { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; margin-top: -2px; }

/* ---- map ---- */
.map-card { grid-template-rows: auto 1fr auto; }
.map { min-height: 340px; border-radius: 10px; overflow: hidden; background: var(--sunk); z-index: 0; }
.map-empty { color: var(--muted); font-size: .9rem; }
.leaflet-container { font: inherit; background: var(--sunk); }
.leaflet-tooltip { font: 500 13px/1.4 var(--body); border-radius: 8px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) grayscale(.6) brightness(.85); }
}

/* ---- table ---- */
.table-box { overflow: auto; max-height: 420px; border: 1px solid var(--line); border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { position: sticky; top: 0; background: var(--card); color: var(--muted); font-weight: 500; font-size: .85rem; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table .area-none { color: var(--muted); }

/* ---- recent ---- */
.recent { list-style: none; margin: 0; padding: 0; display: grid; }
.recent li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.recent li:first-child { border-top: 0; padding-top: 0; }
.recent .id { font-weight: 600; font-variant-numeric: tabular-nums; }
.recent .what { color: var(--ink-2); }
.recent .when { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ---- tooltip ---- */
.tooltip {
  position: fixed; z-index: 40; pointer-events: none; padding: 8px 10px; border-radius: 8px;
  background: var(--ink); color: var(--paper); font-size: .85rem; line-height: 1.4;
  font-variant-numeric: tabular-nums; max-width: 240px;
  box-shadow: 0 6px 20px -8px rgba(0, 0, 0, .4);
}

.foot { display: grid; gap: 6px; padding: 0 0 40px; color: var(--muted); font-size: .9rem; }

/* ---- phone ---- */
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  main { padding-top: 24px; }
  h1 { font-size: 1.875rem; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile { padding: 14px 16px; min-height: 120px; }
  .tile-value { font-size: 1.875rem; }
  .card { padding: 16px; }
  .brand-text small { display: none; }
  .btn { padding: 0 14px; }
  .map { min-height: 280px; }
}
@media (max-width: 640px) {
  .mine-link span { display: none; }
  .mine-link { width: 40px; padding: 0; justify-content: center; }
}
@media (max-width: 400px) {
  .topbar .btn span { display: none; }
  .topbar .btn { width: 44px; padding: 0; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
