/* ============================================================
   Paraview — sistema visual (heredado de Danna2)
   --brand / --accent los define cada empresa (colores corporativos).
   Las series de los gráficos (--s1…--s8) son una paleta categórica
   validada para daltonismo sobre estas superficies, en claro y oscuro.
   ============================================================ */

:root {
    --brand: #6366f1;
    --accent: #22d3ee;
    --radius: 14px;
    --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root,
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b0e14;
    --surface: #151a24;
    --surface-2: #1b2230;
    --surface-3: #232b3c;
    --border: rgba(255, 255, 255, .08);
    --border-strong: rgba(255, 255, 255, .16);
    --text: #f2f4f8;
    --text-2: #b9c0cf;
    --muted: #8a93a6;
    --grid: #262d3c;
    --axis: #3a4356;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --s-other: #5b6578;
    --good: #0ca30c; --warn: #fab219; --critical: #e66767;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f3f4f7;
    --surface: #ffffff;
    --surface-2: #f6f7f9;
    --surface-3: #ffffff;
    --border: rgba(11, 14, 20, .10);
    --border-strong: rgba(11, 14, 20, .20);
    --text: #0b0e14;
    --text-2: #474e5c;
    --muted: #747d8c;
    --grid: #e7e9ee;
    --axis: #c4c9d3;
    --shadow: 0 6px 20px rgba(20, 28, 45, .07);
    --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
    --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
    --s-other: #b3b9c5;
    --good: #006300; --warn: #9a6a00; --critical: #d03b3b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14.5px/1.45 var(--font);
    -webkit-font-smoothing: antialiased;
}

h1, h2, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.spacer { flex: 1; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Botones y controles ---------- */
.btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .5rem .85rem;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    font-weight: 600; font-size: .86rem;
    text-decoration: none; white-space: nowrap;
    cursor: pointer;
    transition: background .15s, border-color .15s, opacity .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-ghost[aria-pressed="true"] { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.btn-icon { padding: .5rem .6rem; }
.btn-sm { padding: .3rem .55rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; padding: .7rem; margin-top: 1.1rem; }
.btn:disabled { opacity: .4; cursor: default; }

.control {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: .45rem .6rem;
    min-height: 36px;
    width: 100%;
}
.control:hover { border-color: var(--border-strong); }
.control.is-active { border-color: var(--brand); }
.control-sm { min-height: 30px; padding: .25rem .45rem; font-size: .82rem; width: auto; max-width: 170px; }
textarea.control { resize: vertical; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .82rem; line-height: 1.5; }
.field-label { display: block; font-size: .76rem; color: var(--muted); margin: .7rem 0 .25rem; }
.link { display: inline-flex; gap: .4rem; align-items: center; font-size: .82rem; color: var(--text-2); }
.link:hover { color: var(--text); }
.linklike { background: none; border: 0; padding: 0; cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }

/* ---------- Marca ---------- */
.brand-mark { display: flex; align-items: center; gap: .6rem; }
.brand-mark strong { display: block; font-size: 1rem; line-height: 1.1; }
.brand-mark small { color: var(--muted); font-size: .7rem; }
.brand-logo {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    color: #fff; font-weight: 800; font-size: .85rem; letter-spacing: -.02em;
}

/* ---------- Barra superior ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: .75rem;
    height: 60px; padding: 0 1.1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.tenant { position: relative; margin-left: .75rem; }
.tenant-btn {
    display: flex; align-items: center; gap: .6rem;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
    padding: .35rem .7rem; cursor: pointer; text-align: left;
}
.tenant-btn > i:first-child { color: var(--accent); }
.tenant-btn strong, .menu-item strong { display: block; font-size: .86rem; line-height: 1.15; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tenant-btn small, .menu-item small { color: var(--muted); font-size: .7rem; }
.menu {
    position: absolute; top: calc(100% + 6px); left: 0; min-width: 270px;
    background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 12px;
    padding: .4rem; box-shadow: var(--shadow);
}
.menu-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .4rem .6rem; }
.menu-item {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%;
    background: none; border: 0; border-radius: 8px; padding: .5rem .6rem; cursor: pointer; text-align: left;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.current i { color: var(--accent); }
.user { display: flex; align-items: center; gap: .5rem; font-size: .86rem; color: var(--text-2); padding-left: .5rem; border-left: 1px solid var(--border); }
.user form { margin: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--border-strong); font-weight: 700; font-size: .8rem; color: var(--text); }

/* ---------- Estructura ---------- */
.layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: calc(100vh - 60px); }
.sources {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.1rem;
    position: sticky; top: 60px; align-self: start;
    height: calc(100vh - 60px); overflow-y: auto;
}
.sources section + section { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }
.sources h2 { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: .7rem; }
.dropzone {
    display: flex; flex-direction: column; align-items: center; gap: .25rem; text-align: center;
    padding: 1.2rem .8rem;
    border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
    background: var(--surface-2);
    cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone i { font-size: 1.6rem; color: var(--accent); margin-bottom: .3rem; }
.dropzone span { font-size: .78rem; color: var(--muted); }
.privacy { font-size: .76rem; color: var(--muted); margin: .65rem 0; display: flex; gap: .4rem; }
.privacy i { color: var(--good); margin-top: .15rem; }
.tenant-note { font-size: .8rem; color: var(--text-2); display: flex; gap: .45rem; align-items: center; }
.tenant-note i { color: var(--accent); }
#sourceSearch { margin-top: .6rem; }
.catalog { margin-top: .7rem; }
.catalog details { margin-bottom: .2rem; }
.catalog summary {
    display: flex; align-items: center; justify-content: space-between;
    padding: .45rem .5rem; border-radius: 8px;
    font-size: .8rem; font-weight: 700; color: var(--text-2);
    cursor: pointer; list-style: none;
}
.catalog summary::-webkit-details-marker { display: none; }
.catalog summary::before { content: "▸"; margin-right: .45rem; color: var(--muted); transition: transform .15s; }
.catalog details[open] > summary::before { transform: rotate(90deg); }
.catalog summary:hover { background: var(--surface-2); }
.count { margin-left: auto; font-weight: 500; font-size: .72rem; color: var(--muted); }
.source {
    display: flex; align-items: center; gap: .6rem; width: 100%;
    background: none; border: 0; border-radius: 8px;
    padding: .42rem .5rem .42rem 1.4rem;
    font-size: .84rem; color: var(--text-2); text-align: left; cursor: pointer;
}
.source i { width: 16px; text-align: center; color: var(--muted); font-size: .82rem; }
.source:hover { background: var(--surface-2); color: var(--text); }
.source.is-open { color: var(--text); }
.source.is-open i { color: var(--accent); }
.source.is-current { background: var(--surface-3); box-shadow: inset 2px 0 0 var(--brand); }

.main { padding: 1.1rem 1.4rem 3rem; min-width: 0; }

/* ---------- Pestañas ---------- */
.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab-wrap { display: flex; align-items: center; border-radius: 10px 10px 0 0; border: 1px solid transparent; border-bottom: 0; margin-bottom: -1px; }
.tab-wrap.is-active { background: var(--surface); border-color: var(--border); box-shadow: inset 0 2px 0 var(--brand); }
.tab { display: flex; align-items: center; gap: .5rem; background: none; border: 0; padding: .55rem .3rem .55rem .8rem; font-size: .85rem; font-weight: 600; color: var(--muted); cursor: pointer; max-width: 240px; }
.tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab.is-active { color: var(--text); }
.tab i { font-size: .78rem; }
.tab-close { background: none; border: 0; color: var(--muted); padding: .3rem .55rem; cursor: pointer; border-radius: 6px; }
.tab-close:hover { color: var(--text); background: var(--surface-2); }

/* ---------- Estado vacío ---------- */
.empty { max-width: 560px; margin: 9vh auto 0; text-align: center; }
.empty-art { width: 76px; height: 76px; margin: 0 auto 1.2rem; border-radius: 22px; display: grid; place-items: center; font-size: 2rem; color: #fff; background: linear-gradient(135deg, var(--brand), var(--accent)); }
.empty h1 { font-size: 1.7rem; letter-spacing: -.02em; margin-bottom: .5rem; }
.empty p { color: var(--text-2); }
.empty ul { margin-top: 1.6rem; display: grid; gap: .6rem; text-align: left; }
.empty li { display: flex; gap: .7rem; align-items: center; padding: .7rem .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: var(--text-2); font-size: .88rem; }
.empty li i { color: var(--accent); width: 18px; text-align: center; }

/* ---------- Tablero ---------- */
.dash { transition: opacity .15s; }
.dash.is-loading { opacity: .45; pointer-events: none; }
.dash-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.dash-head h1 { font-size: 1.45rem; letter-spacing: -.02em; }
.dash-sub { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; color: var(--muted); font-size: .82rem; margin-top: .35rem; }
.dash-actions { display: flex; gap: .45rem; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }
.badge-local i { color: var(--good); }
.badge-pq i { color: var(--accent); }
.badge-warn i { color: var(--warn); }

.filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem; }
.filter-row { display: flex; flex-wrap: wrap; gap: .7rem; align-items: flex-end; }
.filter { display: flex; flex-direction: column; gap: .25rem; min-width: 138px; flex: 0 1 172px; }
.filter > span { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filter-measure { margin-left: auto; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips:not(:empty) { margin-top: .7rem; padding-top: .7rem; border-top: 1px solid var(--border); }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .3rem .22rem .65rem; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); font-size: .78rem; }
.chip-label { color: var(--muted); }
.chip button { background: none; border: 0; cursor: pointer; color: var(--muted); padding: .1rem .35rem; border-radius: 50%; }
.chip button:hover { color: var(--text); }
.chip-clear { padding: .22rem .7rem; cursor: pointer; color: var(--text-2); background: none; }
.chip-clear:hover { color: var(--text); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.kpi {
    position: relative; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: linear-gradient(var(--brand), var(--accent)); }
.kpi-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 1.55rem; font-weight: 650; letter-spacing: -.02em; margin-top: .2rem; white-space: nowrap; }
.kpi-delta { display: flex; align-items: center; gap: .35rem; font-size: .76rem; color: var(--text-2); margin-top: .15rem; }
.spark { display: block; width: 100%; max-width: 120px; height: 24px; margin-top: .45rem; }
.spark polyline { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; opacity: .7; }
.spark circle { fill: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.span-1, .span-2, .span-3 { grid-column: span 12; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: .5rem .8rem; padding: 1rem 1.1rem .4rem; }
.card-head > div:first-child { flex: 1 1 180px; min-width: 0; }
.card-head h2 { font-size: .98rem; font-weight: 650; }
.card-sub { font-size: .76rem; color: var(--muted); margin-top: .15rem; }
.card-tools { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.card-body { padding: .5rem 1.1rem 1.1rem; flex: 1; min-height: 0; }
.card-foot { font-size: .74rem; color: var(--muted); margin-top: .5rem; }
.empty-note { color: var(--muted); font-size: .85rem; padding: 2rem 0; text-align: center; }
.chart-box { position: relative; }
.chart-ts { height: 280px; }

.donut-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.donut-chart { position: relative; width: 168px; height: 168px; flex: 0 0 168px; margin: 0 auto; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-center strong { font-size: 1.15rem; font-weight: 650; }
.donut-center span { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.legend { flex: 1 1 180px; min-width: 0; display: grid; gap: .1rem; }
.legend-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 48px; align-items: center; gap: .5rem; width: 100%; padding: .32rem .4rem; border: 0; border-radius: 7px; background: none; font-size: .82rem; text-align: left; }
button.legend-row { cursor: pointer; }
button.legend-row:hover { background: var(--surface-2); }
button.legend-row[aria-pressed="true"] { background: var(--surface-3); }
.legend-row.is-dim { opacity: .45; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.legend-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.legend-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.legend-share { color: var(--muted); font-size: .76rem; text-align: right; font-variant-numeric: tabular-nums; }

.map-box { height: 300px; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.map-schematic { display: grid; place-items: center; }
.map-svg { width: 100%; height: 100%; }
.map-point { cursor: pointer; }
.map-point:hover circle, .map-point:focus circle { fill-opacity: .95; }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.9) saturate(.55); }
.leaflet-container { background: var(--surface-2); font-family: var(--font); }
.leaflet-interactive:focus { outline: none; }

.insights { padding: .4rem 1.1rem 1.1rem; display: grid; gap: .5rem; }
.span-12 > .insights { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.insights li { display: flex; gap: .7rem; padding: .65rem .8rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; font-size: .86rem; color: var(--text-2); }
.insights li i { color: var(--accent); margin-top: .2rem; width: 16px; text-align: center; flex-shrink: 0; }
.insights strong { color: var(--text); font-weight: 650; }

.mini-table-wrap { max-height: 300px; overflow: auto; }
.mini-table, .data-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.mini-table th, .mini-table td, .data-table th, .data-table td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.mini-table th, .data-table th { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; position: sticky; top: 0; background: var(--surface); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.mini-table tr.is-selected td { background: var(--surface-3); }
.table-card .card-head { align-items: center; padding-bottom: .8rem; }
.table-card .card-head .control { max-width: 260px; }
.table-wrap { overflow-x: auto; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table tfoot td { font-weight: 650; border-top: 1px solid var(--border-strong); border-bottom: 0; }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--text); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; padding: .7rem 1.1rem; font-size: .8rem; color: var(--muted); }
.pager span { margin-right: auto; }

/* ---------- Superposición de arrastre, diálogos, avisos ---------- */
.drop-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: rgba(8, 10, 16, .78); backdrop-filter: blur(3px); pointer-events: none; }
.drop-overlay > div { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 2.4rem 3.2rem; border: 2px dashed var(--accent); border-radius: 24px; background: var(--surface); color: var(--text); }
.drop-overlay i { font-size: 2.6rem; color: var(--accent); }
.drop-overlay strong { font-size: 1.15rem; }
.drop-overlay span { color: var(--muted); font-size: .85rem; }

.dialog { border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; width: min(640px, calc(100vw - 2rem)); box-shadow: var(--shadow); }
.dialog-sm { width: min(400px, calc(100vw - 2rem)); }
.dialog::backdrop { background: rgba(8, 10, 16, .65); }
.dialog-body { padding: 1.3rem 1.4rem; }
.dialog h2 { font-size: 1.1rem; margin-bottom: .3rem; }
.dialog-actions { display: flex; align-items: center; gap: .5rem; margin-top: 1.1rem; flex-wrap: wrap; }
.color-row { display: flex; align-items: center; justify-content: space-between; margin-top: 1rem; font-size: .9rem; }
.color-row input { width: 56px; height: 36px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-2); cursor: pointer; }

.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 200; max-width: min(560px, calc(100vw - 2rem)); padding: .7rem 1.1rem; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: .86rem; }
.toast-error { border-color: var(--critical); }

/* ---------- Acceso ---------- */
.auth-body { display: grid; place-items: center; padding: 1rem; min-height: 100vh; background: radial-gradient(900px 500px at 20% 0%, rgba(99, 102, 241, .16), transparent 60%), radial-gradient(700px 500px at 100% 100%, rgba(34, 211, 238, .10), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 2rem; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.3rem; margin: 1.4rem 0 .3rem; }
.auth-card label { display: block; font-size: .8rem; color: var(--muted); margin: 1rem 0 .3rem; }
.auth-card input[type="text"], .auth-card input[type="password"] { width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .65rem .8rem; }
.alert { margin-top: 1rem; padding: .7rem .9rem; border-radius: 10px; border: 1px solid var(--critical); background: rgba(230, 103, 103, .1); font-size: .86rem; }
.company-list { display: grid; gap: .5rem; margin-top: 1.2rem; }
.company-list form { margin: 0; }
.company-option { display: flex; align-items: center; gap: .8rem; width: 100%; padding: .8rem .9rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; text-align: left; cursor: pointer; }
.company-option:hover { border-color: var(--accent); }
.company-option span { flex: 1; }
.company-option strong { display: block; }
.company-option small, .company-option i { color: var(--muted); }
.company-option i:first-child { color: var(--accent); }
.auth-foot { margin-top: 1.2rem; text-align: center; }

/* ---------- Login con imagen de marca ----------
   El rótulo "ParaMetric" ocupa en la imagen del 18 % al 52 % del alto y del 10 % al 89 %
   del ancho. El formulario se ancla abajo y es bajo (campos en una fila) para no taparlo. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.login-body {
    min-height: 100vh;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    padding: 1rem 1rem 0;
    background:
        linear-gradient(to bottom, transparent 55%, rgba(7, 9, 13, .82) 100%),
        #07090d url('../img/login-bg.webp') center 30% / cover no-repeat;
}
.login-card {
    width: min(780px, 100%);
    background: rgba(13, 17, 25, .74);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 18px;
    padding: 1.1rem 1.3rem 1.25rem;
    box-shadow: var(--shadow);
}
.login-intro { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.login-intro h2 { font-size: 1.1rem; }
.login-intro p { font-size: .82rem; }
.login-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: .8rem; align-items: end; }
.login-form label { display: block; font-size: .76rem; color: var(--text-2); margin-bottom: .3rem; }
.login-form input[type="text"], .login-form input[type="password"] {
    width: 100%; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 10px; padding: .6rem .8rem;
}
.login-form .btn { padding: .65rem 1.6rem; justify-content: center; }
.login-card .alert { margin: 0 0 .8rem; }
.login-by { margin: .9rem 0 1rem; font-size: .74rem; letter-spacing: .14em; color: rgba(255, 255, 255, .62); }

/* Pantallas más altas que anchas: "cover" recortaría el rótulo por los lados, así que la
   imagen se ajusta al ancho arriba y se funde con el fondo. */
@media (max-aspect-ratio: 16/10) {
    .login-body {
        background:
            linear-gradient(to bottom, transparent calc(100vw * .40), #07090d calc(100vw * .557)),
            #07090d url('../img/login-bg.webp') top center / 100% auto no-repeat;
    }
}
@media (max-width: 640px) {
    .login-form { grid-template-columns: 1fr; }
    .login-body { justify-content: flex-start; padding-top: calc(100vw * .56); }
}

/* ---------- Adaptable ---------- */
@media (max-width: 1100px) {
    .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
}
@media (max-width: 860px) {
    .layout { grid-template-columns: 1fr; }
    .sources { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
    .hide-sm { display: none; }
    .main { padding: 1rem; }
    .filter-measure { margin-left: 0; }
}

/* ---------- Impresión / PDF ---------- */
@media print {
    .topbar, .sources, .tabs, .dash-actions, .card-tools, .pager button, .table-card .control, .chip button, .chip-clear, .toast, .drop-overlay { display: none !important; }
    body { background: #fff; }
    .layout { display: block; }
    .main { padding: 0; }
    .card, .kpi, .filters { box-shadow: none; break-inside: avoid; }
    .filter-row { display: none; }
    .filters:has(.chips:empty) { display: none; }
    .chips:not(:empty) { margin: 0; padding: 0; border: 0; }
}

/* ---------- Paraview: pronóstico ---------- */
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inline-fields { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: .4rem; }
.sources .control { width: 100%; }
.sources button.source { width: 100%; background: none; border: 0; cursor: pointer; text-align: left; }
.warn-text { color: var(--warn); font-weight: 600; }
.data-table tr.is-selected td { background: var(--surface-3); }
.data-table small { font-size: .74rem; }

.pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .74rem; border: 1px solid var(--border-strong); color: var(--text-2); white-space: nowrap; }
.pill-alta, .pill-fijo, .pill-ok { border-color: var(--good); color: var(--text); }
.pill-intermitente, .pill-ocasional, .pill-nuevo, .pill-corto, .pill-warn { border-color: var(--warn); color: var(--text); }
.pill-bad { border-color: var(--critical); color: var(--text); }
.pill-inactivo, .pill-vacio { opacity: .6; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.fact { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .55rem .75rem; min-width: 0; }
.fact span { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.fact strong { display: block; font-size: .9rem; margin-top: .15rem; overflow-wrap: anywhere; }

.season { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .3rem; }
.season-cell { text-align: center; padding: .4rem .1rem; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.season-cell span { display: block; font-size: .68rem; text-transform: uppercase; color: var(--muted); }
.season-cell strong { font-size: .84rem; font-variant-numeric: tabular-nums; }
.season-cell.is-up { border-color: var(--good); }
.season-cell.is-down { border-color: var(--critical); }
.season + .card-foot, .params { margin-bottom: 1rem; }

.params { display: flex; flex-wrap: wrap; gap: .7rem; align-items: flex-end; padding: .8rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.params .filter { flex: 0 1 170px; }
.params .card-foot { flex: 1 1 100%; margin-top: 0; }

@media (max-width: 860px) {
    .season { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
.kpis { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }
.kpi-value { font-size: 1.35rem; white-space: normal; overflow-wrap: anywhere; }

/* ---------- Login: ver la contraseña ---------- */
.password-field { position: relative; }
.auth-card .password-field input { padding-right: 2.8rem; }
.password-toggle { position: absolute; top: 0; right: 0; height: 100%; width: 2.8rem; display: grid; place-items: center; background: none; border: 0; border-radius: 0 10px 10px 0; color: var(--muted); cursor: pointer; }
.password-toggle:hover, .password-toggle[aria-pressed="true"] { color: var(--text); }
.password-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- Grupos de ventas (clusterización) ---------- */
.clusters { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .7rem; }
.cluster { display: flex; flex-direction: column; gap: .3rem; text-align: left; padding: .8rem .9rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.cluster:hover { border-color: var(--border-strong); }
.cluster.is-current { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.bars, .bars-axis { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3px; }
.bars { height: 46px; align-items: end; margin-top: .3rem; }
.bars i { display: block; background: var(--s-other); border-radius: 2px 2px 0 0; min-height: 2px; }
.bars i.is-up { background: var(--s3); }
.bars-axis i { font-style: normal; font-size: .62rem; text-align: center; text-transform: uppercase; color: var(--muted); }

/* ---------- Login: imagen de fondo ---------- */
.auth-photo {
    background:
        linear-gradient(rgba(4, 7, 20, .35), rgba(4, 7, 20, .55)),
        #02041a url("../img/login-bg.jpg") center / cover no-repeat fixed;
}
.auth-photo .auth-card { background: rgba(15, 19, 32, .88); border-color: rgba(255, 255, 255, .14); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 24px 60px rgba(0, 0, 0, .55); }
:root[data-theme="light"] .auth-photo .auth-card { background: rgba(255, 255, 255, .93); border-color: rgba(0, 0, 0, .08); }
