:root { color-scheme: dark; --accent: #3fb950; --bg: #0d1117; --fg: #e6edf3; --muted: #8b949e; --card: #161b22; --bar: rgba(13, 17, 23, .82); }
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, sans-serif; background: var(--bg); color: var(--fg); overflow: hidden; }
body.list-mode { overflow: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; padding: max(.6rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) .6rem max(1rem, env(safe-area-inset-left)); background: var(--bar); backdrop-filter: blur(4px); }
h1 { margin: 0; font-size: 1.35rem; }
.metric { display: flex; gap: .25rem; border: 0; margin: 0; padding: 0; }
.metric label { cursor: pointer; padding: .2rem .7rem; border-radius: 6px; background: #21262d; font-weight: 600; }
.metric input { position: absolute; opacity: 0; pointer-events: none; }
.metric label:has(input:checked) { background: #2f81f7; color: #fff; }
.metric label:has(input:focus-visible) { outline: 2px solid #79c0ff; }
.legend { font-size: .75rem; color: var(--muted); }
.legend-bar { height: 8px; border-radius: 4px; }
.legend-ends { display: block; margin: .15rem 0 0; }
/* P6: four tick labels under the diverging bar, at −1, −0.5, 0, +1 */
.legend-ticks { position: relative; height: 1.1em; margin: .1rem .4rem 0; }
.legend-ticks span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.legend-hundred, .legend-grey { margin: 0; }
.swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; background: rgb(107 115 125); vertical-align: -1px; }

.globe { position: fixed; inset: 0; }
.globe canvas { display: block; cursor: grab; touch-action: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.globe canvas.dragging { cursor: grabbing; }
#status { position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; margin: 0; padding: .4rem max(1rem, env(safe-area-inset-right)) max(.4rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); color: var(--muted); font-size: .82rem; background: var(--bar); }
#status.error { color: #ff7b72; }

.tooltip { position: fixed; z-index: 3; max-width: 280px; padding: .5rem .7rem; border-radius: 8px; background: var(--card); border: 1px solid #30363d; pointer-events: none; font-size: .85rem; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.tooltip .score { font-weight: 600; }
.tooltip .muted { color: var(--muted); }

main { max-width: 860px; margin: 0 auto; padding: 9rem 1rem 3rem; }
#country-list { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .75rem; }
.country { background: var(--card); border-radius: 8px; padding: .75rem 1rem; }
.country .head { display: flex; justify-content: space-between; gap: 1rem; }
.country .bar { display: block; height: 6px; border-radius: 3px; margin: .4rem 0; }
.country .detail { color: var(--muted); font-size: .85rem; }
.country .explain { margin: .4rem 0 0; font-size: .9rem; }
.grades { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.badge { font-size: .75rem; padding: 0 .4rem; border-radius: 4px; background: #30363d; }
.grade-A { background: #1f6f3f; } .grade-B { background: #3d5a1f; } .grade-C { background: #6b4f12; }
.grade-assumed, .warn { background: #6e2a2a; }


/* S3: scenario actions, detail panel, params drawer */
button { font: inherit; font-size: .8rem; color: var(--fg); background: #21262d; border: 1px solid #30363d; border-radius: 6px; padding: .2rem .6rem; cursor: pointer; }
button:hover:not(:disabled) { background: #30363d; }
a.button { font-size: .8rem; color: var(--fg); background: #21262d; border: 1px solid #30363d; border-radius: 6px; padding: .2rem .6rem; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
a.button:hover { background: #30363d; }
.explain a { color: #79c0ff; white-space: nowrap; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid #79c0ff; outline-offset: 1px; }
button.icon { font-size: 1.1rem; line-height: 1; padding: .1rem .5rem; }
.ring-key { display: inline-block; width: .7rem; height: .7rem; border: 2px solid #fff; border-radius: 50%; vertical-align: -1px; }

.panel { position: fixed; z-index: 2; top: calc(var(--topbar-h, 3.2rem) + .5rem); right: .75rem; bottom: 2.4rem; width: min(360px, calc(100vw - 1.5rem)); overflow: auto; padding: .75rem 1rem; background: var(--card); border: 1px solid #30363d; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.45); font-size: .85rem; }
.panel[hidden] { display: none; }
.panel.params { right: auto; left: .75rem; width: min(300px, calc(100vw - 1.5rem)); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.panel h2 { margin: 0; font-size: 1.1rem; }
.panel h3 { margin: .8rem 0 .3rem; font-size: .9rem; }
.panel .muted, .panel .source { color: var(--muted); }
.panel p { margin: .2rem 0; }
.fields { display: grid; gap: .55rem; margin-top: .6rem; }
.field { padding: .4rem .5rem; border-radius: 6px; border-left: 3px solid transparent; }
.field label { display: block; font-weight: 600; font-size: .8rem; }
.field-line { display: flex; gap: .35rem; margin: .2rem 0; }
.field input { flex: 1; min-width: 0; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid #30363d; border-radius: 6px; padding: .2rem .4rem; }
.field.assumed { background: rgba(210, 153, 34, .1); border-left-color: #d29922; }
.field.modified { border-left-color: #fff; }
.field.modified input { border-color: #fff; }
.field.invalid input { border-color: #ff7b72; }
.field .source { font-size: .75rem; margin: 0; }
.field-error { color: #ff7b72; font-size: .75rem; margin: 0; }
.field-error:empty { display: none; }
.badge.modified { background: #fff; color: #0d1117; }
.computed { width: 100%; border-collapse: collapse; font-size: .8rem; }
.computed th, .computed td { padding: .15rem .3rem; text-align: left; }
.computed .num { text-align: right; font-variant-numeric: tabular-nums; }
.computed tr.current { background: rgba(47, 129, 247, .18); }
.panel > button:not(.sheet-handle), .panel-body > button { margin-top: .6rem; }
.country { cursor: pointer; }

/* S6: mobile. The detail panel is a bottom sheet at <= 768 px: collapsed it
   peeks (handle, name, meta) above the status line and the globe stays
   visible; expanded it takes 75 % of the height. The params drawer docks at
   the bottom. Touch targets are >= 40 px; safe-area insets respected. */
.sheet-handle { display: none; }
.panel-body { min-height: 0; }
@media (max-width: 768px) {
  .topbar { gap: .4rem .6rem; padding-bottom: .5rem; }
  .metric label { min-height: 40px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
  button.icon { min-width: 40px; min-height: 40px; }
  .legend-hundred { font-size: .7rem; }
  .tooltip { max-width: min(280px, calc(100vw - 8px)); }

  .panel.sheet {
    --peek: calc(5.6rem + env(safe-area-inset-bottom));
    --sheet-base: 0px;
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 75vh; height: 75dvh;
    display: flex; flex-direction: column; overflow: hidden;
    padding: 0 max(1rem, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(1rem, env(safe-area-inset-left));
    border-radius: 14px 14px 0 0; border-bottom: 0; z-index: 3;
    transform: translateY(calc(var(--sheet-base) + var(--sheet-drag, 0px)));
    transition: transform .22s ease-out;
  }
  .panel.sheet[hidden] { display: none; }
  .panel.sheet[data-sheet="collapsed"] { --sheet-base: calc(100% - var(--peek)); }
  .panel.sheet.sheet-dragging { transition: none; }
  .panel.sheet .panel-body { flex: 1; overflow: auto; overscroll-behavior: contain; padding-bottom: .75rem; }
  .panel.sheet[data-sheet="collapsed"] .panel-body { overflow: hidden; }
  .sheet-handle { display: flex; flex: none; align-items: center; justify-content: center; width: 100%; height: 28px; min-height: 28px; padding: 0; margin: 0; border: 0; background: transparent; touch-action: none; cursor: grab; }
  .sheet-handle:hover:not(:disabled) { background: transparent; }
  .sheet-handle span { display: block; width: 44px; height: 5px; border-radius: 3px; background: #6e7681; }
  .panel.params { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 60vh; max-height: 60dvh; border-radius: 14px 14px 0 0; padding-bottom: max(.75rem, env(safe-area-inset-bottom)); z-index: 3; }
}
@media (prefers-reduced-motion: reduce) { .panel.sheet { transition: none; } }

/* S5: flat view, modal, keyboard focus */
.viewmode label { font-weight: 500; }
.globe[hidden], .flat[hidden] { display: none; }
.flat { position: fixed; left: 0; right: 0; top: var(--topbar-h, 7rem); bottom: 2.4rem; padding: .25rem max(.5rem, env(safe-area-inset-left)); display: flex; }
.flat-map { display: block; flex: 1 1 auto; width: 100%; height: 100%; min-width: 0; min-height: 0; }
.flat-map .land path { fill: #1b2430; stroke: #3a4757; stroke-width: .5; fill-rule: evenodd; }
.flat-map .land path.has-data { fill: #222e3c; cursor: pointer; }
.flat-map .land circle.point { stroke: #0d1117; stroke-width: .6; cursor: pointer; }
.flat-map .land circle.point.selected { stroke: #fff; stroke-width: 1.2; }
.flat-map .land circle.no-data-point { fill: #4a5563; stroke: #1b2430; stroke-width: .5; }
.flat-map .land path.selected { fill: #2d3d52; stroke: #c9d1d9; stroke-width: 1; }
.flat-map rect { cursor: pointer; stroke: rgba(0,0,0,.45); stroke-width: .5; }
.flat-map rect.modified { stroke: #fff; stroke-width: 1.2; }
.flat-map rect.selected { stroke: #fff; stroke-width: 2; }
.flat-map rect:focus { outline: none; }
.flat-map rect:focus-visible { stroke: #79c0ff; stroke-width: 2.5; }
a:focus-visible, li.country:focus-visible, .sheet-handle:focus-visible, .modal-card:focus-visible { outline: 2px solid #79c0ff; outline-offset: 2px; }
.modal { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(1, 4, 9, .65); }
.modal[hidden] { display: none; }
.modal-card { width: min(560px, 100%); max-height: calc(100dvh - 2rem); overflow: auto; padding: 1rem 1.25rem; background: var(--card); border: 1px solid #30363d; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.6); font-size: .9rem; }
.modal-card:focus { outline: none; }
.modal-card h2 { margin: 0; font-size: 1.15rem; }
.formulas { margin: .5rem 0; display: grid; grid-template-columns: max-content 1fr; gap: .25rem .8rem; }
.formulas dt { font-family: ui-monospace, monospace; font-weight: 600; white-space: nowrap; }
.formulas dd { margin: 0; color: var(--muted); }
.caveats { margin: .4rem 0; padding-left: 1.2rem; color: var(--muted); }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin: .8rem 0 0; }
@media (max-width: 480px) { .formulas { grid-template-columns: 1fr; } .formulas dd { margin-bottom: .3rem; } }

/* Grade E (estimated): asterisk, est.* badge and its popover, legend swatch */
.grade-E { background: #4a4f6b; }
button.badge.est { border: 0; color: inherit; font: inherit; font-size: .75rem; cursor: pointer; min-height: 0; }
.est-mark { align-self: center; color: var(--muted); font-weight: 600; }
.est-pop { margin: .3rem 0; padding: .4rem .6rem; border: 1px solid #30363d; border-radius: 6px; font-size: .8rem; background: var(--card); }
.est-pop ul { margin: .2rem 0; padding-left: 1.1rem; }
.est-pop p { margin: 0; }
.est-pop a { color: #79c0ff; }
.swatch-est { width: 1.6rem; }
.legend-est { margin: 0; }

/* D1: filtered countries, Detail view (map left, table right; stacked <= 768 px) */
.flat-map rect.filtered { display: none; }
.flat-map .land path.dimmed { fill: #161c25; stroke: #262f3b; cursor: default; }
.detail-view[hidden] { display: none; }
.detail-view { position: fixed; left: 0; right: 0; top: var(--topbar-h, 7rem); bottom: 2.4rem; display: grid; grid-template-columns: 1.6rem minmax(0, 40%) minmax(0, 1fr); gap: .5rem; padding: .25rem max(.5rem, env(safe-area-inset-right)) 0 max(.5rem, env(safe-area-inset-left)); }
.detail-map { display: flex; min-width: 0; min-height: 0; align-items: flex-start; }
.detail-side { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; font-size: .8rem; }
/* E4: map pane capped at 40 %, collapsible; the open panel pushes the view left on desktop */
.map-toggle { align-self: start; width: 1.6rem; padding: .4rem 0; writing-mode: vertical-rl; white-space: nowrap; font-size: .75rem; }
.detail-view.map-collapsed { grid-template-columns: 1.6rem minmax(0, 1fr); }
.detail-view.map-collapsed .detail-map { display: none; }
@media (min-width: 1024px) {
  .detail-view.panel-open { right: calc(min(360px, 100vw - 1.5rem) + 1.25rem); }
}
.filter-bar { display: flex; flex-wrap: wrap; gap: .3rem .8rem; align-items: center; padding: .4rem .5rem; background: var(--card); border: 1px solid #30363d; border-radius: 8px; }
.filter-bar input[type="search"], .filter-bar select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid #30363d; border-radius: 6px; padding: .1rem .35rem; }
.fb-item { display: inline-flex; gap: .3rem; align-items: center; }
.fb-label { color: var(--muted); }
.fb-checks, .fb-grades { display: flex; flex-wrap: wrap; gap: .2rem .7rem; flex-basis: 100%; }
.fb-check { white-space: nowrap; cursor: pointer; }
.fb-range { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.fb-range input { width: 7rem; }
.fb-actions { display: flex; gap: .4rem; align-items: center; margin-left: auto; }
.fb-count { margin: 0; color: var(--muted); }
.table-wrap { flex: 1 1 auto; min-height: 0; max-width: 100%; overflow-x: auto; overflow-y: auto; margin-top: .4rem; border: 1px solid #30363d; border-radius: 8px; }
.detail-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.detail-table th { position: sticky; top: 0; z-index: 1; background: var(--card); text-align: left; padding: 0; white-space: nowrap; }
.detail-table th.num { text-align: right; }
.detail-table th button.sort { width: 100%; border: 0; border-radius: 0; background: transparent; font-weight: 600; padding: .3rem .4rem; text-align: inherit; }
.detail-table th[aria-sort="ascending"] button.sort::after { content: " ▲"; }
.detail-table th[aria-sort="descending"] button.sort::after { content: " ▼"; }
.detail-table td { padding: .2rem .4rem; border-top: 1px solid #21262d; white-space: nowrap; }
.detail-table td.num { text-align: right; }
.detail-table th:first-child { left: 0; z-index: 2; }
.detail-table td.name { position: sticky; left: 0; z-index: 1; background: var(--bg); box-shadow: 1px 0 0 #30363d; }
.detail-table tbody tr[aria-selected="true"] td.name { background: #16273d; }
.detail-table td .iso { color: var(--muted); font-size: .72rem; }
.detail-table .grades-cell .badge { font-size: .68rem; margin-right: .15rem; }
.detail-table sup.gl { color: var(--muted); font-size: .65rem; margin-left: .1rem; }
.detail-table sup.fx { color: #d29922; }
.detail-table tbody tr { cursor: pointer; }
.detail-table tbody tr:hover { background: rgba(47, 129, 247, .08); }
.detail-table tbody tr[aria-selected="true"] { background: rgba(47, 129, 247, .22); }
.detail-table tbody tr:focus-visible { outline: 2px solid #79c0ff; outline-offset: -2px; }
.score-cell { min-width: 5.5rem; }
.sbar { display: inline-block; width: 3rem; height: 6px; margin-right: .3rem; border-radius: 3px; background: #21262d; vertical-align: middle; overflow: hidden; }
.sbar-fill { display: block; height: 100%; }
.snum { display: inline-block; min-width: 1.6rem; }
@media (max-width: 768px) {
  .detail-view { display: block; overflow: auto; }
  .detail-view[hidden] { display: none; }
  .map-toggle { display: none; }
  .detail-view.map-collapsed .detail-map { display: flex; }
  .detail-map { height: 45vh; }
  .detail-side { min-height: 60vh; }
  .table-wrap { max-height: 70vh; }
  .filter-bar select, .filter-bar input[type="search"] { min-height: 36px; }
}
/* G1 rank column: sticky with the name column */
.detail-table th:first-child, .detail-table td.rank { width: 2.6rem; min-width: 2.6rem; max-width: 2.6rem; }
.detail-table td.rank { position: sticky; left: 0; z-index: 1; background: var(--bg); color: var(--muted); }
.detail-table th:nth-child(2) { left: 2.6rem; z-index: 2; }
.detail-table td.name { left: 2.6rem; }
.country .head .rank { color: var(--muted); min-width: 2.5rem; font-variant-numeric: tabular-nums; }
.country .head strong { flex: 1; }

/* H1: header bar (wordmark, view menu, tools), hamburger <= 768 px, legend
   popover, Settings and Import / Export modals, Hide GUI. */
.topbar { flex-wrap: nowrap; gap: .5rem 1rem; padding-top: max(.45rem, env(safe-area-inset-top)); padding-bottom: .45rem; }
.brand { flex: none; margin: 0; font-size: 1.25rem; line-height: 1; }
.brand a { display: inline-flex; align-items: center; gap: .35rem; color: var(--fg); text-decoration: none; }
.mark { flex: none; color: #79c0ff; }
.wordmark { font-weight: 800; letter-spacing: -.02em; }
.wordmark .accent { color: var(--accent); }
.menu { flex: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .75rem; min-width: 0; }
.menu-views { display: flex; gap: .2rem; list-style: none; margin: 0; padding: 0; }
.menu-views a { display: inline-flex; align-items: center; padding: .3rem .7rem; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem; }
.menu-views a:hover { color: var(--fg); background: #21262d; }
.menu-views a[aria-current="page"] { color: #fff; background: #2f81f7; }
.menu-tools { display: flex; flex-wrap: wrap; gap: .3rem; justify-content: flex-end; }
.menu-tools button[aria-expanded="true"] { background: #30363d; border-color: #8b949e; }
.hamburger { display: none; }
/* T1: Outlook, a compact segmented tier control plus the home-country select. */
.menu-right { display: flex; align-items: center; gap: .4rem; margin-left: auto; min-width: 0; }
#btn-outlook { padding: .25rem .6rem; white-space: nowrap; max-width: 18rem; overflow: hidden; text-overflow: ellipsis; }
#btn-outlook.custom { border-color: #d2a8ff; color: #d2a8ff; }
a.icon-link { padding: .2rem .45rem; color: var(--muted); }
a.icon-link:hover { color: var(--fg); background: #30363d; }
.outlook { display: block; }
.outlook h3 { margin: .9rem 0 .4rem; }
.outlook .seg { display: flex; }
.outlook .seg button { flex: 1 1 0; padding: .4rem .5rem; }
#outlook-home { width: 100%; padding: .35rem; }
.outlook-label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.seg { display: inline-flex; border: 1px solid #30363d; border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; margin: 0; padding: .25rem .5rem; font-size: .8rem; background: transparent; color: var(--muted); white-space: nowrap; }
.seg button + button { border-left: 1px solid #30363d; }
.seg button:hover { color: var(--fg); background: #21262d; }
.seg button[aria-pressed="true"] { color: #fff; background: #2f81f7; font-weight: 600; }
.seg button:focus-visible, #outlook-home:focus-visible { outline: 2px solid #79c0ff; outline-offset: -2px; }
#outlook-home { max-width: 9.5rem; font-size: .8rem; padding: .2rem .3rem; }
.legend-outlook { margin: 0 0 .35rem; font-weight: 600; font-size: .85rem; }
.outlook-line { color: #d2a8ff; }
/* Q1: header metric control (S · F · W · Life), same look as the tier buttons */
.metric-seg { flex: none; }
.legend { position: fixed; z-index: 4; top: calc(var(--topbar-h, 3.2rem) + .4rem); right: .75rem; width: min(280px, calc(100vw - 1.5rem)); padding: .6rem .75rem; background: var(--card); border: 1px solid #30363d; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.45); }
.legend[hidden] { display: none; }
.modal-card h3 { margin: .9rem 0 .35rem; font-size: .95rem; }
.modal-card .lead { margin-top: .5rem; color: var(--fg); }
.modal .metric { margin: .6rem 0 0; flex-wrap: wrap; }
.modal .metric legend { padding: 0; margin-bottom: .3rem; color: var(--muted); font-size: .85rem; }
.modal .params .muted { color: var(--muted); margin: 0; }
.modal textarea { width: 100%; margin-top: .3rem; font: .8rem/1.4 ui-monospace, monospace; color: var(--fg); background: var(--bg); border: 1px solid #30363d; border-radius: 6px; padding: .4rem; resize: vertical; }
.modal .muted { color: var(--muted); }
.io-row { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0; }
.io-msg { margin: .4rem 0 0; color: var(--muted); font-size: .85rem; }
.io-msg.error { color: #ff7b72; }
.io-msg:empty { display: none; }
.show-gui { position: fixed; z-index: 5; top: max(.5rem, env(safe-area-inset-top)); right: max(.5rem, env(safe-area-inset-right)); opacity: .8; }
.show-gui[hidden] { display: none; }
body.gui-hidden { --topbar-h: 0px; }
body.gui-hidden .topbar, body.gui-hidden #panel, body.gui-hidden #legend, body.gui-hidden #status { display: none; }
@media (max-width: 768px) {
  .hamburger { display: inline-flex; flex-direction: column; justify-content: center; gap: 4px; margin-left: auto; width: 44px; height: 40px; padding: 0 11px; }
  .hamburger span { display: block; height: 2px; border-radius: 1px; background: var(--fg); }
  .menu { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; padding: .5rem max(1rem, env(safe-area-inset-right)) .75rem max(1rem, env(safe-area-inset-left)); background: var(--card); border-bottom: 1px solid #30363d; box-shadow: 0 8px 20px rgba(0,0,0,.5); }
  .topbar.menu-open .menu { display: flex; }
  .menu-views { flex-direction: column; }
  .menu-views a { min-height: 44px; }
  .menu-tools { justify-content: flex-start; }
  .menu-tools button { flex: 1 1 auto; min-height: 40px; }
  .menu-right { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .menu-right .metric-seg { flex: 1 1 100%; }
  #btn-outlook { flex: 1 1 auto; min-height: 40px; max-width: none; }
  a.icon-link { min-width: 44px; min-height: 40px; }
  .seg { flex: 1 1 100%; }
  .seg button { flex: 1 1 0; min-height: 40px; padding: .25rem .3rem; }
  #outlook-home { flex: 1 1 100%; max-width: none; min-height: 40px; }
  .metric-seg { width: 100%; }
  .show-gui { min-height: 40px; }
}
/* P3: data filters in the Settings modal, out-of-range chip */
.data-filters { border: 0; padding: 0; margin: .6rem 0; display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
.data-filters legend { font-weight: 600; margin-bottom: .2rem; }
.data-filters label { cursor: pointer; display: inline-flex; align-items: center; gap: .3rem; min-height: 32px; }
.badge.oor { white-space: nowrap; margin-left: .25rem; }
.legend-oor { margin: 0; }

/* D2: the S cell is a chip in the P6 colour of S (one treatment for the
   whole scale: black and white ends both read on the dark table), bold. */
.detail-table td.s-cell { padding-top: .1rem; padding-bottom: .1rem; }
.s-chip { display: inline-block; min-width: 3.1rem; padding: .05rem .35rem; border-radius: 4px; font-weight: 700; text-align: right; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); }
.s-chip.ink-dark { color: #0d1117; }
.s-chip.ink-light { color: #fff; }
/* Phone: #, Country and S stay pinned while the rest scrolls sideways. */
@media (max-width: 480px) {
  .detail-table td.name { width: 7rem; min-width: 7rem; max-width: 7rem; overflow: hidden; text-overflow: ellipsis; }
  .detail-table td.name .iso { display: none; }
  .detail-table th.col-S, .detail-table td.s-cell { position: sticky; left: 9.6rem; box-shadow: 1px 0 0 #30363d; }
  .detail-table td.s-cell { z-index: 1; background: var(--bg); }
  .detail-table th.col-S { z-index: 2; }
  .detail-table th:nth-child(2) { width: 7rem; min-width: 7rem; max-width: 7rem; }
}

/* Q1: quality of life lines under the money block; in the tier/expat
   outlooks the premium (what moves with you) is highlighted, the ladder dimmed */
.life { margin: .4rem 0 0; font-size: .85rem; }
.life p { margin: .1rem 0; }
.life.life-outlook .life-ladder { opacity: .55; }
.life.life-outlook .life-premium { color: #d2a8ff; font-weight: 600; }
