/* FCS Inspection Dashboard — civic console: dark ink sidebar, paper workspace, turmeric accent.
   System fonts only (works offline): Segoe UI / Nirmala UI on Windows render English and Kannada. */
:root {
  --ink: #17323C; --ink-2: #21434F; --ink-3: #2d5664;
  --paper: #F4F5F1; --card: #FFFFFF; --sunk: #ECEFEB; --line: #D9DFDB; --line-2: #C6CFCA;
  --text: #17262D; --muted: #56656C; --faint: #8A979D;
  --accent: #C8861E; --accent-ink: #8E5C10; --accent-soft: #F6E9D3;
  --good: #2F7D4F; --good-bg: #DCEFE2; --warn: #A86A0C; --warn-bg: #F7E8C9; --bad: #B23A2E; --bad-bg: #F6DAD5; --none: #7A8288; --none-bg: #E6E8E5;
  --blue: #2F6DB5;
  --font: "Segoe UI", "Nirmala UI", "Noto Sans Kannada", "Noto Sans", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Cascadia Mono", Consolas, "Noto Sans Mono", ui-monospace, monospace;
  --r: 8px;
  --shadow: 0 1px 2px rgba(23, 50, 60, .06), 0 2px 10px rgba(23, 50, 60, .05);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
#app { min-height: 100%; }
body { margin: 0; background: var(--paper); color: var(--text); font: 14px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- login */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login-brand { background: var(--ink); color: #F1F4F2; padding: 56px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.login-brand .seal { width: 56px; height: 56px; border-radius: 12px; background: var(--accent); display: grid; place-items: center; color: var(--ink); font-weight: 800; font-size: 22px; }
.login-brand h1 { font-size: 34px; line-height: 1.15; margin: 18px 0 10px; font-weight: 700; text-wrap: balance; }
.login-brand p { color: #BFD3D6; max-width: 46ch; margin: 0; }
.login-brand .flow { display: grid; gap: 10px; color: #BFD3D6; font-size: 14px; }
.login-brand .flow b { color: #F1F4F2; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.login-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.login-card h2 { margin: 0; font-size: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.input, select.input { border: 1px solid var(--line-2); background: var(--card); border-radius: 6px; padding: 9px 11px; min-width: 0; }
.input:focus { border-color: var(--ink-3); outline: none; box-shadow: 0 0 0 3px rgba(45, 86, 100, .15); }
.btn { border: 1px solid var(--line-2); background: var(--card); border-radius: 6px; padding: 8px 14px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; justify-content: center; white-space: nowrap; }
.btn:hover { background: var(--sunk); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: var(--ink-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #1d1406; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.error { color: var(--bad); font-size: 13px; min-height: 18px; }
.demo-users { border: 1px dashed var(--line-2); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--card); }
.demo-users h3 { margin: 0; font-size: 13px; color: var(--muted); }
.demo-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.demo-list button { text-align: left; border: 1px solid var(--line); background: var(--paper); border-radius: 6px; padding: 7px 9px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.demo-list button:hover { border-color: var(--ink-3); }
.demo-list b { font-size: 13px; }
.demo-list span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-toggle { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.lang-toggle button { border: 0; background: transparent; padding: 5px 11px; cursor: pointer; font-weight: 600; }
.lang-toggle button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--ink); color: #DCE6E8; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 18px 18px 14px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid rgba(255,255,255,.08); }
.side .brand .seal { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: var(--ink); display: grid; place-items: center; font-weight: 800; flex: none; }
.side .brand b { display: block; font-size: 14px; color: #fff; line-height: 1.2; }
.side .brand span { font-size: 11.5px; color: #A9C2C7; }
.nav { display: flex; flex-direction: column; padding: 10px 8px; gap: 2px; overflow-y: auto; flex: 1; }
.nav button { border: 0; background: transparent; color: #C9D8DB; text-align: left; padding: 9px 12px; border-radius: 6px; cursor: pointer; display: flex; gap: 10px; align-items: center; font-weight: 500; }
.nav button svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav button[aria-current="page"] { background: rgba(224,168,74,.16); color: #F5D9A6; }
.nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 8px 6px; }
.side .who { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; display: flex; flex-direction: column; gap: 2px; }
.side .who b { color: #fff; font-size: 13.5px; }
.side .who span { color: #A9C2C7; }
.side .who button { margin-top: 8px; align-self: flex-start; background: transparent; border: 1px solid rgba(255,255,255,.25); color: #DCE6E8; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 500; background: rgba(244,245,241,.94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); padding: 10px 24px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.topbar h1 { font-size: 19px; margin: 0; margin-right: auto; display: flex; align-items: center; gap: 10px; }
.topbar .filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.topbar select.input { padding: 6px 9px; }
.demo-badge { font-size: 11.5px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); border: 1px solid #E9CF9F; border-radius: 4px; padding: 2px 8px; letter-spacing: .02em; }
.menu-btn { display: none; border: 1px solid var(--line-2); background: var(--card); border-radius: 6px; padding: 6px 9px; cursor: pointer; }
.content { padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.lede { color: var(--muted); margin: -6px 0 0; max-width: 90ch; }

/* ---------- cards & grids */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }
.two { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.two-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-h h2 { font-size: 15px; margin: 0; }
.card-h .hint { font-size: 12.5px; color: var(--muted); }
.card-b { padding: 14px 16px; }
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.kpi .lab { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: 27px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .val small { font-size: 14px; color: var(--muted); font-weight: 600; }
.kpi .foot { font-size: 12.5px; color: var(--muted); }
.kpi.alert .val { color: var(--bad); }
.kpi .live-dot { display: inline-block; width: 8px; height: 8px; margin-left: 8px; border-radius: 50%; background: #2fae5b; box-shadow: 0 0 0 3px rgba(47,174,91,.18); vertical-align: 1px; }
.meter { height: 8px; background: var(--sunk); border-radius: 4px; position: relative; margin-top: 6px; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--ink-3); border-radius: 4px; }
.meter b { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--accent); }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 340px; }
.map-box { height: 380px; border-radius: 0 0 var(--r) var(--r); }
.map-box.full { height: calc(100vh - 210px); min-height: 420px; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.t thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--card); position: sticky; top: 0; z-index: 1; cursor: default; white-space: nowrap; }
table.t thead th.sort { cursor: pointer; }
table.t thead th.sort:hover { color: var(--ink); }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover td { background: #F5F7F4; }
.name { font-weight: 600; }
.sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.bar { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.bar .tr { flex: 1; height: 8px; background: var(--sunk); border-radius: 4px; overflow: hidden; }
.bar .tr i { display: block; height: 100%; border-radius: 4px; background: var(--ink-3); }
.bar .tr i.g { background: var(--good); } .bar .tr i.a { background: #C99A2E; } .bar .tr i.r { background: var(--bad); }
.bar .v { width: 46px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 10px; white-space: nowrap; }
.chip.g { background: var(--good-bg); color: var(--good); } .chip.a { background: var(--warn-bg); color: var(--warn); }
.chip.r { background: var(--bad-bg); color: var(--bad); } .chip.n { background: var(--none-bg); color: var(--none); }
.chip.b { background: #DCE7F4; color: var(--blue); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.hc { display: inline-block; min-width: 36px; padding: 3px 0; border-radius: 4px; font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.hc.g { background: var(--good-bg); color: var(--good); } .hc.a { background: var(--warn-bg); color: var(--warn); }
.hc.r { background: var(--bad-bg); color: var(--bad); } .hc.n { background: var(--none-bg); color: var(--none); }
.delta { font-size: 12px; font-weight: 700; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); } .delta.same { color: var(--faint); }

/* ---------- alerts */
.alerts { display: flex; flex-direction: column; }
.alert-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.alert-row:last-child { border-bottom: 0; }
.alert-row .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; }
.alert-row .ic.high { background: var(--bad-bg); color: var(--bad); } .alert-row .ic.medium { background: var(--warn-bg); color: var(--warn); }
.alert-row h3 { margin: 0; font-size: 14px; }
.alert-row p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.alert-row .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.alert-row .tags span { font-size: 12px; background: var(--sunk); border-radius: 4px; padding: 1px 7px; }
.alert-row .count { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- filters / segmented */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; background: var(--card); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 11px; cursor: pointer; font-weight: 600; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.ph { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--card); cursor: pointer; display: flex; flex-direction: column; text-align: left; padding: 0; }
.ph:hover { border-color: var(--ink-3); }
.ph .img { position: relative; aspect-ratio: 4 / 3; background: var(--sunk); max-width: 100%; }
.ph .img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stamp { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.6); color: #fff; font: 11px/1.35 var(--mono); padding: 5px 7px; }
.ph .meta { padding: 9px 11px; display: flex; flex-direction: column; gap: 4px; }
.ph .meta b { font-size: 13px; }
.ph .meta span { font-size: 12px; color: var(--muted); }
.ph .sev { position: absolute; top: 7px; left: 7px; }

/* ---------- modal / drawer */
.backdrop { position: fixed; inset: 0; background: rgba(12, 24, 29, .45); z-index: 2000; display: flex; justify-content: flex-end; }
.drawer { width: min(760px, 100%); height: 100%; background: var(--paper); overflow-y: auto; box-shadow: -8px 0 30px rgba(0,0,0,.18); display: flex; flex-direction: column; }
.drawer-h { position: sticky; top: 0; background: var(--card); border-bottom: 1px solid var(--line); padding: 14px 18px; display: flex; gap: 12px; align-items: flex-start; z-index: 2; }
.drawer-h h2 { margin: 0; font-size: 17px; }
.drawer-h .x { margin-left: auto; border: 0; background: var(--sunk); border-radius: 6px; width: 32px; height: 32px; cursor: pointer; font-size: 18px; flex: none; }
.drawer-b { padding: 16px 18px 30px; display: flex; flex-direction: column; gap: 14px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; }
.kv div { display: flex; flex-direction: column; gap: 1px; }
.kv span { font-size: 12px; color: var(--muted); }
.kv b { font-weight: 600; }
.obs { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.obs .img { position: relative; aspect-ratio: 4/3; border-radius: 6px; overflow: hidden; background: var(--sunk); }
.obs .img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.obs h3 { margin: 0 0 4px; font-size: 14.5px; }
.obs p { margin: 4px 0; color: var(--muted); }
.mini-map { height: 220px; border-radius: var(--r); border: 1px solid var(--line); }
.flag { color: var(--warn); font-weight: 600; }

/* ---------- data entry */
.entry td input { width: 100px; padding: 5px 7px; border: 1px solid var(--line-2); border-radius: 5px; text-align: right; font-variant-numeric: tabular-nums; }
.entry td input:focus { outline: none; border-color: var(--ink-3); box-shadow: 0 0 0 2px rgba(45,86,100,.15); }
.entry td.miss { background: #FFF8EA; }
.entry .pg { font-size: 11.5px; color: var(--muted); display: block; }
/* each parameter = one group of two columns: Due | Achieved, headers right-aligned over their boxes */
.entry th.grp { text-align: center; white-space: normal; border-left: 1px solid var(--line-2); border-bottom: 0; padding-bottom: 2px; }
.entry tr.subh th { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: none; letter-spacing: 0; padding-top: 2px; }
.entry th.due, .entry th.ach, .entry td.due, .entry td.ach { text-align: right; width: 124px; }
.entry th.due, .entry td.due { border-left: 1px solid var(--line-2); }
.entry th.dname { vertical-align: bottom; }
.entry tr.subh th { top: 33px; }
.entry thead tr:first-child th { height: 33px; box-sizing: border-box; }

/* ---------- my work */
.plan-list { display: flex; flex-direction: column; }
.plan-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.plan-item:last-child { border-bottom: 0; }

.empty { padding: 28px; text-align: center; color: var(--muted); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 3000; box-shadow: var(--shadow); }
.leaflet-popup-content { font: 13px/1.45 var(--font); }
.leaflet-popup-content b { font-size: 13.5px; }
.legend-box { background: rgba(255,255,255,.95); padding: 8px 10px; border-radius: 6px; box-shadow: var(--shadow); font: 12px/1.6 var(--font); }
.legend-box i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 6px; vertical-align: -2px; }

@media (max-width: 1100px) { .two, .two-even { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-brand { padding: 28px 20px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 1500; left: 0; top: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-btn { display: inline-block; }
  .topbar, .content { padding-left: 14px; padding-right: 14px; }
  .obs { grid-template-columns: minmax(0, 1fr); }
  .demo-list { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- drill-down affordances */
.go { cursor: pointer; }
.card.kpi.go { transition: border-color .12s, box-shadow .12s, transform .12s; }
.card.kpi.go:hover { border-color: var(--accent); box-shadow: 0 2px 14px rgba(200,134,30,.18); transform: translateY(-1px); }
.card.kpi.go::before { content: "→"; position: absolute; right: 12px; bottom: 10px; color: var(--faint); font-weight: 700; transition: color .12s, transform .12s; }
.card.kpi.go:hover::before { color: var(--accent); transform: translateX(2px); }
.alert-row.go:hover { background: var(--accent-soft); }
.alert-row .tags span.go { background: var(--card); border: 1px solid var(--line-2); }
.alert-row .tags span.go:hover { border-color: var(--accent); color: var(--accent-ink); }
.kpi .meter + .foot b, .kpi .foot b { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.toolbar.wrap { flex-wrap: wrap; gap: 8px; }
.kpis.seven { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }

/* live clock in the top bar */
.clock { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.15; margin-right: 4px; font-variant-numeric: tabular-nums; }
.clock span { font-size: 11px; color: var(--muted); }
.clock b { font-size: 13px; color: var(--ink); }
@media (max-width: 900px) { .clock { display: none; } }

/* KPI rows: same title height so the big numbers line up; secondary figure on its own line */
.kpis .kpi .lab { min-height: 2.95em; display: block; }
.kpi .vsub { font-size: 12.5px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; margin-top: -2px; }


/* ---------- visit drawer: address check, checklist, documents */
.vsec { margin-top: 12px; }
.vsec-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.vsec-h h3 { margin: 0; font-size: 14px; }
.kv.one { grid-template-columns: minmax(0, 1fr); }
.checklist .cl-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
.checklist .cl-row:first-child { border-top: 0; }
.checklist .ans { font-weight: 700; white-space: nowrap; }
.checklist .ans.yes { color: var(--good, #2f7d4f); }
.checklist .ans.no { color: var(--bad); }
.checklist .ans.na { color: var(--muted); }
.docs { display: flex; flex-wrap: wrap; gap: 10px; }
.docs .doc { width: 110px; text-decoration: none; color: inherit; font-size: 12px; }
.docs .doc img { width: 110px; height: 80px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; margin-bottom: 4px; }
