
  :root {
    --obsidian: #0a0c10;
    --obsidian-mid: #10131a;
    --obsidian-card: #13161f;
    --obsidian-border: #1c2030;
    --obsidian-surface: #181b26;
    --obsidian-lift: #1e2235;

    --gold: #c8a96e;
    --gold-light: #dfc28e;
    --gold-pale: #e8d5aa;
    --gold-dim: #9a7f52;
    --gold-glow: rgba(200, 169, 110, 0.12);

    --text-primary: #e8e4dc;
    --text-secondary: #b8b0a0;
    --text-muted: #9a9284; /* lifted from #7a7264 so small text passes contrast on obsidian */

    --ok: #2ecc71;
    --warn: #f39c12;
    --bad: #e74c3c;

    --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    --serif: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; background: var(--obsidian); color: var(--text-primary); font-family: var(--sans); font-size: 14px; line-height: 1.45; }
  button { font: inherit; color: inherit; cursor: pointer; }
  h1, h2, h3, p, ul, dl, dd { margin: 0; padding: 0; }
  ul { list-style: none; }
  :focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }

  /* ---------- Layout ---------- */
  [hidden] { display: none !important; }
  .app { height: 100vh; height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .view { min-height: 0; min-width: 0; }
  #monitorView { display: grid; grid-template-columns: minmax(340px, 400px) minmax(0, 1fr); grid-template-areas: "panel map"; }
  #analyticsView { display: grid; grid-template-columns: minmax(300px, 340px) minmax(0, 1fr); }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 20px; background: var(--obsidian-mid); border-bottom: 1px solid var(--obsidian-border); }
  .brand { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
  .brand h1 { font-family: var(--serif); font-weight: 700; font-size: 20px; color: var(--gold-pale); letter-spacing: 0.005em; }
  .brand p { color: var(--text-muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .actions { display: flex; gap: 8px; flex-shrink: 0; }

  .btn { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--obsidian-lift); background: var(--obsidian-card); border-radius: 6px; font-weight: 500; font-size: 13px; color: var(--text-primary); }
  .btn:hover { border-color: var(--gold-dim); }
  .btn svg, .tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
  .btn-primary { background: var(--gold); border-color: var(--gold); color: var(--obsidian); }
  .btn-primary:hover { background: var(--gold-light); border-color: var(--gold-light); }
  .btn.spinning svg { animation: spin 0.9s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ---------- Panel ---------- */
  .panel { grid-area: panel; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; background: var(--obsidian-mid); border-right: 1px solid var(--obsidian-border); }
  .controls { flex: none; padding: 14px 16px 12px; border-bottom: 1px solid var(--obsidian-border); display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .controls > * { min-width: 0; }   /* a wide child (the scrolling chip row) must not widen the column */
  .controls h2, .list-head h2 { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }

  .seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--obsidian-lift); border-radius: 6px; overflow: hidden; }
  .seg button { background: transparent; border: 0; padding: 7px 8px; font-size: 13px; color: var(--text-secondary); }
  .seg button + button { border-left: 1px solid var(--obsidian-lift); }
  .seg button[aria-pressed="true"] { background: var(--gold-glow); color: var(--gold-pale); font-weight: 600; box-shadow: inset 0 -2px 0 var(--gold); }
  .seg button:hover { color: var(--text-primary); }

  .chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .chips { scrollbar-width: thin; scrollbar-color: var(--obsidian-lift) transparent; }
  .chips::-webkit-scrollbar { height: 6px; } .chips::-webkit-scrollbar-thumb { background: var(--obsidian-lift); border-radius: 3px; }
  .chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--obsidian-lift); background: transparent; color: var(--text-muted); font-size: 12.5px; }
  .chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); opacity: 0.45; }
  .chip .n { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); }
  .chip[aria-pressed="true"] { color: var(--text-primary); border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
  .chip[aria-pressed="true"] .dot { opacity: 1; }
  .chip[aria-pressed="true"] .n { color: var(--text-secondary); }

  details.feeds > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-secondary); display: flex; align-items: center; justify-content: space-between; gap: 8px; list-style: none; }
  details.feeds > summary::-webkit-details-marker { display: none; }
  details.feeds > summary::after { content: "Show"; font-weight: 400; color: var(--text-muted); font-size: 12px; }
  details.feeds[open] > summary::after { content: "Hide"; }
  .feed-list { margin-top: 10px; display: grid; gap: 8px; max-height: min(30vh, 300px); overflow-y: auto; padding-right: 2px; }
  .feeds-dock { flex: none; padding: 10px 16px 12px; border-top: 1px solid var(--obsidian-border); background: var(--obsidian-mid); }
  .feed { padding: 9px 10px; border: 1px solid var(--obsidian-border); border-radius: 6px; background: var(--obsidian-card); }
  .feed-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .feed-head strong { font-weight: 600; font-size: 13px; }
  .feed-detail { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
  .badge { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; }
  .badge[data-s="ok"] { color: var(--ok); }
  .badge[data-s="loading"] { color: var(--text-secondary); }
  .badge[data-s="stale"], .badge[data-s="config"] { color: var(--warn); }
  .badge[data-s="error"] { color: var(--bad); }
  .rw-form { display: flex; gap: 6px; margin-top: 8px; }
  .rw-form input { flex: 1; min-width: 0; padding: 6px 8px; border-radius: 5px; border: 1px solid var(--obsidian-lift); background: var(--obsidian); color: var(--text-primary); font: inherit; font-size: 13px; }
  .rw-form button { padding: 6px 10px; border-radius: 5px; border: 1px solid var(--gold-dim); background: transparent; color: var(--gold-pale); font-size: 13px; }
  .feed a, .about a, .pop a { color: var(--gold-light); }

  .about { margin-top: 10px; font-size: 12.5px; color: var(--text-muted); }
  .about summary { cursor: pointer; color: var(--text-secondary); }
  .about p { margin-top: 6px; }

  .list-head { flex: none; display: flex; justify-content: space-between; align-items: baseline; padding: 12px 16px 6px; }
  .list-head h2 { margin: 0; }
  .list-head span { font-size: 12px; color: var(--text-muted); }
  .list { flex: 1 1 auto; min-height: 150px; overflow-y: auto; padding: 4px 10px 16px; display: grid; align-content: start; gap: 6px; }
  .list::-webkit-scrollbar { width: 8px; }
  .list::-webkit-scrollbar-thumb { background: var(--obsidian-lift); border-radius: 4px; }
  .empty { padding: 28px 12px; text-align: center; color: var(--text-muted); }
  .empty strong { display: block; color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; }

  .ev { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; width: 100%; text-align: left; padding: 9px 10px; background: var(--obsidian-card); border: 1px solid var(--obsidian-border); border-radius: 6px; }
  .ev:hover { border-color: var(--gold-dim); background: var(--obsidian-surface); }
  .ev .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-top: 5px; }
  .ev.unrated .dot { background: transparent; border: 2px solid var(--c); }
  .ev-title { display: block; font-weight: 500; font-size: 13.5px; color: var(--text-primary); overflow-wrap: anywhere; }
  .ev-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; font-size: 12px; color: var(--text-muted); }

  /* severity: monochrome bars, so colour stays reserved for category */
  .sev { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
  .bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
  .bars i { display: block; width: 3px; background: var(--obsidian-lift); border-radius: 1px; }
  .bars i:nth-child(1) { height: 4px; } .bars i:nth-child(2) { height: 7px; } .bars i:nth-child(3) { height: 10px; } .bars i:nth-child(4) { height: 12px; }
  .bars i.on { background: var(--gold); }
  .sev[data-level="Critical"] { color: var(--gold-pale); font-weight: 600; }

  /* ---------- Map ---------- */
  .map-pane { grid-area: map; position: relative; min-height: 0; background: var(--obsidian); }
  #map { position: absolute; inset: 0; background: var(--obsidian); z-index: 0; }
  .map-tools { position: absolute; top: 12px; right: 12px; display: grid; gap: 8px; z-index: 500; }
  .tool { width: 36px; height: 36px; display: grid; place-items: center; background: var(--obsidian-card); border: 1px solid var(--obsidian-lift); border-radius: 6px; color: var(--text-primary); }
  .tool:hover { border-color: var(--gold-dim); }
  .legend { position: absolute; left: 12px; bottom: 12px; z-index: 500; padding: 9px 12px; background: rgba(19, 22, 31, 0.92); border: 1px solid var(--obsidian-lift); border-radius: 6px; font-size: 12px; color: var(--text-secondary); display: grid; gap: 6px; }
  .legend-row { display: flex; align-items: center; gap: 12px; }
  .legend-note { color: var(--text-muted); max-width: 330px; line-height: 1.35; }
  .legend-row span { display: inline-flex; align-items: center; gap: 5px; }
  .legend svg { display: block; }

  .leaflet-container { font-family: var(--sans); background: var(--obsidian); }
  .leaflet-bar a, .leaflet-bar a:hover { background: var(--obsidian-card); color: var(--text-primary); border-color: var(--obsidian-lift); }
  .leaflet-bar a:hover { background: var(--obsidian-surface); }
  .leaflet-control-attribution { background: rgba(10, 12, 16, 0.85) !important; color: var(--text-muted) !important; }
  .leaflet-control-attribution a { color: var(--gold-dim) !important; }
  .wf-popup .leaflet-popup-content-wrapper { background: var(--obsidian-card); color: var(--text-primary); border: 1px solid var(--obsidian-lift); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55); }
  .wf-popup .leaflet-popup-tip { background: var(--obsidian-card); }
  .wf-popup .leaflet-popup-content { margin: 0; width: auto !important; min-width: 280px; }
  .wf-popup a.leaflet-popup-close-button { color: var(--text-muted); }
  .pop { padding: 12px 14px 13px; }
  .pop-cat { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-secondary); }
  .pop-cat .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
  .pop h3 { font-size: 14.5px; font-weight: 600; margin: 5px 24px 8px 0; line-height: 1.3; overflow-wrap: anywhere; }
  .pop dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--obsidian-border); font-size: 12.5px; }
  .pop dt { color: var(--text-muted); }
  .pop dd { color: var(--text-primary); overflow-wrap: anywhere; }
  .pop dd.mono { font-family: var(--mono); font-size: 12px; }
  .pop-links { margin-top: 10px; display: grid; gap: 4px; font-size: 12.5px; }
  .pop-note { margin-top: 8px; font-size: 12px; color: var(--text-muted); }

  /* ---------- Small screens ---------- */
  @media (max-width: 820px) {
    #monitorView { grid-template-columns: minmax(0, 1fr); grid-template-rows: 44vh minmax(0, 1fr); grid-template-rows: 44dvh minmax(0, 1fr); grid-template-areas: "map" "panel"; }
    #analyticsView { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
    .apanel { max-height: 34vh; border-right: 0; border-bottom: 1px solid var(--obsidian-border); }
    .viewtabs button span { display: none; }
    .brand p { display: none; }
    .btn span { display: none; }
    .btn { padding: 8px; }
    .panel { border-right: 0; overflow-y: auto; }
    .list { overflow: visible; flex: none; min-height: 0; }
    .feed-list { max-height: none; }
    .controls { order: 0; } .feeds-dock { order: 1; border-top: 0; padding-top: 0; } .tabs, .rbar, .list-head { order: 2; } .list { order: 3; }
    .legend { display: none; }
  }
  /* Reports tab, theme filter, report cards */
  .tabs { flex: none; display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--obsidian-border); }
  .tab { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 10px 8px 9px; color: var(--text-muted); font-size: 13px; font-weight: 500; }
  .tab .n { font-family: var(--mono); font-size: 11.5px; margin-left: 4px; }
  .tab:hover { color: var(--text-primary); }
  .tab[aria-selected="true"] { color: var(--gold-pale); border-bottom-color: var(--gold); }
  .themes { position: relative; flex: none; padding: 8px 16px 10px; border-bottom: 1px solid var(--obsidian-border); }
  .themes-body { position: absolute; left: 0; right: 0; top: 100%; z-index: 800; padding: 4px 16px 14px; max-height: min(60vh, 420px); overflow-y: auto; background: var(--obsidian-card); border-bottom: 1px solid var(--obsidian-lift); box-shadow: 0 14px 24px rgba(0, 0, 0, 0.55); }
  .themes > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-secondary); display: flex; justify-content: space-between; list-style: none; }
  .themes > summary::-webkit-details-marker { display: none; }
  .themes > summary::after { content: "Show"; font-weight: 400; color: var(--text-muted); font-size: 12px; }
  .themes[open] > summary::after { content: "Hide"; }
  .rbar { flex: none; padding: 8px 16px 0; border-bottom: 1px solid var(--obsidian-border); }
  .rbar input[type="search"] { width: 100%; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--obsidian-lift); background: var(--obsidian); color: var(--text-primary); font: inherit; font-size: 13px; }
  .rbar input[type="search"]::placeholder { color: var(--text-muted); }
  .rbar .themes { padding: 8px 0 10px; border-bottom: 0; }
  .rbar .themes-body { left: -16px; right: -16px; }
  .fgroup h3 { margin: 10px 0 2px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
  .fgroup:first-child h3 { margin-top: 6px; }
  .theme-actions { display: flex; gap: 14px; margin-top: 4px; }
  .theme-actions button { background: transparent; border: 0; padding: 0; color: var(--gold-light); font-size: 12.5px; text-decoration: underline; }
  .theme-chips { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
  .tchip { padding: 3px 9px; border-radius: 999px; border: 1px solid var(--obsidian-lift); background: transparent; color: var(--text-muted); font-size: 12px; }
  .tchip .n { font-family: var(--mono); font-size: 11px; margin-left: 5px; }
  .tchip[aria-pressed="true"] { color: var(--text-primary); border-color: var(--gold-dim); background: var(--gold-glow); }
  .rep { padding: 9px 10px; background: var(--obsidian-card); border: 1px solid var(--obsidian-border); border-radius: 6px; }
  .rep-title { color: var(--text-primary); font-weight: 500; font-size: 13.5px; text-decoration: none; overflow-wrap: anywhere; }
  .rep-title:hover { color: var(--gold-light); text-decoration: underline; }
  .rep-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 3px; font-size: 12px; color: var(--text-muted); }
  .rep-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
  .rep-tags span { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--obsidian-lift); color: var(--text-muted); }
  .rep-tags span.on { border-color: var(--gold-dim); color: var(--gold-pale); }
  .rep-map { display: block; margin-top: 6px; background: transparent; border: 0; padding: 0; color: var(--gold-light); font-size: 12px; text-decoration: underline; }
  .pop-scroll { max-height: 210px; overflow-y: auto; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--obsidian-border); display: grid; gap: 9px; }
  .pop-scroll a { display: block; font-size: 12.5px; line-height: 1.3; }
  .pop-scroll small { display: block; margin-top: 1px; color: var(--text-muted); font-size: 11.5px; }


  /* ---------- View tabs, sheet, analytics ---------- */
  .viewtabs { display: flex; gap: 2px; padding: 3px; background: var(--obsidian); border: 1px solid var(--obsidian-lift); border-radius: 8px; }
  .viewtabs button { background: transparent; border: 0; border-radius: 6px; padding: 6px 14px; color: var(--text-muted); font-size: 13px; font-weight: 500; }
  .viewtabs button:hover { color: var(--text-primary); }
  .viewtabs button[aria-selected="true"] { background: var(--gold-glow); color: var(--gold-pale); box-shadow: inset 0 0 0 1px var(--gold-dim); }
  .btn-gold { border-color: var(--gold-dim); color: var(--gold-pale); }
  .btn-gold:hover { background: var(--gold-glow); }
  select, input.txt { width: 100%; background: var(--obsidian); border: 1px solid var(--obsidian-lift); color: var(--text-primary); border-radius: 6px; padding: 7px 8px; font: inherit; font-size: 13px; }
  select:focus, input.txt:focus { border-color: var(--gold-dim); outline: none; }

  .apanel { min-height: 0; overflow-y: auto; background: var(--obsidian-mid); border-right: 1px solid var(--obsidian-border); }
  .ablock { padding: 14px 16px; border-bottom: 1px solid var(--obsidian-border); display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .ablock h2 { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
  .fl { display: grid; gap: 4px; font-size: 12px; color: var(--text-muted); }
  .anote { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
  .rangebox { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .linkbtn { background: transparent; border: 0; padding: 0; color: var(--gold-light); font-size: 12.5px; text-decoration: underline; justify-self: start; }
  .amain { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
  .apane { flex: 1; min-height: 0; position: relative; }
  #map2 { position: absolute; inset: 0; background: var(--obsidian); }
  .alegend { position: absolute; left: 12px; bottom: 12px; z-index: 500; padding: 9px 12px; background: rgba(19, 22, 31, 0.94); border: 1px solid var(--obsidian-lift); border-radius: 6px; font-size: 12px; color: var(--text-secondary); max-width: 300px; }
  .alegend .lt { font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
  .alegend .lr { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
  .alegend i { width: 16px; height: 11px; border-radius: 2px; display: inline-block; border: 1px solid rgba(255,255,255,.12); }
  .alegend .ln { margin-top: 6px; color: var(--text-muted); }

  .dash { height: 100%; overflow-y: auto; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 14px; align-content: start; }
  .card { background: var(--obsidian-card); border: 1px solid var(--obsidian-border); border-radius: 8px; padding: 12px 14px 14px; min-width: 0; }
  .card.wide { grid-column: 1 / -1; }
  .card h3 { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 2px; }
  .card .sub { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
  .card .cv { position: relative; height: 240px; }
  .card .cv.tall { height: 340px; }
  .kpis { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .kpi { background: var(--obsidian-card); border: 1px solid var(--obsidian-border); border-radius: 8px; padding: 10px 12px; min-width: 0; }
  .kpi .v { font-size: 20px; font-weight: 600; color: var(--gold-pale); overflow-wrap: anywhere; }
  .kpi .l { font-size: 12px; color: var(--text-muted); }
  .kpi .d { font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; overflow-wrap: anywhere; }
  .cardnote { margin-top: 8px; font-size: 12px; color: var(--text-muted); }
  .tablepane { height: 100%; overflow: auto; padding: 0 16px 16px; }
  .tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
  .tbl th { position: sticky; top: 0; background: var(--obsidian-mid); text-align: left; padding: 9px 8px; color: var(--text-secondary); font-weight: 600; border-bottom: 1px solid var(--obsidian-lift); cursor: pointer; white-space: nowrap; }
  .tbl td { padding: 7px 8px; border-bottom: 1px solid var(--obsidian-border); }
  .tbl tr.row { cursor: pointer; } .tbl tr.row:hover td { background: var(--obsidian-surface); }
  .tbl td.num { font-family: var(--mono); font-size: 12.5px; text-align: right; }
  .tbl th.num { text-align: right; }
  .tabletools { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px; font-size: 12.5px; color: var(--text-muted); }

  /* country picker */
  .picker { position: relative; }
  .picker ul { position: absolute; left: 0; right: 0; top: 100%; z-index: 900; margin-top: 2px; max-height: 240px; overflow-y: auto; background: var(--obsidian-card); border: 1px solid var(--obsidian-lift); border-radius: 6px; box-shadow: 0 12px 24px rgba(0,0,0,.55); }
  .picker li { padding: 7px 10px; font-size: 13px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
  .picker li:hover, .picker li[aria-selected="true"] { background: var(--gold-glow); }
  .picker li small { color: var(--text-muted); }
  .cchips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
  .cchip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px; border: 1px solid var(--gold-dim); background: var(--gold-glow); color: var(--gold-pale); font-size: 12px; }
  .cchip button { background: transparent; border: 0; width: 18px; height: 18px; border-radius: 50%; color: var(--gold-pale); line-height: 1; }
  .cchip button:hover { background: rgba(255,255,255,.12); }

  /* sheet (country profile, SITREP, settings) */
  #scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 1100; }
  #sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); z-index: 1200; display: flex; flex-direction: column; background: var(--obsidian-mid); border-left: 1px solid var(--obsidian-lift); box-shadow: -18px 0 40px rgba(0,0,0,.55); }
  .sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--obsidian-border); }
  .sheet-head h2 { font-family: var(--serif); font-size: 19px; color: var(--gold-pale); font-weight: 700; }
  .sheet-head p { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
  .sheet-actions { display: flex; gap: 8px; flex-shrink: 0; }
  .sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px 32px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-content: start; }
  .sec h3 { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
  .sec .cv { position: relative; height: 240px; }
  .sec .cv.sm { height: 200px; }
  .sec .cv.tall { height: 340px; }
  .tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .tile { background: var(--obsidian-card); border: 1px solid var(--obsidian-border); border-radius: 8px; padding: 8px 10px; min-width: 0; }
  .tile .l { font-size: 11.5px; color: var(--text-muted); line-height: 1.3; }
  .tile .v { font-size: 17px; font-weight: 600; color: var(--text-primary); margin-top: 2px; overflow-wrap: anywhere; }
  .tile .y { font-size: 11px; color: var(--text-muted); }
  .tile.na .v { color: var(--text-muted); font-size: 13px; font-weight: 500; }
  .tile svg { display: block; width: 100%; height: 22px; margin-top: 4px; }
  .msg { padding: 10px 12px; border: 1px solid var(--obsidian-lift); border-radius: 6px; font-size: 12.5px; color: var(--text-secondary); background: var(--obsidian-card); }
  .msg.err { border-color: var(--bad); color: #f1a59d; }
  .live { display: grid; gap: 6px; font-size: 13px; }
  .live div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--obsidian-border); padding: 5px 0; }
  .live span:first-child { color: var(--text-muted); } .live span:last-child { text-align: right; overflow-wrap: anywhere; }
  .live a { color: var(--gold-light); }

  /* analysis output */
  .an { display: grid; gap: 14px; }
  .an h4 { font-size: 12.5px; font-weight: 600; color: var(--gold-pale); margin-bottom: 4px; }
  .an p, .an li { font-size: 13px; line-height: 1.5; color: var(--text-primary); overflow-wrap: anywhere; }
  .an ul { padding-left: 18px; list-style: disc; display: grid; gap: 3px; }
  .an .bluf { padding: 10px 12px; border-left: 3px solid var(--gold); background: var(--gold-glow); border-radius: 0 6px 6px 0; }
  .an table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
  .an th, .an td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--obsidian-border); }
  .an th { color: var(--text-muted); font-weight: 500; white-space: nowrap; }
  .an td.c { text-align: center; font-family: var(--mono); }
  .rate { display: inline-block; padding: 1px 9px; border-radius: 999px; border: 1px solid currentColor; font-size: 12px; font-weight: 600; white-space: nowrap; }
  .rate[data-r="Low"] { color: #8fb0d0; } .rate[data-r="Medium"] { color: var(--gold-light); } .rate[data-r="High"] { color: #f39c12; } .rate[data-r="Extreme"] { color: #ff6b5a; }
  .aibar { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--obsidian-lift); border-radius: 8px; background: var(--obsidian-card); }
  .aibar .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
  .aibar small { color: var(--text-muted); font-size: 12px; }
  details.prompt summary { cursor: pointer; font-size: 12.5px; color: var(--text-secondary); }
  details.prompt pre { margin-top: 6px; max-height: 240px; overflow: auto; padding: 8px; background: var(--obsidian); border: 1px solid var(--obsidian-border); border-radius: 6px; font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; color: var(--text-secondary); }
  .fl-row { display: grid; gap: 10px; }

  .leaflet-tooltip.wf-tip { background: var(--obsidian-card); color: var(--text-primary); border: 1px solid var(--obsidian-lift); box-shadow: 0 6px 16px rgba(0,0,0,.5); font-family: var(--sans); font-size: 12.5px; }
  .leaflet-tooltip-top.wf-tip::before { border-top-color: var(--obsidian-lift); }
  .riskcard { border: 1px solid var(--obsidian-border); border-radius: 8px; padding: 10px 12px; background: var(--obsidian-card); display: grid; gap: 6px; }
  .riskhead { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
  .riskhead strong { font-size: 13.5px; }

  /* ReliefWeb search view */
  #rwView { display: grid; grid-template-columns: minmax(340px, 400px) minmax(0, 1fr); grid-template-areas: "panel map"; }
  #rwView.collapsed { grid-template-columns: minmax(0, 1fr); grid-template-areas: "map"; }
  #rwView.collapsed .panel { display: none; }
  #map3 { position: absolute; inset: 0; background: var(--obsidian); z-index: 0; }
  .rwform { display: flex; gap: 8px; } .rwform input { flex: 1; min-width: 0; }
  .seg.five { grid-template-columns: repeat(5, 1fr); }
  .rwfilter { border: 1px solid var(--obsidian-border); border-radius: 6px; background: var(--obsidian-card); }
  .rwfilter > summary { cursor: pointer; padding: 8px 10px; font-size: 13px; font-weight: 600; color: var(--text-secondary); list-style: none; display: flex; justify-content: space-between; gap: 8px; }
  .rwfilter > summary::-webkit-details-marker { display: none; }
  .rwfilter > summary::after { content: "Show"; font-weight: 400; color: var(--text-muted); font-size: 12px; }
  .rwfilter[open] > summary::after { content: "Hide"; }
  .rwfilter .theme-chips { margin: 0; padding: 0 10px 10px; }
  .rwhead { align-items: center; gap: 8px; }
  .rwhead #rwCount { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
  .rwhead select { width: auto; background: var(--obsidian); border: 1px solid var(--obsidian-lift); color: var(--text-secondary); border-radius: 6px; padding: 4px 6px; font: inherit; font-size: 12px; }
  .rwpager { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--obsidian-border); font-size: 12.5px; color: var(--text-muted); background: var(--obsidian-mid); }
  .rwpager .btn { padding: 5px 10px; } .rwpager .btn:disabled { opacity: 0.4; cursor: default; }
  .snip { margin-top: 6px; font-size: 12.5px; line-height: 1.45; color: var(--text-secondary); overflow-wrap: anywhere; }
  mark { background: rgba(200, 169, 110, 0.28); color: var(--gold-pale); border-radius: 2px; padding: 0 1px; }
  .rep-tags button.ctag { font: inherit; font-size: 11.5px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--obsidian-lift); background: transparent; color: var(--text-secondary); cursor: pointer; }
  .rep-tags button.ctag:hover { border-color: var(--gold-dim); color: var(--gold-pale); }
  .rep-tags button.ctag.on { border-color: var(--gold); background: var(--gold-glow); color: var(--gold-pale); }

  /* collapsible side panels and fullscreen */
  .panel-toggle { position: absolute; top: 12px; left: 12px; z-index: 500; }
  .panel-toggle.is-collapsed svg, #aToggle.is-collapsed svg { transform: scaleX(-1); }
  #monitorView.collapsed { grid-template-columns: minmax(0, 1fr); grid-template-areas: "map"; }
  #monitorView.collapsed .panel { display: none; }
  #analyticsView.collapsed { grid-template-columns: minmax(0, 1fr); }
  #analyticsView.collapsed .apanel { display: none; }
  .atabbar { display: flex; align-items: stretch; border-bottom: 1px solid var(--obsidian-border); }
  .atabbar .tabs { flex: 1; min-width: 0; border-bottom: 0; }
  .atabbar .tool { width: 44px; height: auto; border-radius: 0; border: 0; border-right: 1px solid var(--obsidian-border); background: transparent; }
  .ico-exit { display: none; }
  body.fs .ico-exit { display: inline-block; } body.fs .ico-enter { display: none; }
  body.fs .topbar { display: none; }
  body.fs .app { grid-template-rows: minmax(0, 1fr); }
  #fsExit { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 1300; box-shadow: 0 8px 24px rgba(0,0,0,.6); }
  @media (max-width: 820px) {
    #monitorView.collapsed { grid-template-rows: minmax(0, 1fr); grid-template-areas: "map"; }
    #analyticsView.collapsed { grid-template-rows: minmax(0, 1fr); }
    #rwView { grid-template-columns: minmax(0, 1fr); grid-template-rows: 44vh minmax(0, 1fr); grid-template-rows: 44dvh minmax(0, 1fr); grid-template-areas: "map" "panel"; }
    #rwView.collapsed { grid-template-rows: minmax(0, 1fr); grid-template-areas: "map"; }
    .rwpager { order: 4; }
    .alegend { display: none; }              /* a legend would cover a third of the small phone map; tap a country for its value, or use fullscreen */
    body.fs .alegend { display: block; left: 8px; bottom: 60px; max-width: 200px; padding: 8px 10px; font-size: 11.5px; }
    body.fs .alegend .ln { display: none; }
    .panel-toggle { top: 10px; left: 10px; }
  }

  @media (max-width: 820px) { .topbar { padding: 8px 12px; gap: 8px; } }
  @media (max-width: 520px) {
    .brand { display: none; }          /* the view tabs identify the app; space is needed for the buttons */
    #fsBtn { display: none; }          /* the map carries its own fullscreen control */
    .viewtabs button { padding: 6px 10px; }
  }

  @media (max-width: 400px) { #refreshBtn { display: none; } }
  @media (max-width: 360px) { .topbar { padding: 6px 8px; gap: 6px; } .actions { gap: 4px; } .btn { padding: 7px; } .viewtabs button { padding: 6px 8px; font-size: 12.5px; } }
  @media (max-width: 350px) { .topbar { padding: 6px 6px; gap: 4px; } .actions { gap: 2px; } .btn { padding: 6px; } .viewtabs { padding: 2px; gap: 0; } .viewtabs button { padding: 6px 5px; font-size: 11.5px; } }

  /* Short windows (small laptops, high display scaling): tighten the filters so the event list keeps its space */
  @media (max-height: 640px) and (min-width: 821px) {
    .topbar { padding: 6px 16px; }
    .controls { padding: 8px 12px 8px; gap: 8px; }
    .controls h2 { display: none; }
    .seg button { padding: 5px 8px; }
    .chips { gap: 5px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }   /* one scrolling row instead of several wrapped rows */
    .chip { flex: none; padding: 3px 8px; font-size: 12px; }
    .list-head { padding: 8px 12px 4px; }
    .tab { padding: 6px 8px 5px; }
    .themes { padding: 6px 12px 8px; }
    .rbar { padding: 6px 12px 0; }
    .feeds-dock { padding: 7px 12px 8px; }
    .feed-list { max-height: 26vh; }
    .feed { padding: 6px 8px; }
  }
  @media (prefers-reduced-motion: reduce) { .btn.spinning svg { animation: none; } }