/* Gather Energy dashboard — base stylesheet */

*, *::before, *::after { box-sizing: border-box; }

:root {
    /* Gather Energy palette — the same tokens as gatherenergy.nl (website/index.html) */
    color-scheme: dark;
    --color-bg:       #101316;
    --color-surface:  #1A1D1F;
    --color-surface-2: #202122;
    --color-primary:  #00B0F0;
    --color-primary-dark: #0B7FAE;
    --color-primary-soft: rgba(0,176,240,.11);
    --color-primary-line: rgba(0,176,240,.34);
    --color-on-primary: #08191F;
    --color-text:     #F2F4F5;
    --color-text-2:   #AFB6B9;
    --color-muted:    #7E8790;
    --color-border:   #32363A;
    --color-line-soft: rgba(255,255,255,.07);
    --color-error:    #F87171;
    --color-success:  #4ADE80;
    --color-warning:  #FBBF24;
    --color-info:     #00B0F0;
    --color-error-soft:   rgba(248,113,113,.12);
    --color-success-soft: rgba(74,222,128,.12);
    --color-warning-soft: rgba(251,191,36,.12);
    --radius:         3px;

    --font-sans: "Source Sans 3", "Source Sans Pro", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "Source Code Pro", ui-monospace, "SF Mono", Menlo, monospace;

    /* Energy series — one color per entity, used in stat cards, tables and charts */
    --color-solar:        #FACC15;
    --color-consumption:  #F87171;
    --color-grid-import:  #2DD4BF;
    --color-grid-export:  #4ADE80;
    --color-soc:          #00B0F0;
}

/* The UA's [hidden] rule loses to any author `display` rule (e.g. .btn's
   inline-block), which silently breaks the hidden attribute. Restore it. */
[hidden] { display: none !important; }

/* Series/status text utilities — replace inline style="color:#…" */
.text-solar       { color: var(--color-solar); }
.text-consumption { color: var(--color-consumption); }
.text-grid-import { color: var(--color-grid-import); }
.text-grid-export { color: var(--color-grid-export); }
.text-soc         { color: var(--color-soc); }
.text-success     { color: var(--color-success); }
.text-warning     { color: var(--color-warning); }
.text-error       { color: var(--color-error); }

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

/* Native controls and links pick up the dark theme. :where() keeps these at
   zero specificity so every component class below still wins. */
:where(input, select, textarea, button) { font: inherit; }
:where(input:not([type=checkbox], [type=radio], [type=range], [type=submit], [type=button]), select, textarea) {
    background: var(--color-surface-2);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
:where(a) { color: var(--color-primary); }
:where(code, pre, kbd) { font-family: var(--font-mono); font-size: .9em; }
:where(h1, h2, h3, h4) { color: var(--color-text); }
:where(hr) { border: 0; border-top: 1px solid var(--color-border); }
::selection { background: rgba(0,176,240,.35); color: var(--color-text); }

/* ---------------------------------------------------------------------------
   Navbar
--------------------------------------------------------------------------- */
.navbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.navbar-links a {
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
}

.navbar-links a:hover { color: var(--color-primary); }

.navbar-user {
    color: var(--color-muted);
    font-size: 0.875rem;
}

.btn-logout {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.3rem 0.75rem;
    font-size: 0.875rem;
}

/* ---------------------------------------------------------------------------
   Main content
--------------------------------------------------------------------------- */
.main-content {
    padding: 2rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* ---------------------------------------------------------------------------
   Alerts / flash messages
--------------------------------------------------------------------------- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error   { background: var(--color-error-soft);   color: var(--color-error);   border: 1px solid rgba(248,113,113,.35); }
.alert-success { background: var(--color-success-soft); color: var(--color-success); border: 1px solid rgba(74,222,128,.35); }
.alert-warning { background: var(--color-warning-soft); color: var(--color-warning); border: 1px solid rgba(251,191,36,.35); }
.alert-info    { background: var(--color-primary-soft); color: var(--color-info);    border: 1px solid var(--color-primary-line); }

/* ---------------------------------------------------------------------------
   Login page
--------------------------------------------------------------------------- */
.login-wrapper {
    min-height: calc(100vh - 56px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.45);
}

.login-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    margin: 0 0 0.5rem;
    font-size: 1.6rem;
    line-height: 1;
}
.login-mark { display: block; flex: none; }
.login-back { margin: 1.25rem 0 0; }

.login-subtitle {
    text-align: center;
    color: var(--color-muted);
    margin: 0 0 1.75rem;
    font-size: 0.9rem;
}

/* ---------------------------------------------------------------------------
   Forms
--------------------------------------------------------------------------- */
.form-group {
    margin-bottom: 1.1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.form-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    transition: border-color .15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.form-error {
    display: block;
    color: var(--color-error);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

/* ---------------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------------- */
.btn {
    display: inline-block;
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background .15s;
}

.btn-primary {
    font-weight: 700;
    background: var(--color-primary);
    color: var(--color-on-primary);
}

.btn-primary:hover { background: var(--color-primary-dark); }

.btn-full { width: 100%; text-align: center; margin-top: 0.5rem; }

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-bg); }

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.85rem; }

/* ---------------------------------------------------------------------------
   Cards
--------------------------------------------------------------------------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.form-card { margin-bottom: 1.25rem; }

/* ---------------------------------------------------------------------------
   Page header (title + action button row)
--------------------------------------------------------------------------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-header h1 { margin: 0; font-size: 1.75rem; font-weight: 300; letter-spacing: -.015em; }

/* ---------------------------------------------------------------------------
   Section titles inside cards
--------------------------------------------------------------------------- */
.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}
.section-hint {
    color: var(--color-muted);
    font-size: 0.875rem;
    margin: -0.5rem 0 1rem;
}

/* ---------------------------------------------------------------------------
   Stat cards
--------------------------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card { text-align: center; padding: 1.25rem 1rem; }
.stat-card--warning { border-color: var(--color-warning); background: var(--color-warning-soft); }
.stat-card--error   { border-color: var(--color-error);   background: var(--color-error-soft); }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--color-muted); margin-top: 0.35rem; }
.stat-delta { font-size: 0.72rem; color: var(--color-muted); margin-top: 0.3rem; }
/* Arrow + magnitude are colored by whether the move is good for that metric
   (more solar is good, more grid import is not); the trailing "vs previous
   period" text stays muted. */
.stat-delta-val--good { color: var(--color-success); font-weight: 600; }
.stat-delta-val--bad  { color: var(--color-error);   font-weight: 600; }

/* ---------------------------------------------------------------------------
   Tables
--------------------------------------------------------------------------- */
/* Table card header: title left, actions (CSV download) right */
.table-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.75rem;
}

/* Collapsible table container */
.table-details summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--color-muted);
    padding: 0.25rem 0;
    user-select: none;
}
.table-details summary:hover { color: var(--color-text); }
.table-details[open] summary { margin-bottom: 0.5rem; }

/* Scroll containment: wrap wide tables so the page never scrolls sideways */
.table-scroll {
    overflow-x: auto;
    max-height: 480px;
    overflow-y: auto;
}
.table-scroll .table th {
    position: sticky;
    top: 0;
    background: var(--color-surface);
    z-index: 1;
    box-shadow: 0 1px 0 var(--color-border);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-muted);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
}
.table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--color-bg); }
.table a { color: var(--color-primary); text-decoration: none; }
.table a:hover { text-decoration: underline; }
.table code { font-size: 0.85rem; background: var(--color-bg); padding: 0.1rem 0.35rem; border-radius: 3px; }

/* ---------------------------------------------------------------------------
   Badges
--------------------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-muted   { background: var(--color-surface-2);    color: var(--color-muted); }
.badge-error   { background: var(--color-error-soft);   color: var(--color-error); }

/* ---------------------------------------------------------------------------
   Form grid (2-column layout for admin forms)
--------------------------------------------------------------------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0 1.5rem;
}
.form-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-top: 0.25rem;
}

/* ---------------------------------------------------------------------------
   Detail view (site profile display)
--------------------------------------------------------------------------- */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}
.detail-heading {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-muted);
    margin: 0 0 0.5rem;
}
.detail-list { margin: 0; }
.detail-list dt {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-top: 0.5rem;
}
.detail-list dd {
    margin: 0;
    font-size: 0.95rem;
}

/* ---------------------------------------------------------------------------
   Log panel
--------------------------------------------------------------------------- */
.log-panel {
    background: #0B0D0F;
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
}
.log-line {
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}
.log-line--error    { color: #f87171; }
.log-line--critical { color: #fb923c; font-weight: 600; }

/* ---------------------------------------------------------------------------
   Range picker (client dashboard)

   Header trio  [ < ][ current range ][ > ]  with a popover holding the quick
   ranges, a custom from/to form, and the resolution toggle.
--------------------------------------------------------------------------- */
.rangepicker {
    position: relative;          /* anchors .rangepicker__pop */
    display: inline-block;
    margin-bottom: 1.25rem;
}

/* The three controls read as one joined pill. */
.rangepicker__nav { display: flex; align-items: stretch; }

.rangepicker__arrow,
.rangepicker__label {
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.rangepicker__arrow:hover,
.rangepicker__label:hover { background: var(--color-bg); }

.rangepicker__arrow {
    padding: 0.4rem 0.85rem;
    font-size: 1.1rem;
    line-height: 1.1;
}
.rangepicker__arrow:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
    border-right: 0;
}
.rangepicker__arrow:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
    border-left: 0;
}

.rangepicker__label {
    min-width: 280px;
    padding: 0.4rem 1rem;
    font-weight: 500;
}
.rangepicker__label::after {
    content: '';
    display: inline-block;
    margin-left: 0.5rem;
    border: 4px solid transparent;
    border-top-color: var(--color-muted);
    transform: translateY(2px);
}

/* ── Popover ─────────────────────────────────────────────────────────── */
.rangepicker__pop {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 200;                /* clears the sidebar (z-index 100) */
    width: min(640px, calc(100vw - 3rem));
    padding: 1rem 1.25rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
/* Explicit: a display rule below would otherwise defeat the hidden attribute. */
.rangepicker__pop[hidden] { display: none; }

/* Flipped when the popover would overflow the viewport's right edge. */
.rangepicker__pop--right { left: auto; right: 0; }

.rangepicker__cols {
    display: grid;
    grid-template-columns: 1fr auto 200px;
    gap: 1.25rem;
}
.rangepicker__rule { width: 1px; background: var(--color-border); }

.rangepicker__heading {
    margin: 0 0 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
}
.rangepicker__heading--sub { margin-top: 1rem; }

.rangepicker__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.1rem 0.75rem;
    align-items: start;
}
.rangepicker__col { list-style: none; margin: 0; padding: 0; }

.rangepicker__preset {
    display: block;
    padding: 0.25rem 0.5rem;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--color-primary);
    text-decoration: none;
    white-space: nowrap;
}
.rangepicker__preset:hover { background: var(--color-bg); }
.rangepicker__preset--active {
    border-color: var(--color-primary);
    color: var(--color-text);
    font-weight: 600;
}

/* ── Custom range ────────────────────────────────────────────────────── */
.rangepicker__custom-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}
.rangepicker__close {
    border: 0;
    background: none;
    color: var(--color-muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0 0 0.5rem;
}
.rangepicker__close:hover { color: var(--color-text); }

.rangepicker__field-label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.8rem;
    color: var(--color-text);
}
.rangepicker__pair {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.rangepicker__date,
.rangepicker__time {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    min-width: 0;
    transition: border-color .15s;
}
.rangepicker__date { flex: 1 1 60%; }
.rangepicker__time { flex: 1 1 40%; }

.rangepicker__date:focus,
.rangepicker__time:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.rangepicker__apply { margin-top: 0.25rem; }

/* ── Resolution row ──────────────────────────────────────────────────── */
.rangepicker__res {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--color-border);
}
.rangepicker__res-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    margin-right: 0.2rem;
}
.rangepicker__res-btn {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.82rem;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.rangepicker__res-btn:hover { background: var(--color-bg); }
.rangepicker__res-btn--active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-on-primary);
    font-weight: 600;
}

/* Narrow screens: the popover becomes an inline expander rather than an
   overlay, which also sidesteps any right-edge clipping. */
@media (max-width: 900px) {
    .rangepicker,
    .rangepicker__label { width: 100%; }
    .rangepicker__label { min-width: 0; }
    .rangepicker__nav { width: 100%; }
    .rangepicker__label { flex: 1; }

    .rangepicker__pop {
        position: static;
        width: 100%;
        box-shadow: none;
        margin-top: 0.5rem;
    }
    .rangepicker__cols { grid-template-columns: 1fr; }
    .rangepicker__rule { display: none; }
    .rangepicker__grid { grid-template-columns: repeat(2, 1fr); }
}

/* Toast shown when the nav arrows hit the end of the available data. */
#navToast {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-text);
    color: var(--color-surface);
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
    white-space: nowrap;
}
#navToast.show { opacity: 1; }

/* Still used by the admin ENTSO-E page's own preset row. */
.range-btn {
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.82rem;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.range-btn:hover { background: var(--color-bg); }

.range-btn--active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-on-primary);
    font-weight: 600;
}

/* Navigation-in-progress feedback: busy cursor + sweeping top bar */
body.range-loading { cursor: progress; }
body.range-loading::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
    animation: range-loading-sweep 1s linear infinite;
    z-index: 9999;
    pointer-events: none;
}
@keyframes range-loading-sweep {
    from { transform: translateX(-100%); }
    to   { transform: translateX(100%); }
}

/* ---------------------------------------------------------------------------
   Chart layout
--------------------------------------------------------------------------- */
.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .chart-row { grid-template-columns: 1fr; }
}

.chart-wrap {
    position: relative;
    height: 280px;
}
/* Required for chartjs-plugin-zoom touch/pinch events on mobile */
.chart-wrap canvas {
    touch-action: none;
}

.chart-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.72rem;
    color: var(--color-muted);
    min-height: 1.6rem;
}

/* ---------------------------------------------------------------------------
   Empty / no-data state
--------------------------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--color-muted);
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.empty-state h2,
.empty-state h3 {
    color: var(--color-text);
    margin: 0 0 0.5rem;
}

.empty-state p {
    max-width: 480px;
    margin: 0.4rem auto;
    font-size: 0.95rem;
}

/* ---------------------------------------------------------------------------
   Misc
--------------------------------------------------------------------------- */
.text-muted { color: var(--color-muted); }
.text-muted a { color: var(--color-primary); }

/* ---------------------------------------------------------------------------
   Sidebar layout (authenticated pages)
--------------------------------------------------------------------------- */
body.sidebar-layout {
    display: flex;
    min-height: 100vh;
    background: var(--color-bg);
    overflow-x: hidden;
}

.sidebar {
    width: 220px;
    background: var(--color-bg);
    border-right: 1px solid var(--color-line-soft);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 100;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed: narrow strip */
body.sidebar-collapsed .sidebar {
    width: 56px;
}

/* Hover on collapsed: expand as overlay (content doesn't move) */
body.sidebar-collapsed .sidebar:hover {
    width: 220px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: 1.05rem;
    padding: 1.25rem 1rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    letter-spacing: -0.01em;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-logo-icon { flex-shrink: 0; display: block; width: 24px; height: 14px; }
.sidebar-logo-icon img { display: block; width: 24px; height: 14px; }

/* Wordmark, as on gatherenergy.nl: "Gather" bold cyan, "ENERGY" thin caps */
.wordmark { display: inline-flex; align-items: baseline; gap: 6px; letter-spacing: -.01em; color: var(--color-text); }
.wordmark-a { font-weight: 700; color: var(--color-primary); }
.wordmark-b { font-weight: 200; letter-spacing: .14em; text-transform: uppercase; font-size: .86em; }

.sidebar-logo-text {
    white-space: nowrap;
    transition: opacity 0.15s;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
}

.nav-section-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    padding: 0.9rem 1rem 0.3rem;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--color-text-2);
    text-decoration: none;
    padding: 0.45rem 1rem;
    font-size: 0.875rem;
    border-radius: 4px;
    margin: 0 0.5rem;
    transition: background 0.12s, color 0.12s;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--color-text); }

.nav-item--active {
    background: var(--color-primary-soft);
    color: var(--color-primary) !important;
    font-weight: 600;
}
.nav-item--active:hover { background: var(--color-primary-soft); }

/* Shared icon + label styles */
.nav-icon {
    flex-shrink: 0;
    width: 1.1rem;
    text-align: center;
    opacity: 0.85;
}

.nav-icon svg,
.logout-icon svg {
    display: block;
    margin: 0 auto;
}

.nav-label {
    white-space: nowrap;
    transition: opacity 0.15s;
}

/* i-ESS control state beside a site in the sidebar. Only shadow and live get a pill:
   'off' is the default for most sites, and a pill on every row would bury the two that
   matter. Colours sit on the dark sidebar, so they are the light tints of the badges. */
.iess-pill {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 1.35;
    vertical-align: middle;
}
.iess-pill--live   { background: rgba(74,222,128,.18); color: var(--color-success); }
.iess-pill--shadow { background: rgba(251,191,36,.18); color: var(--color-warning); }

/* Site group: collapsible container */
.nav-sub-list {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease;
}
.nav-site-group--open .nav-sub-list {
    max-height: 400px;
}

.nav-site {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    color: var(--color-text-2);
    background: none;
    border: none;
    text-align: left;
    text-decoration: none;
    padding: 0.4rem 1rem 0.4rem 1.25rem;
    font-size: 0.875rem;
    font-family: inherit;
    transition: color 0.12s;
    cursor: pointer;
}

.nav-site:hover { color: var(--color-text); }

.nav-site--active {
    color: var(--color-text);
    font-weight: 500;
}

.nav-chevron {
    font-size: 0.65rem;
    opacity: 0.7;
    flex-shrink: 0;
    width: 0.8rem;
    text-align: center;
}

.nav-sub-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--color-muted);
    text-decoration: none;
    padding: 0.3rem 1rem 0.3rem 2.35rem;
    font-size: 0.83rem;
    transition: color 0.12s, padding-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-sub-item:hover { color: var(--color-text-2); }

.nav-sub-item--active {
    color: var(--color-primary);
    font-weight: 500;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-footer-user {
    color: var(--color-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.15s;
}

.sidebar-footer .btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--color-text-2);
    font-size: 0.8rem;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius);
    text-decoration: none;
    transition: background 0.12s;
    cursor: pointer;
}

.sidebar-footer .btn-logout:hover {
    background: rgba(255,255,255,0.08);
    color: var(--color-text);
}

.logout-icon { display: none; font-size: 1rem; }
.logout-label { white-space: nowrap; }

.sidebar-content {
    margin-left: 220px;
    padding: 2rem 1.5rem;
    min-width: 0;
    flex: 1;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.sidebar-collapsed .sidebar-content {
    margin-left: 56px;
}

/* Sidebar divider between nav sections */
.nav-divider {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.07);
    margin: 0.5rem 0;
}

/* ---------------------------------------------------------------------------
   Collapsed sidebar — centre all icons, hide labels
--------------------------------------------------------------------------- */

/* Logo: hide text, keep ⚡ icon */
body.sidebar-collapsed .sidebar-logo                    { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .sidebar-logo-text               { opacity: 0; width: 0; overflow: hidden; }
body.sidebar-collapsed .sidebar:hover .sidebar-logo     { justify-content: flex-start; padding-left: 1rem; padding-right: 1rem; }
body.sidebar-collapsed .sidebar:hover .sidebar-logo-text { opacity: 1; width: auto; overflow: visible; }

/* Collapse labels to zero width so they don't consume flex space */
body.sidebar-collapsed .nav-label   { opacity: 0; width: 0; overflow: hidden; }

/* Restore labels on hover */
body.sidebar-collapsed .sidebar:hover .nav-label   { opacity: 1; width: auto; overflow: visible; }

/* Chevron stays visible — it is the icon for site rows.
   Make it slightly larger so it reads well in the 56px strip. */
body.sidebar-collapsed .nav-chevron { font-size: 0.8rem; }
body.sidebar-collapsed .sidebar:hover .nav-chevron { font-size: 0.65rem; }

/* All nav rows: gap 0 + centre so the lone icon sits mid-strip */
body.sidebar-collapsed .nav-item {
    gap: 0;
    justify-content: center;
    padding: 0.45rem 0;
    margin: 0;
    border-radius: 0;
}
body.sidebar-collapsed .nav-site     { gap: 0; justify-content: center; padding: 0.4rem 0; }
body.sidebar-collapsed .nav-sub-item { gap: 0; justify-content: center; padding: 0.4rem 0; }

/* Restore full layout on hover */
body.sidebar-collapsed .sidebar:hover .nav-item {
    gap: 0.65rem;
    justify-content: flex-start;
    padding: 0.45rem 1rem;
    margin: 0 0.5rem;
    border-radius: 4px;
}
body.sidebar-collapsed .sidebar:hover .nav-site     { gap: 0.4rem; justify-content: flex-start; padding: 0.4rem 1rem 0.4rem 1.25rem; }
body.sidebar-collapsed .sidebar:hover .nav-sub-item { gap: 0.6rem; justify-content: flex-start; padding: 0.3rem 1rem 0.3rem 2.35rem; }

/* Section label (SITES) */
body.sidebar-collapsed .nav-section-label               { opacity: 0; padding-top: 0.3rem; padding-bottom: 0.3rem; }
body.sidebar-collapsed .sidebar:hover .nav-section-label { opacity: 1; padding-top: 0.9rem; padding-bottom: 0.3rem; }

/* Hide sidebar-nav scrollbar when collapsed; restore on hover */
body.sidebar-collapsed .sidebar-nav                     { overflow: hidden; }
body.sidebar-collapsed .sidebar:hover .sidebar-nav      { overflow-y: auto; }

/* Footer: centre and hide username */
body.sidebar-collapsed .sidebar-footer                  { align-items: center; padding: 0.9rem 0; }
body.sidebar-collapsed .sidebar-footer-user             { opacity: 0; height: 0; overflow: hidden; }
body.sidebar-collapsed .sidebar:hover .sidebar-footer   { align-items: stretch; padding: 0.9rem 1rem; }
body.sidebar-collapsed .sidebar:hover .sidebar-footer-user { opacity: 1; height: auto; overflow: visible; }

/* Logout: show ← arrow only, centred */
body.sidebar-collapsed .logout-label                    { display: none; }
body.sidebar-collapsed .logout-icon                     { display: block; }
body.sidebar-collapsed .sidebar:hover .logout-label     { display: block; }
body.sidebar-collapsed .sidebar:hover .logout-icon      { display: none; }

/* ---------------------------------------------------------------------------
   Sidebar toggle button (floats at sidebar right edge)
--------------------------------------------------------------------------- */
.sidebar-toggle {
    position: fixed;
    top: 50px;
    left: 208px;          /* 220 - 12: centred on right edge */
    width: 24px;
    height: 24px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    color: var(--color-text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 101;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.15s, color 0.15s;
    font-size: 13px;
    line-height: 1;
}

.sidebar-toggle:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
}

.sidebar-toggle-icon {
    display: inline-block;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    /* ‹ points left (expanded = hide). Rotated = › (collapsed = show) */
}

body.sidebar-collapsed .sidebar-toggle {
    left: 44px;           /* 56 - 12 */
}

body.sidebar-collapsed .sidebar-toggle-icon {
    transform: rotate(180deg);
}

/* ---------------------------------------------------------------------------
   Sidebar backdrop (mobile overlay close)
--------------------------------------------------------------------------- */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 98;
}

/* ---------------------------------------------------------------------------
   Responsive — mobile (< 768 px)
--------------------------------------------------------------------------- */
@media (max-width: 767px) {
    /* Sidebar slides in from left as overlay; never pushes content */
    .sidebar {
        width: 220px !important;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }

    body.sidebar-mobile-open .sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

    /* Disable hover-expand on touch devices */
    body.sidebar-collapsed .sidebar:hover {
        width: 220px !important;
        box-shadow: none;
    }

    /* Content always fills full width on mobile */
    .sidebar-content {
        margin-left: 0 !important;
        padding: 1.25rem 1rem;
        transition: none;
    }

    /* Toggle button: top-left corner when sidebar is hidden */
    .sidebar-toggle {
        left: 12px;
        top: 50px;
        transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    body.sidebar-mobile-open .sidebar-toggle {
        left: 208px;
    }

    /* Rotate icon: on mobile, closed = ›, open = ‹ */
    .sidebar-toggle-icon {
        transform: rotate(180deg);
    }

    body.sidebar-mobile-open .sidebar-toggle-icon {
        transform: rotate(0deg);
    }

    body.sidebar-mobile-open .sidebar-backdrop {
        display: block;
    }
}

/* --------------------------------------------------------------------------
   Fleet Health (admin)
   -------------------------------------------------------------------------- */
.health-filters { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* One line per finding. Left rule carries the severity so the column stays
   scannable when a site has several findings at once. */
.finding {
    font-size: 0.8rem;
    line-height: 1.35;
    padding: 0.15rem 0 0.15rem 0.5rem;
    border-left: 3px solid var(--color-border);
    margin-bottom: 0.2rem;
}
.finding:last-child        { margin-bottom: 0; }
.finding--critical         { border-left-color: var(--color-error);   color: var(--color-error); }
.finding--warning          { border-left-color: var(--color-warning); color: var(--color-warning); }
.finding--info             { border-left-color: var(--color-border);  color: var(--color-muted); }
