@font-face {
  /* Digit-only subset of Kalpurush (SIL OFL, see /static/fonts/LICENSE-kalpurush.txt): only 0-9 and ০-৯ use it. */
  font-family: "PB Digits";
  src: url("../fonts/kalpurush-digits.woff2") format("woff2");
  unicode-range: U+0030-0039, U+09E6-09EF;
  font-display: swap;
}
:root {
  --bg: #0c111c;
  --panel: #131a29;
  --panel-2: #182134;
  --line: #243049;
  --text: #e8ecf3;
  --muted: #9aa6bb;
  --accent: #e23b4e;
  --accent-2: #4f7cff;
  --focus: #ffd166;
  --bin-0: #3a4256;
  --bin-1: #8a7350;
  --bin-2: #d98b1f;
  --bin-3: #ef5b3c;
  --bin-4: #e2203f;
  --radius: 10px;
  --font: "PB Digits", "Hind Siliguri", "Noto Sans Bengali", "Kalpurush", "SolaimanLipi", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}
a { color: #8fb0ff; }
a:hover { color: #b8ccff; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--focus); color: #000; padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; }
.muted { color: var(--muted); }
.hp { position: absolute; left: -9999px; }

/* ---------------------------------------------------------------- header */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px; border-bottom: 1px solid var(--line); background: #0e1422;
}
.brand { display: flex; gap: 12px; align-items: center; color: var(--text); text-decoration: none; }
.brand strong { display: block; font-size: 1.45rem; line-height: 1.1; }
.brand small { color: var(--muted); font-size: .85rem; }
.mainnav { display: flex; gap: 4px; margin-inline: auto; flex-wrap: wrap; }
.mainnav a { white-space: nowrap; color: var(--text); text-decoration: none; padding: 8px 14px; border-bottom: 2px solid transparent; }
.mainnav a[aria-current="page"] { border-bottom-color: var(--accent-2); }
.mainnav a:hover { background: var(--panel); border-radius: 6px; }
.updated { text-align: right; font-size: .9rem; }
.updated small { display: block; color: var(--muted); }

main { flex: 1; min-height: 0; }

/* ---------------------------------------------------------------- layouts */
.layout-map {
  display: grid; grid-template-columns: 360px minmax(0, 1fr) 370px;
  height: calc(100vh - 68px); min-height: 560px;
}
.col-left, .col-right { overflow-y: auto; padding: 12px; }
.col-left { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.col-right { border-left: 1px solid var(--line); }
.col-map { position: relative; min-height: 420px; }
#map { position: absolute; inset: 0; background: #0b1220; }

.layout-page { display: grid; grid-template-columns: minmax(0, 1fr) 370px; min-height: calc(100vh - 68px); }
.page-main { padding: 20px 28px; max-width: 1200px; }
.page-head h1 { margin: 0 0 4px; }
.layout-prose { padding: 24px; display: flex; justify-content: center; }
.prose { max-width: 820px; }
.prose h2 { margin-top: 2rem; border-bottom: 1px solid var(--line); padding-bottom: 4px; }

/* ---------------------------------------------------------------- panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.panel-title { font-size: 1.05rem; margin: 10px 0 8px; font-weight: 600; }
.panel-title:first-child { margin-top: 0; }
.panel-title small { color: var(--muted); font-weight: 400; }
.panel-head h1 { font-size: 1.5rem; margin: 4px 4px 0; }
.panel-head p { margin: 0 4px 10px; }

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.segmented button, .map-modes button, .btn, .pager button {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; cursor: pointer;
}
.segmented button[aria-pressed="true"], .map-modes button[aria-pressed="true"], .pager button[aria-current="page"] {
  background: var(--accent-2); border-color: var(--accent-2); color: #fff;
}
.btn { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); margin-top: 10px; width: 100%; }
.custom-range { margin-top: 8px; color: var(--muted); }
.custom-range summary { cursor: pointer; }
.custom-range .row { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin-top: 6px; }
.custom-range label { display: flex; flex-direction: column; font-size: .85rem; }
input[type="date"], input[type="text"], input[type="email"], select, textarea {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
select:disabled { opacity: .5; }
.selects { display: grid; gap: 6px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.checks label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.checks input { width: 18px; height: 18px; accent-color: var(--accent-2); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.stats div { background: var(--panel-2); border-radius: 8px; padding: 8px 4px; }
.stats b { display: block; font-size: 1.6rem; line-height: 1.2; }
.stats div:nth-child(2) b { color: var(--bin-3); }
.stats div:nth-child(3) b { color: var(--bin-2); }
.stats div:nth-child(4) b { color: #ff8fa0; }
.stats span { font-size: .8rem; color: var(--muted); }
.stats-wide { margin: 16px 0; }
.stats-wide b { font-size: 2rem; }

/* ---------------------------------------------------------------- news list */
.news-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; flex: 1; }
.news-list li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.news-item { display: block; width: 100%; text-align: left; font: inherit; color: inherit; background: none; border: 0; padding: 10px 12px; cursor: pointer; }
.news-item:hover, .news-list li.active { background: var(--panel-2); }
.news-list li.active { border-color: var(--accent-2); }
.news-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .85rem; }
.news-place { color: var(--text); font-weight: 600; font-size: .95rem; }
.news-place::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: middle; }
.news-title { font-weight: 600; margin: 4px 0; font-size: 1.02rem; }
.news-foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .85rem; padding: 0 12px 10px; }
.news-foot a { color: var(--muted); }
.tag { display: inline-block; font-size: .75rem; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; margin-left: 6px; }
.news-list-wide .news-title { font-size: 1.1rem; }
.empty { color: var(--muted); padding: 16px; text-align: center; }
.pager { display: flex; gap: 6px; justify-content: center; padding: 10px 0; flex-wrap: wrap; }
.pager button[disabled] { opacity: .4; cursor: default; }

/* ---------------------------------------------------------------- map overlays */
.map-modes { position: absolute; top: 12px; left: 12px; display: flex; gap: 4px; background: rgba(12, 17, 28, .85); padding: 4px; border-radius: 10px; border: 1px solid var(--line); }
.legend { position: absolute; left: 12px; bottom: 28px; background: rgba(12, 17, 28, .9); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; max-width: 240px; }
.legend h2 { font-size: .95rem; margin: 0 0 6px; }
.legend ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 50%; }
.bin-0 { background: var(--bin-0); } .bin-1 { background: var(--bin-1); } .bin-2 { background: var(--bin-2); }
.bin-3 { background: var(--bin-3); } .bin-4 { background: var(--bin-4); }
.legend-note { color: var(--muted); font-size: .75rem; margin: 6px 0 0; }
.coverage-banner { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); background: #3b2a10; color: #ffd9a0; border: 1px solid #7a5418; border-radius: 8px; padding: 6px 12px; font-size: .9rem; max-width: 90%; }
.div-label { color: #fff; font-weight: 700; font-size: 1.05rem; text-shadow: 0 1px 3px #000, 0 0 8px #000; pointer-events: none; }
.cluster-marker { display: grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; cursor: pointer; border: 2px solid rgba(255, 255, 255, .5); box-shadow: 0 0 0 6px rgba(226, 59, 78, .25); font-family: var(--font); }
.maplibregl-popup-content { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; font-family: var(--font); padding: 10px 14px; }
.maplibregl-popup-tip { border-top-color: var(--panel) !important; border-bottom-color: var(--panel) !important; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 18px; }
.popup h3 { margin: 0 0 4px; font-size: 1.05rem; }
.popup p { margin: 2px 0; }
.popup button { margin-top: 6px; }
.noscript { position: absolute; inset: 40% 10%; text-align: center; }

/* ---------------------------------------------------------------- incident card */
.incident-card { border-left: 4px solid var(--accent-2); padding-left: 12px; }
.incident-card h3 { margin: 0 0 6px; font-size: 1.1rem; }
.incident-card .meta { color: var(--muted); font-size: .9rem; display: flex; gap: 12px; flex-wrap: wrap; }
.incident-card ul { padding-left: 18px; margin: 8px 0; }
.incident-card .legal { display: inline-block; background: #2a2140; color: #d9c9ff; border-radius: 6px; padding: 0 8px; font-size: .85rem; }
.incident-card .id { font-family: ui-monospace, monospace; font-size: .75rem; color: var(--muted); word-break: break-all; }

.notice p, .notice-inline { color: var(--muted); font-size: .9rem; margin: 0; }
.notice-inline { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }

/* ---------------------------------------------------------------- analysis */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.chart-box { position: relative; height: 280px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td:not(:first-child), .table th:not(:first-child) { text-align: right; }

/* ---------------------------------------------------------------- form */
.form { display: grid; gap: 12px; max-width: 560px; }
.form label { display: grid; gap: 4px; }
.form .btn { justify-self: start; padding: 8px 20px; }
#correction-status { min-height: 1.5em; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1200px) {
  .layout-map { grid-template-columns: 320px minmax(0, 1fr); }
  .layout-map .col-right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; height: auto; }
  .layout-map { height: auto; grid-template-rows: calc(100vh - 68px) auto; }
}
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  .mainnav { order: 3; width: 100%; margin: 0; overflow-x: auto; flex-wrap: nowrap; }
  .updated { margin-left: auto; }
  .layout-map { display: flex; flex-direction: column; }
  .col-map { order: -1; height: 65vh; }
  .col-left { border-right: 0; }
  .layout-map .col-right { display: block; }
  .layout-page { grid-template-columns: 1fr; }
  .layout-page .col-right { order: -1; border-left: 0; }
  .page-main { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .stats b { font-size: 1.3rem; }
  .legend { bottom: 8px; left: 8px; padding: 6px 10px; }
  .legend-note { display: none; }
  .layout-prose { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
.reset-btn { display: grid !important; place-items: center; }
.age-groups { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.age-groups button { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 6px; cursor: pointer; white-space: nowrap; }
.age-groups button[aria-pressed="true"] { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.hint { color: var(--muted); font-size: .8rem; margin: 6px 0 0; }

/* ---------------------------------------------------------------- page tools: period buttons + filter button */
.layout-page.single { grid-template-columns: minmax(0, 1fr); }
.layout-page.single .page-main { max-width: 1200px; width: 100%; margin: 0 auto; }
.page-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-title-row h1 { margin: 0; }
.page-sub { margin: 8px 0 0; }
.period-chips { display: flex; gap: 6px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.period-chips::-webkit-scrollbar { display: none; }
.period-chips button {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; white-space: nowrap; flex: none;
}
.period-chips button[aria-pressed="true"] { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.filter-btn {
  display: inline-flex; align-items: center; gap: 8px; font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 16px; cursor: pointer; white-space: nowrap; flex: none;
}
.filter-btn:hover { background: var(--panel-2); }
.filter-count { background: var(--accent-2); color: #fff; border-radius: 999px; font-size: .8rem; padding: 0 8px; line-height: 1.6; }
.segmented-3 { grid-template-columns: repeat(3, 1fr); }
.span-2 { grid-column: 1 / -1; }

/* map page: tools bar above the map */
.col-map { display: flex; flex-direction: column; }
.map-tools { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--bg); }
.map-tools .period-chips { margin-top: 0; flex: 1; min-width: 0; }
.map-area { position: relative; flex: 1; min-height: 360px; }

/* filter drawer: side panel on wide screens, bottom sheet on phones */
.filter-drawer { position: fixed; inset: 0; z-index: 60; }
.filter-drawer[hidden] { display: none; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(400px, 100%); background: var(--panel);
  border-left: 1px solid var(--line); display: flex; flex-direction: column; animation: drawer-in .2s ease-out;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 1.2rem; }
.drawer-close { font: inherit; font-size: 1.6rem; line-height: 1; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 2px 8px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.drawer-foot { padding: 12px 16px; border-top: 1px solid var(--line); }
.drawer-foot .btn { width: 100%; padding: 10px; }
body.drawer-open { overflow: hidden; }
@keyframes drawer-in { from { transform: translateX(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (max-width: 860px) {
  .drawer-panel { top: auto; left: 0; width: 100%; max-height: 88vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; animation-name: sheet-in; }
  .map-tools { padding: 8px; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .drawer-panel { animation: none; } }

/* map credits: a small round "i" (bottom-right) that opens on tap */
.maplibregl-ctrl-attrib.maplibregl-compact {
  background: rgba(12, 17, 28, .85) !important; color: var(--muted); border: 1px solid var(--line); min-height: 24px;
}
.maplibregl-ctrl-attrib.maplibregl-compact a { color: var(--muted); }
.maplibregl-ctrl-attrib-button { background-color: #e8ecf3 !important; border-radius: 50% !important; }
