:root {
  --navy: #0F2239; --deep: #1A3A5C; --petrol: #2E86AB; --amber: #F59E0B; --slate: #65758B;
  --mist: #F4F7FA; --line: #DDE4EC; --white: #FFFFFF; --petrol-ink: #1F6A8A;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--mist); color: var(--navy); font: 15px/1.5 Lato, Calibri, Arial, sans-serif; }
h1, h2, h3 { font-family: "Playfair Display", Georgia, serif; color: var(--navy); margin: 0; line-height: 1.2; font-variant-numeric: lining-nums; }
h1 { font-size: 30px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; font-family: Lato, Calibri, Arial, sans-serif; font-weight: 700; }
a { color: var(--petrol-ink); }
p { margin: 0 0 10px; }
code, pre { font-family: Consolas, "Courier New", monospace; font-size: 12.5px; }

/* layout */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--white); border-right: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 0 10px 16px; }
.brand b { display: block; font: 700 18px "Playfair Display", Georgia, serif; line-height: 1.2; }
.brand span { color: var(--slate); font-size: 12px; }
.side nav a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--navy); text-decoration: none; margin-bottom: 2px; }
.side nav a:hover { background: var(--mist); }
.side nav a.on { background: var(--deep); color: var(--white); font-weight: 700; }
.nav-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--slate); padding: 14px 10px 6px; font-weight: 700; }
.who { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 10px 0; font-size: 13px; }
.who small { color: var(--slate); display: block; }
.main { padding: 0 32px 40px; min-width: 0; }
.dummy-bar { margin: 0 -32px 24px; background: var(--navy); color: var(--white); padding: 8px 32px; font-size: 13px; }
.dummy-bar b { color: var(--amber); }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; align-items: flex-end; margin-bottom: 18px; }
.lead { color: var(--slate); max-width: 780px; margin: 6px 0 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sticky-head { position: sticky; top: 0; z-index: 20; background: var(--mist); align-items: center; padding: 10px 0; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.below-sticky { margin-bottom: 18px; }
.city-pick { display: flex; align-items: center; gap: 8px; margin: 0; }
.city-pick label { margin: 0; }
.city-pick select { font-weight: 700; border-color: var(--deep); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; background: var(--white); overflow: hidden; }
.seg a { padding: 6px 12px; text-decoration: none; color: var(--navy); font-size: 13px; border-right: 1px solid var(--line); }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--deep); color: var(--white); font-weight: 700; }
select, input[type=text], input[type=password] { font: inherit; color: var(--navy); padding: 7px 9px; border: 1px solid #C5D0DC; border-radius: 6px; background: var(--white); max-width: 100%; }
label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 3px; }
.btn { font: inherit; font-weight: 700; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--deep); background: var(--deep); color: var(--white); cursor: pointer; text-decoration: none; display: inline-block; }
.btn.ghost { background: var(--white); color: var(--deep); }
.btn.link { background: none; border: 0; padding: 0; color: var(--petrol-ink); font-weight: 400; text-decoration: underline; }
.btn.danger { background: var(--white); border-color: #A33; color: #A33; }

/* cards */
.card { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; min-width: 0; }
.card > h2 { margin-bottom: 4px; }
.sub { color: var(--slate); font-size: 13px; margin: 0 0 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid2 > .card, .grid3 > .card { margin-bottom: 0; }
.stack { margin-bottom: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.kpi b { display: block; font: 700 26px "Playfair Display", Georgia, serif; font-variant-numeric: lining-nums; }
.kpi span { color: var(--slate); font-size: 12.5px; }
.note { background: var(--mist); border-left: 3px solid var(--petrol); padding: 9px 12px; font-size: 13px; border-radius: 0 6px 6px 0; margin: 10px 0 0; }

/* tables */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { text-align: left; font-weight: 700; color: var(--slate); font-size: 12px; padding: 7px 9px; border-bottom: 2px solid var(--line); vertical-align: bottom; }
td { padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th[data-sort] { cursor: pointer; }
th[data-sort]:hover { color: var(--navy); }
th[data-sort]::after { content: " ↕"; opacity: .45; }
.heat td, .heat th { border: 2px solid var(--white); }
.heat td.cell { text-align: center; font-variant-numeric: tabular-nums; min-width: 42px; padding: 6px 4px; }
.heat th.top { text-align: center; font-size: 11.5px; min-width: 42px; }
.heat td.city, .heat th.city { position: sticky; left: 0; background: var(--white); font-weight: 700; white-space: nowrap; }
.home { box-shadow: inset 0 0 0 2px var(--amber); }

/* tags */
.tag { display: inline-block; font-size: 11.5px; font-weight: 700; border-radius: 4px; padding: 1px 7px; background: var(--mist); color: var(--deep); border: 1px solid var(--line); white-space: nowrap; }
.tag.direct { background: var(--deep); color: var(--white); border-color: var(--deep); }
.tag.proxy { background: #E3EFF5; color: var(--deep); border-color: #BFD8E5; }
.tag.alone { background: var(--white); color: var(--slate); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { background: var(--mist); border: 1px solid var(--line); border-radius: 14px; padding: 2px 10px; font-size: 12.5px; }
.chip.shared { background: #E3EFF5; border-color: var(--petrol); font-weight: 700; }

/* deviation bars */
.dev { display: grid; grid-template-columns: minmax(96px, 170px) minmax(0, 1fr) 48px; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; }
.dev .track { position: relative; height: 14px; }
.dev .track::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--slate); }
.dev .bar { position: absolute; top: 2px; height: 10px; }
.dev .bar.pos { left: 50%; background: var(--petrol); border-radius: 0 4px 4px 0; }
.dev .bar.neg { right: 50%; background: var(--slate); border-radius: 4px 0 0 4px; }
.dev .val { text-align: right; font-variant-numeric: tabular-nums; }
.axis-legend { display: flex; justify-content: space-between; color: var(--slate); font-size: 12px; padding-left: 178px; padding-right: 60px; }

/* charts */
.chart { width: 100%; height: auto; display: block; max-width: 900px; }
.chart.scatter { max-width: 460px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tick { font-size: 11px; fill: var(--slate); }
.chart .lab { font-size: 12.5px; fill: var(--navy); }
.chart .lab.small { font-size: 11px; font-weight: 700; }
.chart .link { stroke: #A9B7C6; stroke-width: 2; }
.chart .m-a { fill: var(--petrol); stroke: var(--white); stroke-width: 2; }
.chart .m-b { fill: var(--navy); stroke: var(--white); stroke-width: 2; }
.chart .plot { fill: var(--mist); }
.chart .axis-mid { stroke: var(--slate); stroke-dasharray: 3 3; }
.chart .quad { font-size: 11px; fill: var(--slate); font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; margin-bottom: 8px; }
.legend i { display: inline-block; width: 11px; height: 11px; margin-right: 6px; vertical-align: -1px; }
.legend i.a { background: var(--petrol); border-radius: 50%; }
.legend i.b { background: var(--navy); border-radius: 2px; }

/* interactive charts */
.viz { width: 100%; min-width: 0; }
.hint { color: var(--slate); font-size: 12.5px; margin: 6px 0 0; }

/* plain words */
.explain { border-left: 4px solid var(--petrol); }
.explain .ex-text { margin-top: 8px; max-width: 860px; }
.ex-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 4px; }
.ex-status { color: var(--slate); font-size: 12.5px; }
.ex-warn { background: #FFF6E5; border: 1px solid var(--amber); border-radius: 6px; padding: 6px 10px; font-size: 13px; }
.ex-ask[disabled] { opacity: .55; cursor: wait; }

/* details */
details { border: 1px solid var(--line); border-radius: 7px; padding: 8px 12px; margin-bottom: 8px; }
summary { cursor: pointer; font-weight: 700; font-size: 13.5px; }
pre { background: var(--mist); padding: 10px; border-radius: 6px; overflow: auto; max-height: 340px; margin: 8px 0 0; white-space: pre-wrap; }

/* flash + login */
.flash { padding: 9px 12px; border-radius: 6px; margin-bottom: 14px; font-size: 14px; border: 1px solid var(--line); background: var(--white); }
.flash.error { border-color: #C66; color: #8A1F1F; }
.flash.ok { border-color: var(--petrol); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; }
.field { margin-bottom: 12px; }
.field input, .field select { width: 100%; }
.password-input { position: relative; display: block; width: 100%; }
.password-input input { width: 100%; min-height: 42px; padding-right: 48px; box-sizing: border-box; }
.password-toggle { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 42px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--navy); cursor: pointer; }
.password-toggle:hover { background: var(--mist); }
.password-toggle:focus-visible { outline: 2px solid var(--petrol); outline-offset: -3px; }
.password-toggle svg { width: 21px; height: 21px; pointer-events: none; }
.password-toggle[aria-pressed="false"] .password-toggle-slash { display: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; font-size: 14px; }

@media (max-width: 1100px) { .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; }
  .side nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .who { margin-top: 10px; }
  .main { padding: 0 16px 30px; }
  .dummy-bar { margin: 0 -16px 18px; padding: 8px 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  h1 { font-size: 25px; }
  .axis-legend { padding-left: 0; padding-right: 0; }
}
