/* DayBurn — night sky + amber light. Mobile-first; contrast checked for WCAG AA. */
:root {
  --bg: #0b1020;
  --bg2: #10172b;
  --surface: #151d35;
  --surface2: #1c2644;
  --line: #2b3760;
  --text: #eef1f8;
  --muted: #aab4cc; /* 8.6:1 on --surface */
  --amber: #ffb020; /* 10:1 on --bg */
  --amber-ink: #1b1300;
  --amber-soft: rgba(255, 176, 32, 0.14);
  --blue: #5aa9ff;
  --green: #3fd98a;
  --red: #ff7b7b;
  --violet: #b69cff;
  --teal: #5fd6c8;
  --radius: 14px;
  --tap: 48px;
  --tabbar-h: 68px;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #1b2550 0%, transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
a { color: var(--amber); }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible, .chip input:focus-visible + span {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--amber); color: var(--amber-ink); padding: 8px 12px; border-radius: 8px; z-index: 2000; }
.skip:focus { left: 8px; }
main:focus { outline: none; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(11, 16, 32, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-width: 0; margin-right: auto; }
.logo svg { width: 36px; height: 36px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text b { font-size: 1.2rem; letter-spacing: 0.2px; }
.brand-text small { color: var(--muted); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .topnav, .top .report-top { display: none; }
.lang { min-width: var(--tap); padding: 0 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px;
  border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
  color: var(--text); background: var(--surface2);
}
.btn.primary { background: var(--amber); color: var(--amber-ink); box-shadow: 0 0 0 0 rgba(255,176,32,.5), 0 6px 24px -8px rgba(255, 176, 32, 0.7); }
.btn.primary:hover { background: #ffc24d; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--amber); }
.btn.danger { color: var(--red); }
.btn.sm { min-height: 44px; padding: 8px 14px; font-size: 0.95rem; }
.btn.xl { min-height: 58px; font-size: 1.1rem; }
.btn.block { width: 100%; }
.btn.round { width: 52px; height: 52px; padding: 0; border-radius: 50%; font-size: 1.6rem; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }

/* ---------- layout ---------- */
.view.narrow { max-width: 760px; margin: 0 auto; padding: 16px; }
.stack > * + * { margin-top: 14px; }
.h1 { font-size: 1.7rem; line-height: 1.2; margin: 4px 0 0; }
.h2 { font-size: 1.12rem; margin: 0 0 10px; display: flex; align-items: center; gap: 10px; }
.h2 small { color: var(--muted); font-weight: 400; }
.h3 { font-size: 1rem; margin: 16px 0 8px; }
.h2 .n { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--amber); color: var(--amber-ink); font-size: 0.9rem; }
.lede { color: var(--muted); margin: 6px 0 0; font-size: 1.02rem; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 0.87rem; margin: 8px 0 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 8px; font-size: 1rem; }
.card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card.success { border-color: var(--green); background: linear-gradient(0deg, rgba(63,217,138,.08), rgba(63,217,138,.08)), var(--surface); }
.card.success p { margin: 4px 0 0; color: var(--text); }
.empty { text-align: left; }
.empty p { margin: 0 0 12px; }

/* ---------- badges / pills ---------- */
.pill, .badge, .tag {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  font-size: 0.78rem; font-weight: 700; letter-spacing: .2px;
  padding: 3px 9px; border-radius: 999px; vertical-align: middle;
}
.pill { color: #0b1020; }
.st-reported.pill { background: var(--amber); }
.st-sent.pill { background: var(--blue); }
.st-ack.pill { background: var(--violet); }
.st-fixed.pill { background: var(--green); }
.st-stillon.pill { background: var(--red); }
.badge { background: var(--surface2); color: var(--text); border: 1px solid var(--line); }
.badge.sample { background: #3a2f10; color: #ffd27a; border-color: #6b5214; }
.badge.live { color: #9ff0c5; border-color: #2a6a4a; background: #11301f; }
.badge.xs { font-size: 0.7rem; padding: 1px 6px; }
.tag.day { background: var(--amber-soft); color: #ffd27a; border: 1px solid #6b5214; }
.tag.night { background: #1a2248; color: #c8d2f5; border: 1px solid #34407a; }
.tag.sm { padding: 1px 6px; }

/* ---------- map view ---------- */
.mapview { display: flex; flex-direction: column; }
.map-wrap { position: relative; }
#map { height: 56vh; min-height: 320px; background: #1a2240; }
.map-fallback { padding: 24px; color: var(--muted); }
.map-controls { background: var(--bg2); border-bottom: 1px solid var(--line); padding: 10px 16px; }
.toggles { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.toggles label { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-size: 0.95rem; cursor: pointer; }
.toggles input { width: 20px; height: 20px; accent-color: var(--amber); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #0b1020; box-shadow: 0 0 0 1px #56618a; display: inline-block; }
.legend i.glow { background: radial-gradient(circle, rgba(255,138,0,.9), rgba(255,176,32,.2)); }
.side { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; min-width: 0; }
.stat .k { color: var(--muted); font-size: 0.8rem; }
.stat .v { font-size: 1.55rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .v.amber { color: var(--amber); }
.stat .s { color: var(--muted); font-size: 0.75rem; }
.card .stats .stat { background: var(--bg2); }

.c311 { border-color: #24545a; background: linear-gradient(180deg, rgba(95,214,200,.07), transparent 60%), var(--surface); }
.c311 h3 { font-size: 1rem; }
.big311 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 10px 0 4px; }
.big311 .v { display: block; font-size: 1.6rem; font-weight: 800; color: var(--teal); font-variant-numeric: tabular-nums; }
.big311 .k { display: block; font-size: 0.78rem; color: var(--muted); line-height: 1.3; }

/* ---------- report form ---------- */
.loc-status { margin: 0 0 10px; color: var(--text); }
.loc-status.warn { color: #ffd27a; font-weight: 700; }
.pickmap { height: 210px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #1a2240; margin-bottom: 10px; }
.search { display: flex; gap: 8px; margin-top: 10px; }
.search input { flex: 1; }
.results { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.results li + li { border-top: 1px solid var(--line); }
.results li.muted { padding: 12px; }
.results button { width: 100%; text-align: left; background: var(--bg2); color: var(--text); border: 0; padding: 12px; font: inherit; min-height: var(--tap); cursor: pointer; }
.results button:hover { background: var(--surface2); }
input[type=search], input[type=text], input:not([type]), input[type=number], input[type=file] {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  background: var(--bg2); color: var(--text); border: 1px solid #3a4777; border-radius: 10px; font: inherit;
}
input::placeholder { color: #8b96b3; }
.field { display: block; margin-top: 12px; }
.field > span { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.95rem; }
.field small { color: var(--muted); font-weight: 400; }
.photo input { padding: 10px; }
.photo-prev { margin-top: 10px; max-width: 100%; max-height: 220px; border-radius: 10px; }

.sunbox { border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; border: 1px solid; }
.sunbox strong { font-size: 1.15rem; letter-spacing: .5px; }
.sunbox span { color: var(--text); font-size: 0.93rem; }
.sunbox.day { background: linear-gradient(90deg, rgba(255,176,32,.22), rgba(255,176,32,.06)); border-color: #7a5a14; }
.sunbox.day strong { color: var(--amber); }
.sunbox.night { background: #141c3d; border-color: #34407a; }
.sunbox.night strong { color: #c8d2f5; }

.dup { border: 2px solid var(--amber); background: linear-gradient(0deg, var(--amber-soft), var(--amber-soft)), var(--surface); }
.dup p { margin: 6px 0; }

.chips.types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 12px 8px; min-height: 96px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg2);
  font-size: 0.9rem; line-height: 1.2;
}
.chip svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.chip input:checked + span { border-color: var(--amber); background: var(--amber-soft); }
.chip input:checked + span svg { color: var(--amber); }
.count { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper output { min-width: 2ch; text-align: center; font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.submitbar {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 5;
  padding: 12px 0; background: linear-gradient(0deg, var(--bg) 70%, transparent);
}

/* ---------- detail ---------- */
.back { display: inline-flex; min-height: 44px; align-items: center; text-decoration: none; }
.detail-h { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.detail-h .h1 { margin-right: 4px; }
.lede .ico svg, .rcard .ico svg { width: 26px; height: 26px; fill: none; stroke: var(--amber); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -7px; margin-right: 6px; }
.hero { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.hero > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-width: 0; }
.hero .v { display: block; font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.hero .k { display: block; color: var(--muted); font-size: 0.82rem; }
.hero .burn { grid-column: 1 / -1; background: linear-gradient(120deg, rgba(255,176,32,.25), rgba(255,120,0,.08)); border-color: #7a5a14; }
.hero .burn .v { font-size: 3rem; color: var(--amber); line-height: 1; }
.hero .burn .k { font-size: 1rem; color: var(--text); }
.warnline { color: #c8d2f5; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.actions .row .btn { flex: 1 1 auto; }
details.utility { border: 1px dashed var(--line); border-radius: 12px; padding: 4px 12px 12px; }
details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; position: relative; padding-bottom: 14px; }
.timeline li:not(:last-child)::before { content: ''; position: absolute; left: 8px; top: 20px; bottom: 0; width: 2px; background: var(--line); }
.timeline .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); background: var(--bg); flex: none; margin-top: 3px; }
.timeline li.done .dot { background: var(--amber); border-color: var(--amber); }
.timeline li.done.st-sent .dot { background: var(--blue); border-color: var(--blue); }
.timeline li.done.st-ack .dot { background: var(--violet); border-color: var(--violet); }
.timeline li.done.st-fixed .dot { background: var(--green); border-color: var(--green); }
.timeline li.done.st-stillon .dot { background: var(--red); border-color: var(--red); }
.timeline li div { display: flex; flex-direction: column; }
.timeline li:not(.done) b { color: var(--muted); font-weight: 600; }
.evlog { list-style: none; margin: 0; padding: 0; font-size: 0.92rem; }
.evlog li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.evlog time { color: var(--muted); white-space: nowrap; font-size: 0.85rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 8px 0 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.photo-full { margin-top: 12px; width: 100%; border-radius: 12px; }
pre.txt { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg2); padding: 12px; border-radius: 10px; font-size: 0.85rem; color: var(--text); }

/* ---------- tracker ---------- */
.chips.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn { min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.chip-btn[aria-pressed=true] { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }
.chip-btn .cnt { opacity: .85; font-weight: 800; margin-left: 4px; }
.rlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rcard { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.rcard:hover { border-color: var(--amber); }
.rcard .main { flex: 1; min-width: 0; line-height: 1.7; }
.rcard .nums { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.rcard .nums b { font-size: 1.7rem; color: var(--amber); line-height: 1; font-variant-numeric: tabular-nums; }
.rcard .nums span { color: var(--muted); font-size: 0.8rem; }
.rcard .nums em { font-style: normal; font-weight: 700; font-size: 0.9rem; }

/* ---------- numbers ---------- */
.formula { display: flex; flex-direction: column; gap: 6px; }
.formula code, .wi-out code { display: block; background: var(--bg2); border: 1px solid var(--line); padding: 10px 12px; border-radius: 10px; font-size: 0.9rem; color: #ffd27a; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.bullets { padding-left: 20px; }
.bullets li + li { margin-top: 6px; }
.grid2, .grid3 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.grid3 .field:first-child { grid-column: 1 / -1; }
.wi-out { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- tab bar (mobile) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(11, 16, 32, 0.96); border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tabbar-h); color: var(--muted); text-decoration: none; font-size: 0.74rem; font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current] { color: var(--amber); }
.tabbar a.fab { color: var(--amber-ink); }
.tabbar a.fab svg { width: 56px; height: 56px; padding: 14px; margin-top: -26px; border-radius: 50%; background: var(--amber); stroke-width: 3; box-shadow: 0 0 0 6px var(--bg), 0 0 28px 4px rgba(255, 176, 32, 0.55); }
.tabbar a.fab span { color: var(--amber); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 3000; background: #f5f7fc; color: #0b1020; padding: 12px 16px; border-radius: 12px; max-width: min(92vw, 520px); font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.5); }

/* ---------- Leaflet tweaks ---------- */
.leaflet-container { font: inherit; }
.leaflet-popup-content { font-size: 0.92rem; line-height: 1.45; color: #111; }
.leaflet-popup-content a { color: #7a4a00; font-weight: 700; }
.leaflet-popup-content .muted { color: #555; }
.leaflet-control-attribution { font-size: 10px; }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .toast { bottom: 24px; }
  .submitbar { bottom: 0; }
  .top .topnav { display: flex; gap: 4px; }
  .topnav a { color: var(--text); text-decoration: none; padding: 10px 14px; border-radius: 10px; font-weight: 600; }
  .topnav a:hover { background: var(--surface); }
  .topnav a[aria-current] { color: var(--amber); background: var(--surface); }
  .top .report-top { display: inline-flex; }
  .mapview { display: grid; grid-template-columns: minmax(0, 1fr) 400px; height: calc(100vh - 63px); }
  .map-wrap { display: flex; flex-direction: column; min-height: 0; }
  #map { flex: 1; height: auto; }
  .side { overflow-y: auto; border-left: 1px solid var(--line); }
  .hero { grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 10px; }
  .hero .v { font-size: 1.5rem; }
  .hero .burn { grid-column: auto; }
  .chips.types { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid3 .field:first-child { grid-column: auto; }
  .view.narrow { padding: 24px 16px 40px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
.basemap { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--muted); }
.basemap select { min-height: 40px; background: var(--bg2); color: var(--text); border: 1px solid #3a4777; border-radius: 8px; padding: 4px 8px; font: inherit; }
