/* ============================================================
   Data Explorer (/data) — standalone dashboard shell.
   Own tokens (style.css is NOT loaded here), light + dark
   themes via html[data-theme], a fixed sidebar and a card grid
   on a soft grey ground. Spacing rhythm: --gap between cards,
   --pad inside them, nothing else improvised.
   ============================================================ */
:root{
    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f6f8fc;
    --line: #e5e8f0;
    --ink: #0f1222;
    --muted: #6b7186;
    --blue: #006eff;
    --blue-strong: #0058d6;
    --blue-soft: #e8f0ff;
    --green: #12b76a;
    --up-solid: #067647;
    --up-soft: #e6f7ee;
    --down-solid: #d92d20;
    --down-soft: #fdecec;
    --navy: #0b1530;
    --shadow: 0 1px 2px rgb(15 18 34 / .04), 0 8px 24px rgb(15 18 34 / .05);
    --shadow-lg: 0 20px 50px rgb(15 18 34 / .16);
    --radius: 16px;
    --radius-sm: 10px;
    --sidebar: 248px;
    --gap: 20px;
    --pad: 22px;
    --topbar: 64px;
    color-scheme: light;
}
html[data-theme="dark"]{
    --bg: #0f121b;
    --surface: #171b27;
    --surface-2: #1e2333;
    --line: #29304a;
    --ink: #eef0f7;
    --muted: #9aa2ba;
    --blue: #3d8dff;
    --blue-strong: #5f9fff;
    --blue-soft: rgba(61, 141, 255, .16);
    --up-solid: #4ade80;
    --up-soft: rgba(74, 222, 128, .14);
    --down-solid: #f87171;
    --down-soft: rgba(248, 113, 113, .14);
    --navy: #0a0e1a;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    --shadow-lg: 0 20px 50px rgb(0 0 0 / .45);
    color-scheme: dark;
}

*{ box-sizing: border-box; margin: 0; }
html, body{ height: 100%; }
body{
    background: var(--bg);
    color: var(--ink);
    font-family: "Lato", sans-serif;
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    transition: background .2s ease, color .2s ease;
}
a{ color: inherit; }
button, input, select{ font: inherit; color: inherit; }
[hidden]{ display: none !important; }
svg{ display: block; }
h1, h2, h3, h4{ font-weight: 600; line-height: 1.2; }

/* --------------------------------------------------------------- shell -- */
.db{
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    min-height: 100vh;
}

/* ------------------------------------------------------------- sidebar -- */
.db-side{
    position: sticky; top: 0;
    height: 100vh;
    display: flex; flex-direction: column;
    padding: 24px 18px 20px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    z-index: 30;
}
.db-brand{
    display: flex; align-items: center; gap: 12px;
    padding: 2px 8px 22px;
    text-decoration: none;
}
.db-brand img{ height: 40px; width: auto; }
.db-brand-rule{ width: 2px; height: 32px; background: #ffcc00; border-radius: 2px; }
.db-brand-text{ display: flex; flex-direction: column; line-height: 1.15; }
.db-brand-text b{ font-size: 1.05rem; font-weight: 700; letter-spacing: .02em; }
.db-brand-text span{ font-size: .74rem; color: var(--muted); }

.db-nav{ display: flex; flex-direction: column; gap: 4px; }
.db-nav-title{
    padding: 14px 10px 6px;
    font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
    color: var(--muted);
}
.db-nav a, .db-nav button{
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 9px 12px;
    border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--ink);
    font-size: .92rem; font-weight: 500; text-align: left; text-decoration: none;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}
.db-nav a svg, .db-nav button svg{ width: 18px; height: 18px; flex: 0 0 auto; color: var(--muted); }
.db-nav a:hover, .db-nav button:hover{ background: var(--surface-2); }
.db-nav .is-active{ background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.db-nav .is-active svg{ color: var(--blue); }
.db-nav-count{ margin-left: auto; font-size: .72rem; color: var(--muted); font-weight: 500; }
.db-nav-sep{ height: 1px; background: var(--line); margin: 14px 4px; }

/* dataset groups: a header that toggles its list */
.db-group summary{
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    font-size: .92rem; font-weight: 500;
}
.db-group summary::-webkit-details-marker{ display: none; }
.db-group summary:hover{ background: var(--surface-2); }
.db-group summary svg{ width: 18px; height: 18px; color: var(--muted); }
.db-group summary .db-caret{ margin-left: auto; width: 14px; height: 14px; transition: transform .15s ease; }
.db-group[open] summary .db-caret{ transform: rotate(180deg); }
.db-group-list{ display: flex; flex-direction: column; gap: 2px; padding: 2px 0 6px 12px; }
.db-group-list a{
    padding: 7px 10px 7px 18px; font-size: .84rem; font-weight: 400;
    color: var(--muted); position: relative;
}
.db-group-list a::before{
    content: ""; position: absolute; left: 6px; top: 50%;
    width: 5px; height: 5px; border-radius: 50%; background: var(--line);
    transform: translateY(-50%);
}
.db-group-list a:hover{ color: var(--ink); }
.db-group-list a.is-active{ color: var(--blue); background: var(--blue-soft); }
.db-group-list a.is-active::before{ background: var(--blue); }

.db-side-foot{ margin-top: auto; padding-top: 18px; }
.db-help{
    padding: 16px 16px 14px; border-radius: var(--radius);
    background: var(--blue-soft);
}
.db-help b{ display: block; font-size: .9rem; margin-bottom: 4px; }
.db-help p{ font-size: .8rem; color: var(--muted); line-height: 1.45; }
.db-help a{
    display: inline-flex; align-items: center; justify-content: center;
    margin-top: 12px; padding: 8px 16px; border-radius: 999px;
    background: var(--blue); color: #fff; font-size: .82rem; font-weight: 600; text-decoration: none;
}
.db-help a:hover{ background: var(--blue-strong); }

/* ---------------------------------------------------------------- main -- */
.db-main{
    min-width: 0;
    padding: 20px 28px 36px;
    display: flex; flex-direction: column; gap: var(--gap);
}

.db-top{
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    min-height: var(--topbar);
}
.db-top-left{ display: flex; align-items: center; gap: 14px; min-width: 0; }
.db-top h1{ font-size: 1.55rem; letter-spacing: -.01em; white-space: nowrap; }
.db-facts{ display: flex; gap: 8px; flex-wrap: wrap; }
.db-fact{
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 11px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--line);
    font-size: .78rem; color: var(--muted); white-space: nowrap;
}
.db-fact b{ color: var(--ink); font-weight: 600; }
.db-top-right{ display: flex; align-items: center; gap: 12px; }

.db-menu-btn{
    display: none; width: 40px; height: 40px; border-radius: var(--radius-sm);
    border: 1px solid var(--line); background: var(--surface); cursor: pointer;
    place-items: center;
}
.db-menu-btn svg{ width: 20px; height: 20px; }

/* theme switch: sun · pill · moon, as in the reference */
.db-theme{
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 10px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--line);
    cursor: pointer; user-select: none;
}
.db-theme svg{ width: 16px; height: 16px; color: var(--muted); }
.db-theme input{ position: absolute; opacity: 0; width: 0; height: 0; }
.db-theme-track{
    position: relative; width: 36px; height: 20px; border-radius: 999px;
    background: var(--blue); transition: background .15s ease;
}
.db-theme-track::after{
    content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px;
    border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3);
    transition: transform .15s ease;
}
.db-theme input:checked + .db-theme-track::after{ transform: translateX(16px); }
.db-theme input:focus-visible + .db-theme-track{ box-shadow: 0 0 0 3px var(--blue-soft); }
.db-theme .db-sun{ color: #f79009; }
html[data-theme="dark"] .db-theme .db-sun{ color: var(--muted); }
html[data-theme="dark"] .db-theme .db-moon{ color: #7cc4ff; }

.db-lang{ display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.db-lang a{ display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; }
.db-lang a img{ width: 18px; height: 13px; border-radius: 2px; object-fit: cover; }
.db-lang a.is-active{ background: var(--blue-soft); }

.db-site{
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface);
    font-size: .86rem; font-weight: 600; text-decoration: none;
}
.db-site svg{ width: 16px; height: 16px; }
.db-site:hover{ border-color: var(--blue); color: var(--blue); }

/* ---------------------------------------------------------------- cards -- */
.card{
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: background .2s ease, border-color .2s ease;
}

/* KPI row */
.db-kpis{
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: var(--gap);
}
.kpi{
    display: flex; flex-direction: column; gap: 6px;
    padding: 18px 20px 14px;
    text-decoration: none;
    transition: transform .15s ease, border-color .15s ease, background .2s ease;
}
.kpi:hover{ transform: translateY(-2px); border-color: var(--blue); }
.kpi-head{ display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label{ font-size: .82rem; font-weight: 500; color: var(--muted); }
.kpi-ico{
    width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto;
    display: grid; place-items: center;
    background: var(--blue-soft); color: var(--blue);
}
.kpi-ico svg{ width: 17px; height: 17px; }
.kpi-value{ font-size: 1.75rem; font-weight: 600; line-height: 1.05; letter-spacing: -.01em; }
.kpi-meta{ display: flex; align-items: center; gap: 8px; font-size: .76rem; color: var(--muted); }
.kpi-delta{ display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 999px; font-weight: 600; font-size: .72rem; }
.kpi-delta.is-up{ background: var(--up-soft); color: var(--up-solid); }
.kpi-delta.is-down{ background: var(--down-soft); color: var(--down-solid); }
.xp-spark{ width: 100%; height: 34px; margin-top: 4px; }
.xp-spark path.line{ fill: none; stroke: var(--blue); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.xp-spark circle{ fill: var(--blue); }

/* ------------------------------------------------------------ workbench -- */
.xp-work{
    display: flex;
    flex-direction: column;    /* the builder sits above the results */
    gap: var(--gap);
}
.xp-side{ flex: 0 0 auto; }
.xp-panel{ padding: var(--pad); }
.xp-panel-head{ display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.xp-panel h2{ font-size: 1.1rem; }

.xp-link{ background: none; border: 0; padding: 0; cursor: pointer; font-size: .84rem; font-weight: 600; color: var(--blue); }
.xp-link:hover{ text-decoration: underline; }

.xp-step{ position: relative; padding: 16px 0 16px 34px; border-top: 1px solid var(--line); }
.xp-step:first-of-type{ border-top: 0; padding-top: 10px; }
.xp-step:first-of-type .xp-step-n{ top: 10px; }
.xp-step-n{
    position: absolute; left: 0; top: 16px;
    width: 24px; height: 24px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--blue-soft); color: var(--blue);
    font-size: .76rem; font-weight: 700;
}
/* line-height matches the 24px step badge so the two share a centre line */
.xp-step-label{ display: block; font-weight: 600; font-size: .94rem; line-height: 24px; margin-bottom: 12px; }

.xp-select{
    width: 100%;
    padding: 9px 34px 9px 12px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface-2) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7186' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>") no-repeat right 11px center / 15px;
    appearance: none; -webkit-appearance: none;
    font-size: .9rem; color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.xp-select:focus{ outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.xp-select-sm{ padding: 7px 28px 7px 10px; font-size: .83rem; }
.xp-row{ display: flex; gap: 8px; flex-wrap: wrap; }
.xp-row > *{ flex: 1 1 100px; }

/* the builder spans the page, so the filters flow into columns */
.xp-filters{ display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px 20px; align-items: start; }
/* from / to dropdowns keep room for "2026Q2" next to the arrow */
.xp-filter[data-kind="range"] .xp-select{ min-width: 0; }
.xp-filters > select{ grid-column: 1 / -1; justify-self: start; width: auto; min-width: 230px; max-width: 100%; }
.xp-filter{ display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.xp-filter-label{ font-size: .79rem; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 20px; }
.xp-filter-label b{ font-weight: 600; color: var(--blue); font-size: .72rem; }
.xp-filter input{
    width: 100%; min-width: 0;
    padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    font-size: .84rem; background: var(--surface-2); color: var(--ink);
}
.xp-filter input:focus{ outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.xp-multi{ max-height: 150px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px; background: var(--surface-2); }
.xp-multi label{ display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; font-size: .81rem; cursor: pointer; }
.xp-multi label:hover{ background: var(--blue-soft); }
.xp-multi input{ accent-color: var(--blue); margin: 0; width: auto; }
.xp-multi-tools{ display: flex; gap: 12px; padding-left: 2px; font-size: .75rem; }
.xp-multi-tools button{ background: none; border: 0; padding: 0; color: var(--blue); font-weight: 600; cursor: pointer; }

.xp-actions{ padding-top: 16px; border-top: 1px solid var(--line); }

.xp-btn{
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border-radius: 999px;
    border: 1px solid transparent; cursor: pointer;
    font-size: .9rem; font-weight: 600; line-height: 1;
    transition: transform .12s ease, opacity .12s ease, background .12s ease, border-color .12s ease, color .12s ease;
}
.xp-btn svg{ width: 16px; height: 16px; }
.xp-btn:disabled{ opacity: .45; cursor: not-allowed; }
.xp-btn-primary{ width: 100%; background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 8px 20px rgba(0,110,255,.25); }
.xp-btn-primary:not(:disabled):hover{ background: var(--blue-strong); transform: translateY(-1px); }
.xp-btn-ghost{ background: var(--surface); border-color: var(--line); color: var(--ink); }
.xp-btn-ghost:not(:disabled):hover{ border-color: var(--blue); color: var(--blue); }
.xp-btn-sm{ padding: 7px 14px; font-size: .8rem; }

/* result card */
.xp-result{ flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; padding: var(--pad); position: relative; min-height: 560px; }
.xp-result-head{ display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.xp-result-title h2{ font-size: 1.25rem; }
.xp-result-meta{ margin-top: 3px; font-size: .84rem; color: var(--muted); }
.xp-result-tools{ display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.xp-tabs{ display: inline-flex; padding: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.xp-tab{ padding: 6px 15px; border: 0; border-radius: 999px; background: transparent; font-size: .84rem; font-weight: 600; color: var(--muted); cursor: pointer; transition: background .12s ease, color .12s ease; }
.xp-tab.is-active{ background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.xp-export{ position: relative; }
.xp-menu{
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
    list-style: none; margin: 0; padding: 6px;
    min-width: 230px; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
}
.xp-menu button{ display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: none; font-size: .86rem; text-align: left; cursor: pointer; }
.xp-menu button:hover{ background: var(--blue-soft); }
.xp-menu-ico{ flex: 0 0 auto; min-width: 42px; padding: 3px 6px; border-radius: 6px; background: var(--blue-soft); color: var(--blue); font-size: .66rem; font-weight: 700; letter-spacing: .04em; text-align: center; }

.xp-alert{ margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--down-soft); border: 1px solid var(--down-solid); color: var(--down-solid); font-size: .86rem; }

.xp-empty{ flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 80px 20px 70px; color: var(--muted); }
.xp-empty svg{ width: 68px; height: 68px; color: var(--blue); opacity: .85; }
.xp-empty h3{ margin-top: 16px; font-size: 1.05rem; color: var(--ink); }
.xp-empty p{ margin-top: 6px; max-width: 34rem; line-height: 1.55; font-size: .9rem; }
.xp-empty-quick{ display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; margin-top: 22px; font-size: .82rem; }
.xp-pill{ padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--ink); transition: border-color .12s ease, color .12s ease, background .12s ease; }
.xp-pill:hover{ border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }

.xp-view{ flex: 1; display: flex; flex-direction: column; min-height: 0; margin-top: 18px; }
.xp-chartbar{ display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.xp-seg{ display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.xp-seg button{ width: 38px; height: 34px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.xp-seg button + button{ border-left: 1px solid var(--line); }
.xp-seg button svg{ width: 18px; height: 18px; }
.xp-seg button.is-active{ background: var(--blue-soft); color: var(--blue); }
.xp-inline{ display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); }
.xp-inline .xp-select{ width: auto; min-width: 140px; }
/* sized by the card, never by the drawn chart, so it cannot outgrow the builder;
   ApexCharts writes its own inline min-height (height + 15px) on render, hence !important */
.xp-chart{ flex: 1 1 0; min-height: 460px !important; contain: size; }
.xp-note{ font-size: .79rem; color: var(--muted); margin-top: 8px; line-height: 1.45; }

.xp-tablewrap{ overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 60vh; }
.xp-table{ width: 100%; border-collapse: separate; border-spacing: 0; font-size: .86rem; }
.xp-table th, .xp-table td{ padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.xp-table th{ position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-weight: 600; font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); cursor: pointer; user-select: none; }
.xp-table th.is-num, .xp-table td.is-num{ text-align: right; font-variant-numeric: tabular-nums; }
.xp-table th[data-dir]::after{ content: " ↑"; color: var(--blue); }
.xp-table th[data-dir="desc"]::after{ content: " ↓"; }
.xp-table tbody tr:hover td{ background: var(--blue-soft); }
.xp-table tbody tr:last-child td{ border-bottom: 0; }
.xp-pager{ display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; font-size: .82rem; color: var(--muted); }
.xp-pager-ctl{ display: flex; gap: 8px; align-items: center; }
.xp-pager-ctl .xp-select{ width: auto; }

.xp-query-grid{ display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--gap); }
.xp-query-block h4{ font-size: .74rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.xp-summary{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.xp-summary li{ display: grid; grid-template-columns: 110px 1fr; gap: 10px; font-size: .86rem; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.xp-summary li span:first-child{ color: var(--muted); font-weight: 600; }
.xp-sql{ margin: 0; padding: 16px 18px; border-radius: var(--radius-sm); background: var(--navy); color: #dbe7ff; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .79rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; overflow: auto; max-height: 420px; }
.xp-sql .kw{ color: #7cc4ff; font-weight: 700; }
.xp-sql .str{ color: #a5f3b5; }
.xp-sql .num{ color: #ffd479; }

.xp-loading{ position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; gap: 12px; background: color-mix(in srgb, var(--surface) 72%, transparent); backdrop-filter: blur(2px); border-radius: var(--radius); font-weight: 600; color: var(--blue); }
.xp-spinner{ width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--blue-soft); border-top-color: var(--blue); animation: xp-spin .8s linear infinite; }
@keyframes xp-spin{ to{ transform: rotate(360deg); } }

/* ------------------------------------------------------------- catalog -- */
.db-catalog{ padding: var(--pad); }
.db-catalog-head{ display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.db-catalog-head h2{ font-size: 1.1rem; }
.db-catalog-head span{ font-size: .82rem; color: var(--muted); }
.db-catalog .xp-tablewrap{ max-height: 420px; }
.db-catalog .xp-table th{ cursor: default; }
.db-topic{ display: inline-flex; padding: 3px 9px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: .74rem; font-weight: 600; }
.db-open{ padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .78rem; font-weight: 600; cursor: pointer; }
.db-open:hover{ border-color: var(--blue); color: var(--blue); }

/* inflation page: the 12 COICOP divisions, each opening onto its groups */
.cpi-map .db-catalog-head{ align-items: flex-start; }
.cpi-divs{ display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; align-items: start; }
.cpi-div{ border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.cpi-div[open]{ background: var(--surface); border-color: var(--blue); }
.cpi-div summary{ display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; list-style: none; font-size: .86rem; }
.cpi-div summary::-webkit-details-marker{ display: none; }
.cpi-div summary:hover{ color: var(--blue); }
.cpi-code{ flex: 0 0 auto; min-width: 30px; font-size: .7rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.cpi-name{ flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the year-on-year change leads; the index level sits beside it, quieter */
.cpi-yoy{ flex: 0 0 auto; min-width: 58px; text-align: right; font-size: .98rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cpi-yoy.is-bad{ color: var(--down-solid); }
.cpi-yoy.is-good{ color: var(--up-solid); }
.cpi-val{ flex: 0 0 auto; min-width: 40px; text-align: right; font-size: .76rem; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.cpi-div .kpi-delta{ flex: 0 0 auto; }
.cpi-n{ flex: 0 0 auto; font-size: .72rem; color: var(--muted); white-space: nowrap; }
.cpi-caret{ flex: 0 0 auto; width: 14px; height: 14px; color: var(--muted); transition: transform .15s ease; }
.cpi-div[open] .cpi-caret{ transform: rotate(180deg); }
.cpi-groups{ display: flex; flex-direction: column; gap: 2px; padding: 6px 8px 10px; border-top: 1px solid var(--line); }
.cpi-row{
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 7px 8px; border: 0; border-radius: 8px; background: none;
    text-align: left; font: inherit; font-size: .82rem; color: inherit; cursor: pointer;
}
.cpi-row:hover{ background: var(--blue-soft); color: var(--blue); }
.cpi-row .cpi-name{ font-weight: 500; }
.cpi-row.is-all .cpi-name{ font-weight: 600; color: var(--blue); }

.db-foot{ font-size: .8rem; color: var(--muted); text-align: right; }
.db-foot a{ color: var(--blue); font-weight: 600; }

/* ---------------------------------------------------------- breakpoints -- */

/* ------------------------------------------------------------- overview -- */
.db-sec-head{ display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 4px; }
.db-sec-head h2{ font-size: 1.25rem; letter-spacing: -.01em; }
.db-sec-head p{ margin-top: 3px; font-size: .86rem; color: var(--muted); max-width: 70ch; }
.ov{ display: flex; flex-direction: column; gap: var(--gap); }
.db-kpis{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi{ gap: 8px; padding: 18px 20px 16px; }
.kpi-row{ display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kpi-value{ font-size: 1.9rem; }
.kpi-delta svg{ width: 12px; height: 12px; }
.kpi-delta.is-good{ background: var(--up-soft); color: var(--up-solid); }
.kpi-delta.is-bad{ background: var(--down-soft); color: var(--down-solid); }

.ov-grid{ display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-flow: row dense; gap: var(--gap); }
.ov-card{ display: flex; flex-direction: column; gap: 14px; padding: var(--pad); min-width: 0; }
.ov-wide, .ov-hero{ grid-column: span 2; }
.ov-card-head{ display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ov-card-head h3{ font-size: 1rem; }
.ov-sub{ display: block; margin-top: 2px; font-size: .8rem; color: var(--muted); }
.ov-more{
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 12px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface);
    font-size: .78rem; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap;
    transition: border-color .12s ease, color .12s ease;
}
.ov-more:hover{ border-color: var(--blue); color: var(--blue); }

.ov-hero-body{ display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 18px; align-items: center; }
.ov-hero-stat{ display: flex; flex-direction: column; gap: 4px; }
.ov-big{ font-size: 2.5rem; font-weight: 600; line-height: 1; letter-spacing: -.02em; }
.ov-big-sub{ font-size: .86rem; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.ov-note{ font-size: .8rem; color: var(--muted); }
.ov-note b{ color: var(--ink); font-weight: 600; }
.ov-note small{ font-size: .74rem; }
.ov-note b.is-up{ color: var(--down-solid); }     /* prices up: flagged, not celebrated */
.ov-note b.is-down{ color: var(--up-solid); }

/* inflation: the 12 COICOP divisions under the headline line */
.ov-cpi .ov-card-head h3{ font-size: 1.15rem; }
.ov-divs{ display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.ov-div{
    display: flex; align-items: center; gap: 8px; min-width: 0;
    padding: 5px 6px; margin: 0 -6px; border-radius: 8px;
    color: inherit; text-decoration: none; font-size: .8rem;
    transition: background .12s ease;
}
.ov-div:hover{ background: var(--surface-2); }
.ov-div-code{ flex: 0 0 auto; font-size: .68rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.ov-div-name{ flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-div .kpi-delta, .ov-div-value{ flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.ov-div-value{ font-size: .78rem; font-weight: 600; }
.ov-divs-cap{ font-size: .76rem; color: var(--muted); margin-top: -6px; }
.ov-chart{ min-height: 250px; }
.ov-chart-sm{ min-height: 190px; }
.ov-gauge{ min-height: 200px; margin: -8px 0 -30px; }
.ov-gauge-cap{ text-align: center; font-size: .8rem; color: var(--muted); padding: 0 12px; }
.ov-foot{ display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.ov-foot b{ color: var(--ink); font-weight: 600; }

.ov-segs{ display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.ov-seg{ display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ov-seg-bar{ display: block; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.ov-seg-bar i{ display: block; height: 100%; border-radius: 999px; background: var(--seg); }
.ov-seg-value{ font-size: 1.35rem; font-weight: 600; line-height: 1.1; }
.ov-seg-label{ font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ov-rates{ display: flex; gap: 22px; justify-content: center; padding-top: 4px; border-top: 1px solid var(--line); }
.ov-rates span{ display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 10px; }
.ov-rates em{ font-style: normal; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ov-rates b{ font-size: 1.1rem; font-weight: 600; }

.ov-tablewrap{ overflow-x: auto; }
.ov-table{ width: 100%; border-collapse: collapse; font-size: .86rem; }
.ov-table th{ padding: 4px 10px 10px; text-align: left; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
.ov-table td{ padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.ov-table tr:last-child td{ border-bottom: 0; }
.ov-table .is-num{ text-align: right; font-variant-numeric: tabular-nums; }
.ov-rank{ color: var(--muted); width: 32px; }
.ov-country{ font-weight: 600; }
.ov-region{ display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); font-size: .76rem; font-weight: 600; }
.ov-region::before{ content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--seg); }
.ov-share{ display: inline-block; width: 56px; height: 5px; margin-right: 8px; border-radius: 999px; background: var(--surface-2); vertical-align: middle; overflow: hidden; }
.ov-share i{ display: block; height: 100%; background: var(--blue); border-radius: 999px; }

.ov-census-stat{ display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
/* who lives here: a breakdown's largest group, the tile linking to its dataset */
.ov-seg-link{ text-decoration: none; color: inherit; padding: 4px; margin: -4px; border-radius: 10px; transition: background .15s ease; }
.ov-seg-link:hover{ background: var(--surface-2); }
.ov-seg-group{ font-size: .86rem; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* age structure: under 15 / working age / 65+ as one strip */
.ov-strip{ display: flex; gap: 2px; height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.ov-strip i{ display: block; height: 100%; }
.ov-strip .is-young, .ov-strip-legend .is-young{ --seg: #f5a623; }
.ov-strip .is-work, .ov-strip-legend .is-work{ --seg: var(--blue); }
.ov-strip .is-old, .ov-strip-legend .is-old{ --seg: #6a4bd0; }
.ov-strip i{ background: var(--seg); }
.ov-strip-legend{ justify-content: flex-start; gap: 16px; }
.ov-strip-legend b{ color: var(--seg); }
.ov-bars{ display: flex; align-items: flex-end; gap: 6px; height: 96px; margin-top: auto; padding-top: 10px; }
.ov-bar{ flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.ov-bar i{ display: block; width: 100%; min-height: 3px; border-radius: 5px 5px 2px 2px; background: var(--blue-soft); }
.ov-bar:last-child i{ background: var(--blue); }
.ov-bar span{ margin-top: 5px; font-size: .64rem; color: var(--muted); }

/* ---------------------------------------------------------- topic page -- */
.tp-head{ align-items: center; }
.tp-crumb{ display: block; margin-bottom: 4px; font-size: .76rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tp-crumb a{ text-decoration: none; color: var(--blue); }
.tp-crumb a:hover{ text-decoration: underline; }
.tp-head h2{ font-size: 1.5rem; }
.tp-tools{ display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tp-headline{
    display: flex; flex-direction: column; gap: 2px;
    padding: 10px 16px; border-radius: var(--radius-sm);
    background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.tp-headline-label{ font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.tp-headline-value{ font-size: 1.9rem; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.tp-headline-value.is-bad{ color: var(--down-solid); }
.tp-headline-value.is-good{ color: var(--up-solid); }
.tp-headline-sub{ font-size: .76rem; color: var(--muted); }
.db-open{ text-decoration: none; display: inline-block; }

@media (max-width: 1500px){
    .db-kpis{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1320px){
    .db-facts{ display: none; }
}
@media (max-width: 991px){
    .db{ grid-template-columns: 1fr; }
    .db-side{
        position: fixed; left: 0; top: 0; width: var(--sidebar);
        transform: translateX(-100%); transition: transform .2s ease;
        box-shadow: none;
    }
    .db.is-nav-open .db-side{ transform: none; box-shadow: var(--shadow-lg); }
    .db-backdrop{ position: fixed; inset: 0; z-index: 25; background: rgba(6, 12, 30, .45); }
    .db-menu-btn{ display: grid; }
    .db-main{ padding: 16px 18px 28px; }
    .xp-query-grid{ grid-template-columns: 1fr; }
}
@media (max-width: 767px){
    .db-kpis{ grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    /* an odd tile count: let the last one span the row instead of dangling */
    .db-kpis .kpi:last-child:nth-child(odd){ grid-column: 1 / -1; }
    .kpi-value{ font-size: 1.4rem; }
    .db-top h1{ font-size: 1.25rem; }
    .db-site span{ display: none; }
    .xp-result{ padding: 18px 16px 20px; }
    .xp-result-tools{ width: 100%; justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce){
    .kpi, .xp-btn, .db-side{ transition: none; }
    .xp-spinner{ animation-duration: 1.6s; }
}
@media (max-width: 1500px){
    .ov-hero-body{ grid-template-columns: 160px minmax(0, 1fr); }
    .ov-divs{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cpi-n{ display: none; }   /* room for the division name beside its change and index */
}
@media (max-width: 1199px){
    .ov-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px){
    .ov-grid{ grid-template-columns: 1fr; gap: 12px; }
    .ov-wide, .ov-hero{ grid-column: auto; }
    .ov-hero-body{ grid-template-columns: 1fr; }
    .ov-segs{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ov-divs{ grid-template-columns: 1fr; }
    .cpi-divs{ grid-template-columns: 1fr; }
    .cpi-n{ display: none; }
    .ov-card{ padding: 18px 16px; }
    .ov-big{ font-size: 2rem; }
    .db-sec-head h2{ font-size: 1.1rem; }
}
