/* IsoQC UI stylesheet (v3). Tokens (light + dark) → layout → components → responsive → logo/loading → wizard. */

:root {
  --iq-canvas:      #F4F6FA;
  --iq-surface:     #FFFFFF;
  --iq-surface-2:   #F8FAFC;
  --iq-border:      #E3E8EF;
  --iq-border-soft: #EEF2F6;
  --iq-border-strong:#CBD5E1;
  --iq-ink:         #0F172A;
  --iq-ink-2:       #334155;
  --iq-muted:       #64748B;
  --iq-subtle:      #94A3B8;

  --iq-brand:       #0A92FF;
  --iq-brand-600:   #0077D9;
  --iq-brand-50:    #EAF5FF;
  --iq-brand-100:   #D3EAFF;
  --iq-on-accent:   #FFFFFF;   /* text on filled brand / flag / ok / warn */

  --iq-o18:         #0A92FF;
  --iq-h2:          #E5484D;
  --iq-dex:         #16A34A;
  --iq-flag:        #7C3AED;
  --iq-flag-50:     #F3EEFF;
  --iq-flag-200:    #DDD0FB;
  --iq-ok:          #16A34A;
  --iq-ok-50:       #EAF8EF;
  --iq-warn:        #D97706;
  --iq-warn-50:     #FFF6E6;

  --iq-field-bg:    var(--iq-surface);
  --iq-btn-bg:      var(--iq-surface);
  --iq-map-bg:      #EEF2F6;
  --iq-ring:        0 0 0 3px rgba(10,146,255,.15);

  --iq-radius-sm:   8px;
  --iq-radius:      12px;
  --iq-shadow-sm:   0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
  --iq-shadow:      0 4px 16px -4px rgba(15,23,42,.10), 0 2px 4px rgba(15,23,42,.04);
  --iq-shadow-lg:   0 18px 40px -12px rgba(15,23,42,.22);
  --iq-nav-h:       64px;
  --iq-rail-w:      0px;
  --iq-display:     "Sora", "Inter", system-ui, sans-serif;
  --iq-mono:        ui-monospace, SFMono-Regular, Menlo, monospace;

  /* bslib navbar follows the surface on every bslib version */
  --bslib-navbar-default-bg: var(--iq-surface); --bslib-navbar-light-bg: var(--iq-surface); --bslib-navbar-inverse-bg: var(--iq-surface);
}

[data-bs-theme="dark"] {
  --iq-canvas:      #0B1220;
  --iq-surface:     #111A2B;
  --iq-surface-2:   #152036;
  --iq-border:      #22304A;
  --iq-border-soft: #1D2A3F;
  --iq-border-strong:#2E3F5E;
  --iq-ink:         #E8EEF7;
  --iq-ink-2:       #C3CEDD;
  --iq-muted:       #8A9AB2;
  --iq-subtle:      #7A8AA3;   /* ≥4.6:1 on surfaces (was #64748B, 3.4:1) */
  --iq-brand:       #3AA8FF;
  --iq-brand-600:   #7CC4FF;
  --iq-brand-50:    #0E2A47;
  --iq-brand-100:   #134070;
  --iq-on-accent:   #0B1220;   /* white on the light dark-mode accents was <3:1 */
  --iq-o18:         #3AA8FF;
  --iq-h2:          #F2666A;
  --iq-dex:         #34C77B;
  --iq-flag:        #A78BFA;
  --iq-flag-50:     #231A42;
  --iq-flag-200:    #3B2A6B;
  --iq-ok:          #34C77B;
  --iq-ok-50:       #0F2A1E;
  --iq-warn:        #F2A33A;
  --iq-warn-50:     #33240E;
  --iq-field-bg:    var(--iq-surface-2);
  --iq-btn-bg:      var(--iq-surface-2);
  --iq-map-bg:      #0E1626;
  --iq-ring:        0 0 0 3px rgba(58,168,255,.25);
  --iq-shadow-sm:   0 1px 2px rgba(0,0,0,.3);
  --iq-shadow:      0 6px 20px -6px rgba(0,0,0,.5);
  --iq-shadow-lg:   0 24px 48px -12px rgba(0,0,0,.6);
  --bs-body-bg: #111A2B; --bs-body-color: #E8EEF7; --bs-border-color: #22304A;
  --bs-secondary-bg: #152036; --bs-tertiary-bg: #152036; --bs-emphasis-color: #E8EEF7;
  color-scheme: dark;
}

/* ---------- Base ---------- */
html, body { background-color: var(--iq-canvas) !important; }
body {
  color: var(--iq-ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
.iq-kpi-value, table td { font-variant-numeric: tabular-nums; }
a { color: var(--iq-brand); text-decoration: none; }
a:hover, a:focus-visible { color: var(--iq-brand-600); text-decoration: underline; text-underline-offset: 2px; }
::selection { background: var(--iq-brand-100); }
.muted { color: var(--iq-muted); }

/* One keyboard focus ring for every custom control */
:is(a, button, .btn, .nav-link, .dropdown-item, summary, [role="switch"]):focus-visible {
  outline: 2px solid var(--iq-brand); outline-offset: 2px;
}
.btn:focus-visible { box-shadow: none; }

/* ---------- Navbar ---------- */
html body .navbar, html body .navbar.bg-light, html body .navbar.navbar-default, html body .navbar[data-bs-theme] {
  background: var(--iq-surface) !important; color: var(--iq-ink);
  --bs-navbar-color: var(--iq-ink-2); --bs-navbar-hover-color: var(--iq-ink); --bs-navbar-active-color: var(--iq-ink); --bs-navbar-brand-color: var(--iq-ink);
}
.navbar {
  border-bottom: 1px solid var(--iq-border);
  min-height: var(--iq-nav-h);
  padding-top: 0; padding-bottom: 0;
  box-shadow: none;
  z-index: 1030;
}
.navbar > .container-fluid { min-height: var(--iq-nav-h); padding-left: 20px; padding-right: 16px; }
.navbar-brand { padding: 0; margin-right: 24px; display: flex; align-items: center; }
.navbar .navbar-nav .nav-link {
  color: var(--iq-muted) !important;
  font-weight: 500;
  font-size: 14px;
  padding: 8px 14px !important;
  border-radius: 8px;
  display: inline-flex; align-items: center; gap: 8px;
  position: relative;
  transition: color .15s ease, background-color .15s ease;
}
.navbar .navbar-nav .nav-link:hover { color: var(--iq-ink) !important; background: var(--iq-surface-2); text-decoration: none; }
.navbar .navbar-nav .nav-link.active { color: var(--iq-ink) !important; background: transparent; }
.navbar .navbar-nav .nav-link.active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -14px;
  height: 2px; border-radius: 2px; background: var(--iq-brand);
}
.navbar .navbar-nav .nav-link :is(.fa,.fas,.far,.fab), .navbar .navbar-nav .nav-link svg { font-size: 13px; opacity: .85; }
.navbar > .container-fluid, .navbar-collapse, .navbar .navbar-nav { align-items: center; }
.navbar .navbar-nav .nav-link.active, .navbar .navbar-nav .nav-link:focus { border: 0 !important; box-shadow: none !important; }
.navbar .navbar-nav .nav-link:focus-visible { outline-offset: -2px; }
.navbar .navbar-nav .nav-item { display: flex; align-items: center; }
.iq-nav-tools { display: flex; align-items: center; gap: 8px; }
.iq-nav-center { display: flex; align-items: center; gap: 12px; margin-left: 8px; }
@media (max-width: 991.98px) {
  .navbar .navbar-nav .nav-link.active::after { display: none; }
  .navbar .navbar-nav .nav-link.active { background: var(--iq-brand-50); color: var(--iq-brand-600) !important; }
}

/* ---------- Brand ---------- */
.iq-brand { display: flex; align-items: center; gap: 10px; text-decoration: none !important; color: var(--iq-ink); }
.iq-brand-mark { width: 38px; height: 38px; flex: 0 0 38px; display: block; }
.iq-wordmark { font-family: var(--iq-display); font-weight: 600; font-size: 22px; letter-spacing: -.025em; color: var(--iq-ink); line-height: 1; }
.iq-brand-sub {
  font-size: 12.5px; color: var(--iq-muted); white-space: nowrap; line-height: 1.2;
  padding-left: 12px; margin-left: 2px; border-left: 1px solid var(--iq-border);
}
@media (max-width: 1399.98px) { .iq-brand-sub { display: none; } }

/* ---------- Dataset pill + δ18O / δ2H donut ---------- */
.iq-ds-pill {
  display: inline-flex; align-items: center; gap: 9px; height: 38px; padding: 0 12px 0 6px;
  border: 1px solid var(--iq-border); border-radius: 999px; background: var(--iq-surface-2);
  max-width: 300px; min-width: 0;
}
.iq-ds-pill[data-state="empty"] { opacity: .8; }
.iq-ds-text { display: grid; line-height: 1.15; min-width: 0; }
.iq-ds-text b { font-size: 12.5px; font-weight: 600; color: var(--iq-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iq-ds-text span { font-size: 11.5px; color: var(--iq-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.iso-pie-host { width: 26px; height: 26px; flex: 0 0 26px; position: relative; display: flex; align-items: center; justify-content: center; }
.iso-pie-svg { width: 26px; height: 26px; overflow: visible; }
.iso-pie-track { opacity: .16; }
.iso-pie-segment { cursor: pointer; transition: stroke-width .18s ease; }
.iso-pie-tooltip {
  position: absolute; left: 50%; top: calc(100% + 12px); transform: translateX(-50%);
  background: var(--iq-ink); color: var(--iq-surface);
  border-radius: 8px; padding: 6px 10px; box-shadow: var(--iq-shadow);
  font-size: 11.5px; font-weight: 600; line-height: 1.25; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .16s ease; z-index: 2000;
}
.iso-pie-tooltip.is-visible { opacity: 1; }

/* ---------- Station field: search + dropdown in one ---------- */
.iq-search { position: relative; width: 100%; }
.iq-search .shiny-input-container { margin: 0 !important; }
.iq-search .selectize-input { min-height: 40px; padding-left: 34px !important; padding-right: 84px !important; border-radius: 10px; font-weight: 600; }
.iq-search .selectize-input input::placeholder { font-weight: 400; color: var(--iq-subtle); }
.iq-search-ico { position: absolute; left: 12px; top: 20px; transform: translateY(-50%); color: var(--iq-subtle); font-size: 13px; z-index: 2; pointer-events: none; }
.iq-search:focus-within .iq-search-ico { color: var(--iq-brand); }
.iq-kbd {
  position: absolute; right: 34px; top: 20px; transform: translateY(-50%); z-index: 2; pointer-events: none;
  font-family: var(--iq-mono); font-size: 11px; color: var(--iq-muted);
  border: 1px solid var(--iq-border-strong); border-radius: 5px; padding: 1px 6px; background: var(--iq-surface-2);
  transition: opacity .15s;
}
.iq-search:focus-within .iq-kbd { opacity: 0; }
/* Station search: a field in the header on desktop; below 1200 px a panel opened by the magnifier button */
.iq-station-bar { display: flex; align-items: center; gap: 10px; }
.iq-station-bar .iq-station-search { width: 260px; }
.iq-station-bar .shiny-input-container { margin: 0 !important; }
.iq-ds-pill:not([data-state="loaded"]) ~ .iq-bar-slot { display: none; }       /* nothing to search yet */
.iq-icon-btn.iq-search-btn, .iq-bar-slot-float { display: none; }
/* the header stays one row: drop what is least needed as the window narrows */
@media (min-width: 1200px) {
  .navbar > .container-fluid, .navbar .navbar-collapse, .navbar .navbar-nav { flex-wrap: nowrap !important; }
  .iq-nav-center { min-width: 0; }
  .iq-ds-pill { flex: 0 1 auto; min-width: 0; }
}
@media (min-width: 1200px) and (max-width: 1499.98px) { .iq-brand-sub { display: none !important; } }
@media (min-width: 1200px) and (max-width: 1299.98px) { .iq-institution { display: none !important; } .iq-station-bar .iq-station-search { width: 230px; } }
@media (max-width: 1199.98px) {
  body[data-iq-data="loaded"] .iq-icon-btn.iq-search-btn { display: inline-flex; }
  .iq-bar-slot-float {
    position: fixed; z-index: 1046; top: calc(var(--iq-nav-h) + 8px); left: 50%; transform: translateX(-50%);
    width: min(460px, calc(100vw - 24px)); padding: 10px;
    background: var(--iq-surface); border: 1px solid var(--iq-border); border-radius: 14px; box-shadow: var(--iq-shadow-lg);
  }
  body.iq-search-open .iq-bar-slot-float { display: block; }
  .iq-bar-slot-float .iq-station-search { width: 100%; }
  .iq-bar-slot-float .iq-kbd { display: none; }
  .iq-bar-slot-float .iq-search .selectize-input { padding-right: 34px !important; }
}

/* Period, above the time series and as wide as they are: From and To over the two ends of the slider */
.iq-period-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: end; gap: 4px 10px;
  padding: 10px 14px 8px; background: var(--iq-surface); border: 1px solid var(--iq-border);
  border-radius: var(--iq-radius); box-shadow: var(--iq-shadow-sm);
}
.iq-period-from { grid-column: 1; grid-row: 1; }
.iq-period-to { grid-column: 3; grid-row: 1; }
.iq-period-reset { grid-column: 4; grid-row: 1; }
.iq-period-slider { grid-column: 1 / -1; grid-row: 2; min-width: 0; text-align: center; }
.iq-period-field { display: flex; align-items: center; gap: 8px; }
.iq-period-field > label { margin: 0; font-size: 12px; font-weight: 600; color: var(--iq-muted); }
.iq-period-row .shiny-input-container { margin: 0 !important; }
.iq-period-row .form-control { min-height: 36px; text-align: center; padding-left: 6px; padding-right: 6px; }
.iq-period-slider .iq-date-slider .shiny-input-container { width: 100% !important; }
.iq-period-slider .iq-date-slider .irs--shiny { height: 24px; }
.iq-period-slider .iq-bounds-note { display: inline-flex; margin: 0; font-size: 11.5px; }
/* year scale under the track, bubble over the dragged handle, live From / To field */
.iq-period-slider { position: relative; }
.iq-pscale { position: relative; height: 24px; margin: 0 11px 2px; }
.iq-pscale i { position: absolute; top: 0; width: 1px; height: 5px; background: var(--iq-border-strong); }
.iq-pscale i.maj { height: 9px; background: var(--iq-subtle); }
.iq-pscale span { position: absolute; top: 11px; transform: translateX(-50%); font: 500 10.5px/1 var(--iq-mono); color: var(--iq-muted); white-space: nowrap; text-align: center; }
.iq-pscale span small { display: block; margin-top: 3px; font-size: 10px; font-weight: 600; color: var(--iq-ink-2); }
.iq-pscale.two { height: 36px; }
.iq-pscale b { position: absolute; left: -6px; top: 24px; font: 600 10px/1 var(--iq-mono); color: var(--iq-ink-2); white-space: nowrap; }   /* month / year the scale starts in */
.iq-pscale b.at { transform: translateX(-50%); }
.iq-pscale em { position: absolute; top: -3px; width: 2px; height: 14px; margin-left: -1px; border-radius: 2px; background: var(--iq-brand); opacity: 0; transition: opacity .12s; }
.iq-pscale em.on { opacity: 1; }
.iq-pbub {
  position: absolute; bottom: calc(100% - 4px); left: 50%; transform: translateX(-50%) translateY(4px); z-index: 5;
  padding: 5px 10px; border-radius: 8px; background: var(--iq-ink); color: var(--iq-surface);
  font-size: 12px; font-weight: 600; line-height: 1.25; white-space: nowrap; font-variant-numeric: tabular-nums;
  opacity: 0; pointer-events: none; transition: opacity .12s, transform .12s; box-shadow: var(--iq-shadow);
}
.iq-pbub.on { opacity: 1; transform: translateX(-50%); }
.iq-pbub small { display: block; font-size: 10.5px; font-weight: 500; opacity: .7; }
/* From / To picker: year, month, day side by side (www/isoqc.js); the calendar pop-up is not used */
.datepicker.datepicker-dropdown { display: none !important; }
.iq-period-field { position: relative; }
.iq-dp {
  position: absolute; z-index: 1056; top: calc(100% + 8px); left: 0; width: 300px; max-width: calc(100vw - 28px);
  padding: 10px; background: var(--iq-surface); border: 1px solid var(--iq-border); border-radius: 14px; box-shadow: var(--iq-shadow-lg);
}
.iq-dp-cols { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 8px; }
.iq-dp-col { display: grid; gap: 5px; min-width: 0; }
.iq-dp-col > span { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--iq-muted); text-align: center; }
.iq-dp-list {
  position: relative; height: 204px; overflow-y: auto; overscroll-behavior: contain; padding: 4px; display: grid; gap: 2px; align-content: start;
  border: 1px solid var(--iq-border); border-radius: 10px; background: var(--iq-surface-2);
}
.iq-dp-list { scrollbar-color: transparent transparent; padding-right: 2px; }
.iq-dp-list:hover, .iq-dp-list:focus-within { scrollbar-color: var(--iq-border-strong) transparent; }   /* thumb only while in use */
.iq-dp-c {
  position: relative; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--iq-ink-2);
  padding: 6px 4px; font-size: 13px; line-height: 1.2; text-align: center; font-variant-numeric: tabular-nums; cursor: pointer;
}
.iq-dp-c:hover { border-color: var(--iq-brand); }
.iq-dp-c.sel { background: var(--iq-brand); color: var(--iq-on-accent); font-weight: 600; }
.iq-dp-c.off { opacity: .32; pointer-events: none; }
.iq-dp-c.has::after { content: ""; position: absolute; right: 6px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: var(--iq-brand); }
.iq-dp-c.sel.has::after { background: var(--iq-on-accent); }
.iq-dp-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.iq-dp-foot > span:last-child { display: inline-flex; align-items: center; gap: 12px; }
.iq-dp-key { font-size: 11.5px; color: var(--iq-muted); display: inline-flex; align-items: center; gap: 6px; }
.iq-dp-key i { width: 5px; height: 5px; border-radius: 50%; background: var(--iq-brand); }
.iq-period-field.is-open .form-control { border-color: var(--iq-brand) !important; box-shadow: var(--iq-ring) !important; }
@media (max-width: 575.98px) { .iq-dp { width: min(300px, calc(100vw - 28px)); } }
.iq-period-field.is-live .form-control {
  border-color: var(--iq-brand) !important; box-shadow: var(--iq-ring) !important; background: var(--iq-brand-50); font-weight: 600;
}
.iq-period-reset.btn.iq-sq-sm { width: 36px; height: 36px; }
@media (max-width: 575.98px) {
  .iq-period-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .iq-period-to { grid-column: 2; }
  .iq-period-reset { grid-column: 3; }
  .iq-period-field { flex-direction: column; align-items: stretch; gap: 3px; }
  .iq-period-row .iq-period-field .shiny-input-container { width: 100% !important; }
}
@media (hover: none), (max-width: 575.98px) { .iq-kbd { display: none; } .iq-search .selectize-input { padding-right: 34px !important; } }

/* ---------- Icon / ghost buttons, theme switch ---------- */
.iq-icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--iq-border); border-radius: 9px; background: var(--iq-surface); color: var(--iq-ink-2);
  transition: border-color .15s, color .15s, background-color .15s;
}
.iq-icon-btn:hover, .iq-icon-btn:focus-visible { border-color: var(--iq-brand); color: var(--iq-brand-600); background: var(--iq-brand-50); }

.iq-btn-ghost {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 12px;
  border: 1px solid var(--iq-border); border-radius: 8px;
  background: var(--iq-surface); color: var(--iq-ink-2);
  font-size: 13px; font-weight: 500;
  transition: border-color .15s, background-color .15s, color .15s;
}
.iq-btn-ghost:hover, .iq-btn-ghost:focus-visible, .iq-btn-ghost[aria-expanded="true"] {
  border-color: var(--iq-brand); color: var(--iq-brand-600); background: var(--iq-brand-50);
}
.iq-btn-ghost::after { display: none; }

.iq-theme-switch { border: 0; background: none; padding: 0; display: inline-flex; align-items: center; cursor: pointer; border-radius: 999px; }
.iq-ts-track {
  position: relative; width: 58px; height: 30px; border-radius: 999px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px; background: var(--iq-surface-2); border: 1px solid var(--iq-border-strong); transition: background-color .2s, border-color .2s;
}
.iq-ts-track svg { width: 14px; height: 14px; position: relative; z-index: 1; transition: color .2s; }
.iq-ts-sun { color: var(--iq-warn); } .iq-ts-moon { color: var(--iq-subtle); }
.iq-ts-thumb {
  position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--iq-surface); box-shadow: 0 1px 3px rgba(15,23,42,.28); transition: transform .22s cubic-bezier(.3,.7,.4,1);
}
.iq-theme-switch:hover .iq-ts-track { border-color: var(--iq-brand); }
[data-bs-theme="dark"] .iq-ts-track { background: var(--iq-canvas); }
[data-bs-theme="dark"] .iq-ts-thumb { transform: translateX(28px); background: #22314D; }
[data-bs-theme="dark"] .iq-ts-sun { color: var(--iq-subtle); }
[data-bs-theme="dark"] .iq-ts-moon { color: #C4B5FD; }

/* ---------- Cite menu + institution ---------- */
.iq-cite-menu {
  width: min(440px, calc(100vw - 32px));
  padding: 16px; border: 1px solid var(--iq-border); border-radius: var(--iq-radius);
  box-shadow: var(--iq-shadow-lg); background: var(--iq-surface);
}
.iq-cite-menu .iq-eyebrow { margin-bottom: 8px; }
.iq-cite-menu p { font-size: 12.5px; line-height: 1.55; color: var(--iq-ink-2); margin: 0 0 14px; }
.iq-cite-actions { display: flex; gap: 8px; }
.iq-institution { display: flex; align-items: center; padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--iq-border); }
.iq-institution img { height: 34px; width: auto; display: block; }
[data-bs-theme="dark"] .iq-institution img { filter: brightness(0) invert(.92); }

/* ---------- Page layout ---------- */
.bslib-page-navbar > .container-fluid,
.bslib-page-navbar .navbar + .container-fluid { padding: 0; }
.tab-content > .tab-pane { padding: 0; }
.bslib-sidebar-layout {
  --_border: 0; border: 0 !important; border-radius: 0 !important;
  background: transparent;
}
.bslib-sidebar-layout > .main { padding: 24px 28px 32px !important; background: transparent; overflow-x: hidden; }
.bslib-sidebar-layout > .sidebar {
  --_sidebar-bg: var(--iq-surface); --_sidebar-fg: var(--iq-ink-2);
  background: var(--iq-surface) !important; color: var(--iq-ink-2);
  border-right: 1px solid var(--iq-border) !important;
}
.bslib-sidebar-layout > .sidebar > .sidebar-content { padding: 20px 20px 28px; gap: 0; overflow-x: hidden; }
.iq-sidebar .irs { margin: 0 4px; }
.bslib-sidebar-layout > .collapse-toggle { color: var(--iq-muted); }
.iq-main { max-width: 1680px; margin: 0 auto; width: 100%; }
.iq-main > * + *, .iq-main .shiny-panel-conditional > * + * { margin-top: 20px; }

/* ---------- Sidebar sections ---------- */
.iq-sidebar .iq-section { border-top: 1px solid var(--iq-border); margin-top: 18px; padding-top: 18px; }
.iq-sidebar .sidebar-content > .iq-section:first-child,
.iq-sidebar .iq-sheet-head + .iq-section { border-top: 0; margin-top: 0; padding-top: 0; }
.iq-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase;
  color: var(--iq-muted); margin-bottom: 12px;
}
.iq-section-title .iq-step {
  width: 20px; height: 20px; border-radius: 6px; flex: 0 0 20px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--iq-brand-50); color: var(--iq-brand-600);
  font-size: 11px; letter-spacing: 0;
}
.iq-section-title :is(.fa,.fas,.far,.fab) { color: var(--iq-subtle); font-size: 12px; }
.iq-section-title .iq-unit { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--iq-subtle); }
.iq-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.iq-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 8px; }
.iq-grid-2 > *, .iq-grid-3 > * { min-width: 0; }
.iq-note { font-size: 11.5px; color: var(--iq-muted); margin: -4px 0 0; line-height: 1.45; }
.iq-note a { font-weight: 500; }
.iq-help { font-size: 12px; color: var(--iq-muted); margin: 6px 0 0; line-height: 1.45; }
.iq-or {
  display: flex; align-items: center; gap: 10px; margin: 6px 0 12px;
  color: var(--iq-subtle); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
}
.iq-or::before, .iq-or::after { content: ""; flex: 1; height: 1px; background: var(--iq-border); }

/* ---------- Form controls ---------- */
.form-group, .shiny-input-container { margin-bottom: 14px; }
.shiny-input-container:not(.shiny-input-container-inline) { width: 100%; max-width: 100%; }
.control-label, .form-label, .shiny-input-container > label {
  font-size: 12.5px; font-weight: 500; color: var(--iq-ink-2); margin-bottom: 5px;
}
.form-control, .form-select, .selectize-input, select.form-control {
  min-height: 36px; font-size: 13.5px; color: var(--iq-ink);
  border: 1px solid var(--iq-border-strong); border-radius: var(--iq-radius-sm);
  box-shadow: none !important; background-color: var(--iq-field-bg);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:hover, .form-select:hover, .selectize-input:hover { border-color: var(--iq-subtle); }
.form-control:focus, .form-select:focus, .selectize-input.focus {
  border-color: var(--iq-brand) !important;
  box-shadow: var(--iq-ring) !important;
}
.selectize-input { padding: 7px 10px; display: flex; align-items: center; }
.selectize-input input { color: var(--iq-ink) !important; }
.selectize-control .selectize-input, .selectize-control .selectize-input.full,
.selectize-control.single .selectize-input.input-active, .selectize-control .selectize-input.dropdown-active {
  background: var(--iq-field-bg) !important; color: var(--iq-ink);
}
.selectize-control .selectize-input > .item { color: var(--iq-ink); }
.selectize-dropdown, .selectize-dropdown-content { background: var(--iq-surface); color: var(--iq-ink-2); }
.selectize-dropdown { border-radius: var(--iq-radius-sm); border-color: var(--iq-border); box-shadow: var(--iq-shadow); font-size: 13.5px; }
.selectize-dropdown .active { background: var(--iq-brand-50); color: var(--iq-ink); }
input[type="number"].form-control { padding-right: 6px; }
.input-group .btn-file, .btn-file {
  background: var(--iq-surface-2); color: var(--iq-ink-2); border: 1px solid var(--iq-border-strong);
  font-weight: 500; font-size: 13px;
}
.btn-file:hover { border-color: var(--iq-subtle); color: var(--iq-ink); }
.input-group .form-control[readonly] { background: var(--iq-surface); }
.shiny-file-input-progress { height: 3px; margin-top: 6px; border-radius: 3px; background: var(--iq-brand-50); }
.shiny-file-input-progress .progress-bar { background: var(--iq-brand); font-size: 0; }
.shiny-options-group .form-check { margin-bottom: 2px; }
.form-check-input:checked { background-color: var(--iq-brand); border-color: var(--iq-brand); }
.form-check-label { font-size: 13px; }

/* date inputs */
.shiny-date-input .form-control { font-variant-numeric: tabular-nums; }
.datepicker { border-radius: var(--iq-radius-sm); box-shadow: var(--iq-shadow-lg); font-size: 13px; }
[data-bs-theme="dark"] .datepicker, [data-bs-theme="dark"] .datepicker table { background: var(--iq-surface); color: var(--iq-ink); }
[data-bs-theme="dark"] .datepicker table tr td.day:hover, [data-bs-theme="dark"] .datepicker table tr td span:hover { background: var(--iq-surface-2); }

/* ionRangeSlider */
.irs--shiny .irs-bar { background: var(--iq-brand); border-color: var(--iq-brand); height: 4px; top: 27px; }
.irs--shiny .irs-line { background: var(--iq-border); border: 0; height: 4px; top: 27px; border-radius: 4px; }
.irs--shiny .irs-handle {
  width: 18px; height: 18px; top: 20px; border: 2px solid var(--iq-brand);
  background: var(--iq-surface); box-shadow: 0 1px 3px rgba(15,23,42,.25);
}
.irs--shiny .irs-handle:hover, .irs--shiny .irs-handle.state_hover { background: var(--iq-brand-50); }
.irs--shiny .irs-from, .irs--shiny .irs-to, .irs--shiny .irs-single {
  background: var(--iq-ink); color: var(--iq-surface); font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 6px;
}
.irs--shiny .irs-from:before, .irs--shiny .irs-to:before, .irs--shiny .irs-single:before { border-top-color: var(--iq-ink); }
.irs--shiny .irs-min, .irs--shiny .irs-max { background: transparent; color: var(--iq-subtle); font-size: 10.5px; }
.irs--shiny .irs-grid-text { color: var(--iq-subtle); font-size: 10px; }
[data-bs-theme="dark"] .irs--shiny :is(.irs-grid-text, .irs-min, .irs-max) { color: var(--iq-muted); }
[data-bs-theme="dark"] .irs--shiny :is(.irs-from, .irs-to, .irs-single) { background: var(--iq-brand); color: var(--iq-on-accent); }
[data-bs-theme="dark"] .irs--shiny :is(.irs-from, .irs-to, .irs-single):before { border-top-color: var(--iq-brand); }

/* date slider: values already shown in From / To */
.iq-date-slider :is(.irs-from, .irs-to, .irs-single, .irs-min, .irs-max) { display: none !important; }
.iq-date-slider .irs--shiny { height: 44px; }
.iq-date-slider .irs--shiny .irs-line, .iq-date-slider .irs--shiny .irs-bar { top: 10px; }
.iq-date-slider .irs--shiny .irs-handle { top: 3px; }
.iq-date-slider .irs--shiny .irs-grid { top: 20px; }
.iq-date-slider .shiny-input-container { margin-bottom: 6px; }

/* native selects (selectize = FALSE): chevron */
select.form-control {
  appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2364748B' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.6' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 11px 7px;
}

/* ---------- Buttons ---------- */
.btn { font-weight: 550; font-size: 13.5px; border-radius: var(--iq-radius-sm); padding: 8px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn :is(.fa,.fas,.far,.fab), .btn svg { font-size: 13px; }
.btn-primary { background: var(--iq-brand); border-color: var(--iq-brand); color: var(--iq-on-accent); box-shadow: 0 1px 2px rgba(10,146,255,.25); }
.btn-primary:hover, .btn-primary:focus-visible { background: var(--iq-brand-600); border-color: var(--iq-brand-600); color: var(--iq-on-accent); }
.btn-outline-primary { color: var(--iq-brand-600); border-color: var(--iq-brand-100); background: var(--iq-brand-50); }
.btn-outline-primary:hover, .btn-outline-primary:focus-visible { color: var(--iq-on-accent); background: var(--iq-brand); border-color: var(--iq-brand); }
.btn-default:not(.btn-primary):not(.btn-outline-primary):not(.btn-link-muted):not(.btn-flag), .btn-secondary, .btn-light {
  background: var(--iq-btn-bg); color: var(--iq-ink-2); border: 1px solid var(--iq-border-strong);
}
.btn-default:not(.btn-primary):not(.btn-outline-primary):not(.btn-link-muted):not(.btn-flag):hover, .btn-secondary:hover, .btn-light:hover { background: var(--iq-surface-2); color: var(--iq-ink); border-color: var(--iq-subtle); }
.btn-sm { font-size: 12.5px; padding: 5px 10px; }
.btn-link-muted { background: none; border: 0; padding: 0; color: var(--iq-muted); font-size: 12.5px; font-weight: 500; }
.btn-link-muted:hover, .btn-link-muted:focus-visible { color: var(--iq-brand-600); background: none; }
.w-100.btn { display: flex; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--iq-border) !important; border-radius: var(--iq-radius) !important;
  box-shadow: var(--iq-shadow-sm); background: var(--iq-surface);
  overflow: visible;
}
.card-header {
  background: var(--iq-surface) !important; border-bottom: 1px solid var(--iq-border) !important;
  padding: 12px 16px; min-height: 52px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-top-left-radius: var(--iq-radius) !important; border-top-right-radius: var(--iq-radius) !important;
}
.card-body { padding: 12px 16px 14px; }
.card-footer {
  background: var(--iq-surface-2) !important; border-top: 1px solid var(--iq-border) !important; padding: 10px 16px; font-size: 12px; color: var(--iq-muted);
  border-bottom-left-radius: var(--iq-radius) !important; border-bottom-right-radius: var(--iq-radius) !important;
}
.iq-card-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.iq-card-title h3 { font-size: 14.5px; font-weight: 650; margin: 0; color: var(--iq-ink); letter-spacing: -.005em; }
.iq-card-title small { display: block; font-size: 12px; color: var(--iq-muted); font-weight: 400; margin-top: 1px; }
.iq-card-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.iq-card-tools .form-group, .iq-card-tools .shiny-input-container { margin: 0; width: auto; }
.iq-card-tools select.form-control, .iq-card-tools .form-select {
  min-height: 32px; height: 32px; padding: 0 30px 0 10px; font-size: 12.5px; font-weight: 500; width: auto;
}
.iq-card-hint { font-size: 12px; color: var(--iq-muted); gap: 6px; }
.iq-card-hint :is(.fa,.fas,.far,.fab), .iq-card-hint svg { font-size: 11px; color: var(--iq-subtle); }
.iq-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: 0 0 10px; }
.iq-swatch-o18 { background: var(--iq-o18); }
.iq-swatch-h2  { background: var(--iq-h2); }
.iq-swatch-dex { background: var(--iq-dex); }
.iq-swatch-xy  { background: linear-gradient(135deg, var(--iq-o18) 50%, var(--iq-h2) 50%); }
.iq-swatch-map { background: var(--iq-ink-2); }

/* ---------- Eyebrow / headings ---------- */
.iq-eyebrow { font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--iq-muted); }
.iq-keepcase { text-transform: none !important; letter-spacing: .02em; }
.iq-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 28px !important; }
.iq-section-head h2 { font-size: 16px; font-weight: 650; margin: 2px 0 0; color: var(--iq-ink); }

/* ---------- Station hero, header, KPI tiles ---------- */
.iq-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.iq-hero > .shiny-html-output { min-width: 0; flex: 1 1 420px; }
.iq-station-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.iq-hero .iq-station-head { display: grid; gap: 0; }
.iq-station-name { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 8px; color: var(--iq-ink); line-height: 1.15; }
.iq-station-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 2px 0 8px; }
.iq-station-title .iq-station-name { margin: 0; font-family: var(--iq-display); }
.iq-hero-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.iq-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.iq-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--iq-surface); border: 1px solid var(--iq-border);
  font-size: 12px; color: var(--iq-ink-2); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.iq-chip :is(.fa,.fas,.far,.fab) { color: var(--iq-subtle); font-size: 11px; }
.iq-chip-btn { cursor: pointer; color: var(--iq-brand-600); border-style: dashed; transition: background-color .15s, border-color .15s; }
.iq-chip-btn:hover { background: var(--iq-brand-50); border-color: var(--iq-brand); }
/* newer bslib makes these wrappers display: contents, which drops their margins */
.iq-main > #network_params, .iq-main > #network_body, .iq-main > #flags_body { display: block; }
.iq-main > #network_body { margin-bottom: 20px; }
.iq-main > .shiny-html-output:empty { margin: 0 !important; }   /* not display:none: hidden outputs are never rendered */
.iq-param-chips { margin-top: 0; }
.iq-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 16px; }
.iq-kpi {
  background: var(--iq-surface); border: 1px solid var(--iq-border); border-radius: var(--iq-radius);
  padding: 14px 16px; box-shadow: var(--iq-shadow-sm); position: relative; overflow: hidden;
}
.iq-kpi-label { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 550; color: var(--iq-muted); }
.iq-kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; color: var(--iq-ink); line-height: 1.15; margin-top: 6px; }
.iq-kpi-value .iq-kpi-of { font-size: 14px; font-weight: 500; color: var(--iq-subtle); letter-spacing: 0; margin-left: 2px; }
.iq-kpi-sub { font-size: 12px; color: var(--iq-muted); margin-top: 3px; }
.iq-kpi.is-flagged { border-color: var(--iq-flag-200); background: linear-gradient(180deg, var(--iq-flag-50), var(--iq-surface) 70%); }
.iq-kpi.is-flagged .iq-kpi-value { color: var(--iq-flag); }
.iq-kpi-bar { height: 4px; border-radius: 4px; background: var(--iq-surface-2); margin-top: 10px; overflow: hidden; }
.iq-kpi-bar > span { display: block; height: 100%; border-radius: 4px; background: var(--iq-flag); }
.iq-btn-group { display: inline-flex; }
.iq-btn-group .btn + .btn { margin-left: -1px; }
.iq-btn-group .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.iq-btn-group .btn:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.btn.iq-sq { width: 38px; height: 38px; padding: 0; }
.btn-flag { background: var(--iq-flag-50); color: var(--iq-flag); border: 1px solid transparent; }
.btn-flag:hover, .btn-flag:focus-visible { background: var(--iq-flag); color: var(--iq-on-accent); }
.dropdown-menu { border-color: var(--iq-border); border-radius: 10px; box-shadow: var(--iq-shadow-lg); background: var(--iq-surface); padding: 6px; }
.dropdown-item { border-radius: 7px; font-size: 13px; padding: 8px 10px; color: var(--iq-ink-2); display: flex; gap: 8px; align-items: center; }
.dropdown-item:hover, .dropdown-item:focus-visible { background: var(--iq-brand-50); color: var(--iq-ink); }
.dropdown-item:focus-visible { outline-offset: -2px; }

/* status pills */
.iq-status {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.2; font-family: Inter, system-ui, sans-serif;
}
.iq-status :is(.fa,.fas,.far,.fab), .iq-status svg { font-size: 11px; }
.iq-status.is-clean   { background: var(--iq-ok-50);   color: var(--iq-ok); }
.iq-status.is-review  { background: var(--iq-flag-50); color: var(--iq-flag); }
.iq-status.is-none    { background: var(--iq-surface-2); color: var(--iq-muted); border: 1px solid var(--iq-border); }
.iq-flagpill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--iq-flag-50); color: var(--iq-flag); white-space: nowrap; }
.iq-flagpill.strong { background: var(--iq-flag); color: var(--iq-on-accent); }
.iq-flagpill.ok { background: var(--iq-ok-50); color: var(--iq-ok); }
.iq-dec { display: inline-block; min-width: 56px; text-align: center; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--iq-subtle); }
.iq-dec.is-keep { background: var(--iq-ok-50); color: var(--iq-ok); }
.iq-dec.is-exclude { background: var(--iq-ink); color: var(--iq-surface); }
.iq-dec.is-unsure { background: var(--iq-warn-50); color: var(--iq-warn); }

/* ---------- Bar key (how to read) ---------- */
.iq-key { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--iq-ink-2); }
.iq-key-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.iq-key-swatch { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }
.iq-key-light  { background: #CBD5E1; }
.iq-key-dark   { background: #64748B; }
.iq-key-flag   { background: var(--iq-flag); opacity: .8; }
.iq-key-strong { background: var(--iq-flag); box-shadow: inset 0 0 0 1.5px var(--iq-ink); }
.iq-key-mean   { width: 18px; height: 0; border-top: 2px dotted var(--iq-ink); border-radius: 0; }
.iq-key-near   { width: 18px; height: 0; border-top: 1.5px solid #94A3B8; border-radius: 0; }
.iq-key-band   { background: rgba(100,116,139,.18); border: 1px solid rgba(100,116,139,.25); }
.iq-key-weak   { width: 10px; height: 10px; border-radius: 50%; background: transparent; border: 1.2px solid rgba(217,119,6,.8); }

/* ---------- Map + legend ---------- */
.iq-map-wrap { position: relative; }
.iq-map-wrap .leaflet-container { border-radius: 0 0 var(--iq-radius) var(--iq-radius); font-family: inherit; background: var(--iq-map-bg); }
.iq-map-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.iq-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1px solid rgba(15,23,42,.55); }
.iq-dot-sel  { background: var(--iq-brand); border-color: #fff; box-shadow: 0 0 0 1.5px var(--iq-ink); }
.iq-dot-near { background: #475569; }
.iq-dot-oth  { background: #E2E8F0; }
.iq-dot-nodata { background: transparent; border: 1.5px dashed var(--iq-muted); }
.iq-st-clean   { background: #94A3B8; border-color: #fff; }
.iq-st-review  { background: #7C3AED; border-color: #fff; }
.iq-st-none    { background: var(--iq-surface); border-color: var(--iq-subtle); }
.iq-ring { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 1.5px dashed var(--iq-brand); background: rgba(10,146,255,.08); }
.iq-dash { width: 16px; height: 0; border-top: 1.5px dashed var(--iq-subtle); display: inline-block; margin-left: -2px; }
.iq-dash.iq-solid { border-top-style: solid; border-top-color: var(--iq-ink-2); }
.iq-bounds-note { margin: 0 0 6px; display: flex; align-items: center; gap: 4px; }
.iq-bounds-note :is(.fa,.fas,.far,.fab) { font-size: 10px; color: var(--iq-subtle); }
[data-bs-theme="dark"] .leaflet-container { background: var(--iq-map-bg); }
.leaflet-tooltip { border-radius: 6px; border: 0; box-shadow: var(--iq-shadow); font-size: 12px; font-weight: 500; padding: 4px 8px; }
.leaflet-bar a { color: var(--iq-ink-2) !important; }
[data-bs-theme="dark"] .leaflet-bar a { background: var(--iq-surface); border-color: var(--iq-border); }
[data-bs-theme="dark"] .leaflet-control-attribution { background: rgba(17,26,43,.8) !important; color: var(--iq-muted); }
[data-bs-theme="dark"] .leaflet-control-attribution a { color: var(--iq-brand-600); }
[data-bs-theme="dark"] .leaflet-tooltip { background: var(--iq-surface); color: var(--iq-ink); border-color: var(--iq-border); }

/* ---------- Plots, validation messages, recalculating ---------- */
.shiny-output-error-validation {
  display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  min-height: 160px; height: 100%; color: var(--iq-muted); font-size: 13px;
  background: repeating-linear-gradient(-45deg, var(--iq-surface-2), var(--iq-surface-2) 8px, var(--iq-surface) 8px, var(--iq-surface) 16px);
  border-radius: var(--iq-radius-sm); padding: 24px;
}
/* htmlwidgets places the message in an absolutely positioned box sized to its text: stretch it over the plot area */
.htmlwidgets-error.shiny-output-error-validation { left: 0 !important; right: 0; width: auto; max-width: none !important; margin-inline: 10px; box-sizing: border-box; }
.recalculating { opacity: .45; transition: opacity .25s ease .15s, filter .25s ease .15s; }
.html-widget-output.recalculating, .shiny-plot-output.recalculating, .iq-blur { filter: blur(3px) saturate(.75); opacity: .6; transition: opacity .25s ease .1s, filter .25s ease .1s; }
.js-plotly-plot .plotly .modebar { top: 2px !important; }
.js-plotly-plot .plotly .modebar-btn path { fill: var(--iq-subtle); }
.js-plotly-plot .plotly .modebar-btn:hover path, .js-plotly-plot .plotly .modebar-btn.active path { fill: var(--iq-brand) !important; }

/* ---------- Tables ---------- */
.iq-table-wrap { overflow-x: auto; margin: -12px -16px -14px; }
.iq-table-wrap table { margin: 0; font-size: 12.5px; width: 100%; }
.iq-table-wrap thead th {
  background: var(--iq-surface-2); color: var(--iq-muted); font-weight: 600; font-size: 11.5px;
  letter-spacing: .03em; text-transform: uppercase; border-bottom: 1px solid var(--iq-border) !important;
  white-space: nowrap; padding: 9px 14px !important; position: sticky; top: 0;
}
.iq-table-wrap tbody td { padding: 7px 14px !important; border-color: var(--iq-border-soft) !important; color: var(--iq-ink-2); white-space: nowrap; }
.iq-table-wrap tbody tr:hover td { background: var(--iq-brand-50); }
[data-bs-theme="dark"] .table { --bs-table-bg: transparent; --bs-table-color: var(--iq-ink-2); }

/* DataTables */
.dataTables_scrollHead table.dataTable, .dataTables_scrollBody table.dataTable { margin-top: 0 !important; margin-bottom: 0 !important; }
.iq-dt.dataTable, table.dataTable.iq-dt { font-size: 13px; color: var(--iq-ink-2); border-collapse: collapse !important; }
table.dataTable.iq-dt thead th { font-size: 12px; letter-spacing: 0; color: var(--iq-muted); font-weight: 600; border-bottom: 1px solid var(--iq-border) !important; background: var(--iq-surface-2); white-space: nowrap; }
table.dataTable.iq-dt tbody td { border-top: 1px solid var(--iq-border) !important; padding: 8px 10px; background: transparent; }
table.dataTable.iq-dt tbody tr { cursor: pointer; background: transparent !important; }
table.dataTable.iq-dt tbody tr:hover td { background: var(--iq-brand-50) !important; }
table.dataTable.iq-dt tbody tr.selected td, table.dataTable.iq-dt tbody tr.selected > * { background: var(--iq-brand-100) !important; box-shadow: none !important; color: var(--iq-ink) !important; }
.dataTables_wrapper .dataTables_filter { float: none; text-align: left; margin-bottom: 8px; }
.dataTables_wrapper .dataTables_filter input { margin-left: 0 !important; width: 260px; border: 1px solid var(--iq-border-strong) !important; border-radius: 8px !important; padding: 6px 10px !important; background: var(--iq-surface) !important; color: var(--iq-ink) !important; box-shadow: none !important; }
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--iq-brand) !important; box-shadow: var(--iq-ring) !important; outline: 0; }
.dataTables_wrapper .dataTables_info { font-size: 12px; color: var(--iq-muted) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: 7px !important; font-size: 12.5px; color: var(--iq-ink-2) !important; border: 0 !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--iq-brand-50) !important; color: var(--iq-brand-600) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button:hover { background: var(--iq-surface-2) !important; color: var(--iq-ink) !important; }

/* ---------- Empty states / hero ---------- */
.iq-empty {
  background: var(--iq-surface); border: 1px dashed var(--iq-border-strong); border-radius: 16px;
  padding: 44px 32px; text-align: center;
}
.iq-empty-icon {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  background: var(--iq-brand-50); color: var(--iq-brand); font-size: 22px;
}
.iq-empty h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 6px; }
.iq-empty p { color: var(--iq-muted); font-size: 14px; max-width: 560px; margin: 0 auto; line-height: 1.55; }
.iq-empty-hero h2 { font-family: var(--iq-display); font-size: 22px; max-width: 680px; margin-inline: auto; text-wrap: balance; }
.iq-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 28px auto 0; max-width: 980px; text-align: left; }
.iq-empty .iq-hero-cite { margin: 28px auto 0; max-width: 760px; font-size: 12px; color: var(--iq-muted); line-height: 1.5; }
.iq-hero-cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 4px 0 18px; }
.iq-banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border: 1px solid var(--iq-brand-100); background: var(--iq-brand-50); color: var(--iq-ink-2);
  border-radius: var(--iq-radius); font-size: 13px;
}
.iq-banner :is(.fa,.fas,.far,.fab) { color: var(--iq-brand); }
.iq-banner-warn { border-color: transparent; background: var(--iq-warn-50); color: var(--iq-ink-2); }
.iq-banner-warn :is(.fa,.fas,.far,.fab), .iq-banner-warn svg { color: var(--iq-warn) !important; }
.iq-banner-ok { background: var(--iq-ok-50); color: var(--iq-ok); border-color: color-mix(in srgb, var(--iq-ok) 30%, transparent); }
.iq-dataset-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.iq-dataset-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin: 2px 0 0; }
.iq-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.iq-import-btn { margin-bottom: 6px; }
.iq-dl-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.iq-dl-row .btn { gap: 6px; }

/* ---------- Screening settings (one block, shown in the sidebar of the open tab) ---------- */
.iq-settings-head {
  display: flex; gap: 10px; align-items: center; padding: 10px 12px; margin-bottom: 16px;
  border-radius: 10px; background: var(--iq-surface-2); border: 1px solid var(--iq-border);
}
.iq-settings-head > :is(.fa,.fas,.far,svg) { color: var(--iq-brand); font-size: 13px; }
.iq-settings-head strong { display: block; font-size: 13px; font-weight: 650; color: var(--iq-ink); line-height: 1.3; }
.iq-sidebar .iq-settings-slot { border-top: 1px solid var(--iq-border); margin-top: 18px; padding-top: 18px; }
.iq-sidebar .iq-sheet-head + .iq-settings-slot { border-top: 0; margin-top: 0; padding-top: 0; }
.iq-settings .iq-settings-head + .iq-section { border-top: 0; margin-top: 0; padding-top: 0; }
@media (min-width: 1200px) {   /* the settings are visible beside the page */
  .iq-param-chips { display: none; }
  #network_params:not(:has(.iq-banner)) { margin: 0 !important; }
}

/* ---------- Scrollbars: slim, in the app's own colours (not the browser's dark or light default) ---------- */
:root { color-scheme: light; }
[data-bs-theme="dark"] { color-scheme: dark; }
* { scrollbar-width: thin; scrollbar-color: var(--iq-border-strong) transparent; }
@supports not (scrollbar-color: auto) {   /* older Chrome / Safari */
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--iq-border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
  ::-webkit-scrollbar-button { display: none; }
}

/* ---------- Foldable controls sidebar (desktop) ---------- */
.iq-side-toggle, .iq-rail-controls { display: none; }
@media (min-width: 1200px) {
  .iq-side-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    position: fixed; z-index: 1032; top: calc(var(--iq-nav-h) + 18px);
    left: calc(var(--iq-rail-w) + var(--iq-side-w, 320px) - 13px);
    width: 26px; height: 26px; padding: 0; border-radius: 50%;
    border: 1px solid var(--iq-border-strong); background: var(--iq-surface); color: var(--iq-muted);
    box-shadow: var(--iq-shadow-sm); font-size: 11px; cursor: pointer;
    transition: color .15s, border-color .15s;
  }
  .iq-side-toggle:hover { color: var(--iq-brand-600); border-color: var(--iq-brand); }
  body[data-iq-active="Instructions"] .iq-side-toggle, body:not([data-iq-active]) .iq-side-toggle { display: none; }
  body.iq-side-collapsed .iq-side-toggle { display: none; }
  /* folded: a "Controls" item on top of the rail opens them again */
  body.iq-side-collapsed:not([data-iq-active="Instructions"]) { --iq-rail-shift: 74px; }
  body.iq-side-collapsed:not([data-iq-active="Instructions"]) .iq-rail-controls {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
    position: fixed; z-index: 1032; left: 9px; top: calc(var(--iq-nav-h) + 14px); width: 66px; height: 62px;
    border: 1px dashed var(--iq-border-strong); border-radius: 14px; background: var(--iq-surface-2);
    color: var(--iq-ink-2); font-size: 11.5px; font-weight: 600; cursor: pointer;
    transition: border-color .15s, color .15s, background-color .15s;
  }
  .iq-rail-controls:hover { border-color: var(--iq-brand); color: var(--iq-brand-600); background: var(--iq-brand-50); }
  .iq-rail-controls-ico { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; }
  .iq-rail-controls-ico > :last-child { font-size: 9px; }
  body.iq-side-collapsed .bslib-sidebar-layout { grid-template-columns: 0 minmax(0, 1fr) !important; }
  body.iq-side-collapsed .bslib-sidebar-layout > .sidebar { display: none !important; }
  body.iq-side-collapsed .bslib-sidebar-layout > .main { grid-column: 1 / -1 !important; }
}

/* ---------- Card header tools: small square buttons ---------- */
.btn.iq-sq.iq-sq-sm { width: 32px; height: 32px; font-size: 12.5px; flex: 0 0 auto; }
.bslib-card[data-full-screen="true"] [data-iq-expand] { display: none; }
.iq-card-tools { gap: 6px; }

/* ---------- Export menus, label legend ---------- */
.iq-export .dropdown-menu .dropdown-item { display: flex; align-items: center; gap: 9px; width: 100%; font-size: 13.5px; padding: 8px 12px; }
.iq-export .dropdown-item > :is(.fa,.fas,.far,svg):not(.iq-mini) { flex: 0 0 16px; width: 16px; margin: 0 !important; text-align: center; color: var(--iq-subtle); }
.iq-export-btn { gap: 7px; }
.iq-legend-menu { width: min(400px, calc(100vw - 32px)); }
.iq-legend-menu dl { display: grid; grid-template-columns: 118px 1fr; gap: 7px 12px; align-items: baseline; margin: 0 0 16px; font-size: 12.5px; }
.iq-legend-menu dl:last-child { margin-bottom: 0; }
.iq-legend-menu dt { font-weight: 400; }
.iq-legend-menu dd { margin: 0; color: var(--iq-ink-2); line-height: 1.45; }

/* ---------- Station page: time series beside a map + scatter column that stays in view ---------- */
.iq-station-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.iq-station-side { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); min-width: 0; }
.iq-station-ts { display: grid; gap: 20px; min-width: 0; }
.iq-station-ts .iq-section-head { margin-top: 0 !important; }
.iq-station-side #map, .iq-station-side #plot_XY { height: 300px !important; }
.iq-station-side .card-footer { padding-top: 8px; padding-bottom: 8px; }
/* Network map: as tall as the window allows, so the legend stays in view */
.iq-net-card #netmap { height: clamp(380px, calc(100dvh - 490px), 820px) !important; }
.iq-main .bslib-card.card[data-full-screen="true"] :is(#map, #plot_XY, #netmap) { height: 100% !important; }
/* .is-wide is set by www/isoqc.js when the page is at least 860 px wide */
.iq-station-grid.is-wide { grid-template-columns: minmax(0, 1fr) clamp(300px, 34%, 470px); align-items: start; }
.iq-station-grid.is-wide .iq-station-ts { grid-column: 1; grid-row: 1; }
.iq-station-grid.is-wide .iq-station-side { grid-column: 2; grid-row: 1; grid-template-columns: minmax(0, 1fr); position: sticky; top: 16px; }
/* both cards fit between the header and the footer bar */
.iq-station-grid.is-wide .iq-map-legend { font-size: 12px; gap: 3px 12px; }
.iq-station-grid.is-wide .iq-station-side .card-header { padding-top: 8px; padding-bottom: 8px; min-height: 0; }
.iq-station-grid.is-wide .iq-map-card .iq-card-title small { display: none; }   /* room for the map tools */
/* a sticky box is its own stacking layer: release it while one of its cards is full screen */
.iq-station-grid .iq-station-side:has(.bslib-card[data-full-screen="true"]) { position: static; }
.iq-main .bslib-card.card[data-full-screen="true"] :is(#map, #plot_XY, #netmap) { height: 100% !important; }

/* ---------- Network / Flags pages ---------- */
.iq-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.iq-page-title { font-family: var(--iq-display); font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 4px; color: var(--iq-ink); }
.iq-page-sub { color: var(--iq-muted); font-size: 13.5px; max-width: 72ch; margin: 0; }
.iq-page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.iq-page-actions .shiny-download-link { display: inline-flex; }
.iq-filter-bar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.iq-filter-bar .shiny-input-container { margin-bottom: 0; width: auto !important; }
.iq-review-progress { margin-left: auto; }
.iq-progress-wrap { display: grid; gap: 6px; font-size: 12.5px; color: var(--iq-muted); min-width: 200px; text-align: right; }
.iq-progress { height: 6px; border-radius: 6px; background: var(--iq-surface-2); border: 1px solid var(--iq-border); overflow: hidden; }
.iq-progress > span { display: block; height: 100%; background: var(--iq-ok); border-radius: 6px; transition: width .3s ease; }
.iq-upload-compact .shiny-input-container { margin: 0; }
.iq-upload-compact .input-group { flex-wrap: nowrap; }
.iq-upload-compact .input-group > .form-control { display: none; }
.iq-upload-compact .btn-file { border-radius: var(--iq-radius-sm) !important; }
.iq-upload-compact .shiny-file-input-progress { display: none !important; }

/* ---------- Guide (instructions) + changelog ---------- */
.iq-scroll { flex: 1 1 auto; min-height: 0; height: 100%; overflow-y: auto; }
.iq-doc { max-width: 880px; margin: 0 auto; padding: 32px 24px 48px; }
.iq-doc .card-body { padding: 36px 44px 40px; }
.instructions-content { font-size: 14.5px; line-height: 1.7; color: var(--iq-ink-2); }
.instructions-content h1 { font-size: 22px; font-weight: 700; color: var(--iq-ink); letter-spacing: -.01em; margin: 36px 0 12px; }
.instructions-content h1:first-child { margin-top: 0; }
.instructions-content h2 { font-size: 17px; font-weight: 650; color: var(--iq-ink); margin: 26px 0 8px; }
.instructions-content h3 { font-size: 15px; font-weight: 650; color: var(--iq-brand-600); margin: 20px 0 6px; }
.instructions-content hr { border: 0; border-top: 1px solid var(--iq-border); margin: 28px 0; opacity: 1; }
.instructions-content code { background: var(--iq-surface-2); border: 1px solid var(--iq-border); border-radius: 5px; padding: 1px 5px; font-size: 12.5px; color: var(--iq-ink); }
.instructions-content ul { padding-left: 1.2rem; }
.instructions-content li { margin: 2px 0; }
.instructions-content li::marker { color: var(--iq-subtle); }
.iq-cite-card { margin-top: 20px; }

.iq-cl-source { padding: 10px 14px; margin-bottom: 16px; border: 1px solid var(--iq-border); border-radius: 10px; background: var(--iq-surface-2); font-size: 13.5px; }
.iq-cl-source a { color: var(--iq-brand-600); font-weight: 600; }
.iq-cl { display: flex; flex-direction: column; gap: 6px; }
.iq-cl details { border: 1px solid var(--iq-border); border-radius: 10px; background: var(--iq-surface); }
.iq-cl details[open] { border-color: var(--iq-border-strong); }
.iq-cl summary { display: grid; grid-template-columns: 72px 92px minmax(0,1fr) 16px; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer; list-style: none; border-radius: 10px; }
.iq-cl summary:hover { background: var(--iq-surface-2); }
.iq-cl summary::-webkit-details-marker { display: none; }
.iq-cl summary::after {
  content: ""; width: 8px; height: 8px; border-right: 2px solid var(--iq-subtle); border-bottom: 2px solid var(--iq-subtle);
  transform: rotate(45deg); transition: transform .15s;
}
.iq-cl summary::after { justify-self: end; margin-top: -4px; }
.iq-cl details[open] summary::after { transform: rotate(225deg); margin-top: 4px; }
.iq-cl summary:focus-visible { outline-offset: -2px; }
.iq-cl-v { font-family: var(--iq-display); font-weight: 600; color: var(--iq-ink); }
.iq-cl-d { font-size: 12.5px; color: var(--iq-muted); font-variant-numeric: tabular-nums; }
.iq-cl-s { font-size: 13.5px; color: var(--iq-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iq-cl ul { margin: 0; padding: 2px 16px 12px 36px; font-size: 13.5px; line-height: 1.6; color: var(--iq-ink-2); }
.iq-cl li { margin: 3px 0; }
.iq-cl li b { color: var(--iq-ink); font-weight: 600; }

/* ---------- Modal, notifications, toast ---------- */
.modal-content { border: 0; border-radius: 16px; box-shadow: var(--iq-shadow-lg); background: var(--iq-surface); color: var(--iq-ink); }
.modal-header { border-bottom: 1px solid var(--iq-border); padding: 16px 22px; }
.modal-title { font-size: 16px; font-weight: 650; }
.modal-body { padding: 20px 22px; font-size: 14px; line-height: 1.6; color: var(--iq-ink-2); }
.modal-body h2 { font-size: 16px; font-weight: 700; color: var(--iq-ink); margin: 22px 0 2px; padding-top: 18px; border-top: 1px solid var(--iq-border); }
.modal-body h2:first-of-type { border-top: 0; padding-top: 0; }
.modal-footer { border-top: 1px solid var(--iq-border); padding: 12px 22px; }
.modal-backdrop.show { opacity: .35; }
[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

#shiny-notification-panel { width: 360px; }
.shiny-notification { border-radius: var(--iq-radius); border: 1px solid var(--iq-border); box-shadow: var(--iq-shadow-lg); background: var(--iq-surface); color: var(--iq-ink); font-size: 13px; opacity: 1; }
.shiny-notification-error { border-left: 4px solid var(--iq-h2); }
.shiny-notification-warning { border-left: 4px solid var(--iq-warn); }

.iq-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); z-index: 2100;
  background: var(--iq-ink); color: var(--iq-surface); padding: 10px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 500; box-shadow: var(--iq-shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; max-width: min(560px, calc(100vw - 32px));
}
.iq-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.iq-toast[data-kind="flag"] { background: var(--iq-flag); color: var(--iq-on-accent); }
.iq-toast[data-kind="error"] { background: var(--iq-h2); color: var(--iq-on-accent); }

/* ---------- Footer ---------- */
.iq-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--iq-surface); border-top: 1px solid var(--iq-border);
  font-size: 12px; color: var(--iq-muted);
}
.iq-footer a { color: var(--iq-ink-2); font-weight: 500; }
.iq-footer a:hover { color: var(--iq-brand-600); }
.iq-footer .iq-sep { color: var(--iq-border-strong); margin: 0 6px; }
.iq-version {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px;
  background: var(--iq-surface-2); border: 1px solid var(--iq-border); font-variant-numeric: tabular-nums;
}
.iq-version::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--iq-dex); }

/* ---------- Sample detail drawer ---------- */
.iq-detail { width: min(460px, 100vw) !important; background: var(--iq-surface); color: var(--iq-ink); border-left: 1px solid var(--iq-border) !important; }
.iq-detail .offcanvas-header { border-bottom: 1px solid var(--iq-border); padding: 14px 18px; }
.iq-detail .offcanvas-title { font-size: 13px; font-weight: 600; color: var(--iq-muted); text-transform: uppercase; letter-spacing: .06em; }
.iq-detail .offcanvas-body { padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; overflow-x: hidden; }
.iq-detail #flag_detail { min-width: 0; }
.iq-detail-head { display: grid; gap: 6px; }
.iq-detail-head h3 { font-family: var(--iq-display); font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.iq-detail-head .iq-flagpill { justify-self: start; }
.iq-detail-pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.iq-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.iq-detail-grid > div { border: 1px solid var(--iq-border); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; }
.iq-detail-grid small, .iq-detail-grid span { font-size: 11.5px; color: var(--iq-muted); }
.iq-detail-grid b { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--iq-ink); }
.iq-detail-grid b.is-flag { color: var(--iq-flag); }
.iq-detail-sub { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--iq-muted); margin: 6px 0 0; font-weight: 600; }
.iq-detail-table { margin: 0 !important; max-width: 100%; max-height: 260px; overflow: auto; border: 1px solid var(--iq-border); border-radius: 10px; }
.iq-detail-table table { font-size: 12.5px; margin: 0; color: var(--iq-ink-2); --bs-table-bg: transparent; }
.iq-detail-table th { font-size: 11px; color: var(--iq-muted); text-transform: uppercase; position: sticky; top: 0; background: var(--iq-surface-2); }
.iq-detail .iq-detail-table :is(th, td) { padding: 6px 8px; }
.iq-detail-table td:nth-child(n+2), .iq-detail-table th:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }
.iq-detail .iq-detail-table td:first-child { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iq-decide { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.iq-decide .btn { min-width: 0; padding-left: 6px; padding-right: 6px; }
/* decision state (beats the generic .btn-default rule in both themes) */
.iq-detail .iq-decide .btn.btn-default.is-on { border-color: var(--iq-brand) !important; background: var(--iq-brand-50) !important; color: var(--iq-brand-600) !important; box-shadow: inset 0 0 0 1px var(--iq-brand); }
.iq-detail .iq-decide .btn.btn-default.iq-ex.is-on { border-color: var(--iq-ink) !important; background: var(--iq-ink) !important; color: var(--iq-surface) !important; box-shadow: none; }
.iq-decided {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 8px 12px; border-radius: 10px; font-size: 13px;
  border: 1px solid var(--iq-border); background: var(--iq-surface-2); color: var(--iq-ink-2);
}
.iq-decided > :is(.fa,.fas,.far,.fab, svg) { font-size: 15px; }
.iq-decided.is-keep { border-color: color-mix(in srgb, var(--iq-ok) 35%, transparent); background: var(--iq-ok-50); color: var(--iq-ok); }
.iq-decided.is-exclude { border-color: var(--iq-ink); background: var(--iq-surface-2); color: var(--iq-ink); }
.iq-decided.is-unsure { border-color: color-mix(in srgb, var(--iq-warn) 35%, transparent); background: var(--iq-warn-50); color: var(--iq-warn); }
.iq-decided b { font-weight: 650; }
.iq-decided a { margin-left: auto; font-weight: 600; font-size: 12.5px; color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.iq-detail-nav { display: flex; align-items: center; gap: 8px; font-size: 12.5px; flex-wrap: wrap; }
.iq-detail-nav .iq-spacer { flex: 1; }
.offcanvas-backdrop.show { opacity: .3; }

/* =====================================================================
   Responsive shell
   ≥1200    desktop: left navigation rail, sidebar column, header search
   576–1199 tablet : top tabs, sidebar becomes a slide-in drawer ("Controls")
   <576     phone  : bottom tab bar + controls bottom sheet (floating button)
   ===================================================================== */
.iq-bottombar, .iq-backdrop, .iq-sheet-head, .iq-controls-btn, .iq-fab, .iq-rail-bg { display: none; }

@media (min-width: 1200px) {
  :root { --iq-rail-w: 84px; }
  .iq-rail-bg {
    display: block; position: fixed; z-index: 1029; left: 0; top: var(--iq-nav-h); bottom: 0; width: var(--iq-rail-w);
    background: var(--iq-surface); border-right: 1px solid var(--iq-border);
  }
  .navbar .navbar-nav > li.nav-item:nth-child(-n+5) { position: fixed; left: 0; width: var(--iq-rail-w); z-index: 1031; justify-content: center; }
  .navbar .navbar-nav > li.nav-item:nth-child(1) { top: calc(var(--iq-nav-h) + var(--iq-rail-shift, 0px) + 14px); }
  .navbar .navbar-nav > li.nav-item:nth-child(2) { top: calc(var(--iq-nav-h) + var(--iq-rail-shift, 0px) + 14px + 70px); }
  .navbar .navbar-nav > li.nav-item:nth-child(3) { top: calc(var(--iq-nav-h) + var(--iq-rail-shift, 0px) + 14px + 140px); }
  .navbar .navbar-nav > li.nav-item:nth-child(4) { top: calc(var(--iq-nav-h) + var(--iq-rail-shift, 0px) + 14px + 210px); }
  .navbar .navbar-nav > li.nav-item:nth-child(5) { top: calc(var(--iq-nav-h) + var(--iq-rail-shift, 0px) + 14px + 280px); }
  .navbar .navbar-nav > li.nav-item:nth-child(-n+5) > .nav-link {
    flex-direction: column; gap: 5px; width: 66px; height: 62px; padding: 8px 2px !important; justify-content: center;
    font-size: 11.5px; font-weight: 600; border-radius: 14px;
  }
  .navbar .navbar-nav > li.nav-item:nth-child(-n+5) > .nav-link :is(.fa,.fas,.far,.fab),
  .navbar .navbar-nav > li.nav-item:nth-child(-n+5) > .nav-link svg { font-size: 17px; opacity: 1; }
  .navbar .navbar-nav > li.nav-item:nth-child(-n+5) > .nav-link.active { background: var(--iq-brand-50); color: var(--iq-brand-600) !important; }
  .navbar .navbar-nav > li.nav-item:nth-child(-n+5) > .nav-link.active::after {
    left: -9px; right: auto; top: 14px; bottom: 14px; width: 3px; height: auto; border-radius: 0 3px 3px 0;
  }
  .navbar > .container-fluid { padding-left: 18px; }
  body > .container-fluid, .bslib-page-navbar > .container-fluid { padding-left: var(--iq-rail-w) !important; }
  .iq-detail { top: 0; }
}
@media (min-width: 1200px) and (max-width: 1399.98px) { .iq-ds-pill { max-width: 220px; } }

@media (max-width: 1199.98px) {
  .iq-nav-center { display: none !important; }
  .bslib-sidebar-layout { grid-template-columns: minmax(0, 1fr) !important; }
  .bslib-sidebar-layout > .main { grid-column: 1 / -1 !important; grid-row: 1 !important; padding: 20px 20px 28px !important; }
  .bslib-sidebar-layout > .collapse-toggle { display: none !important; }

  .bslib-sidebar-layout > .sidebar {
    position: fixed !important; z-index: 1060;
    top: var(--iq-nav-h); bottom: 0; left: 0; right: auto;
    width: min(360px, 88vw) !important; max-width: none !important;
    height: auto !important; max-height: none !important;
    display: block !important; visibility: visible !important;
    overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(-104%);
    transition: transform .28s cubic-bezier(.22,1,.36,1);
    box-shadow: var(--iq-shadow-lg);
  }
  .bslib-sidebar-layout > .sidebar > .sidebar-content { height: auto !important; overflow: visible !important; opacity: 1 !important; visibility: visible !important; }
  body.iq-controls-open .tab-pane.active .bslib-sidebar-layout > .sidebar { transform: none; }

  .iq-backdrop {
    display: block; position: fixed; inset: 0; z-index: 1055;
    background: rgba(15,23,42,.38); opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  body.iq-controls-open .iq-backdrop { opacity: 1; pointer-events: auto; }

  .iq-sheet-head {
    display: flex; align-items: center; gap: 10px; justify-content: space-between;
    position: sticky; top: -20px; z-index: 2;
    margin: -20px -20px 16px; padding: 14px 20px;
    background: var(--iq-surface); border-bottom: 1px solid var(--iq-border);
  }
  .iq-sheet-head strong { font-size: 14px; font-weight: 650; color: var(--iq-ink); }
  .iq-sheet-head + .iq-settings-slot .iq-settings-head { display: none; }   /* the sheet already has this title */
  .iq-sheet-grip { display: none; }
  .iq-sheet-head + .iq-section { border-top: 0 !important; margin-top: 0 !important; padding-top: 0 !important; }

  .iq-controls-btn { display: inline-flex; }
  body[data-iq-active="Instructions"] .iq-controls-btn { display: none; }
  .iq-controls-btn.is-active { border-color: var(--iq-brand); color: var(--iq-brand-600); background: var(--iq-brand-50); }

  .iq-institution { display: none; }
}

/* tablet: top navigation stays expanded (no hamburger) */
@media (min-width: 576px) and (max-width: 1199.98px) {
  .navbar .navbar-toggler, .navbar .navbar-toggle { display: none !important; }
  .navbar > .container-fluid { flex-wrap: nowrap; }
  .navbar .navbar-collapse { display: flex !important; flex-basis: auto; flex-grow: 1; align-items: center; }
  .navbar .navbar-nav { flex-direction: row; flex-wrap: nowrap; white-space: nowrap; }
  .iq-kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .navbar .navbar-nav .nav-link { padding: 8px 9px !important; }
  .navbar-brand { margin-right: 8px; }
  .navbar .navbar-nav .nav-link.active::after { display: block; left: 9px; right: 9px; }
  .navbar .navbar-nav .nav-link.active { background: transparent; color: var(--iq-ink) !important; }
  .iq-nav-tools { padding: 0 !important; margin-left: auto; }
}
/* around 1024 px the top tabs need the room: Cite keeps its icon only */
@media (min-width: 992px) and (max-width: 1099.98px) { .iq-cite-btn-label { display: none; } }
@media (min-width: 576px) and (max-width: 991.98px) {
  .navbar .navbar-nav > li.nav-item > .nav-link { font-size: 0; gap: 0; }
  .navbar .navbar-nav > li.nav-item > .nav-link :is(.fa,.fas,.far,.fab), .navbar .navbar-nav > li.nav-item > .nav-link svg { font-size: 16px; }
  .iq-controls-btn span, .iq-cite-btn-label { display: none; }
  .iq-wordmark { font-size: 20px; }
}

/* phone */
@media (max-width: 575.98px) {
  :root { --iq-nav-h: 56px; }
  html, body { overflow-x: hidden; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.iq-controls-open { overflow: hidden; }

  /* one natural page scroll: newer bslib keeps a viewport-bound height on the layout */
  html, body, body.bslib-page-fill { height: auto !important; min-height: 100%; }
  body > .container-fluid, .tab-content, .tab-content > .tab-pane,
  .bslib-sidebar-layout, .bslib-sidebar-layout > .main, .iq-scroll {
    height: auto !important; max-height: none !important; min-height: 0 !important;
    overflow: visible !important; flex: 0 0 auto !important;
  }
  .bslib-sidebar-layout { display: block !important; }

  .navbar { position: sticky; top: 0; }
  .navbar > .container-fluid { padding-left: 14px; padding-right: 10px; min-height: var(--iq-nav-h); flex-wrap: nowrap; }
  .navbar .navbar-toggler, .navbar .navbar-toggle { display: none !important; }
  /* collapsed navbar keeps only the tools (search, theme, cite) */
  .navbar .navbar-collapse { display: flex !important; flex-basis: auto; flex-grow: 1; justify-content: flex-end; }
  .navbar .navbar-nav { flex-direction: row; }
  .navbar .navbar-nav > li.nav-item:nth-child(-n+6) { display: none !important; }
  .navbar .navbar-nav .bslib-nav-spacer { display: none; }
  .iq-controls-btn { display: none !important; }
  .iq-cite-btn-label { display: none; }
  .iq-wordmark { font-size: 20px; }
  .iq-brand-mark { width: 33px; height: 33px; flex-basis: 33px; }

  /* touch targets ≥ 40 px */
  .iq-nav-tools { gap: 6px; }
  .iq-icon-btn, .iq-btn-ghost { width: auto; min-width: 40px; height: 40px; justify-content: center; }
  .iq-icon-btn { width: 40px; }
  .iq-theme-switch { min-height: 40px; }
  .btn.iq-sq { width: 40px; height: 40px; }
  .btn:not(.btn-link-muted) { min-height: 40px; }
  .dropdown-item { min-height: 40px; }
  .iq-chip-btn { position: relative; padding: 4px 12px; }
  .iq-chip-btn::after { content: ""; position: absolute; inset: -8px -4px; }   /* 40px+ hit area, same look */
  .form-control, .form-select, .selectize-input, select.form-control { min-height: 40px; }
  .iq-card-tools select.form-control, .iq-card-tools .form-select { min-height: 40px; height: 40px; }

  .bslib-sidebar-layout > .sidebar {
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100% !important; max-height: 84vh !important;
    border-radius: 18px 18px 0 0; border-right: 0 !important;
    transform: translateY(104%);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .iq-sheet-grip { display: block; position: absolute; top: 6px; left: 50%; transform: translateX(-50%); width: 40px; height: 4px; border-radius: 4px; background: var(--iq-border-strong); }
  .iq-sheet-head { padding-top: 18px; border-radius: 18px 18px 0 0; }

  .iq-bottombar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1050;
    height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--iq-surface); border-top: 1px solid var(--iq-border);
    box-shadow: 0 -6px 20px -12px rgba(15,23,42,.25);
  }
  .iq-bb-item {
    border: 0; background: none; color: var(--iq-muted);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    font-size: 10.5px; font-weight: 600; letter-spacing: .01em; position: relative;
    -webkit-tap-highlight-color: transparent;
  }
  .iq-bb-item:focus-visible { outline-offset: -4px; border-radius: 10px; }
  .iq-bb-item :is(.fa,.fas,.far,.fab), .iq-bb-item svg { font-size: 18px; }
  .iq-bb-item.is-active { color: var(--iq-brand-600); }
  .iq-bb-item.is-active::before {
    content: ""; position: absolute; top: 0; left: 26%; right: 26%; height: 3px;
    border-radius: 0 0 3px 3px; background: var(--iq-brand);
  }

  /* floating "Controls" button on tabs with a sidebar */
  .iq-fab {
    display: none; position: fixed; right: 16px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 1052;
    align-items: center; gap: 8px; height: 46px; padding: 0 18px; border-radius: 999px; border: 0;
    background: var(--iq-ink); color: var(--iq-surface); font-weight: 600; font-size: 13.5px;
    box-shadow: 0 10px 24px -8px rgba(15,23,42,.45);
  }
  body:not([data-iq-active="Instructions"]) .iq-fab { display: inline-flex; }
  body.iq-controls-open .iq-fab { display: none !important; }

  .bslib-sidebar-layout > .main { padding: 16px 14px 24px !important; }
  .iq-main > * + * { margin-top: 14px; }
  .iq-station-name { font-size: 21px; }
  .iq-page-title { font-size: 22px; }
  .iq-hero-actions { width: 100%; }
  .iq-hero-actions .btn-flag { flex: 1; }
  .iq-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .iq-kpis > .iq-kpi:first-child { grid-column: 1 / -1; }
  .iq-kpi { padding: 12px; }
  .iq-kpi-value { font-size: 22px; }
  .iq-kpi-sub { font-size: 11px; }
  .iq-map-wrap .leaflet-container { height: 320px !important; }
  .iq-section-head { margin-top: 18px !important; }
  .iq-key { font-size: 11px; gap: 4px 10px; }
  .card-header { padding: 10px 12px; min-height: 0; }
  .iq-card-hint { display: none; }
  .iq-empty { padding: 28px 18px; }
  .iq-empty h2 { font-size: 18px; }
  .iq-dataset-head h2 { font-size: 18px; }
  .iq-doc { padding: 16px 12px 24px; }
  .iq-doc .card-body { padding: 20px 18px; }
  .iq-review-progress { margin-left: 0; width: 100%; }
  .iq-progress-wrap { text-align: left; }
  .dataTables_wrapper .dataTables_filter input { width: 100%; }
  .iq-footer { padding: 12px 16px; flex-direction: column; align-items: flex-start; font-size: 11px;
               margin-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .iq-toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .js-plotly-plot .plotly .modebar-container { display: none !important; }
  .iq-cl summary { grid-template-columns: 60px minmax(0,1fr) 16px; }
  .iq-cl-d { display: none; }
  .iq-cl-s { white-space: normal; }
}

/* =====================================================================
   Logo (a drop whose outline is the letter Q, with a short tail)
   + "from bars" loading motion: a histogram grows, its odd bar becomes the tail
   ===================================================================== */
:root { --iq-disc-top: #5AB8FF; --iq-disc-side: #0A6FD6; --iq-disc-xtop: #A78BFA; --iq-disc-xside: #6D28D9; --iq-disc-flash: #E0F2FE; --iq-disc-scan: #0A92FF; }
[data-bs-theme="dark"] { --iq-disc-top: #8FD0FF; --iq-disc-side: #2E8BFF; --iq-disc-xtop: #C4B5FD; --iq-disc-xside: #8B5CF6; --iq-disc-flash: #FFFFFF; --iq-disc-scan: #8FD0FF; }
.iq-mark { overflow: visible; }
.iq-mark .iq-ring { stroke: var(--iq-disc-side); }
.iq-mark .iq-bar { fill: var(--iq-disc-side); transform-box: fill-box; transform-origin: 50% 100%; }
.iq-mark .iq-tail { stroke: var(--iq-disc-xside); transform-box: fill-box; transform-origin: center; transition: transform .4s cubic-bezier(.3,1.5,.5,1); }
.iq-brand:hover .iq-mark .iq-tail { transform: translate(1.5px, 1.6px); }

/* animated: .iq-loader (overlays, splash, progress) and the header logo while busy */
:is(.iq-loader, .iq-busy .iq-brand-mark) .iq-bars { opacity: 1; }
:is(.iq-loader, .iq-busy .iq-brand-mark) .iq-bar { animation: iq-bar 3.6s linear infinite both; animation-delay: calc(var(--i) * .07s); }
:is(.iq-loader, .iq-busy .iq-brand-mark) .iq-ring { stroke-dasharray: 1 2; stroke-linecap: round; animation: iq-ring 3.6s ease-in-out infinite both; }
:is(.iq-loader, .iq-busy .iq-brand-mark) .iq-tail { animation: iq-tail 3.6s ease-in-out infinite both; transition: none; }
@keyframes iq-bar {
  0% { transform: scaleY(0); animation-timing-function: cubic-bezier(.3,1.5,.5,1); }
  14%, 30% { transform: scaleY(1); animation-timing-function: ease-in; }
  44%, 100% { transform: scaleY(0); }
}
@keyframes iq-ring {
  0%, 41% { stroke-dashoffset: 1.1; opacity: 0; }
  42% { stroke-dashoffset: 1.1; opacity: 1; }
  66%, 90% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
@keyframes iq-tail {
  0%, 7% { transform: translate(10.55px, -1.6px) rotate(42.9deg) scale(0); opacity: 1; animation-timing-function: cubic-bezier(.3,1.5,.5,1); }
  17%, 44% { transform: translate(10.55px, -1.6px) rotate(42.9deg) scale(1); opacity: 1; animation-timing-function: cubic-bezier(.5,0,.3,1.25); }
  64%, 90% { transform: translate(0px, 0px) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translate(0px, 0px) rotate(0deg) scale(1); opacity: 0; }
}

/* loading card over a recalculating output */
.iq-loading {
  position: absolute; z-index: 5; display: grid; place-items: center; pointer-events: none;
  opacity: 0; transition: opacity .18s ease;
}
.iq-loading.is-on { opacity: 1; }
.iq-loading-card {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px 10px 10px; border-radius: 14px;
  background: var(--iq-surface); border: 1px solid var(--iq-border); box-shadow: var(--iq-shadow-lg);
}
.iq-loading-card .iq-loader { width: 52px; height: 52px; display: block; }
.iq-loading-card b { display: block; font-size: 13.5px; color: var(--iq-ink); font-weight: 600; }
.iq-loading-card span { display: block; font-size: 12px; color: var(--iq-muted); }
.iq-loading.is-compact .iq-loading-card { padding: 8px; }
.iq-loading.is-compact .iq-loading-card .iq-txt { display: none; }

/* splash until connected */
.iq-splash { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; background: var(--iq-canvas); transition: opacity .35s ease, visibility .35s; }
.iq-splash.is-gone { opacity: 0; visibility: hidden; }
.iq-splash-in { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.iq-splash .iq-loader { width: 84px; height: 84px; }
.iq-splash-t { font-family: var(--iq-display); font-weight: 600; font-size: 22px; letter-spacing: -.02em; color: var(--iq-ink); }
.iq-splash-s { font-size: 13px; color: var(--iq-muted); margin-top: -8px; }

/* mini bar loader in buttons while a file is prepared */
.iq-mini { width: 1.05em; height: 1.05em; display: none; vertical-align: -0.15em; overflow: visible; }
.iq-mini .iq-m { fill: currentColor; transform-box: fill-box; transform-origin: 50% 100%; animation: iq-mini 1s ease-in-out infinite; animation-delay: calc(var(--i) * .15s); }
@keyframes iq-mini { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
.is-preparing { cursor: progress !important; pointer-events: none; }
.is-preparing > :is(.fa, .fas, .far, .fab, svg:not(.iq-mini)) { display: none !important; }
.is-preparing > .iq-mini { display: inline-block; }

/* network screening: centred progress card instead of the corner notification */
.shiny-progress-notification .iq-loader { width: 40px; height: 40px; float: left; margin: 2px 12px 4px 0; }
body.iq-progress-on #shiny-notification-panel {
  position: fixed !important; inset: 0 !important; width: auto !important; max-width: none !important; margin: 0 !important; padding: 16px; z-index: 2000;
  display: grid; place-items: center; align-content: center; gap: 10px;
  background: color-mix(in srgb, var(--iq-canvas) 55%, transparent);
  -webkit-backdrop-filter: blur(5px) saturate(.9); backdrop-filter: blur(5px) saturate(.9);
}
body.iq-progress-on #shiny-notification-panel .shiny-notification { width: min(440px, 100%); margin: 0; opacity: 1; }
body.iq-progress-on .shiny-notification:has(.shiny-progress-notification) {
  padding: 26px 28px 22px; text-align: center; border-radius: 18px; box-shadow: var(--iq-shadow-lg); border: 1px solid var(--iq-border); background: var(--iq-surface);
}
body.iq-progress-on .shiny-notification:has(.shiny-progress-notification) .shiny-notification-close { display: none; }
body.iq-progress-on .shiny-progress-notification { display: flex; flex-direction: column; padding: 0; border: 0; box-shadow: none; background: transparent; }
body.iq-progress-on .shiny-progress-notification > .iq-loader { order: 0; float: none; display: block; width: 76px; height: 76px; margin: 0 auto 14px; }
body.iq-progress-on .shiny-progress-notification > .progress-text { order: 1; display: flex; flex-direction: column; align-items: center; }
body.iq-progress-on .shiny-progress-notification .progress { order: 3; height: 6px; margin: 16px 0 0; border-radius: 6px; background: var(--iq-surface-2); }
body.iq-progress-on .shiny-progress-notification .progress-bar { border-radius: 6px; background: var(--iq-brand); }
body.iq-progress-on .shiny-progress-notification .progress-message { display: block; font-family: var(--iq-display); font-size: 17px; font-weight: 600; color: var(--iq-ink); }
body.iq-progress-on .shiny-progress-notification .progress-detail { display: block; font-size: 13px; color: var(--iq-muted); margin-top: 2px; }

@media (prefers-reduced-motion: reduce) {
  .iq-mark .iq-tail, .iq-ts-thumb, .iq-ts-track, .iq-ts-track svg { transition: none; }
  :is(.iq-loader, .iq-busy .iq-brand-mark) :is(.iq-bar, .iq-ring, .iq-tail) { animation: none !important; }
  :is(.iq-loader, .iq-busy .iq-brand-mark) .iq-bars { opacity: 0; }
  :is(.iq-loader, .iq-busy .iq-brand-mark) .iq-ring { stroke-dasharray: none; }
  .iq-mini .iq-m { animation: none; }
}

/* =====================================================================
   Import wizard
   ===================================================================== */
.modal-dialog:has(.iq-wiz) { max-width: min(1240px, 96vw); margin: 2vh auto; }
.modal-dialog:has(.iq-wiz) .modal-content { border-radius: 18px; overflow: hidden; border: 1px solid var(--iq-border); background: var(--iq-canvas); }
.modal-dialog:has(.iq-wiz) .modal-header, .modal-dialog:has(.iq-wiz) .modal-footer { display: none; }
.modal-dialog:has(.iq-wiz) .modal-body { padding: 0; }
.iq-wiz { display: flex; flex-direction: column; height: 96vh; max-height: 96vh; }
.iq-wiz > .shiny-html-output { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.iq-wiz-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 20px; background: var(--iq-surface); border-bottom: 1px solid var(--iq-border); }
.iq-wiz-title { display: flex; align-items: center; gap: 12px; margin-right: auto; min-width: 0; }
.iq-wiz-title h3 { margin: 0; font: 600 18px var(--iq-display); letter-spacing: -.01em; color: var(--iq-ink); }
.iq-wiz-title span { display: block; font-size: 12.5px; color: var(--iq-muted); max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iq-wiz-mark { width: 34px; height: 34px; flex: none; }
.iq-wiz-close { color: var(--iq-muted); font-size: 18px; padding: 4px 8px; border-radius: 8px; min-width: 36px; min-height: 36px; display: inline-grid; place-items: center; }
.iq-wiz-close:hover, .iq-wiz-close:focus-visible { background: var(--iq-surface-2); color: var(--iq-ink); text-decoration: none; }
.iq-wiz-steps { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.iq-wiz-step { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--iq-muted); font-weight: 500; }
.iq-wiz-step b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; background: var(--iq-surface-2); border: 1px solid var(--iq-border); color: var(--iq-muted); }
.iq-wiz-step + .iq-wiz-step::before { content: ""; width: 18px; height: 1px; background: var(--iq-border-strong); margin-right: 4px; }
.iq-wiz-step.done b { background: var(--iq-ok); border-color: var(--iq-ok); color: var(--iq-on-accent); }
.iq-wiz-step.cur { color: var(--iq-ink); font-weight: 600; }
.iq-wiz-step.cur b { background: var(--iq-brand); border-color: var(--iq-brand); color: var(--iq-on-accent); }
.iq-wiz-body { flex: 1; min-height: 0; overflow: auto; padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.iq-wiz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 14px; }
.iq-wiz-card { background: var(--iq-surface); border: 1px solid var(--iq-border); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.iq-wiz-card > :is(.fa, .fas, .far, .fab, svg) { font-size: 22px; color: var(--iq-brand); }
.iq-wiz-card h4 { margin: 0; font: 600 16px var(--iq-display); color: var(--iq-ink); }
.iq-wiz-card p { margin: 0; font-size: 13.5px; color: var(--iq-ink-2); }
.iq-wiz-drop { border-style: dashed; border-width: 1.5px; background: var(--iq-surface-2); }
.iq-wiz-drop .form-group { margin: 6px 0 0; }
.iq-wiz-card textarea { font-family: var(--iq-mono); font-size: 12px; }
.iq-wiz-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.iq-wiz-kv > div { background: var(--iq-surface); border: 1px solid var(--iq-border); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.iq-wiz-kv small { display: block; font-size: 11.5px; color: var(--iq-muted); }
.iq-wiz-kv strong { font-size: 14px; color: var(--iq-ink); font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.iq-wiz-ctrl { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: flex-end; background: var(--iq-surface); border: 1px solid var(--iq-border); border-radius: 12px; padding: 12px 14px; }
.iq-wiz-ctrl .form-group { margin: 0; }
.iq-wiz-st-on { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 6px 10px; border-radius: 9px; background: var(--iq-ok-50); color: var(--iq-ok); font-weight: 600; }
.iq-wiz-st-on a { color: var(--iq-muted); font-weight: 500; }
.iq-wiz-raw, .iq-wiz-scroll { overflow: auto; background: var(--iq-surface); border: 1px solid var(--iq-border); border-radius: 12px; }
.iq-wiz-rawtbl { border-collapse: collapse; font: 12px/1.4 var(--iq-mono); width: max-content; min-width: 100%; }
.iq-wiz-rawtbl th { position: sticky; left: 0; background: var(--iq-surface-2); color: var(--iq-subtle); font-weight: 500; text-align: right; padding: 4px 8px; }
.iq-wiz-rawtbl td { padding: 4px 10px; border-bottom: 1px solid var(--iq-border); color: var(--iq-ink-2); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.iq-wiz-rawtbl tr[data-row] { cursor: pointer; }
.iq-wiz-rawtbl tr[data-row]:not(.is-head):hover td { background: var(--iq-surface-2); }
.iq-wiz-rawtbl tr.is-head td { background: var(--iq-brand-50); color: var(--iq-brand-600); font-weight: 600; }
.iq-wiz-rawtbl tr.is-above td, .iq-wiz-rawtbl tr.is-unit td { opacity: .45; text-decoration: line-through; }
.iq-wiz-sub { margin: 4px 0 0; font: 600 14px var(--iq-display); color: var(--iq-ink); }
.iq-wiz-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.iq-wiz-chip { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--iq-border); background: var(--iq-surface); color: var(--iq-ink-2); }
.iq-wiz-chip b { font-weight: 600; color: var(--iq-ink); }
/* confidence classes iq-wc-{high,manual,medium,low,none} come from wiz_conf_class() */
.iq-wiz-chip:is(.iq-wc-high, .iq-wc-manual) { border-color: color-mix(in srgb, var(--iq-ok) 40%, transparent); background: var(--iq-ok-50); }
.iq-wiz-chip:is(.iq-wc-medium, .iq-wc-low) { border-color: color-mix(in srgb, var(--iq-warn) 45%, transparent); background: var(--iq-warn-50); }
.iq-wiz-grid-tbl { border-collapse: separate; border-spacing: 0; font-size: 12.5px; width: max-content; min-width: 100%; }
.iq-wiz-grid-tbl th { vertical-align: top; padding: 10px 8px 8px; min-width: 150px; max-width: 220px; background: var(--iq-surface); border-bottom: 1px solid var(--iq-border); border-top: 3px solid var(--iq-border); }
.iq-wiz-grid-tbl th:is(.iq-wc-high, .iq-wc-manual) { border-top-color: var(--iq-ok); }
.iq-wiz-grid-tbl th:is(.iq-wc-medium, .iq-wc-low) { border-top-color: var(--iq-warn); }
.iq-wiz-grid-tbl th.iq-wc-none { opacity: .7; }
.iq-wiz-grid-tbl th .form-group { margin: 4px 0; }
.iq-wiz-grid-tbl th select { font-size: 12.5px; padding: 4px 6px; }
.iq-wiz-grid-tbl th:is(.iq-wc-high, .iq-wc-manual) select { border-color: var(--iq-ok); background-color: var(--iq-ok-50); color: var(--iq-ok); font-weight: 600; }
.iq-wiz-grid-tbl th:is(.iq-wc-medium, .iq-wc-low) select { border-color: var(--iq-warn); background-color: var(--iq-warn-50); color: var(--iq-warn); font-weight: 600; }
.iq-wiz-colname { font: 500 11.5px var(--iq-mono); color: var(--iq-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iq-wiz-note { font-size: 11px; font-weight: 500; color: var(--iq-muted); }
.iq-wiz-grid-tbl td { padding: 5px 8px; border-bottom: 1px solid var(--iq-border); font: 12px var(--iq-mono); color: var(--iq-ink-2); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.iq-wiz-result th { min-width: 0; border-top-width: 1px; font-size: 11.5px; color: var(--iq-muted); font-weight: 600; }
.iq-wiz-bar { height: 8px; border-radius: 6px; background: var(--iq-surface-2); overflow: hidden; display: flex; }
.iq-wiz-bar span { display: block; height: 100%; }
.iq-wiz-bar .ok { background: var(--iq-ok); }
.iq-wiz-bar .bad { background: var(--iq-warn); }
.iq-wiz-report { display: flex; flex-direction: column; gap: 6px; }
.iq-wiz-ri { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start; padding: 9px 12px; border-radius: 11px; border: 1px solid var(--iq-border); background: var(--iq-surface); font-size: 13.5px; }
.iq-wiz-ri b { font-weight: 600; color: var(--iq-ink); }
.iq-wiz-ri small { display: block; color: var(--iq-muted); font-size: 12.5px; }
.iq-wiz-ri .ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: var(--iq-on-accent); font-size: 10.5px; margin-top: 1px; }
.iq-wiz-ri.ok .ic { background: var(--iq-ok); }
.iq-wiz-ri.warn .ic { background: var(--iq-warn); }
.iq-wiz-ri.error .ic { background: var(--iq-flag); }
.iq-wiz-foot { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; position: sticky; bottom: -20px; margin: auto -20px -20px; padding: 12px 20px; background: var(--iq-surface); border-top: 1px solid var(--iq-border); }
.iq-wiz-foot-r { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.iq-wiz-tpl { padding: 0 2px; }
@media (max-width: 575.98px) {
  .modal-dialog:has(.iq-wiz) { margin: 0; max-width: 100vw; }
  .iq-wiz { height: 100dvh; max-height: 100dvh; }
  .modal-dialog:has(.iq-wiz) .modal-content { border-radius: 0; }
  .iq-wiz-steps .iq-wiz-step:not(.cur) { font-size: 0; gap: 0; }
  .iq-wiz-head { padding: 12px 14px; }
  .iq-wiz-body { padding: 14px; }
  .iq-wiz-foot { margin: auto -14px -14px; padding: 12px 14px; bottom: -14px; }
  .iq-wiz-close { min-width: 40px; min-height: 40px; }
}

/* =====================================================================
   Start screen (no dataset yet): no rail, no sidebar; drop zone
   ===================================================================== */
body.iq-start-on { --iq-rail-w: 0px; }
body.iq-start-on :is(.iq-rail-bg, .iq-bottombar, .iq-fab, .iq-side-toggle, .iq-rail-controls, .iq-nav-center, .iq-search-btn),
body.iq-start-on .navbar .navbar-nav > li.nav-item:nth-child(-n+5) { display: none !important; }
body.iq-start-on .bslib-sidebar-layout { grid-template-columns: 0 minmax(0, 1fr) !important; }
body.iq-start-on .bslib-sidebar-layout > :is(.sidebar, .collapse-toggle) { display: none !important; }
body.iq-start-on .bslib-sidebar-layout > .main { grid-column: 1 / -1 !important; }
.iq-start { max-width: 880px; margin: 18px auto 0; border-style: solid; padding: 40px 28px 30px; }
.iq-start > p { max-width: 620px; }
.iq-drop {
  max-width: 700px; margin: 24px auto 0; padding: 28px 22px 24px; border-radius: 18px;
  border: 2px dashed color-mix(in srgb, var(--iq-brand) 55%, var(--iq-border)); background: var(--iq-brand-50);
  transition: border-color .15s, background-color .15s, transform .15s;
}
.iq-drop.is-over { border-color: var(--iq-brand); border-style: solid; background: color-mix(in srgb, var(--iq-brand) 16%, var(--iq-surface)); transform: scale(1.01); }
.iq-drop > :is(.fa, .fas, svg) { font-size: 26px; color: var(--iq-brand-600); }
.iq-drop h3 { font-family: var(--iq-display); font-size: 18px; font-weight: 600; margin: 8px 0 4px; }
.iq-drop p { color: var(--iq-muted); font-size: 13.5px; margin: 0; }
.iq-drop .iq-hero-cta { margin: 16px 0 0; align-items: center; }
.iq-drop-tpl { font-size: 13px; margin-left: 4px; }
.iq-start-alt {
  display: flex; align-items: center; gap: 14px; text-align: left; max-width: 700px; margin: 14px auto 0;
  padding: 12px 16px; border: 1px solid var(--iq-border); border-radius: 14px; background: var(--iq-surface-2);
}
.iq-start-alt > div { flex: 1 1 0; min-width: 0; }
.iq-start-alt h4 { font-size: 14.5px; font-weight: 650; margin: 0; }
.iq-start-alt p { font-size: 12.5px; color: var(--iq-muted); margin: 2px 0 0; max-width: none; }
.iq-steps-line { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; margin-top: 24px; font-size: 12.5px; color: var(--iq-muted); }
.iq-steps-line b { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 6px; border-radius: 50%; background: var(--iq-brand-50); color: var(--iq-brand-600); font-size: 11px; font-weight: 700; }
.iq-steps-line i { font-style: normal; color: var(--iq-subtle); }
@media (max-width: 575.98px) { .iq-start { padding: 26px 16px 22px; } .iq-start-alt { flex-direction: column; align-items: stretch; } }

/* the reference database is not public: no dataset export while it is loaded */
body[data-iq-locked="1"] li:has(> #dl_reviewed_dataset) { display: none; }

/* =====================================================================
   Screening settings dialog (asked after a dataset is loaded)
   ===================================================================== */
.modal-content:has(.iq-ss) { border-radius: 18px; overflow: hidden; }
.modal-body:has(.iq-ss) { padding: 0; }
.iq-ss-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--iq-border); }
.iq-ss-mark { width: 34px; height: 34px; flex: 0 0 34px; }
.iq-ss-head h3 { font-family: var(--iq-display); font-size: 19px; font-weight: 600; margin: 0; }
.iq-ss-head span { font-size: 12.5px; color: var(--iq-muted); }
.iq-ss-body { padding: 16px 22px 6px; display: grid; gap: 16px; }
.iq-ss-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.iq-ss-pills span { border: 1px solid var(--iq-border); border-radius: 999px; padding: 3px 11px; font-size: 12.5px; background: var(--iq-surface-2); color: var(--iq-ink-2); }
.iq-ss-pills b { color: var(--iq-ink); }
.iq-ss-lab { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--iq-muted); margin-bottom: 8px; }
.iq-ss-grp .form-group { margin-bottom: 0; }
.iq-ss-grp label { font-size: 12.5px; color: var(--iq-ink-2); margin-bottom: 3px; }
.iq-ss-row { display: grid; gap: 10px; }
.iq-ss-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .iq-ss-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.iq-ss-hint { margin-top: 10px; padding: 8px 12px; border-radius: 10px; font-size: 12.5px; background: var(--iq-brand-50); color: var(--iq-ink-2); }
.iq-ss-note { margin: 7px 0 0; font-size: 12px; line-height: 1.45; color: var(--iq-muted); }
.iq-ss-later { margin: 0; font-size: 12px; line-height: 1.45; color: var(--iq-muted); }
.iq-ss-hint.is-warn { background: var(--iq-warn-50); }
.iq-ss-hint b { color: var(--iq-ink); }
.iq-ss-foot { display: flex; align-items: center; gap: 10px; padding: 14px 22px; margin-top: 12px; border-top: 1px solid var(--iq-border); background: var(--iq-surface-2); }
.iq-ss-sp { flex: 1 1 0; }
.iq-ss-foot a { font-size: 13px; font-weight: 600; }
@media (max-width: 575.98px) { .iq-ss-3 { grid-template-columns: 1fr 1fr; } .iq-ss-foot { flex-wrap: wrap; } }

/* =====================================================================
   Station time series: Compact (default) and Detailed layout
   Compact  = one figure: period on top, three short bands with one time axis.
   Detailed = tall panels with the neighbour list; on wide screens the settings
              sidebar and the map column are narrower so the panels get the width.
   body.iq-ts-detailed is set by www/isoqc.js; the plot layout follows in app.R.
   ===================================================================== */
.iq-station-ts .iq-section-head { display: grid; gap: 10px; justify-content: stretch; align-items: start; }
.iq-ts-headline { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.iq-ts-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--iq-muted); }
body.iq-ts-detailed .iq-only-compact, body:not(.iq-ts-detailed) .iq-only-detailed { display: none; }
.iq-view { display: inline-flex; align-items: center; gap: 9px; }
.iq-view-lbl { font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--iq-muted); }
.iq-seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--iq-border-strong); border-radius: 10px; background: var(--iq-surface); box-shadow: var(--iq-shadow-sm); }
.iq-seg-btn { display: inline-flex; align-items: center; gap: 7px; border: 0; border-radius: 7px; background: transparent; color: var(--iq-ink-2);
  font: 600 13px/1 Inter, system-ui, sans-serif; padding: 7px 13px; cursor: pointer; transition: background-color .15s, color .15s; }
.iq-seg-btn :is(.fa, .fas, svg) { font-size: 12px; color: var(--iq-subtle); }
.iq-seg-btn:hover { background: var(--iq-surface-2); color: var(--iq-ink); }
.iq-seg-btn.is-on, .iq-seg-btn.is-on:hover { background: var(--iq-brand); color: #fff; }
.iq-seg-btn.is-on :is(.fa, .fas, svg) { color: #fff; }
.iq-seg-btn:focus-visible { outline: 2px solid var(--iq-brand); outline-offset: -2px; }
.iq-ts-count { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--iq-surface-2); color: var(--iq-muted); border: 1px solid var(--iq-border); }
.iq-ts-count.is-flagged { background: var(--iq-flag-50); color: var(--iq-flag); border-color: transparent; }
.iq-ts-card > .card-header { gap: 10px; }
.iq-ts-card > .card-header .iq-card-hint { margin-left: auto; }
.iq-main .bslib-card.card[data-full-screen="true"] :is(#plot_O18, #plot_H2, #plot_D_excess) { height: 100% !important; }

/* Both views: the period and the three panels are one block, without gaps */
.iq-ts-fig {
  display: grid; gap: 0; min-width: 0; background: var(--iq-surface); border: 1px solid var(--iq-border); border-radius: var(--iq-radius);
  box-shadow: var(--iq-shadow-sm); overflow: hidden;
}
.iq-ts-fig > .iq-period-row {
  border: 0; border-bottom: 1px solid var(--iq-border); border-radius: 0; box-shadow: none; background: var(--iq-surface-2);
  padding: 8px 24px 4px 72px;   /* the slider spans the plot area below (plot margins 64 / 16 + card padding) */
}
.iq-ts-fig > .iq-ts-card:not([data-full-screen="true"]) { border: 0; border-radius: 0; box-shadow: none; margin: 0 !important; position: relative; overflow: visible; }
.iq-ts-fig > .iq-ts-card:not([data-full-screen="true"]) + .iq-ts-card { border-top: 1px solid var(--iq-border); }
.iq-ts-fig > .iq-ts-card:not([data-full-screen="true"]) > :is(.card-header, .card-body) { border-radius: 0; }
/* Detailed: the slider ends where the plot area ends (the legend takes 215 px on the right) */
@media (min-width: 768px) {
  body.iq-ts-detailed .iq-ts-fig > .iq-period-row { padding-left: 74px; padding-right: 26px; }
  body.iq-ts-detailed:not(.iq-ts-nolegend) .iq-ts-fig > .iq-period-row { padding-right: 225px; }
}

/* Compact */
body:not(.iq-ts-detailed) .iq-ts-fig > .iq-ts-card:not([data-full-screen="true"]) + .iq-ts-card { border-top-color: var(--iq-border-soft); }
body:not(.iq-ts-detailed) .iq-ts-card:not([data-full-screen="true"]) > .card-header {
  position: absolute; z-index: 2; left: 78px; top: 3px; min-height: 0; padding: 1px 6px; border: 0; border-radius: 8px; gap: 8px;
  background: color-mix(in srgb, var(--iq-surface) 84%, transparent); pointer-events: none;
}
body:not(.iq-ts-detailed) .iq-ts-card:not([data-full-screen="true"]) > .card-header :is(small, .iq-card-hint) { display: none; }
body:not(.iq-ts-detailed) .iq-ts-card:not([data-full-screen="true"]) > .card-header h3 { font-size: 12.5px; }
body:not(.iq-ts-detailed) .iq-ts-card:not([data-full-screen="true"]) > .card-header .iq-swatch { width: 9px; height: 9px; }
body:not(.iq-ts-detailed) .iq-ts-card:not([data-full-screen="true"]) > .card-header .iq-ts-count { padding: 1px 9px; pointer-events: auto; }
body:not(.iq-ts-detailed) .iq-ts-card:not([data-full-screen="true"]) > .card-body { padding: 0 8px !important; }
/* band height: 180 px at least, up to 203 px where the window is high enough to keep all three in view */
body:not(.iq-ts-detailed) { --iq-band: clamp(180px, calc((100dvh - 520px) / 3), 203px); }
body:not(.iq-ts-detailed) .iq-ts-card:not([data-full-screen="true"]) :is(#plot_O18, #plot_H2) { height: var(--iq-band) !important; }
body:not(.iq-ts-detailed) .iq-ts-card:not([data-full-screen="true"]) #plot_D_excess { height: calc(var(--iq-band) + 24px) !important; }   /* + the dates */
@media (max-width: 767.98px) {
  .iq-ts-fig > .iq-period-row { padding: 8px 12px 4px; }
  body:not(.iq-ts-detailed) .iq-ts-card:not([data-full-screen="true"]) > .card-header { left: 70px; }
}

/* Detailed on wide screens: narrow settings sidebar (Station tab only) and narrow map column */
@media (min-width: 1200px) {
  body.iq-ts-detailed .iq-station-grid.is-wide { grid-template-columns: minmax(0, 1fr) 310px; }
  body.iq-ts-detailed .iq-station-grid.is-wide .iq-map-card .iq-card-title h3 { font-size: 13.5px; }
  body.iq-ts-detailed .iq-station-grid.is-wide .iq-map-card .iq-card-tools :is(.shiny-input-container, select) { width: 74px !important; }
  body.iq-ts-detailed .iq-station-grid.is-wide .iq-map-card > .card-header { flex-wrap: nowrap; gap: 6px; }
  body.iq-ts-detailed .iq-station-grid.is-wide .iq-map-card .iq-swatch { display: none; }
  /* the column is set directly as well: bslib versions differ in how they apply the width variable */
  body.iq-ts-detailed[data-iq-active="Dashboard"]:not(.iq-side-collapsed) .tab-pane.active .bslib-sidebar-layout {
    --_sidebar-width: 178px !important; --bslib-sidebar-width: 178px !important;
    grid-template-columns: 178px minmax(0, 1fr) !important;
  }
  body.iq-ts-detailed[data-iq-active="Dashboard"]:not(.iq-side-collapsed) .tab-pane.active .bslib-sidebar-layout > .sidebar { width: 178px !important; min-width: 0 !important; max-width: 178px !important; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .bslib-sidebar-layout > .bslib-sidebar-resize-handle { display: none; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .sidebar-content { padding: 14px 12px 16px; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar :is(.iq-grid-2, .iq-grid-3) { grid-template-columns: 1fr 1fr; gap: 0 8px; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .iq-lbl-more { display: none; }   /* "gradient": the section title says it */
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .form-group { margin-bottom: 8px; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .form-group > label { margin-bottom: 2px; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .form-control { padding-left: 9px; padding-right: 6px; min-height: 34px; height: 34px; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .iq-section { margin-top: 12px; padding-top: 12px; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .iq-section-title { gap: 6px; letter-spacing: .03em; font-size: 11px; line-height: 1.25; margin-bottom: 8px; align-items: flex-start; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .iq-section-title > :is(.fa, .fas, svg) { display: none; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .iq-section-title .iq-unit { padding-left: 2px; flex: none; white-space: nowrap; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .iq-note { margin-top: 0; font-size: 11px; line-height: 1.4; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .iq-settings-head { padding: 8px 10px; margin-bottom: 12px; gap: 8px; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .iq-settings-head strong { font-size: 12.5px; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .irs--shiny { height: 46px; }
  /* the radius scale keeps 0, 250 and 500 */
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .irs-grid-text:not(.js-grid-text-0, .js-grid-text-5, .js-grid-text-10) { visibility: hidden !important; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar :is(.irs-min, .irs-max) { display: none; }
}
@media (min-width: 1200px) and (max-height: 800px) {
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .iq-note-why { display: none; }
}
/* low windows: the settings stay in view without scrolling */
@media (min-width: 1200px) and (max-height: 700px) {
  .iq-sidebar .iq-note-why { display: none; }
  .iq-sidebar .iq-section { margin-top: 12px; padding-top: 12px; }
  .bslib-sidebar-layout > .sidebar > .sidebar-content { padding-top: 14px; padding-bottom: 8px; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .iq-section { margin-top: 8px; padding-top: 8px; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .iq-settings-head { display: none; }
  body.iq-ts-detailed[data-iq-active="Dashboard"] .tab-pane.active .iq-sidebar .iq-settings .iq-settings-head + .iq-section { margin-top: 0; padding-top: 0; }
}

/* Legend switch (Detailed) */
.iq-switch { display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 4px 2px; margin-right: 6px;
  font: 600 12.5px/1 Inter, system-ui, sans-serif; color: var(--iq-ink-2); cursor: pointer; }
.iq-switch-track { position: relative; width: 30px; height: 17px; border-radius: 999px; background: var(--iq-border-strong); transition: background-color .15s; flex: none; }
.iq-switch-knob { position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .3); transition: transform .15s; }
.iq-switch.is-on .iq-switch-track { background: var(--iq-brand); }
.iq-switch.is-on .iq-switch-knob { transform: translateX(13px); }
.iq-switch:focus-visible { outline: 2px solid var(--iq-brand); outline-offset: 2px; border-radius: 6px; }

/* Station page, wide layout: the map and the scatter plot fold away to the right (www/isoqc.js) */
.iq-aside-head, .iq-aside-rail { display: none; }
.iq-station-grid.is-wide .iq-aside-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 38px; margin-bottom: -8px; }
.iq-aside-toggle {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 8px; border: 1px solid var(--iq-border-strong);
  background: var(--iq-surface); color: var(--iq-ink-2); box-shadow: var(--iq-shadow-sm); font: 600 12.5px/1 Inter, system-ui, sans-serif; cursor: pointer;
  transition: color .15s, border-color .15s, background-color .15s;
}
.iq-aside-toggle :is(.fa, .fas, svg) { font-size: 11px; color: var(--iq-brand); }
.iq-aside-toggle:hover { color: var(--iq-brand-600); border-color: var(--iq-brand); background: var(--iq-brand-50); }
.iq-station-grid.is-wide .iq-station-side:has(.bslib-card[data-full-screen="true"]) .iq-aside-head { display: none; }
/* both cards and their header fit between the page header and the footer bar */
.iq-station-grid.is-wide .iq-station-side { --iq-aside-rest: 540px; }
body.iq-ts-detailed .iq-station-grid.is-wide .iq-station-side { --iq-aside-rest: 580px; }   /* narrower column: its legend and subtitle wrap */
.iq-station-grid.is-wide .iq-station-side #map { height: clamp(200px, calc((100dvh - var(--iq-aside-rest)) * .55), 420px) !important; }
.iq-station-grid.is-wide .iq-station-side #plot_XY { height: clamp(190px, calc((100dvh - var(--iq-aside-rest)) * .45), 360px) !important; }
body.iq-aside-collapsed .iq-station-grid.is-wide { grid-template-columns: minmax(0, 1fr) 40px !important; }
/* folded: kept rendered (off screen) so the map and the plot stay up to date */
body.iq-aside-collapsed .iq-station-grid.is-wide .iq-station-side > .card:not([data-full-screen="true"]) {
  position: absolute; left: -9999px; top: 0; width: 310px; visibility: hidden; pointer-events: none;
}
body.iq-aside-collapsed .iq-station-grid.is-wide .iq-aside-head { display: none; }
body.iq-aside-collapsed .iq-station-grid.is-wide .iq-aside-rail {
  display: flex; flex-direction: column; align-items: center; gap: 12px; width: 40px; padding: 12px 0 16px;
  border: 1px solid var(--iq-border); border-radius: var(--iq-radius); background: var(--iq-surface); box-shadow: var(--iq-shadow-sm);
  color: var(--iq-brand); font: 600 12px/1 Inter, system-ui, sans-serif; cursor: pointer; transition: color .15s, border-color .15s, background-color .15s;
  animation: iq-aside-in .18s ease;
}
body.iq-aside-collapsed .iq-station-grid.is-wide .iq-aside-rail:hover { border-color: var(--iq-brand); background: var(--iq-brand-50); }
@keyframes iq-aside-in { from { opacity: 0; } to { opacity: 1; } }
.iq-aside-rail > :is(.fa, .fas, svg) { font-size: 12px; }
.iq-aside-rail-ico { font-size: 15px; color: var(--iq-muted); }
.iq-aside-rail-txt { writing-mode: vertical-rl; letter-spacing: .02em; white-space: nowrap; color: var(--iq-ink-2); }
/* folding and unfolding: the cards slide and fade (cheap to draw); the layout changes once, so the plots are redrawn once */
.iq-station-grid.is-wide .iq-station-side > :is(.card, .iq-aside-head) { transition: transform .22s ease, opacity .22s ease; }
body:is(.iq-aside-closing, .iq-aside-opening) .iq-station-grid.is-wide .iq-station-side > :is(.card, .iq-aside-head) { transform: translateX(44px); opacity: 0; }
body.iq-aside-closing .iq-station-grid.is-wide .iq-station-side, body.iq-aside-opening .iq-station-grid.is-wide .iq-station-side { overflow: hidden; }
body.iq-aside-opening .iq-station-grid.is-wide .iq-station-side > :is(.card, .iq-aside-head) { transition: none; }   /* start position, set at once */
@media (prefers-reduced-motion: reduce) { .iq-station-grid.is-wide .iq-station-side > :is(.card, .iq-aside-head) { transition: none; } }

/* Where the slider is wide enough (.is-roomy, set by www/isoqc.js), the station record sits between From and To,
   which leaves its line to the panels */
@media (min-width: 1500px) { body:not(.iq-ts-detailed) { --iq-band: clamp(180px, calc((100dvh - 500px) / 3), 203px); } }
.iq-ts-fig > .iq-period-row.is-roomy .iq-period-slider { position: relative; }
.iq-ts-fig > .iq-period-row.is-roomy #date_bounds_note { position: absolute; top: -32px; left: 50%; transform: translateX(-50%); white-space: nowrap; }

/* Usage statistics switch on the Guide page (www/isoqc.js, section 2) */
.instructions-content [data-iq-count] { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 10px 0 14px; padding: 10px 14px;
  border: 1px solid var(--iq-border); border-radius: 10px; background: var(--iq-surface-2, transparent); }
.instructions-content [data-iq-count] .iq-switch[disabled] { opacity: .55; cursor: not-allowed; }
.iq-count-note { font-size: 12.5px; color: var(--iq-muted); }
