/* ===========================================================================
   EVO-DATA v2.1 — Command Center
   Dark analytical dashboard. Self-contained (no Bootstrap).
   =========================================================================== */

:root {
    /* surfaces */
    --bg:            #0b0d13;
    --bg-elev:       #10131c;
    --surface:       #151926;
    --surface-2:     #1c2131;
    --surface-hover: #20263a;
    --border:        rgba(255, 255, 255, .07);
    --border-strong: rgba(255, 255, 255, .13);

    /* text */
    --text:       #e8eaf1;
    --text-dim:   #9097a8;
    --text-faint: #5d6478;

    /* accents */
    --primary:      #f5b13d;
    --primary-ink:  #1a1404;
    --primary-soft: rgba(245, 177, 61, .13);
    --teal:         #3fd0c9;
    --teal-soft:    rgba(63, 208, 201, .12);
    --red:          #f0584b;
    --red-soft:     rgba(240, 88, 75, .12);
    --green:        #57c98a;
    --violet:       #8b7cf6;
    --blue:         #5a9bf6;

    /* wykresy (czytane przez Chart.js) */
    --chart-grid: rgba(255, 255, 255, .06);
    --chart-text: #9097a8;

    /* tło paska górnego (półprzezroczyste, zależne od motywu) */
    --topbar-bg: rgba(11, 13, 19, .72);

    /* geometry */
    --radius:    16px;
    --radius-sm: 10px;
    --radius-lg: 22px;

    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px -8px rgba(0,0,0,.5);
    --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.7);

    --sidebar-w: 264px;

    --font-display: "Bricolage Grotesque", Georgia, serif;
    --font-body:    "IBM Plex Sans", system-ui, sans-serif;
    --font-mono:    "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
html, body { max-width: 100%; overflow-x: hidden; }

body {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    position: relative;
}

/* atmospheric background: dual radial glow + grain + faint grid */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(900px 600px at 12% -5%, rgba(245,177,61,.10), transparent 60%),
        radial-gradient(1000px 700px at 100% 110%, rgba(63,208,201,.08), transparent 55%),
        linear-gradient(180deg, #0c0f17, #090b11);
}
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: .035;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--primary); color: var(--primary-ink); }

/* scrollbars */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #262c3d; border-radius: 99px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #333a4f; }

/* ===========================================================================
   LOGIN
   =========================================================================== */
.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 410px;
    background: linear-gradient(180deg, var(--surface), var(--bg-elev));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px 36px 32px;
    position: relative;
    overflow: hidden;
}
.login-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--teal));
}
.login-brand {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 28px;
}
.login-brand .logo { width: 42px; height: 42px; }
.login-brand h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.55rem;
    letter-spacing: -.02em;
}
.login-brand p { color: var(--text-dim); font-size: .82rem; margin-top: 1px; }

.field { margin-bottom: 18px; }
.field label {
    display: block;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-dim);
    margin-bottom: 7px;
    font-weight: 500;
}
.input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: .95rem;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
    background: var(--bg-elev);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 11px 16px;
    font-family: var(--font-body);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform .08s, background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--primary);
    color: var(--primary-ink);
}
.btn-primary:hover { background: #ffbf57; box-shadow: 0 6px 18px -6px rgba(245,177,61,.5); }
.btn-full { width: 100%; }
.btn-ghost {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--text-faint); }

.alert {
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    font-size: .86rem;
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.alert-danger { background: var(--red-soft); border-color: rgba(240,88,75,.35); color: #ff9d94; }

.login-hint {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: .78rem;
    color: var(--text-faint);
    text-align: center;
}
.login-hint code {
    font-family: var(--font-mono);
    color: var(--primary);
    background: var(--primary-soft);
    padding: 1px 6px;
    border-radius: 5px;
}

/* ===========================================================================
   APP SHELL
   =========================================================================== */
.app { display: flex; min-height: 100vh; }

/* sidebar */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--bg-elev), var(--bg));
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 22px 22px 20px;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo { width: 36px; height: 36px; flex-shrink: 0; }
.sidebar-brand .name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.04rem;
    letter-spacing: -.01em;
    line-height: 1.1;
}
.sidebar-brand .ver {
    font-family: var(--font-mono);
    font-size: .66rem;
    color: var(--text-faint);
    letter-spacing: .05em;
}

.nav { padding: 16px 12px; flex: 1; overflow-y: auto; }
.nav-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--text-faint);
    padding: 8px 12px 6px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: background .14s, color .14s;
    margin-bottom: 2px;
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
}
.nav-item.active::before {
    content: "";
    position: absolute;
    left: -12px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 22px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}
.nav-item .badge-count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: .72rem;
    background: var(--surface-2);
    color: var(--text-dim);
    padding: 1px 7px;
    border-radius: 99px;
}
.nav-item.active .badge-count { background: rgba(245,177,61,.2); color: var(--primary); }

.sidebar-foot {
    border-top: 1px solid var(--border);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 11px;
}
.avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--teal));
    color: var(--primary-ink);
    display: grid; place-items: center;
    font-weight: 700;
    font-family: var(--font-display);
    flex-shrink: 0;
}
.sidebar-foot .who { flex: 1; min-width: 0; }
.sidebar-foot .who .u { font-weight: 600; font-size: .88rem; }
.sidebar-foot .who .r { font-size: .73rem; color: var(--text-faint); }
.icon-btn {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: 9px;
    color: var(--text-dim);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .14s, color .14s, border-color .14s;
}
.icon-btn:hover { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); border-color: rgba(240,88,75,.3); }
.icon-btn svg { width: 18px; height: 18px; }

/* main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar .title-block { flex: 1; min-width: 0; }
.topbar h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.1;
}
.topbar .sub { color: var(--text-dim); font-size: .84rem; margin-top: 2px; }

.toolbar { display: flex; align-items: center; gap: 10px; }

.seg {
    display: inline-flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 3px;
}
.seg button {
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: .78rem;
    font-weight: 500;
    padding: 5px 11px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .14s, color .14s;
}
.seg button.active { background: var(--surface-2); color: var(--text); }

.hamburger { display: none; }

.content { padding: 28px 32px 56px; flex: 1; }

/* section visibility */
.section { display: none; animation: fade .4s ease both; }
.section.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===========================================================================
   KPI CARDS
   =========================================================================== */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 26px;
}
.kpi {
    background: linear-gradient(180deg, var(--surface), var(--bg-elev));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: relative;
    overflow: visible;
    transition: border-color .15s, transform .15s;
    display: flex;
    flex-direction: column;
}
.kpi:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.kpi .k-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-height: 2.2em; }
.kpi .k-label {
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-dim);
    line-height: 1.3;
}
.kpi .k-ico {
    width: 32px; height: 32px;
    border-radius: 9px;
    display: grid; place-items: center;
    background: var(--primary-soft);
    color: var(--primary);
}
.kpi .k-ico svg { width: 17px; height: 17px; }
.kpi.teal .k-ico { background: var(--teal-soft); color: var(--teal); }
.kpi.red  .k-ico { background: var(--red-soft); color: var(--red); }
.kpi .k-value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -.02em;
    margin: 12px 0 10px;
    line-height: 1;
}
.kpi .k-value .unit { font-size: 1rem; color: var(--text-dim); margin-left: 2px; }
.kpi .k-foot { font-size: .78rem; color: var(--text-faint); display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: auto; min-height: 22px; }
.trend { font-family: var(--font-mono); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.trend.up   { color: var(--red); }
.trend.down { color: var(--green); }
.trend.flat { color: var(--text-dim); }

/* ===========================================================================
   PANELS / CHARTS
   =========================================================================== */
.grid {
    display: grid;
    gap: 20px;
}
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.panel {
    background: linear-gradient(180deg, var(--surface), var(--bg-elev));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.panel-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.panel-head h3 {
    font-family: var(--font-display);
    font-size: 1.02rem;
    font-weight: 600;
    letter-spacing: -.01em;
    flex: 1;
}
.panel-body { padding: 18px 20px 20px; }
.chart-box { position: relative; height: 300px; overflow: hidden; }
.chart-box.tall { height: 340px; }
.chart-box canvas { max-height: 100% !important; }
.main { overflow-x: hidden; }

/* source badge */
.badge {
    font-family: var(--font-mono);
    font-size: .68rem;
    font-weight: 500;
    letter-spacing: .04em;
    padding: 3px 9px;
    border-radius: 99px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid transparent;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.badge.live     { background: var(--teal-soft); color: var(--teal); border-color: rgba(63,208,201,.3); }
.badge.live .dot { background: var(--teal); box-shadow: 0 0 0 0 var(--teal); animation: pulse 1.8s infinite; }
.badge.static   { background: var(--surface-2); color: var(--text-dim); border-color: var(--border-strong); }
.badge.editorial{ background: var(--primary-soft); color: var(--primary); border-color: rgba(245,177,61,.3); }
.k-foot .badge { font-size: .62rem; padding: 2px 7px; flex: 0 0 auto; }
.k-foot .src-name { color: var(--text-faint); font-size: .72rem; }
/* tooltip ze źródłem (tylko dane live) */
.badge.has-tip { cursor: help; }
.badge.has-tip::after {
    content: attr(data-tip);
    position: absolute;
    left: 0; bottom: calc(100% + 8px);
    z-index: 40;
    min-width: 180px; max-width: 320px;
    padding: 8px 11px;
    background: var(--surface-2, #1b1f29);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: .68rem;
    line-height: 1.5;
    letter-spacing: 0;
    text-transform: none;
    white-space: pre-line;
    word-break: break-word;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    opacity: 0; transform: translateY(4px);
    pointer-events: none;
    transition: opacity .14s, transform .14s;
}
.badge.has-tip:hover::after { opacity: 1; transform: translateY(0); }
.k-foot .badge.has-tip { position: relative; }
/* w nagłówku panelu (overflow:hidden) chmurka idzie W DÓŁ i do prawej, by się nie obciąć */
.panel-head .badge.has-tip { position: relative; }
.panel-head .badge.has-tip::after { top: calc(100% + 8px); bottom: auto; left: auto; right: 0; transform: translateY(-4px); }
.panel-head .badge.has-tip:hover::after { transform: translateY(0); }
/* legenda provenance (Przegląd) */
.prov-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 22px;
    margin-top: 22px;
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.prov-legend-title {
    font-family: var(--font-mono);
    font-size: .7rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.prov-item { display: inline-flex; align-items: center; gap: 8px; }
.prov-desc { font-size: .78rem; color: var(--text-faint); }

/* analiza krzyżowa */
.cross-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.cross-chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 12px; border-radius: 99px; cursor: pointer;
    font-family: var(--font-body); font-size: .8rem; font-weight: 500;
    background: var(--surface-2); color: var(--text-dim);
    border: 1px solid var(--border-strong); transition: all .15s;
}
.cross-chip:hover { color: var(--text); }
.cross-chip-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--chip); opacity: .35; transition: opacity .15s; }
.cross-chip.on { color: var(--text); border-color: var(--chip); background: color-mix(in srgb, var(--chip) 14%, transparent); }
.cross-chip.on .cross-chip-dot { opacity: 1; }
.cross-corr-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.cross-corr-controls .input { width: auto; min-width: 190px; }
.cross-corr-vs { font-family: var(--font-mono); color: var(--text-dim); font-size: .85rem; }
.cross-corr-result { display: flex; flex-wrap: wrap; align-items: baseline; gap: 14px; margin-bottom: 14px; }
.cross-corr-r { font-family: var(--font-mono); font-size: 1.9rem; font-weight: 600; padding: 2px 12px; border-radius: 8px; }
.cross-corr-r.st-gray { background: var(--surface-2); color: var(--text-dim); }
.cross-corr-r.st-amber { background: rgba(245,177,61,.14); color: var(--primary); }
.cross-corr-r.st-red { background: var(--red-soft); color: var(--red); }
.cross-corr-desc { font-size: .9rem; color: var(--text-dim); }
.cross-corr-na { color: var(--text-faint); font-size: .9rem; }
.cross-corr-warn { display: flex; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-dim); font-size: .8rem; line-height: 1.5; }
.btn-csv {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 11px; border-radius: 8px; cursor: pointer;
    font-family: var(--font-mono); font-size: .72rem; letter-spacing: .04em;
    background: var(--surface-2); color: var(--text-dim);
    border: 1px solid var(--border-strong); transition: all .15s; white-space: nowrap;
}
.btn-csv:hover { color: var(--primary); border-color: var(--primary); }
.btn-csv svg { width: 15px; height: 15px; }
.export-grp { display: inline-flex; gap: 8px; }
.seg-sm button { padding: 4px 10px; font-size: .72rem; }
/* narzędzia wykresu: tryb (zaznacz/przesuń) + reset — w rogu boksu */
.chart-tools { position: absolute; top: 8px; right: 8px; z-index: 6; display: flex; gap: 6px; opacity: 0; transition: opacity .15s; }
.chart-box:hover .chart-tools { opacity: 1; }
.chart-tool {
    width: 27px; height: 27px; border-radius: 7px; cursor: pointer;
    border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-dim);
    font-size: 14px; line-height: 1; display: grid; place-items: center;
    transition: color .15s, border-color .15s, background .15s;
}
.chart-tool:hover { color: var(--primary); border-color: var(--primary); }
.chart-tool.zoom-mode.on { color: var(--teal); border-color: var(--teal); }
/* link "Co oznacza ten wskaznik?" pod kazdym wykresem/tabela -> slowniczek */
.gloss-link {
    display: inline-flex; align-items: center; gap: 5px;
    margin: 8px 0 2px; padding: 3px 2px;
    font-family: var(--font-mono); font-size: .72rem; letter-spacing: .01em;
    color: var(--text-faint); text-decoration: none;
    border-bottom: 1px dashed transparent; transition: color .15s, border-color .15s;
}
.gloss-link:hover { color: var(--primary); border-bottom-color: var(--primary); }
/* tła kadencji: przełącznik + legenda partii */
.cross-eras { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.era-toggle { display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; color: var(--text-dim); cursor: pointer; }
.era-toggle input { accent-color: var(--primary); width: 15px; height: 15px; }
.era-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.era-leg { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; color: var(--text-faint); }
.era-sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
/* tablica rozliczeń rządów */
.rozlicz-wrap { overflow-x: auto; }
.rozlicz-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.rozlicz-table th, .rozlicz-table td { padding: 9px 11px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.rozlicz-table th { font-family: var(--font-mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--surface); }
.rozlicz-table th:hover { color: var(--primary); }
.rozlicz-table th.r, .rozlicz-table td.r { text-align: right; font-family: var(--font-mono); }
.rozlicz-table tbody tr:hover { background: var(--surface-2); }
.rozlicz-table .rz-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 7px; vertical-align: -1px; }
.rozlicz-table .rz-party { color: var(--text-faint); font-size: .8rem; }
.rozlicz-table .rz-na { color: var(--text-faint); }
.rozlicz-caveat { display: flex; margin-top: 20px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-dim); font-size: .82rem; line-height: 1.55; }
/* karta rządu */
.govcard-facts { display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.gcf { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.gcf span { color: var(--text-dim); }
.gcf b { font-family: var(--font-mono); }
.gcf.gcf-h { font-weight: 600; color: var(--text); border-bottom: 2px solid var(--border-strong); padding-bottom: 11px; margin-bottom: 4px; justify-content: flex-start; }
.gcf.gcf-h .rz-dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-right: 8px; }
.gcf.gcf-idx { border-bottom: none; margin-top: 4px; }
.gcf.gcf-idx b { font-size: 1.1rem; color: var(--primary); }
.nav-links { display: flex; flex-direction: column; gap: 6px; padding: 14px 18px 4px; margin-top: 10px; border-top: 1px solid var(--border); }
.nav-links a { color: var(--text-faint); font-size: .78rem; text-decoration: none; transition: color .15s; }
.nav-links a:hover { color: var(--primary); }
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(63,208,201,.5); }
    70%  { box-shadow: 0 0 0 6px rgba(63,208,201,0); }
    100% { box-shadow: 0 0 0 0 rgba(63,208,201,0); }
}

/* ===========================================================================
   TABLE
   =========================================================================== */
.table-wrap { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}
table.data thead th {
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-dim);
    font-weight: 600;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}
table.data tbody td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface); }
table.data .num { font-family: var(--font-mono); text-align: right; white-space: nowrap; }
table.data .col-link { white-space: nowrap; }

/* sortowalne naglowki */
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--text); }
table.data thead th .sort-ind { opacity: .4; font-size: .7em; margin-left: 4px; }
table.data thead th.sort-asc .sort-ind, table.data thead th.sort-desc .sort-ind { opacity: 1; color: var(--primary); }

/* kolorowe statusy */
.st { font-size: .74rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; border: 1px solid transparent; display: inline-block; }
.st-green { background: rgba(87,201,138,.14); color: var(--green); border-color: rgba(87,201,138,.3); }
.st-red   { background: var(--red-soft); color: var(--red); border-color: rgba(240,88,75,.3); }
.st-amber { background: var(--primary-soft); color: var(--primary); border-color: rgba(245,177,61,.3); }
.st-blue  { background: rgba(90,155,246,.14); color: var(--blue); border-color: rgba(90,155,246,.3); }
.st-gray  { background: var(--surface-2); color: var(--text-dim); border-color: var(--border-strong); }

/* klikalne elementy drill-down */
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--primary); }
.kpi .k-drill { font-size: .7rem; color: var(--primary); opacity: 0; transition: opacity .15s; }
.kpi.clickable:hover .k-drill { opacity: 1; }

/* MODAL drill-down */
.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); z-index: 80; opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; }
.modal-scrim.open { opacity: 1; visibility: visible; }
.modal { position: fixed; z-index: 90; top: 50%; left: 50%; transform: translate(-50%, -48%); width: min(1080px, 94vw); max-height: 88vh;
    background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; opacity: 0; visibility: hidden; transition: opacity .2s, transform .2s, visibility .2s; }
.modal.open { opacity: 1; visibility: visible; transform: translate(-50%, -50%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-family: var(--font-display); font-size: 1.15rem; flex: 1; min-width: 0; }
.modal-head .count { font-family: var(--font-mono); font-size: .8rem; color: var(--text-dim); }
.modal-toolbar { padding: 12px 22px; border-bottom: 1px solid var(--border); }
.modal-toolbar .input { width: 100%; }
.modal-body { overflow: auto; padding: 0 8px 8px; }
.modal-body table.data thead th { position: sticky; top: 0; background: var(--bg-elev); z-index: 1; }
.modal-empty { padding: 40px; text-align: center; color: var(--text-faint); }
.pill {
    font-size: .75rem;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 99px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    white-space: nowrap;
}
/* damage meter inside table */
.meter {
    display: inline-flex; align-items: center; gap: 9px;
    font-family: var(--font-mono);
    font-weight: 600;
}
.meter .bar {
    width: 64px; height: 6px;
    border-radius: 99px;
    background: var(--surface-2);
    overflow: hidden;
}
.meter .bar i { display: block; height: 100%; border-radius: 99px; }

/* ===========================================================================
   FILTERS DRAWER
   =========================================================================== */
.scrim {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(2px);
    z-index: 40;
    opacity: 0; visibility: hidden;
    transition: opacity .25s, visibility .25s;
}
.scrim.open { opacity: 1; visibility: visible; }
.drawer {
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    width: 340px;
    max-width: 90vw;
    background: var(--bg-elev);
    border-left: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head {
    display: flex; align-items: center;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}
.drawer-head h3 { font-family: var(--font-display); font-size: 1.15rem; flex: 1; }
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.drawer-foot {
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    display: flex; gap: 10px;
}
.filter-group { margin-bottom: 24px; }
.filter-group > label.gl {
    display: block;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-dim);
    margin-bottom: 12px;
    font-weight: 600;
}
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row select {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-mono);
    padding: 9px 10px;
    font-size: .88rem;
    cursor: pointer;
}
.range-row select:focus { outline: none; border-color: var(--primary); }
.range-row .sep { color: var(--text-faint); font-size: .8rem; }

.check {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: 9px;
    cursor: pointer;
    transition: background .12s;
    font-size: .88rem;
}
.check:hover { background: var(--surface); }
.check input { appearance: none; width: 18px; height: 18px; border: 1.5px solid var(--text-faint); border-radius: 5px; cursor: pointer; position: relative; flex-shrink: 0; transition: background .14s, border-color .14s; }
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input:checked::after {
    content: "";
    position: absolute;
    left: 5px; top: 1px;
    width: 5px; height: 10px;
    border: solid var(--primary-ink);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.mini-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.mini-link {
    background: none; border: none;
    color: var(--primary);
    font-size: .76rem; font-weight: 600;
    cursor: pointer; padding: 0;
}
.mini-link:hover { text-decoration: underline; }

/* notice / error banner */
.notice {
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 22px;
    font-size: .88rem;
    display: none;
    align-items: center;
    gap: 10px;
}
.notice.show { display: flex; }
.notice.warn { background: var(--red-soft); border: 1px solid rgba(240,88,75,.35); color: #ff9d94; }

.empty {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-faint);
    font-size: .9rem;
}

/* legend chips under topbar */
.legend { display: flex; gap: 8px; align-items: center; }

/* ===========================================================================
   RESPONSIVE
   =========================================================================== */
@media (max-width: 1100px) {
    .grid.cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform .3s cubic-bezier(.4,0,.2,1);
    }
    .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
    .hamburger { display: grid; }
    .topbar { padding: 16px 18px; }
    .content { padding: 20px 18px 48px; }
    .topbar h2 { font-size: 1.2rem; }
    .legend { display: none; }
}

/* ===========================================================================
   PRINT (export to PDF via browser)
   =========================================================================== */
@media print {
    body { background: #fff; color: #111; }
    body::before, body::after { display: none; }
    .sidebar, .topbar .toolbar, .hamburger, .drawer, .scrim, .icon-btn { display: none !important; }
    .app { display: block; }
    .panel, .kpi { border: 1px solid #ccc; box-shadow: none; background: #fff; color: #111; break-inside: avoid; }
    .section { display: block !important; page-break-before: always; }
    .section:first-of-type { page-break-before: avoid; }
    .topbar { position: static; border: none; }
}

/* ===========================================================================
   LIGHT THEME
   =========================================================================== */
:root[data-theme="light"] {
    --bg:            #eef1f7;
    --bg-elev:       #ffffff;
    --surface:       #ffffff;
    --surface-2:     #eef1f7;
    --surface-hover: #e6eaf3;
    --border:        rgba(18, 24, 44, .10);
    --border-strong: rgba(18, 24, 44, .17);

    --text:       #161a26;
    --text-dim:   #535b70;
    --text-faint: #8b92a4;

    --primary:      #d9920f;
    --primary-ink:  #ffffff;
    --primary-soft: rgba(217, 146, 15, .12);
    --teal:         #119e96;
    --teal-soft:    rgba(17, 158, 150, .12);
    --red:          #d63d31;
    --red-soft:     rgba(214, 61, 49, .10);
    --green:        #1f9e62;
    --violet:       #6d5bd6;
    --blue:         #2f73d6;

    --chart-grid: rgba(18, 24, 44, .08);
    --chart-text: #535b70;
    --topbar-bg: rgba(241, 244, 250, .82);

    --shadow:    0 1px 2px rgba(18,24,44,.06), 0 10px 26px -12px rgba(18,24,44,.18);
    --shadow-lg: 0 24px 60px -20px rgba(18,24,44,.28);
}
:root[data-theme="light"] body::before {
    background:
        radial-gradient(900px 600px at 12% -5%, rgba(217,146,15,.10), transparent 60%),
        radial-gradient(1000px 700px at 100% 110%, rgba(17,158,150,.09), transparent 55%),
        linear-gradient(180deg, #f3f5fa, #e9edf5);
}
:root[data-theme="light"] body::after { opacity: .02; }
:root[data-theme="light"] .kpi .k-value .unit,
:root[data-theme="light"] .login-brand p { color: var(--text-dim); }
:root[data-theme="light"] ::-webkit-scrollbar-thumb { background: #cdd3e0; border-color: var(--bg); }
:root[data-theme="light"] .btn-primary { color: #fff; }
:root[data-theme="light"] .pill { background: var(--surface-2); }
:root[data-theme="light"] .avatar { color: #fff; }

/* ===========================================================================
   RWD — dodatkowe punkty kontrolne
   =========================================================================== */
@media (max-width: 640px) {
    .kpis { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .kpi { padding: 14px 15px; }
    .kpi .k-value { font-size: 1.55rem; }
    .kpi .k-label { font-size: .68rem; }
    .chart-box, .chart-box.tall { height: 260px; }
    .panel-head { padding: 13px 15px; }
    .panel-body { padding: 14px 15px 16px; }
    .topbar h2 { font-size: 1.08rem; }
    .topbar .sub { font-size: .76rem; }
    .seg button { padding: 5px 9px; font-size: .72rem; }
    /* nowe sekcje: kontrolki i tabele na mobile */
    .panel-head h3 { flex-basis: 100%; }            /* tytuł w osobnym wierszu, kontrolki pod spodem */
    .govcard-facts { margin-top: 14px; }
    .rozlicz-table { font-size: .78rem; }
    .rozlicz-table th, .rozlicz-table td { padding: 7px 8px; }
    #govcard-sel, .cross-corr-controls .input { width: 100%; }
    .content { padding: 16px 14px 44px; }
    table.data { font-size: .82rem; }
    table.data thead th, table.data tbody td { padding: 10px 10px; }
    .meter .bar { width: 44px; }
    .drawer { width: 100%; }
    /* analiza krzyżowa: selecty korelacji w kolumnie (nie mieszczą się obok siebie) */
    .cross-corr-controls { flex-direction: column; align-items: stretch; gap: 8px; }
    .cross-corr-controls .input { width: 100%; min-width: 0; }
    .cross-corr-vs { text-align: center; }
    .cross-corr-r { font-size: 1.5rem; }
    .cross-chip { font-size: .76rem; padding: 5px 10px; }
    .prov-legend { gap: 8px 14px; padding: 12px 14px; }
    .btn-csv span { display: none; }   /* w wąskim nagłówku zostaje sama ikona */
}
@media (max-width: 420px) {
    .kpis { grid-template-columns: 1fr; }
    .toolbar .btn span { display: none; }      /* przycisk Filtry -> sama ikona */
    .toolbar { gap: 7px; }
}

