/* Transfo theme — modern variant.
   Palette from https://transfo.energy/ (orange #ff712a, green #59b73f),
   restyled into a soft, airy, glassy dashboard look. */
:root {
    --orange: #ff712a;
    --green: #59b73f;
    --green-soft: #8fd07a;
    --blue: #5bb3e6;
    --brand-blue: #13a2dd;   /* the blue from the transfo logo */
    --dark: #1c2530;
    --slate: #7b8794;
    --slate-light: #9aa5b1;
    --line: #e8ecf0;
    --card: rgba(255, 255, 255, 0.72);
    --card-solid: #ffffff;
    --radius: 20px;
    --radius-sm: 14px;
    --shadow: 0 6px 28px rgba(28, 52, 38, 0.07);
    --shadow-sm: 0 2px 10px rgba(28, 52, 38, 0.05);
}

* { box-sizing: border-box; }

/* Top-level page: a flex column at least viewport-tall so the footer sticks to
   the bottom on big screens (content grows to fill). Scoped to .topbar so the
   Dash iframe body stays content-height (the height-fit script needs that). */
body:has(.topbar) { min-height: 100vh; display: flex; flex-direction: column; }

body {
    margin: 0;
    font-family: 'Poppins', 'Segoe UI', Helvetica, Arial, sans-serif;
    color: var(--dark);
    /* transparent by default so the Dash iframe shows the page gradient through
       (overrides Bootstrap's white body background loaded inside the iframe). */
    background: transparent;
    -webkit-font-smoothing: antialiased;
}

/* The ambient gradient lives only on the top-level page (it has the .topbar).
   Dash apps render in transparent iframes that reload this same stylesheet; if
   the iframe body painted the gradient too it would restart at the iframe's
   origin and leave a hard seam at its edge. So the iframe body stays
   transparent and the page gradient shows through continuously. */
body:has(.topbar) {
    background:
        radial-gradient(1200px 480px at 18% -8%, rgba(89, 183, 63, 0.18), transparent 60%),
        radial-gradient(1000px 420px at 92% -12%, rgba(91, 179, 230, 0.14), transparent 55%),
        linear-gradient(180deg, #f3f7f4 0%, #f7f9f8 38%, #f6f8fa 100%);
    background-attachment: fixed;
}

/* The Dash app renders inside an iframe with a transparent body so the
   parent gradient shows through. */
.dash-root { background: transparent; padding: 6px 16px 12px; overflow-x: hidden; }

/* ============================ Top bar ============================ */
.topbar {
    position: relative;
    z-index: 200;                 /* keep nav dropdowns above the dashboard iframe */
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
    padding: 0 30px;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
}
.topbar-left { display: flex; align-items: center; gap: 11px; }
.brand-logo { width: 34px; height: 34px; object-fit: contain; display: block; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: -0.4px; color: var(--dark); }
.brand-dot { color: var(--green); }
.topbar-client-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.topbar-client {
    font-size: 13px; font-weight: 600; color: var(--green);
    background: rgba(89, 183, 63, 0.14); padding: 5px 14px; border-radius: 999px;
    white-space: nowrap;
}
.client-picker-form { display: flex; margin: 0; }
.client-picker {
    font-family: inherit; font-size: 13px; font-weight: 600; color: var(--green);
    background: rgba(89, 183, 63, 0.14); border: 1px solid rgba(89, 183, 63, 0.28);
    padding: 5px 30px 5px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%2359b73f' stroke-width='1.6' stroke-linecap='round'/></svg>");
    background-repeat: no-repeat; background-position: right 12px center;
}
.client-picker:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(89, 183, 63, 0.15); }

/* centre pill nav (decorative, echoes the reference) */
.nav-pill {
    display: flex; align-items: center; gap: 4px;
    background: var(--dark); border-radius: 999px; padding: 6px;
    box-shadow: 0 6px 18px rgba(28, 37, 48, 0.28);
}
.nav-pill .nav-item {
    color: #aeb6c2; font-size: 13px; font-weight: 500;
    padding: 7px 16px; border-radius: 999px; cursor: default; white-space: nowrap;
}
.nav-pill .nav-item.active { background: #fff; color: var(--dark); font-weight: 600; }

/* centered grouped pill nav with dropdown submenus */
.topnav {
    position: absolute; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 4px;
    background: rgba(255, 255, 255, 0.65); backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.7); border-radius: 999px;
    padding: 5px; box-shadow: var(--shadow-sm);
}
.topnav-group { position: relative; }
.topnav-pill {
    display: flex; align-items: center; gap: 7px;
    background: transparent; border: none; cursor: pointer; text-decoration: none;
    color: var(--dark); font-family: inherit; font-size: 13px; font-weight: 500;
    padding: 8px 16px; border-radius: 999px; white-space: nowrap; transition: background .12s ease;
}
.topnav-pill:hover { background: rgba(89, 183, 63, 0.1); }
.topnav-pill.active { background: var(--brand-blue); color: #fff; font-weight: 600; }

/* second-level nav bar: pages within the active top-level group */
.subnav {
    position: relative; z-index: 150;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
}
.subnav-inner {
    display: flex; gap: 4px; flex-wrap: wrap; justify-content: center;
    padding: 8px 30px; max-width: 1480px; margin: 0 auto;
}
.subnav-link {
    text-decoration: none; color: var(--slate); font-size: 13px; font-weight: 500;
    padding: 7px 14px; border-radius: 999px; white-space: nowrap; transition: all .12s ease;
}
.subnav-link:hover { color: var(--dark); background: rgba(89, 183, 63, 0.1); }
.subnav-link.active { background: var(--brand-blue); color: #fff; font-weight: 600; }
.topnav-icon { display: inline-flex; align-items: center; }
.topnav-caret { font-size: 9px; opacity: .6; margin-left: -2px; }
.topnav-menu {
    position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    display: none; flex-direction: column; min-width: 210px;
    background: #fff; border: 1px solid var(--line); border-radius: 14px;
    box-shadow: 0 12px 34px rgba(28, 52, 38, 0.14); padding: 6px; z-index: 50;
}
/* transparent bridge filling the gap so hover doesn't drop between pill & menu */
.topnav-menu::before {
    content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px;
}
@media (hover: hover) { .topnav-group:hover .topnav-menu { display: flex; } }
.topnav-group.open .topnav-menu { display: flex; }
.topnav-link {
    text-decoration: none; color: var(--dark); font-size: 13px; font-weight: 500;
    padding: 9px 12px; border-radius: 9px; white-space: nowrap; transition: all .1s ease;
}
.topnav-link:hover { background: rgba(89, 183, 63, 0.1); }
.topnav-link.active { background: var(--brand-blue); color: #fff; font-weight: 600; }

.icon-btn {
    width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.6); color: var(--slate); cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all .12s ease;
}
.icon-btn:hover { background: #fff; color: var(--dark); border-color: var(--green); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--green), var(--green-soft));
    color: #fff; font-weight: 600; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-name { font-size: 13px; font-weight: 600; color: var(--dark); }
.user-role { font-size: 11px; color: var(--slate-light); }
.logout-form { margin: 0; }
.btn-logout {
    color: #fff; background: var(--dark); border: none;
    padding: 9px 18px; border-radius: 999px; font-size: 13px; font-weight: 500;
    cursor: pointer; font-family: inherit;
    box-shadow: 0 4px 14px rgba(28, 37, 48, 0.22); transition: transform .12s ease;
}
.btn-logout:hover { transform: translateY(-1px); background: #2a3744; }

.content { padding: 18px 30px 24px; flex: 1 0 auto; }   /* grow to push footer down */
.dash-wrap { max-width: none; margin: 0; }   /* full-width dashboards */

/* ============================ Title strip ============================ */
.title-strip { display: flex; align-items: center; gap: 14px; margin: 2px 0 12px; }
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -0.6px; color: var(--dark); }
.client-badge {
    font-size: 12px; font-weight: 600; color: var(--green);
    background: rgba(89, 183, 63, 0.14); padding: 5px 14px; border-radius: 999px;
}
.strip-sub { font-size: 14px; font-weight: 500; color: var(--slate); }
.data-badge { font-size: 11px; font-weight: 600; color: var(--slate-light); padding: 4px 10px; }
.data-badge:empty { display: none; }

/* Right-aligned page actions (Export to Excel). */
.title-strip-actions { margin-left: auto; display: inline-flex; align-items: center; }
.export-btn {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: inherit; font-size: 13px; font-weight: 600; color: #fff;
    background: var(--green); border: none; padding: 9px 16px;
    border-radius: 999px; cursor: pointer; white-space: nowrap;
    box-shadow: 0 2px 6px rgba(89, 183, 63, 0.28); transition: all .12s ease;
}
.export-btn:hover { background: #4ea336; box-shadow: 0 3px 9px rgba(89, 183, 63, 0.38); }
.export-btn:active { transform: translateY(1px); }
.xls-icon { display: inline-flex; }
/* A small spreadsheet glyph drawn in CSS (no external asset needed). */
.xls-glyph {
    display: inline-block; width: 13px; height: 13px; border-radius: 2px;
    background: #fff;
    background-image:
        linear-gradient(to right, rgba(89,183,63,0.55) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(89,183,63,0.55) 1px, transparent 1px);
    background-size: 4.3px 4.3px;
}

/* ============================ Cards / panels ============================ */
.panel, .kpi-card {
    background: var(--card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.panel { padding: 20px; height: 100%; }
.kpi-card .card-body { padding: 20px; }

.panel-head {
    font-size: 15px; font-weight: 600; color: var(--dark);
    margin-bottom: 16px;
}

/* ---- Filter rail ---- */
.filter-panel .filter-label { font-size: 12px; color: var(--slate); margin: 4px 0 2px; }
.ref-date-big { font-size: 30px; font-weight: 700; color: var(--dark); margin-bottom: 12px; letter-spacing: -0.5px; }
.filter-item { margin-top: 10px; }
.filter-panel hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.filter-dd .Select-control {
    border-radius: 10px !important; border-color: var(--line) !important; font-size: 13px;
}
/* Open dropdown menus must float above the panels/charts that follow them in
   the DOM (Gains & Losses, the chart cards). The filter rail gets its own
   stacking context above those siblings, and the react-select menu sits on top. */
.filter-panel { position: relative; z-index: 60; }
.filter-dd { position: relative; }
.filter-dd .Select-menu-outer,
.filter-dd .Select-menu,
.filter-panel .Select.is-open { z-index: 1000 !important; }
.filter-dd .Select-menu-outer {
    border-radius: 10px; box-shadow: 0 12px 34px rgba(28, 52, 38, 0.18);
    border-color: var(--line);
}

/* ---- KPI cards (middle) ---- */
.card-kpi-title { font-size: 14px; font-weight: 600; color: var(--slate); margin-bottom: 4px; }
.card-kpi-value {
    font-size: 44px; font-weight: 700; color: var(--dark);
    line-height: 1.05; margin: 2px 0 14px; letter-spacing: -1px;
}
.card-chart-title { font-size: 12px; color: var(--slate-light); margin-bottom: 2px; font-weight: 500; }

/* Big-number stat row inside the Active-Contracts card (Total / EL / Gas) */
.kpi-stat-row { display: flex; gap: 34px; align-items: flex-end; flex-wrap: wrap; margin: 4px 0 10px; }
.kpi-stat { display: flex; flex-direction: column; }
.kpi-stat-label { font-size: 12px; font-weight: 600; color: var(--slate); margin-bottom: 2px; }
.kpi-stat-value { font-size: 34px; font-weight: 700; color: var(--dark); letter-spacing: -1px; line-height: 1.05; }
.kpi-stat.primary .kpi-stat-value { font-size: 46px; }
.kpi-stat.el .kpi-stat-value { color: var(--green); }
.kpi-stat.ng .kpi-stat-value { color: var(--blue); }

/* Period range sub-labels in the filter rail */
.filter-sublabel { font-size: 11px; color: var(--slate-light); margin: 6px 0 1px; }

/* Left filter sidebar + main content column */
.page-grid { display: flex; gap: 16px; align-items: flex-start; }
.page-sidebar { flex: 0 0 250px; max-width: 250px; position: sticky; top: 12px; }
.page-main { flex: 1 1 auto; min-width: 0; }           /* min-width:0 lets charts shrink */
.page-main > .mt:first-child, .page-main > .panel:first-child,
.page-main > .kpi-card:first-child { margin-top: 0; }
/* stack the filter fields vertically in the sidebar */
.page-sidebar .filter-bar { flex-direction: column; align-items: stretch; gap: 16px; }
/* a clear "Filters" heading at the top of the sidebar filter pane */
.page-sidebar .filter-bar::before {
    content: "Filters";
    flex: 0 0 100%; order: -1;
    font-size: 15px; font-weight: 700; color: var(--dark);
    padding-bottom: 10px; margin-bottom: 2px; border-bottom: 1px solid var(--line);
}
.page-sidebar .filter-field,
.page-sidebar .period-field { flex: 1 1 auto; width: 100%; min-width: 0; }
.page-sidebar .seg-toggle { width: 100%; justify-content: center; }
@media (max-width: 820px) {
    .page-grid { flex-direction: column; }
    .page-sidebar { position: static; flex-basis: auto; max-width: none; width: 100%; }
    .page-sidebar .filter-bar { flex-direction: row; flex-wrap: wrap; }
}

/* Reporting-period range slider */
.period-field { flex: 2 1 360px; min-width: 240px; }
.period-label-row, .period-field .period-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.period-range-label { color: var(--brand-blue); font-weight: 600; font-size: 12px; }
.period-slider { padding-top: 10px; padding-bottom: 2px; }
/* Dash 4 slider classes: track = full rail, range = selected fill, thumb = handle */
.period-slider .dash-slider-track { background-color: var(--line) !important; border-radius: 999px; }
.period-slider .dash-slider-range { background-color: var(--brand-blue) !important; border-radius: 999px; }
.period-slider .dash-slider-thumb {
    background-color: var(--brand-blue) !important; border: 2px solid #fff !important;
    box-shadow: 0 1px 4px rgba(28, 52, 38, 0.25) !important;
}
.period-slider .dash-slider-thumb:hover,
.period-slider .dash-slider-thumb:focus,
.period-slider .dash-slider-thumb:active {
    box-shadow: 0 0 0 5px rgba(19, 162, 221, 0.25) !important;
}
.period-slider .dash-slider-dot { display: none; }
.period-slider .dash-slider-mark { font-size: 11px; color: var(--slate); }

/* Horizontal filter bar at the top of the page */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 16px 20px; align-items: flex-end;
    padding: 14px 18px; position: relative; z-index: 60;
}
.filter-field { display: flex; flex-direction: column; flex: 1 1 170px; min-width: 150px; }
.filter-field .filter-label { font-size: 12px; color: var(--slate); margin: 0 0 4px; }
.filter-bar .Select-menu-outer,
.filter-bar .Select.is-open { z-index: 1000 !important; }
@media (max-width: 560px) { .filter-field { flex-basis: 100%; } }

/* ---- Snapshot analysis panel (right) ---- */
.snap-metric {
    margin-bottom: 14px; padding: 14px 16px;
    background: rgba(255, 255, 255, 0.55); border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.7);
}
.snap-metric:last-child { margin-bottom: 0; }
.snap-label { font-size: 12px; color: var(--slate); margin-bottom: 4px; }
.snap-value-row { display: flex; align-items: baseline; gap: 8px; }
.snap-value { font-size: 30px; font-weight: 700; color: var(--dark); letter-spacing: -0.5px; }
.kpi-delta {
    font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
}
.kpi-delta.up { color: var(--orange); background: rgba(255, 113, 42, 0.12); }
.kpi-delta.down { color: var(--green); background: rgba(89, 183, 63, 0.14); }
.kpi-delta.flat { color: var(--slate-light); background: rgba(123, 135, 148, 0.1); }

/* ---- Gains & Losses ---- */
.gainloss-panel { margin-top: 12px; }
.main-row { align-items: stretch; }

/* ============================ Login ============================ */
.login-wrap { min-height: calc(100vh - 68px); display: flex; align-items: center; justify-content: center; }
.login-card {
    background: rgba(255, 255, 255, 0.75); backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.8); border-radius: 24px;
    padding: 40px 38px; width: 380px; box-shadow: 0 20px 60px rgba(28, 52, 38, 0.12);
}
.login-logo { width: 56px; height: 56px; object-fit: contain; display: block; margin: 0 auto 16px; }
.login-title { margin: 0 0 4px; font-size: 24px; font-weight: 700; color: var(--dark); letter-spacing: -0.5px; text-align: center; }
.login-sub { text-align: center; }
.login-sub { margin: 0 0 24px; font-size: 13px; color: var(--slate); }
.login-card label { display: block; font-size: 12px; color: var(--slate); margin: 12px 0 5px; }
.login-card input[type=text], .login-card input[type=password] {
    width: 100%; padding: 12px 14px; border: 1px solid var(--line);
    border-radius: 12px; font-size: 14px; background: rgba(255, 255, 255, 0.8); font-family: inherit;
}
.login-card input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(89, 183, 63, 0.15); }
.btn-primary {
    width: 100%; margin-top: 22px; padding: 13px; border: none; border-radius: 12px;
    background: linear-gradient(135deg, var(--orange), #ff8a4d); color: #fff;
    font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
    box-shadow: 0 8px 20px rgba(255, 113, 42, 0.3); transition: transform .12s ease;
}
.btn-primary:hover { transform: translateY(-1px); }
.login-error { background: #fdecea; color: #d6452f; font-size: 12px; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; }
.login-hint { margin-top: 20px; font-size: 11px; color: var(--slate-light); text-align: center; }
.login-card input[type=email] {
    width: 100%; padding: 12px 14px; border: 1px solid var(--line);
    border-radius: 12px; font-size: 14px; background: rgba(255, 255, 255, 0.8); font-family: inherit;
}
.login-card input[disabled] { background: var(--grey-bg); color: var(--slate); cursor: not-allowed; }
.pw-rules { margin: 8px 0 0; padding-left: 18px; font-size: 11px; color: var(--slate-light); line-height: 1.6; }
.onboard-steps { text-align: center; font-size: 12px; margin: 0 0 20px; color: var(--slate-light); }
.onboard-steps .step-on { color: var(--green); font-weight: 600; }
.onboard-steps .step-off { color: var(--slate-light); }
.login-hint code { background: rgba(89, 183, 63, 0.12); color: var(--green); padding: 2px 6px; border-radius: 6px; }

/* ---- Two-factor wizard (django-two-factor-auth default templates) ---- */
.twofa-card h1 { margin: 0 0 6px; font-size: 22px; font-weight: 700; color: var(--dark); letter-spacing: -0.5px; text-align: center; }
.twofa-card p { font-size: 13px; color: var(--slate); line-height: 1.5; }
.twofa-card .container, .twofa-card .row { margin: 0; padding: 0; }
.twofa-card .col-md-5, .twofa-card [class*="col-"] { padding: 0; max-width: 100%; flex: 1; }
.twofa-card table { width: 100%; }
.twofa-card table th { text-align: left; font-size: 12px; color: var(--slate); font-weight: 500; padding: 6px 0; vertical-align: middle; }
.twofa-card input[type=text], .twofa-card input[type=password], .twofa-card input[type=number], .twofa-card input[type=tel] {
    width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
    font-size: 14px; background: rgba(255, 255, 255, 0.8); font-family: inherit;
}
.twofa-card input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(89, 183, 63, 0.15); }
.twofa-card ul.errorlist { list-style: none; margin: 6px 0; padding: 0; color: #d6452f; font-size: 12px; }
.twofa-card .helptext { font-size: 11px; color: var(--slate-light); }
.twofa-card .btn {
    margin-top: 14px; margin-right: 8px; padding: 11px 18px; border: 1px solid var(--line); border-radius: 12px;
    background: #fff; color: var(--slate); font-size: 14px; font-weight: 600; cursor: pointer;
    font-family: inherit; text-decoration: none; display: inline-block;
}
.twofa-card .btn-primary {
    width: auto; min-width: 96px; margin-top: 14px; margin-right: 0; color: #fff; border: none;
    background: linear-gradient(135deg, var(--orange), #ff8a4d);
}
.twofa-card .btn[disabled] { opacity: .45; cursor: default; }
.twofa-card .btn-block { display: block; width: 100%; text-align: center; }
.twofa-card img[alt="QR Code"] { display: block; margin: 6px auto 4px; padding: 10px; background: #fff; border-radius: 12px; }
.twofa-card a { color: var(--green); word-break: break-all; }
.twofa-card hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

.no-client { text-align: center; padding: 90px 20px; color: var(--slate); }

/* ============================ Dashboard switcher ============================ */
.dash-switcher {
    display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.55); backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.7); border-radius: 999px;
    padding: 6px; box-shadow: var(--shadow-sm); width: fit-content; max-width: 100%;
}
.switch-item {
    text-decoration: none; color: var(--slate); font-size: 13px; font-weight: 500;
    padding: 8px 16px; border-radius: 999px; white-space: nowrap; transition: all .12s ease;
}
.switch-item:hover { color: var(--dark); background: rgba(89, 183, 63, 0.1); }
.switch-item.active { background: var(--brand-blue); color: #fff; font-weight: 600; }

/* 'vs' separator between the two MEC selectors on the Variance page */
.var-vs-sep {
    align-self: flex-end; padding: 0 4px 10px; color: var(--slate-light);
    font-size: 13px; font-weight: 600; flex: 0 0 auto;
}

/* DataTable export button (e.g. on the EB Export page) */
.dash-spreadsheet-menu { margin-bottom: 10px; }
.dash-spreadsheet-menu .export {
    background: var(--green); color: #fff; border: none; cursor: pointer;
    font-family: inherit; font-size: 13px; font-weight: 600;
    padding: 8px 18px; border-radius: 999px;
    box-shadow: 0 4px 14px rgba(89, 183, 63, 0.28); transition: transform .12s ease, background .12s ease;
}
.dash-spreadsheet-menu .export::before { content: "⤓ "; }
.dash-spreadsheet-menu .export:hover { background: #4ba233; transform: translateY(-1px); }

/* section header within a page (e.g. 'Details' on the Variance page) */
.page-section-head {
    font-size: 16px; font-weight: 700; color: var(--dark);
    margin: 16px 0 4px; letter-spacing: -0.3px;
}

/* utility */
.mt { margin-top: 16px; }
.card-chart-title.mt { margin-top: 14px; }

/* ============================ KPI table ============================ */
.kpi-sections { display: flex; flex-direction: column; gap: 32px; }
.kpi-filter { margin-bottom: 14px; }
.kpi-filter .filter-field { flex: 0 0 auto; }

/* segmented two-option toggle (e.g. Compare to: Previous MEC / Budget) */
.seg-toggle {
    display: inline-flex; gap: 4px; padding: 4px;
    background: rgba(255, 255, 255, 0.6); border: 1px solid var(--line);
    border-radius: 999px; width: fit-content;
}
.seg-btn {
    border: none; background: transparent; color: var(--slate);
    font-family: inherit; font-size: 13px; font-weight: 500; padding: 7px 16px;
    border-radius: 999px; cursor: pointer; white-space: nowrap; transition: all .12s ease;
}
.seg-btn:hover { color: var(--dark); background: rgba(89, 183, 63, 0.1); }
.seg-btn.active { background: var(--brand-blue); color: #fff; font-weight: 600; }
.seg-btn.active:hover { background: var(--brand-blue); color: #fff; }
.kpi-table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    background: var(--card); border: 1px solid rgba(255,255,255,0.7);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
    /* fixed geometry so every section table shares identical column widths and
       the numbers line up vertically across Portfolio / Volumes / Margin */
    table-layout: fixed;
}
.kpi-section-th, .kpi-row-label { width: 28%; }
.kpi-col-th, .kpi-cell { width: 18%; }
.kpi-section-th {
    text-align: left; font-size: 17px; font-weight: 700; color: var(--dark);
    padding: 12px 14px; background: rgba(89,183,63,0.08);
    letter-spacing: -0.3px;
}
.kpi-col-th {
    text-align: right; font-size: 11px; font-weight: 600; color: var(--slate);
    padding: 8px 14px; background: rgba(89,183,63,0.08); white-space: nowrap;
}
.kpi-row-label { font-size: 13px; font-weight: 600; color: var(--dark); padding: 6px 14px;
    border-top: 1px solid var(--line); }
.kpi-cell { text-align: right; padding: 6px 14px; border-top: 1px solid var(--line);
    white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi-value { font-size: 17px; font-weight: 700; color: var(--dark); letter-spacing: -0.5px; }
.kpi-budget { color: var(--slate); font-size: 13px; }
/* Section totals (Total Active EAN, Total Margin, ...) stand out from the
   detail rows they summarise (client feedback 14/07/2026). */
.kpi-total-row .kpi-row-label, .kpi-total-row .kpi-cell {
    background: var(--grey-bg, #f4f6f9);
    border-top: 1px solid #d8dee6; font-weight: 700;
}
.kpi-sup { font-size: 9px; margin-left: 3px; font-weight: 600; }
.kpi-sup.good { color: var(--green); }
.kpi-sup.bad { color: var(--orange); }

/* ============================ Margin Analysis table ============================ */
.ma-table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    background: var(--card); border: 1px solid rgba(255,255,255,0.7);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
}
.ma-table th, .ma-table td { padding: 6px 12px; font-size: 13px; }
.ma-col-th {
    text-align: right; font-size: 11px; font-weight: 600; color: var(--slate);
    background: rgba(89,183,63,0.08); white-space: nowrap;
}
.ma-section-td {
    background: rgba(89,183,63,0.14); font-weight: 700; font-size: 14px;
    color: var(--dark); padding: 10px 12px; letter-spacing: 0.2px;
}
.ma-label { font-weight: 500; color: var(--dark); white-space: nowrap;
    border-top: 1px solid var(--line); }
.ma-unit { color: var(--slate); font-size: 11px; border-top: 1px solid var(--line); }
.ma-cell { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums;
    border-top: 1px solid var(--line); }
.ma-total-col { font-weight: 700; }
.ma-gross-row td { font-weight: 700; background: var(--grey-bg, #f4f6f9); }
.ma-ratio-row td { color: var(--slate); font-style: italic; font-size: 12px; }
.ma-grand-row td { background: rgba(89,183,63,0.16); font-weight: 700;
    border-top: 2px solid var(--green); }
.ma-neg { color: #d6452f; }

/* ============================ Energy Balance table ============================ */
.eb-table-wrap { overflow-x: auto; max-height: 560px; overflow-y: auto; }
.eb-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.eb-th {
    position: sticky; top: 0; background: #fff; text-align: right; color: var(--slate);
    font-weight: 600; padding: 10px 12px; border-bottom: 2px solid var(--line); white-space: nowrap;
}
.eb-th-period { text-align: left; }
.eb-period { text-align: right; color: var(--slate); padding: 8px 12px; border-bottom: 1px solid var(--line); }
.eb-cell { text-align: right; padding: 8px 12px; border-bottom: 1px solid var(--line);
    color: var(--dark); white-space: nowrap; }
.eb-cell:nth-child(2), .eb-cell:nth-child(6) {
    background: rgba(89,183,63,0.10); font-weight: 600;
}
.eb-totals { font-weight: 700; color: var(--dark); background: rgba(89,183,63,0.08); }

/* Variance Details tables: fixed geometry so numbers line up across tables
   (like the KPI sheet); label column left-aligned, value columns tabular. */
.vd-table { table-layout: fixed; }
.vd-table .eb-th-period, .vd-table .eb-period { width: 28%; text-align: left; }
.vd-table .eb-th, .vd-table .eb-cell { width: 18%; font-variant-numeric: tabular-nums; }

/* ============================ Variance cards ============================ */
.var-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.var-card {
    background: rgba(255,255,255,0.6); border: 1px solid rgba(255,255,255,0.7);
    border-radius: var(--radius-sm); padding: 10px 12px;
}
.var-label { font-size: 12px; color: var(--slate); margin-bottom: 2px; }
.var-value-row { display: flex; align-items: baseline; gap: 8px; }
.var-value { font-size: 20px; font-weight: 700; color: var(--dark); letter-spacing: -0.5px; }
.var-sub { font-size: 10px; color: var(--slate-light); }

/* ============================ Manage area ============================ */
.btn-ghost {
    color: var(--dark); background: rgba(255,255,255,0.6); border: 1px solid var(--line);
    padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
    text-decoration: none; transition: all .12s ease;
}
.btn-ghost:hover { background: #fff; border-color: var(--green); }

.manage-wrap { max-width: none; margin: 0; }   /* operator: full width, like .dash-wrap */
.manage-wrap.manage-narrow { max-width: 1200px; margin: 0 auto; }   /* public landing */
.manage-head { margin-bottom: 16px; }
.manage-head .page-title { display: block; margin-bottom: 12px; }
.manage-grid { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }

.manage-form { display: flex; flex-direction: column; gap: 4px; }
.manage-form label { font-size: 12px; color: var(--slate); margin-top: 10px; }
.manage-form label.check { flex-direction: row; display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.manage-form input[type=text], .manage-form input[type=email], .manage-form input[type=password],
.manage-form select, .manage-form input[type=file] {
    padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
    font-size: 14px; font-family: inherit; background: rgba(255,255,255,0.8);
}
.manage-form input:focus, .manage-form select:focus { outline: none; border-color: var(--green); }
.manage-form .btn-primary { margin-top: 16px; width: auto; }
.form-hint { font-size: 11px; color: var(--slate-light); margin: 10px 0 0; }
.form-hint code { background: var(--grey-bg); padding: 1px 5px; border-radius: 4px; }

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.data-table th { text-align: left; color: var(--slate); font-weight: 600; padding: 9px 10px;
    border-bottom: 2px solid var(--line); }
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); color: var(--dark); vertical-align: middle; }
.data-table .muted { color: var(--slate-light); }
.pill-ok { background: rgba(89,183,63,0.14); color: var(--green); padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-pending { background: rgba(255,113,42,0.12); color: var(--orange); padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.btn-link-danger { background: none; border: none; color: var(--orange); cursor: pointer; font-size: 13px; font-family: inherit; padding: 0; }
.btn-link-danger:hover { text-decoration: underline; }

/* account settings */
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.account-meta { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 4px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.account-meta > div { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.account-meta .meta-k { color: var(--slate); }
.account-meta .meta-v { color: var(--dark); font-weight: 600; }
.account-status { font-size: 14px; margin: 0 0 4px; }
.account-actions { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
.inline-btn { display: inline-block; width: auto; margin-top: 14px; text-decoration: none; text-align: center; }
.pw-help { font-size: 11px; color: var(--slate-light); margin: 6px 0 2px; }
.pw-help ul { margin: 0; padding-left: 16px; line-height: 1.6; }
.manage-form ul.errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: #d6452f; font-size: 12px; }

/* copyable invite link */
.copy-link { display: flex; align-items: center; gap: 6px; }
.copy-link-input {
    width: 260px; max-width: 38vw; padding: 6px 9px; border: 1px solid var(--line);
    border-radius: 8px; font-size: 12px; font-family: ui-monospace, "Cascadia Code", monospace;
    color: var(--slate); background: var(--grey-bg); cursor: text;
}
.copy-btn { padding: 6px 12px; font-size: 12px; }
.copy-open { font-size: 12px; color: var(--green); }

/* messages */
.msg-list { max-width: 1480px; margin: 0 auto 14px; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 11px 16px; border-radius: 12px; font-size: 13px; border: 1px solid; }
.msg-success { background: rgba(89,183,63,0.1); border-color: rgba(89,183,63,0.3); color: #2f7a1d; }
.msg-error { background: #fdecea; border-color: #f5c6c0; color: #c0341d; }
.msg-info, .msg-warning { background: rgba(91,179,230,0.1); border-color: rgba(91,179,230,0.3); color: #1a6a96; }

/* source-data dashboard controls */
.sd-controls { margin-bottom: 12px; }
.sd-radio label { margin-right: 18px; font-size: 13px; color: var(--dark); }
.sd-notice { padding: 24px; color: var(--slate); font-size: 14px; }

/* ============================ Footer ============================ */
.site-footer { background: var(--dark); color: #cfd6de; margin-top: 24px; flex-shrink: 0; }
.footer-inner {
    padding: 18px 30px;
    display: flex; justify-content: space-between; align-items: center;
    gap: 40px; flex-wrap: wrap;
}
.footer-copyright { font-size: 13px; color: #9aa5b1; }
.footer-brand { max-width: 460px; }
.footer-logo-row { display: flex; align-items: center; gap: 10px; }
.footer-logo { width: 30px; height: 30px; object-fit: contain; }
.footer-brand-name { font-size: 22px; font-weight: 700; color: #fff; letter-spacing: -0.4px; }
.footer-tagline-sm {
    font-size: 10px; font-weight: 600; letter-spacing: 2px; color: #8b94a0;
    margin: 6px 0 0 40px;
}
.footer-blurb { margin: 16px 0 0; font-size: 14px; line-height: 1.6; color: #cfd6de; }
.footer-head { margin: 0 0 10px; font-size: 18px; font-weight: 700; font-style: italic; color: #fff; }
.footer-slash { color: var(--green); font-style: normal; }
.footer-contact-row {
    display: inline-flex; align-items: center; gap: 10px;
    color: #cfd6de; text-decoration: none; font-size: 14px;
}
.footer-contact-row svg { color: var(--green); }
.footer-contact-row:hover { color: #fff; }
.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    max-width: 1480px; margin: 0 auto; padding: 10px 30px;
    font-size: 13px; color: #9aa5b1;
}
.footer-orange { color: var(--orange); }

/* ============================ Responsive ============================ */
@media (max-width: 1024px) {
    /* nav no longer fits centered between logo and actions -> wrap to its own row */
    .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; }
    .topnav {
        position: static; transform: none; order: 3;
        width: 100%; margin-top: 8px; justify-content: center; flex-wrap: wrap;
    }
}
@media (max-width: 820px) {
    .content { padding: 16px 14px 32px; }
    .page-title { font-size: 22px; }
    .var-grid { grid-template-columns: 1fr; }
    .manage-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .user-meta { display: none; }       /* keep avatar + logout, drop name/role */
    .brand { font-size: 16px; }
    .dash-switcher { width: 100%; justify-content: flex-start; }
    .topnav-menu { left: 0; transform: none; min-width: 180px; }
    .topnav-pill { padding: 7px 12px; }
}

/* Tenant logo letterbox (operator portal + landing): every logo — square
   icon or wide wordmark — sits in the same fixed box so names align. */
.tenant-logo {
    display: inline-flex; align-items: center; justify-content: center;
    width: 48px; height: 26px; margin-right: 10px; vertical-align: middle;
    border-radius: 4px; background: #f4f6f9; flex: 0 0 auto;
}
.tenant-logo img { max-width: 42px; max-height: 22px; object-fit: contain; }
.tenant-cell { display: inline-flex; align-items: center; }
