/* The RailSnap tokens from design-ref/Main.dc.html. The dark steps are chosen
   for that surface rather than inverted: emerald #007A56 on a dark ground fails
   contrast, so the app's own bright stripe green carries the accent there. */
@font-face { font-family: "Plus Jakarta Sans"; src: url(/fonts/PlusJakartaSans-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url(/fonts/PlusJakartaSans-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url(/fonts/PlusJakartaSans-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url(/fonts/PlusJakartaSans-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Anek Bangla"; src: url(/fonts/AnekBangla-400.woff2) format("woff2"); font-weight: 400 500; font-display: swap; unicode-range: U+0980-09FF, U+200C-200D; }
@font-face { font-family: "Anek Bangla"; src: url(/fonts/AnekBangla-600.woff2) format("woff2"); font-weight: 600 700; font-display: swap; unicode-range: U+0980-09FF, U+200C-200D; }

:root {
  --bg: #F5FBF8; --surface: #FFFFFF; --sunken: #EDF6F1; --ink: #10291F; --muted: #4F6B60; --faint: #7C958A;
  --line: #DDEBE5; --line-strong: #C8DAD2; --primary: #007A56; --on-primary: #FFFFFF; --mint: #DFF8EC; --on-mint: #007A56;
  --sun: #FFC233; --sun-tint: #FFF3D6; --on-sun: #6B4A00; --danger: #C2412D; --danger-tint: #FBE6E1; --on-danger: #FFFFFF;
  --series-good: #007A56; --series-bad: #C2412D; --series-warn: #E0A100; --series-track: #E6F1EC;
  --shadow: 0 8px 28px rgb(16 41 31 / .14);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0C1A15; --surface: #13241D; --sunken: #0F1F19; --ink: #E6F1EC; --muted: #9DBDAF; --faint: #7C958A;
  --line: #24392F; --line-strong: #33504A; --primary: #3DDC97; --on-primary: #0C1A15; --mint: #15392B; --on-mint: #A9E8CC;
  --sun: #FFC233; --sun-tint: #3A2F12; --on-sun: #FFD979; --danger: #F0836F; --danger-tint: #40201A; --on-danger: #0C1A15;
  --series-good: #22A874; --series-bad: #D9594A; --series-warn: #C2951F; --series-track: #24392F;
  --shadow: 0 8px 28px rgb(0 0 0 / .5);
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #0C1A15; --surface: #13241D; --sunken: #0F1F19; --ink: #E6F1EC; --muted: #9DBDAF; --faint: #7C958A;
  --line: #24392F; --line-strong: #33504A; --primary: #3DDC97; --on-primary: #0C1A15; --mint: #15392B; --on-mint: #A9E8CC;
  --sun: #FFC233; --sun-tint: #3A2F12; --on-sun: #FFD979; --danger: #F0836F; --danger-tint: #40201A; --on-danger: #0C1A15;
  --series-good: #22A874; --series-bad: #D9594A; --series-warn: #C2951F; --series-track: #24392F;
  --shadow: 0 8px 28px rgb(0 0 0 / .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 400 13.5px/20px "Plus Jakarta Sans", "Anek Bangla", system-ui, sans-serif; font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased; }
html[lang="bn"] body { font-family: "Anek Bangla", "Plus Jakarta Sans", system-ui, sans-serif; font-size: 14.5px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; line-height: 28px; font-weight: 700; }
h2 { font-size: 13.5px; line-height: 20px; font-weight: 700; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; line-height: 16px; }
.mono { font-variant-numeric: tabular-nums; } .right { text-align: right; } .wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .grow { flex: 1 1 auto; min-width: 0; } .between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; } .tight { gap: 6px; }
[hidden] { display: none !important; }
/* An SVG with no size fills its container. Charts opt out with their own rule below. */
svg { width: 16px; height: 16px; flex: none; }

/* Shell */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: 52px minmax(0, 1fr); height: 100vh; }
.side { grid-row: 1 / 3; background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.side .brand { display: flex; align-items: center; height: 32px; padding: 0 8px; margin-bottom: 10px; }
.side .brand img { height: 22px; width: auto; display: block; }
:root[data-theme="dark"] .side .brand img, :root[data-resolved="dark"] .side .brand img, :root[data-theme="dark"] .login-card img, :root[data-resolved="dark"] .login-card img { background: #F5FBF8; border-radius: 6px; padding: 3px 6px; height: 28px; }
.nav-group { font-size: 11px; font-weight: 700; color: var(--faint); letter-spacing: .04em; text-transform: uppercase; padding: 12px 8px 4px; }
html[lang="bn"] .nav-group { text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.nav-link { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.nav-link:hover { background: var(--sunken); text-decoration: none; color: var(--ink); }
.nav-link.on { background: var(--mint); color: var(--on-mint); font-weight: 600; }
.nav-link svg { width: 16px; height: 16px; flex: none; }
.nav-link .count { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--sun); color: #10291F; border-radius: 9px; padding: 0 6px; line-height: 16px; }
.top { display: flex; align-items: center; gap: 8px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.main { overflow-y: auto; padding: 16px 20px 40px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.menu-btn { display: none; }
.search-trigger span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: left; }
.search-trigger { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; min-width: 280px; background: var(--sunken); color: var(--muted); border: 1px solid var(--line); border-radius: 8px; font: inherit; cursor: pointer; }
kbd { font: 600 10.5px/15px "Plus Jakarta Sans", system-ui; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; color: var(--muted); background: var(--surface); }

/* Controls */
button, input, select, textarea { font: inherit; color: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--sunken); text-decoration: none; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.08); background: var(--primary); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-tint); }
.btn.danger-solid { background: var(--danger); color: var(--on-danger); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.icon { width: 30px; padding: 0; }
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.input, select.input, textarea.input { height: 30px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); width: 100%; min-width: 0; }
textarea.input { height: auto; padding: 7px 9px; resize: vertical; min-height: 70px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label, .field-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 11.5px; line-height: 15px; color: var(--faint); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.switch { position: relative; width: 34px; height: 20px; flex: none; appearance: none; border-radius: 10px; background: var(--line-strong); cursor: pointer; margin: 0; transition: background .12s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .12s; }
.switch:checked { background: var(--primary); } .switch:checked::after { left: 16px; }
.switch:disabled { opacity: .5; cursor: not-allowed; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { height: 26px; padding: 0 9px; border-radius: 13px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--mint); color: var(--on-mint); border-color: transparent; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow: auto hidden; scrollbar-width: none; }
.tab { padding: 7px 11px; font-weight: 600; color: var(--muted); border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); }

/* Surfaces */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); min-height: 42px; flex-wrap: wrap; }
.panel-body { padding: 12px; }
.panel-body.flush { padding: 0; }
.cols { display: grid; gap: 12px; align-items: start; }
.cols.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cols.side-r { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stat { background: var(--surface); padding: 10px 12px; display: block; color: inherit; }
a.stat:hover { background: var(--sunken); text-decoration: none; }
.stat .v { font-size: 21px; line-height: 28px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat.good .v { color: var(--primary); } .stat.bad .v { color: var(--danger); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 0; } .kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 19px; padding: 0 7px; border-radius: 10px; font-size: 11px; font-weight: 700; background: var(--sunken); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.good { background: var(--mint); color: var(--on-mint); } .badge.warn { background: var(--sun-tint); color: var(--on-sun); } .badge.bad { background: var(--danger-tint); color: var(--danger); }

.alert { display: flex; align-items: flex-start; gap: 9px; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); }
.alert.warn { background: var(--sun-tint); border-color: transparent; color: var(--on-sun); }
.alert.bad { background: var(--danger-tint); border-color: transparent; color: var(--danger); }
.alert.good { background: var(--mint); border-color: transparent; color: var(--on-mint); }
.alert svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.legacy-mark { display: flex; gap: 9px; padding: 9px 12px; border: 1px dashed var(--line-strong); border-radius: 9px; background: var(--sunken); color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.data th { position: sticky; top: 0; background: var(--surface); text-align: left; font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 7px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
table.data th.sortable { cursor: pointer; } table.data th.num, table.data td.num { text-align: right; }
table.data td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; } table.data tbody tr.clickable:hover { background: var(--sunken); }
.desk-bar { display: flex; gap: 8px; padding: 9px 12px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.desk-bar .input { max-width: 260px; }
.more { padding: 8px 12px; text-align: center; border-top: 1px solid var(--line); }

/* States */
.state { padding: 28px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.state svg { width: 22px; height: 22px; color: var(--faint); }
.state .t { font-weight: 700; color: var(--ink); }
.state.error svg { color: var(--danger); }
.not-collected { display: flex; gap: 8px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 8px; color: var(--muted); font-size: 12.5px; }
.not-collected strong { color: var(--ink); }
.skel { background: linear-gradient(90deg, var(--sunken), var(--line), var(--sunken)); background-size: 200% 100%; animation: shine 1.2s linear infinite; border-radius: 6px; }
@keyframes shine { to { background-position: -200% 0; } }
.skel-card { height: 92px; } .skel-tall { height: 260px; }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* Charts: text uses ink tokens, series colours only on marks. */
.chart > svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { fill: var(--faint); font-size: 10px; } .chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .good { fill: var(--series-good); } .chart .bad { fill: var(--series-bad); } .chart .warn { fill: var(--series-warn); } .chart .track { fill: var(--series-track); }
.chart .line { fill: none; stroke: var(--series-good); stroke-width: 2; stroke-linejoin: round; } .chart .dot { fill: var(--series-good); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; } .chart .hit:hover { fill: rgb(127 127 127 / .12); }
.legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; } .legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.legend i.good { background: var(--series-good); } .legend i.bad { background: var(--series-bad); } .legend i.warn { background: var(--series-warn); }
.chart details { margin-top: 6px; font-size: 12px; color: var(--muted); } .chart details summary { cursor: pointer; }
#tip { position: fixed; z-index: 70; pointer-events: none; background: var(--ink); color: var(--bg); padding: 4px 8px; border-radius: 6px; font-size: 11.5px; line-height: 16px; max-width: 240px; white-space: pre-line; }
.hbar { display: grid; grid-template-columns: minmax(90px, 40%) minmax(0, 1fr) 42px; gap: 8px; align-items: center; padding: 3px 0; font-size: 12.5px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .trk { height: 10px; background: var(--series-track); border-radius: 4px; overflow: hidden; } .hbar .fill { display: block; height: 100%; background: var(--series-good); border-radius: 4px; }
.heat td { text-align: center; font-size: 11.5px; } .heat td.c0 { color: var(--faint); }
.heat td.c1 { background: rgb(0 122 86 / .12); } .heat td.c2 { background: rgb(0 122 86 / .28); } .heat td.c3 { background: rgb(0 122 86 / .48); } .heat td.c4 { background: rgb(0 122 86 / .72); color: #fff; }
.funnel-step { display: grid; grid-template-columns: 110px minmax(0, 1fr) 96px; gap: 8px; align-items: center; padding: 3px 0; }
.funnel-step .bar { height: 18px; background: var(--series-track); border-radius: 4px; } .funnel-step .bar b { display: block; height: 100%; background: var(--series-good); border-radius: 4px; min-width: 2px; }

/* Lists */
.need { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); color: inherit; align-items: center; }
.need:last-child { border-bottom: 0; } .need:hover { background: var(--sunken); text-decoration: none; }
.need b { font-size: 16px; }
.tl { display: flex; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--line); } .tl:last-child { border-bottom: 0; }
.tl .when { width: 124px; flex: none; color: var(--faint); font-size: 12px; }
.tag { display: inline-flex; align-items: center; gap: 4px; background: var(--mint); color: var(--on-mint); border-radius: 5px; padding: 1px 7px; font-size: 12px; font-weight: 600; }
.tag button { border: 0; background: none; padding: 0; cursor: pointer; color: inherit; line-height: 1; }
.setting { display: flex; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); align-items: center; justify-content: space-between; flex-wrap: wrap; } .setting:last-child { border-bottom: 0; }
.setting .input { width: 110px; } .setting .input.wide { width: 280px; }
.ticket { padding: 12px; border-radius: 8px; background: var(--sunken); }

/* Overlays */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgb(8 20 16 / .5); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; overflow-y: auto; }
.dialog { width: 100%; max-width: 480px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); }
.dialog.wide { max-width: 680px; }
.dialog-head { padding: 13px 16px 0; } .dialog-head h2 { font-size: 15px; }
.dialog-body { padding: 10px 16px 4px; display: flex; flex-direction: column; gap: 10px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px 14px; }
.form-error { color: var(--danger); font-size: 12.5px; }
.palette { width: 100%; max-width: 560px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.palette input { width: 100%; height: 44px; padding: 0 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; outline: none; font-size: 14px; }
.palette .results { max-height: 52vh; overflow-y: auto; padding: 5px; }
.palette .opt { display: flex; justify-content: space-between; gap: 10px; padding: 7px 9px; border-radius: 7px; cursor: pointer; }
.palette .opt.on { background: var(--mint); color: var(--on-mint); }
.palette .head { padding: 6px 9px 2px; font-size: 11px; color: var(--faint); font-weight: 700; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 6px; max-width: 360px; }
.toast { padding: 9px 12px; border-radius: 8px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); }
.toast.bad { background: var(--danger); color: var(--on-danger); }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; align-items: center; }

/* Sign in */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.login-card img { height: 26px; align-self: flex-start; }

/* Desktop first; a phone still has to work in an emergency. */
@media (max-width: 1080px) { .cols.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols.side-r { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 40; width: 240px; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .15s; }
  .shell.open .side { transform: none; box-shadow: var(--shadow); }
  .menu-btn { display: inline-flex; }
  .cols.c2, .cols.c3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .search-trigger { min-width: 0; flex: 1; } .search-trigger kbd, .hide-sm { display: none; }
  .main { padding: 12px 16px 32px; }
  .tl .when { width: 92px; }
}
.grid-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 0; }
.panel.panel-body { margin-bottom: 12px; }
