/* =============================================================
   Dashboard อ่างเก็บน้ำ ภูเก็ต — Stylesheet
   ============================================================= */

/* ── Reset & Base ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html { font-size: 16px; }
body {
    font-family: 'Sarabun', sans-serif;
    background: #daedf8;
    background-image:
        radial-gradient(ellipse 100% 65% at 0% -5%,  rgba(8,65,120,.18) 0%, transparent 52%),
        radial-gradient(ellipse 80% 60% at 105% 108%, rgba(6,115,148,.14) 0%, transparent 50%),
        radial-gradient(ellipse 70% 80% at 50% 45%,  rgba(186,230,253,.30) 0%, transparent 68%);
    background-attachment: fixed;
    color: #1a2332;
    min-height: 100vh;
    line-height: 1.5;
}

/* ── Top Navigation Bar ── */
.topbar {
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(168,210,245,.7);
    display: flex;
    align-items: center;
    height: 62px;
    padding: 0 40px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 24px rgba(18,83,160,.12);
}
.topbar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2.5px;
    background: linear-gradient(to right, #1253a0 0%, #1d91c8 30%, #0fb8a8 60%, #10b981 80%, transparent 100%);
    opacity: .9;
}
.tb-brand {
    display: flex;
    align-items: center;
    gap: 11px;
}
.tb-icon {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(145deg, #1253a0, #1d91c8 60%, #0fb8a8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(18,83,160,.45), inset 0 1px 0 rgba(255,255,255,.18);
    animation: iconPulse 5s ease-in-out infinite;
}
@keyframes iconPulse {
    0%, 100% { box-shadow: 0 4px 14px rgba(18,83,160,.45), inset 0 1px 0 rgba(255,255,255,.18); }
    50%       { box-shadow: 0 7px 26px rgba(18,83,160,.65), 0 0 32px rgba(29,180,200,.2), inset 0 1px 0 rgba(255,255,255,.18); }
}
.tb-title {
    font-size: 15px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -.2px;
}
.tb-sub {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 1px;
    letter-spacing: .3px;
}
.tb-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 9px;
}
.badge-live {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px 4px 8px;
    border-radius: 20px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    font-size: 11.5px;
    font-weight: 600;
    color: #16a34a;
}
.dot-live {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    animation: blink 2s infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: .35; }
}
.badge-date {
    padding: 7px 18px;
    border-radius: 20px;
    background: linear-gradient(to bottom, #f8fafc, #f1f5f9);
    border: 1px solid #dde3ec;
    font-size: 14px;
    color: #374151;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
/* ── Rain badge on card ─────────────────────────────────────── */
.card-rain {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 7px 0 4px;
    padding: 7px 12px;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 600;
    border: 1px solid;
    transition: box-shadow .15s, transform .15s, filter .15s;
}
.card-rain--wet {
    background: linear-gradient(to right, #eff6ff, #dbeafe);
    border-color: #93c5fd;
    color: #1d4ed8;
    box-shadow: 0 1px 4px rgba(29,78,216,.1);
}
.card-rain--dry {
    background: linear-gradient(to right, #fef3c7, #fefce8);
    border-color: #fcd34d;
    color: #92400e;
    box-shadow: 0 1px 4px rgba(146,64,14,.08);
}
.cr-icon  { font-size: 15px; line-height: 1; flex-shrink: 0; }
.cr-label { font-weight: 700; }
.cr-sub   { font-size: 11.5px; color: #60a5fa; font-weight: 500; }
/* dry streak badge */
.cr-dry-streak {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    padding: 1px 7px;
    border-radius: 20px;
    background: rgba(0,0,0,.06);
    color: #92400e;
}
.cr-dry-warn { color: #b45309; background: #fef3c7; font-weight: 700; }
.cr-dry-crit { color: #dc2626; background: #fee2e2; font-weight: 800; }
/* clickable rain badge */
.card-rain--clickable {
    cursor: pointer;
    user-select: none;
}
.card-rain--clickable:hover {
    filter: brightness(.95);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.cr-history-hint {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    color: #92400e;
    white-space: nowrap;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,.12);
    background: rgba(255,255,255,.55);
    opacity: .7;
    transition: opacity .15s, background .15s;
    flex-shrink: 0;
}
.card-rain--wet .cr-history-hint { color: #1d4ed8; }
.card-rain--clickable:hover .cr-history-hint {
    opacity: 1;
    background: rgba(255,255,255,.9);
}
html.dark .card-rain--wet { background: linear-gradient(to right,#0c1a2e,#0f2847); border-color: #1e3a6e; color: #7dd3fc; }
html.dark .card-rain--dry { background: linear-gradient(to right,#2d1f03,#241a04); border-color: #78350f; color: #fcd34d; }
html.dark .cr-dry-warn { background: #2d2007; color: #fbbf24; }
html.dark .cr-dry-crit { background: #2d0f0f; color: #f87171; }
html.dark .cr-history-hint { border-color: rgba(255,255,255,.15); background: rgba(255,255,255,.08); color: inherit; }
/* ── Rain History Modal ── */
.rh-modal {
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 32px 80px rgba(0,0,0,.28), 0 4px 16px rgba(0,0,0,.08);
    width: min(660px, 96vw);
    max-height: 92vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: fcModalIn .22s cubic-bezier(.4,0,.2,1) both;
}
.rh-modal-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 22px 26px 18px;
    background: linear-gradient(135deg, #0f3460 0%, #1253a0 45%, #1d91c8 80%, #0fb8a0 100%);
    position: relative;
    overflow: hidden;
}
.rh-modal-head::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}
.rh-modal-icon {
    font-size: 34px;
    line-height: 1;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,.3));
    flex-shrink: 0;
    position: relative;
}
.rh-modal-titles { flex: 1; position: relative; }
.rh-modal-title { font-size: 18px; font-weight: 800; color: #fff; letter-spacing: -.2px; }
.rh-modal-sub   { font-size: 12px; color: rgba(255,255,255,.75); margin-top: 3px; }
.rh-modal-close {
    background: rgba(255,255,255,.18);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 10px;
    width: 36px; height: 36px;
    font-size: 15px;
    cursor: pointer;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
    position: relative;
}
.rh-modal-close:hover { background: rgba(255,255,255,.3); }
/* Summary strip */
.rh-modal-summary {
    display: flex;
    gap: 0;
    background: linear-gradient(to bottom, #eaf4fd, #f0f8ff);
    border-bottom: 1px solid rgba(168,210,245,.6);
}
.rhs-item {
    flex: 1;
    padding: 12px 14px;
    text-align: center;
    border-right: 1px solid rgba(168,210,245,.5);
}
.rhs-item:last-child { border-right: none; }
.rhs-val  { font-size: 20px; font-weight: 900; color: #0f2744; letter-spacing: -.5px; line-height: 1.1; }
.rhs-unit { font-size: 12px; font-weight: 500; color: #64748b; }
.rhs-lbl  { font-size: 10px; color: #64748b; margin-top: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.rhs-blue   { color: #1d6fa4; }
.rhs-orange { color: #ea580c; }
/* Legend */
.rh-modal-legend {
    display: flex;
    gap: 12px;
    padding: 8px 18px;
    background: #f8fafc;
    border-bottom: 1px solid #e9eef4;
    flex-wrap: wrap;
}
.rh-leg {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 4px;
}
.rh-leg--heavy { color: #1e40af; }
.rh-leg--mod   { color: #b45309; }
.rh-leg--light { color: #15803d; }
.rh-leg--dry   { color: #9ca3af; }
/* Table */
.rh-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-family: 'Sarabun', sans-serif;
}
.rh-table thead th {
    padding: 9px 16px;
    text-align: left;
    font-size: 10.5px;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .8px;
    background: #f8fafc;
    border-bottom: 1px solid #e9eef4;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}
.rh-table tbody tr { border-bottom: 1px solid #f1f5f9; transition: background .1s; }
.rh-table tbody tr:hover { background: #f0f7ff; }
.rh-row--dry { opacity: .65; }
.rh-table tbody td { padding: 8px 16px; vertical-align: middle; }
.rh-date { font-weight: 700; color: #374151; white-space: nowrap; font-size: 12.5px; }
.rh-rain-val { font-size: 13px; white-space: nowrap; min-width: 80px; }
.rh-rain-val strong { font-weight: 800; }
.rh-heavy strong { color: #1e40af; }
.rh-mod   strong { color: #b45309; }
.rh-light strong { color: #15803d; }
.rh-zero  { color: #d1d5db; }
.rh-bar-cell { width: 40%; padding: 8px 12px; }
.rh-bar-wrap {
    width: 100%;
    height: 8px;
    background: #f1f5f9;
    border-radius: 99px;
    overflow: hidden;
}
.rh-bar {
    height: 100%;
    border-radius: 99px;
    transition: width .4s cubic-bezier(.4,0,.2,1);
}
.rh-bar--rh-heavy { background: linear-gradient(to right, #1e40af, #3b82f6); }
.rh-bar--rh-mod   { background: linear-gradient(to right, #d97706, #fbbf24); }
.rh-bar--rh-light { background: linear-gradient(to right, #059669, #34d399); }
.rh-temp { color: #ea580c; font-weight: 700; white-space: nowrap; }
.rh-hum  { color: #0369a1; font-weight: 700; white-space: nowrap; }
html.dark .rh-modal { background: #1a1d27; }
html.dark .rh-modal-summary { background: #141a2a; border-color: #2d3f60; }
html.dark .rhs-item { border-color: #2d3f60; }
html.dark .rhs-val  { color: #f1f5f9; }
html.dark .rh-modal-legend { background: #141620; border-color: #2d3148; }
html.dark .rh-table thead th { background: #141620; border-color: #2d3148; color: #64748b; }
html.dark .rh-table tbody tr { border-color: #1e2235; }
html.dark .rh-table tbody tr:hover { background: #1a2535; }
html.dark .rh-date  { color: #e2e8f0; }
html.dark .rh-temp  { color: #fb923c; }
html.dark .rh-hum   { color: #7dd3fc; }
html.dark .rh-bar-wrap { background: #2d3148; }
/* rain-adjusted forecast row */
.card-rain-adj {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 4px 0 2px;
    padding: 5px 10px;
    border-radius: 8px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    font-size: 12px;
    color: #15803d;
}
.cra-icon { font-size: 13px; line-height: 1; }
.cra-txt  strong { font-weight: 700; }
.cra-gain {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    color: #059669;
    white-space: nowrap;
}
html.dark .card-rain-adj  { background: #052e16; border-color: #166534; color: #4ade80; }
html.dark .cra-gain        { color: #22c55e; }
/* ── Correlation chart box ─────────────────────────────────────── */
.corr-box {
    padding: 20px 24px 16px;
}
.corr-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}
.corr-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #1e293b;
}
.corr-vs { color: #94a3b8; font-weight: 400; margin: 0 4px; }
.corr-legend {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #64748b;
}
.corr-leg-item {
    display: flex;
    align-items: center;
    gap: 5px;
}
.corr-leg-bar {
    width: 12px; height: 10px;
    border-radius: 2px;
    background: rgba(56,189,248,.7);
    flex-shrink: 0;
}
.corr-leg-line {
    width: 16px; height: 2.5px;
    border-radius: 2px;
    background: var(--leg-color, #10b981);
    background-image: repeating-linear-gradient(
        90deg,
        var(--leg-color, #10b981) 0,
        var(--leg-color, #10b981) var(--dash, 100%),
        transparent var(--dash, 100%),
        transparent calc(var(--dash, 100%) + var(--gap, 0px))
    );
    flex-shrink: 0;
}
.corr-canvas-wrap { position: relative; }
.corr-note {
    margin-top: 10px;
    font-size: 11.5px;
    color: #94a3b8;
    line-height: 1.5;
}
html.dark .corr-title { color: #e2e8f0; }
html.dark .corr-note  { color: #4b5563; }
/* ── Correlation insight box ────────────────────────────────── */
.corr-insight {
    margin-top: 10px;
    padding: 14px 18px 12px;
    border-radius: 10px;
    background: linear-gradient(to bottom, #f3f9fe, #eef5fb);
    border: 1px solid rgba(168,210,240,.7);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ci-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}
.ci-stat {
    flex: 1 1 120px;
    padding: 0 18px 0 0;
    margin: 0 18px 0 0;
    border-right: 1px solid #e2e8f0;
}
.ci-stat:last-child { border-right: none; margin-right: 0; padding-right: 0; }
.ci-stat-lbl  { font-size: 11px; color: #94a3b8; margin-bottom: 3px; }
.ci-stat-val  { font-size: 18px; font-weight: 700; color: #1e293b; line-height: 1.2; }
.ci-stat-unit { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.ci-ok   { color: #10b981; }
.ci-warn { color: #f59e0b; }
.ci-crit { color: #ef4444; }
.ci-guide {
    list-style: none;
    margin: 0; padding: 0;
    display: flex; flex-direction: column; gap: 5px;
}
.ci-guide li {
    font-size: 12px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    line-height: 1.6;
}
.ci-swatch {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}
.ci-swatch-bar  { background: rgba(56,189,248,.7); height: 9px; }
.ci-swatch-dash {
    height: 2.5px; width: 14px;
    background: repeating-linear-gradient(
        90deg,
        var(--sc, #94a3b8) 0, var(--sc, #94a3b8) 4px,
        transparent 4px, transparent 7px
    );
}
/* summary sentence */
.ci-summary {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12.5px;
    line-height: 1.65;
    border: 1px solid;
}
.ci-summary--crit { background: #fff1f2; border-color: #fecdd3; color: #9f1239; }
.ci-summary--warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.ci-summary--ok   { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.ci-sum-icon { font-size: 15px; line-height: 1.65; flex-shrink: 0; }
.ci-sum-body strong { font-weight: 700; }
html.dark .ci-summary--crit { background: #2d0a0f; border-color: #7f1d1d; color: #fca5a5; }
html.dark .ci-summary--warn { background: #2d1f03; border-color: #78350f; color: #fcd34d; }
html.dark .ci-summary--ok   { background: #052e16; border-color: #14532d; color: #86efac; }
html.dark .corr-insight  { background: #1a1d27; border-color: #2d3148; }
html.dark .ci-stats      { border-color: #2d3148; }
html.dark .ci-stat       { border-color: #2d3148; }
html.dark .ci-stat-lbl   { color: #475569; }
html.dark .ci-stat-val   { color: #f1f5f9; }
html.dark .ci-stat-unit  { color: #475569; }
html.dark .ci-guide li   { color: #475569; }
/* ── Weather strip ──────────────────────────────────────────── */
.tb-weather {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 auto;
    padding: 5px 14px;
    border-radius: 20px;
    background: linear-gradient(to bottom, #f0f9ff, #e0f2fe);
    border: 1px solid #bae6fd;
    box-shadow: 0 1px 4px rgba(14,165,233,.1);
    font-size: 12.5px;
    color: #0c4a6e;
    white-space: nowrap;
    cursor: default;
}
.tw-item {
    display: flex;
    align-items: center;
    gap: 3px;
}
.tw-icon { font-size: 13px; line-height: 1; }
.tw-val  { font-weight: 700; }
.tw-sep  { color: #93c5fd; font-size: 11px; }
.tw-cloud {
    font-weight: 500;
    font-size: 12px;
    color: #1e40af;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-upload-nav {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 8px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    font-size: 12px;
    font-weight: 600;
    color: #1d4ed8;
    text-decoration: none;
    transition: background .15s;
}
.btn-upload-nav:hover { background: #dbeafe; }
.badge-refresh {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #9ca3af;
}
#refreshCountdown {
    min-width: 72px;
    text-align: right;
}
.btn-refresh {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e3e8f0;
    font-size: 11.5px;
    color: #374151;
    font-weight: 500;
    cursor: pointer;
    font-family: Sarabun, sans-serif;
    transition: background .15s;
}
.btn-refresh:hover { background: #e0f2fe; border-color: #bae6fd; color: #0369a1; }
.btn-refresh svg { flex-shrink: 0; }

/* ── System Progress Bar ── */
.sys-bar-wrap {
    display: flex;
    align-items: center;
    gap: 18px;
    border-radius: 16px;
    padding: 16px 22px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    border: 1px solid;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.sys-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    min-width: 160px;
}
.sys-bar-label {
    font-size: 11.5px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}
.sys-bar-pct {
    font-size: 22px;
    font-weight: 900;
    letter-spacing: -1px;
    line-height: 1;
}
.sys-bar-track {
    flex: 1;
    height: 12px;
    background: rgba(0,0,0,.08);
    border-radius: 99px;
    overflow: visible;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0,0,0,.1);
}
.sys-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width .9s cubic-bezier(.4,0,.2,1);
    position: relative;
}
.sys-bar-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, rgba(255,255,255,0) 30%, rgba(255,255,255,.3) 70%, rgba(255,255,255,0) 100%);
    border-radius: 99px;
}
.sys-bar-mark {
    position: absolute;
    top: -3px;
    width: 2px;
    height: 16px;
    background: #fff;
    border-radius: 1px;
    transform: translateX(-50%);
    opacity: .8;
}
.sys-bar-right {
    flex-shrink: 0;
    min-width: 160px;
    text-align: right;
}
.sys-bar-vol {
    font-size: 14px;
    color: #111827;
    white-space: nowrap;
}

/* ── Warning Banner ── */
.warn-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(to right, #fff7ed, #fffbf5);
    border: 1px solid #fed7aa;
    border-left: 4px solid #f97316;
    border-radius: 14px;
    padding: 14px 20px;
    margin-bottom: 22px;
    animation: slideDown .4s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 4px 16px rgba(249,115,22,.1);
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.warn-icon { font-size: 18px; flex-shrink: 0; }
.warn-body {
    flex: 1;
    font-size: 13px;
    color: #92400e;
    line-height: 1.5;
}
.warn-body strong { color: #b45309; }
.warn-item { white-space: nowrap; }
.warn-pct {
    font-weight: 700;
    color: #dc2626;
    margin-left: 3px;
}
.warn-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #b45309;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
    opacity: .7;
}
.warn-close:hover { opacity: 1; }

/* ── Page Wrapper ── */
.page {
    max-width: 1600px;
    margin: 0 auto;
    padding: 36px 40px 80px;
    animation: pageFadeIn .5s cubic-bezier(.4,0,.2,1) both;
}
@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Section Labels ── */
.sec-label {
    font-size: 11px;
    font-weight: 800;
    color: #2d4f72;
    text-transform: uppercase;
    letter-spacing: 1.8px;
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sec-label::before {
    content: '';
    width: 4px;
    height: 18px;
    background: linear-gradient(to bottom, #1253a0, #1d8fc8 50%, #10b981);
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(18,83,160,.45);
}
.sec-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, #dde3ec, transparent);
}

/* ── KPI Row ── */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
    margin-bottom: 34px;
}
.kpi {
    background: #fff;
    border: 1px solid rgba(168,210,240,.6);
    border-radius: 20px;
    padding: 26px 28px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 4px 18px rgba(18,83,160,.09), 0 1px 4px rgba(0,0,0,.04);
    transition: box-shadow .3s cubic-bezier(.4,0,.2,1), transform .3s cubic-bezier(.4,0,.2,1), border-color .3s;
    position: relative;
    overflow: visible;
    animation: cardIn .5s cubic-bezier(.4,0,.2,1) both;
}
.kpi:nth-child(1) { animation-delay: .05s; }
.kpi:nth-child(2) { animation-delay: .10s; }
.kpi:nth-child(3) { animation-delay: .15s; }
.kpi:nth-child(4) { animation-delay: .20s; }
.kpi:nth-child(5) { animation-delay: .25s; }
.kpi:nth-child(6) { animation-delay: .30s; }
@keyframes cardIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.kpi::after {
    content: '';
    position: absolute;
    bottom: 0; right: 0;
    width: 80px; height: 80px;
    background: radial-gradient(circle, rgba(29,111,164,.05) 0%, transparent 70%);
    pointer-events: none;
}
.kpi::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2.5px;
    background: linear-gradient(to right, #1d6fa4, #2ca0c4);
    opacity: 0;
    transition: opacity .3s;
    border-radius: 2px 2px 0 0;
}
.kpi:hover {
    box-shadow: 0 16px 40px rgba(18,83,160,.22), 0 4px 12px rgba(0,0,0,.06);
    transform: translateY(-5px);
    border-color: rgba(29,111,164,.35);
}
.kpi:hover::before { opacity: 1; }
.kpi-icon {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    box-shadow: 0 4px 12px rgba(0,0,0,.11), inset 0 1px 0 rgba(255,255,255,.6);
    background-image: linear-gradient(145deg, rgba(255,255,255,.45) 0%, rgba(255,255,255,0) 65%);
    transition: transform .3s cubic-bezier(.4,0,.2,1), box-shadow .3s;
}
.kpi:hover .kpi-icon {
    transform: scale(1.12) rotate(-6deg);
    box-shadow: 0 6px 18px rgba(0,0,0,.16), inset 0 1px 0 rgba(255,255,255,.6);
}
.kpi-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.kpi-info {
    font-size: 11px;
    color: #9ca3af;
    cursor: help;
    position: relative;
    font-style: normal;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}
.kpi-info::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: #f9fafb;
    font-size: 11px;
    font-weight: 400;
    padding: 6px 10px;
    border-radius: 7px;
    white-space: pre;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
    z-index: 999;
    min-width: 180px;
    text-align: left;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
.kpi-info:hover::after { opacity: 1; }
.kpi-val {
    font-size: 38px;
    font-weight: 900;
    color: #0f172a;
    line-height: 1.05;
    letter-spacing: -1.5px;
}
.kpi-unit {
    font-size: 12px;
    color: #1f2937;
    margin-top: 2px;
}

/* ── Reservoir Cards ── */
.cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 26px;
    margin-bottom: 36px;
}
.card {
    background: #fff;
    border: 1px solid rgba(168,210,240,.55);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 6px 24px rgba(18,83,160,.10), 0 1px 4px rgba(0,0,0,.05);
    transition: box-shadow .35s cubic-bezier(.4,0,.2,1), transform .35s cubic-bezier(.4,0,.2,1), border-color .35s;
    animation: cardIn .5s cubic-bezier(.4,0,.2,1) both;
}
.card:nth-child(1) { animation-delay: .07s; }
.card:nth-child(2) { animation-delay: .14s; }
.card:nth-child(3) { animation-delay: .21s; }
.card:hover {
    box-shadow: 0 24px 60px rgba(18,83,160,.22), 0 6px 18px rgba(0,0,0,.07);
    transform: translateY(-7px);
    border-color: rgba(29,111,164,.3);
}
.card:hover .card-foot { background: linear-gradient(to bottom, #f2f7fd, #ecf3fa); }
.card:hover .cf-val { transform: scale(1.05); }
.card-stripe {
    height: 8px;
    position: relative;
}
.card-stripe::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, rgba(255,255,255,0) 50%, rgba(255,255,255,.3) 100%);
}
.card-body {
    padding: 28px 30px 22px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-name {
    font-size: 16px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.4;
    flex: 1;
    margin-right: 8px;
}

/* Status Pills */
.pill {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: .3px;
}
.pill-g { background: linear-gradient(to bottom,#f0fdf4,#dcfce7); color: #15803d; border-color: #86efac; box-shadow: 0 1px 4px rgba(21,128,61,.12); }
.pill-w { background: linear-gradient(to bottom,#fefce8,#fef9c3); color: #a16207; border-color: #fde68a; box-shadow: 0 1px 4px rgba(161,98,7,.1); }
.pill-r { background: linear-gradient(to bottom,#fff1f2,#ffe4e6); color: #be123c; border-color: #fecdd3; box-shadow: 0 1px 4px rgba(190,18,60,.1); }

/* Percentage display */
.pct-row {
    display: flex;
    align-items: baseline;
    gap: 4px;
}
.pct-big {
    font-size: 68px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -4px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,.1));
}
.pct-sym {
    font-size: 20px;
    font-weight: 500;
    color: #9ca3af;
    margin-bottom: 2px;
}
.card-delta {
    font-size: 11.5px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 20px;
    margin-left: 4px;
    align-self: center;
    white-space: nowrap;
}
.delta-up   { background: #f0fdf4; color: #059669; }
.delta-down { background: #fff1f2; color: #dc2626; }
.delta-flat { background: #f8fafc; color: #94a3b8; }

/* Progress Bar */
.bar-wrap {
    background: #eaeff6;
    border-radius: 99px;
    height: 10px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,.08);
}
.bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width .8s cubic-bezier(.4,0,.2,1);
    position: relative;
}
.bar-fill::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: -60%;
    width: 60%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,.48) 50%, rgba(255,255,255,0) 100%);
    border-radius: 99px;
    animation: barShimmer 3s ease-in-out infinite;
    animation-delay: 1.5s;
}
@keyframes barShimmer {
    0%        { left: -60%; }
    60%, 100% { left: 130%; }
}

.card-vol { font-size: 15px; color: #111827; }
.card-date {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    color: #1f2937;
    font-weight: 400;
}
.card-forecast {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}
.fc-icon { font-size: 12px; }
.fc-good   { background: #f0fdf4; color: #059669; }
.fc-warn   { background: #fefce8; color: #b45309; }
.fc-danger { background: #fff1f2; color: #dc2626; }

/* Critical forecast badge (trend 7-day, 30% threshold) */
.card-critical {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 7px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 8px;
    background: #fff7ed;
    border: 1px dashed #fed7aa;
    color: #c2410c;
}
.card-critical.crit-already {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #dc2626;
}
.card-critical strong { font-weight: 800; }
.crit-date {
    margin-left: auto;
    font-size: 10.5px;
    font-weight: 500;
    background: rgba(255,255,255,.55);
    padding: 1px 6px;
    border-radius: 6px;
}
.crit-info {
    font-size: 11px;
    color: inherit;
    opacity: .6;
    cursor: help;
    position: relative;
    margin-left: 2px;
    flex-shrink: 0;
}
.crit-info::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    background: #1f2937;
    color: #f9fafb;
    font-size: 11px;
    font-weight: 400;
    padding: 6px 10px;
    border-radius: 7px;
    white-space: pre;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
    z-index: 999;
    min-width: 200px;
    text-align: left;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
.crit-info:hover::after { opacity: 1; }
.card-spark {
    margin-top: 10px;
    line-height: 0;
    width: 100%;
    height: 36px;
    position: relative;
}
.card-spark canvas,
.spark-canvas {
    width: 100% !important;
    height: 36px !important;
    display: block;
}
.card-vol strong { color: #1f2937; font-weight: 700; }

/* Card Footer (inflow/outflow) */
.card-foot {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid #edf0f6;
    background: linear-gradient(to bottom, #f8fafd, #f4f7fb);
}
.cf-item { padding: 16px 22px; text-align: center; }
.cf-item + .cf-item { border-left: 1px solid rgba(237,240,246,.8); }
.cf-val { font-size: 17px; font-weight: 800; transition: transform .25s cubic-bezier(.4,0,.2,1); }
.cf-key {
    font-size: 11px;
    color: #1f2937;
    margin-top: 3px;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: uppercase;
}

/* ── Chart Filter Bar ── */
.chart-filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 20px;
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(168,210,245,.75);
    border-radius: 16px;
    padding: 14px 22px;
    margin-bottom: 18px;
    box-shadow: 0 4px 20px rgba(18,83,160,.12), 0 1px 4px rgba(0,0,0,.04);
}
.cfb-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.cfb-icon { font-size: 15px; }
.cfb-lbl {
    font-size: 11.5px;
    font-weight: 700;
    color: #6b7280;
    white-space: nowrap;
    margin-right: 2px;
}
.cfb-btns {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}
.cfb-btn {
    padding: 5px 14px;
    border-radius: 8px;
    border: 1px solid #e3e8f0;
    background: #f8fafc;
    color: #374151;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Sarabun', sans-serif;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    white-space: nowrap;
}
.cfb-btn:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}
.cfb-btn-active {
    background: linear-gradient(135deg, #1253a0 0%, #1d8fd0 55%, #12b8b0 100%);
    border-color: #1566b0;
    color: #fff !important;
    box-shadow: 0 4px 14px rgba(18,83,160,.45), inset 0 1px 0 rgba(255,255,255,.18);
}
.cfb-btn-active:hover {
    background: linear-gradient(135deg, #0e4590 0%, #1780c0 55%, #0da8a0 100%);
    border-color: #0e4590;
}
/* ── Flow direction button: distinct semantic colors ── */
.cfb-btn-active[data-val="in"] {
    background: linear-gradient(135deg, #047857 0%, #10b981 100%);
    border-color: #059669;
    box-shadow: 0 4px 14px rgba(5,150,105,.40), inset 0 1px 0 rgba(255,255,255,.18);
}
.cfb-btn-active[data-val="in"]:hover {
    background: linear-gradient(135deg, #065f46 0%, #059669 100%);
    border-color: #047857;
}
.cfb-btn-active[data-val="out"] {
    background: linear-gradient(135deg, #b91c1c 0%, #f87171 100%);
    border-color: #dc2626;
    box-shadow: 0 4px 14px rgba(220,38,38,.38), inset 0 1px 0 rgba(255,255,255,.18);
}
.cfb-btn-active[data-val="out"]:hover {
    background: linear-gradient(135deg, #991b1b 0%, #ef4444 100%);
    border-color: #b91c1c;
}
.cfb-btn-active[data-val="both"] {
    background: linear-gradient(135deg, #4338ca 0%, #818cf8 100%);
    border-color: #4f46e5;
    box-shadow: 0 4px 14px rgba(79,70,229,.40), inset 0 1px 0 rgba(255,255,255,.18);
}
.cfb-btn-active[data-val="both"]:hover {
    background: linear-gradient(135deg, #3730a3 0%, #6366f1 100%);
    border-color: #4338ca;
}
/* flow view: keep navy-teal; rain/corr: amber */
.cfb-btn-active[data-val="corr"] {
    background: linear-gradient(135deg, #b45309 0%, #fbbf24 100%);
    border-color: #d97706;
    box-shadow: 0 4px 14px rgba(180,83,9,.38), inset 0 1px 0 rgba(255,255,255,.18);
}
.cfb-btn-active[data-val="corr"]:hover {
    background: linear-gradient(135deg, #92400e 0%, #f59e0b 100%);
    border-color: #b45309;
}
.cfb-divider {
    width: 1px;
    height: 28px;
    background: #e3e8f0;
    flex-shrink: 0;
}

/* ── Chart Panels ── */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    margin-bottom: 28px;
}
/* Flow chart grid always stays 1fr 1fr */
.flow-grid {
    margin-bottom: 28px;
    grid-template-columns: 1fr 1fr;
}
@media (max-width: 720px) {
    .flow-grid { grid-template-columns: 1fr; }
}
/* Per-reservoir filter bar inside flow chart panel */
.flow-res-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 22px 8px;
    background: #f8fafc;
    border-bottom: 1px solid rgba(237,240,246,.8);
    flex-wrap: wrap;
}
.panel {
    background: #fff;
    border: 1px solid rgba(168,210,240,.6);
    border-radius: 18px;
    box-shadow: 0 4px 24px rgba(18,83,160,.10), 0 1px 4px rgba(0,0,0,.04);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.panel-wide {
    background: #fff;
    border: 1px solid rgba(168,210,240,.6);
    border-radius: 18px;
    box-shadow: 0 4px 24px rgba(18,83,160,.10), 0 1px 4px rgba(0,0,0,.04);
    overflow: hidden;
    margin-bottom: 28px;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 22px 14px;
    background: linear-gradient(to bottom, #eaf4fd, #ddeefa);
    border-bottom: 1px solid rgba(175,215,245,.8);
    gap: 10px;
    position: relative;
}
.panel-head::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(to right, #1253a0, #1d91c8 35%, #0fb8a0 65%, #10b981 80%, rgba(16,185,129,.15));
    box-shadow: 0 1px 6px rgba(18,83,160,.3);
}
.panel-title {
    font-size: 13.5px;
    font-weight: 800;
    color: #0f2744;
}
.panel-sub {
    font-size: 13px;
    color: #1f2937;
    margin-top: 1px;
}
/* Flow chart subtitle colored hints */
.flow-chart-sub { color: #111827; }
.fsub-in  {
    display: inline-flex; align-items: center;
    color: #059669; font-weight: 700;
    background: #f0fdf4; border: 1px solid #86efac;
    border-radius: 5px; padding: 0 6px; font-size: 12px; line-height: 1.7;
}
.fsub-out {
    display: inline-flex; align-items: center;
    color: #dc2626; font-weight: 700;
    background: #fff1f2; border: 1px solid #fca5a5;
    border-radius: 5px; padding: 0 6px; font-size: 12px; line-height: 1.7;
}
.fsub-tip {
    color: #1d6fa4; font-weight: 600;
    background: #eff6ff; border: 1px solid #bfdbfe;
    border-radius: 5px; padding: 0 6px; font-size: 12px; line-height: 1.7;
    display: inline-flex; align-items: center;
}
html.dark .fsub-in  { background: #052e16; border-color: #166534; color: #4ade80; }
html.dark .fsub-out { background: #2d0f0f; border-color: #7f1d1d; color: #f87171; }
html.dark .fsub-tip { background: #0c1a2e; border-color: #1e3a6e; color: #7dd3fc; }
.panel-body { padding: 18px 20px 16px; flex: 1; min-height: 0; }

/* ── % Capacity chart legend note ── */
.pct-legend-note {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 12px;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid #e3e8f0;
    border-radius: 10px;
    font-size: 11.5px;
    color: #6b7280;
    line-height: 1.5;
}
.pln-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.pln-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}
.pln-red    .pln-dot { background: rgba(239,68,68,0.55); }
.pln-yellow .pln-dot { background: rgba(234,179,8,0.65); }
.pln-green  .pln-dot { background: rgba(16,185,129,0.55); }
.pln-item strong { color: #374151; font-weight: 700; }
.pln-sep { color: #d1d5db; font-size: 14px; }

/* Select Controls */
.sel-wrap {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.sel-lbl {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
}
select.sel {
    background: #f8fafc;
    border: 1px solid #e3e8f0;
    color: #374151;
    border-radius: 7px;
    padding: 5px 24px 5px 9px;
    font-size: 12px;
    font-family: 'Sarabun', sans-serif;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%239ca3af' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    transition: border-color .15s;
}
select.sel:focus {
    border-color: #1d6fa4;
    box-shadow: 0 0 0 3px rgba(29, 111, 164, .1);
}
.sel-divider {
    width: 1px;
    height: 16px;
    background: #e3e8f0;
    flex-shrink: 0;
}

/* ── Doughnut Gauge Panel ── */
.gauge-rows {
    display: flex;
    flex-direction: column;
    padding: 4px 0;
    flex: 1;
}
.gauge-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    border-bottom: 1px solid #f1f5f9;
    flex: 1;
    min-height: 0;
}
.g-chart { flex-shrink: 0; }
.g-info { flex: 1; min-width: 0; }
.g-name {
    font-size: 11.5px;
    font-weight: 500;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.g-pct {
    font-size: 26px;
    font-weight: 900;
    letter-spacing: -1px;
    line-height: 1;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,.08));
}
.g-sub {
    font-size: 10.5px;
    color: #9ca3af;
    margin-top: 3px;
}

/* ── Table Filters ── */
.tbl-filters {
    background: rgba(255,255,255,.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(227,232,240,.7);
    border-radius: 14px;
    padding: 12px 18px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.tf-lbl {
    font-size: 11.5px;
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
}
.tf-div {
    width: 1px;
    height: 16px;
    background: #e3e8f0;
    flex-shrink: 0;
}
.tf-count {
    font-size: 11.5px;
    color: #9ca3af;
    margin-left: auto;
}
.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    background: linear-gradient(to bottom, #f0fdf4, #dcfce7);
    border: 1px solid #86efac;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
    color: #15803d;
    text-decoration: none;
    white-space: nowrap;
    transition: all .2s;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(21,128,61,.12);
}
.btn-export:hover {
    background: linear-gradient(to bottom, #dcfce7, #bbf7d0);
    border-color: #4ade80;
    box-shadow: 0 4px 12px rgba(21,128,61,.2);
    transform: translateY(-1px);
}

/* ── Data Table ── */
.tbl-wrap {
    background: #fff;
    border: 1px solid rgba(227,232,240,.8);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
thead th {
    padding: 12px 18px;
    background: linear-gradient(to bottom, #f4f8fc, #eef3f9);
    font-size: 10px;
    font-weight: 800;
    color: #7b8ea8;
    text-transform: uppercase;
    letter-spacing: .8px;
    text-align: left;
    border-bottom: 1px solid #dde5f0;
    white-space: nowrap;
}
tbody tr {
    border-bottom: 1px solid #f4f7fb;
    transition: background .15s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafd; }
tbody tr:nth-child(even) { background: #fafcff; }
tbody tr:nth-child(even):hover { background: #f4f8fd; }
td {
    padding: 11px 18px;
    color: #374151;
    vertical-align: middle;
}
td:first-child {
    color: #9ca3af;
    font-size: 12px;
    white-space: nowrap;
}
.tdot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 7px;
    vertical-align: middle;
    box-shadow: 0 0 0 2px rgba(0,0,0,.05);
}
.pct-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* ── Collapsible Sections ── */
.sec-coll-hdr {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    margin: 0 0 0;
    background: rgba(255,255,255,.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(227,232,240,.7);
    border-radius: 14px;
    cursor: pointer;
    user-select: none;
    transition: background .2s, border-color .2s, box-shadow .2s;
    box-shadow: 0 1px 6px rgba(0,0,0,.05);
}
.sec-coll-hdr:hover {
    background: rgba(248,250,252,.95);
    border-color: rgba(29,111,164,.2);
    box-shadow: 0 4px 14px rgba(29,111,164,.1);
}
.sec-coll-hdr::before {
    content: '';
    width: 3px;
    height: 14px;
    background: linear-gradient(to bottom, #1d6fa4, #2ca0c4);
    border-radius: 2px;
    flex-shrink: 0;
}
.sec-coll-title {
    flex: 1;
    font-size: 11px;
    font-weight: 800;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 1.4px;
}
.sec-coll-badge {
    font-size: 11px;
    font-weight: 700;
    color: #1d6fa4;
    background: linear-gradient(to bottom, #e0f2fe, #bae6fd);
    padding: 4px 12px;
    border-radius: 20px;
    flex-shrink: 0;
    transition: background .2s, color .2s, box-shadow .2s;
    border: 1px solid rgba(29,111,164,.15);
    box-shadow: 0 1px 4px rgba(29,111,164,.1);
}
.sec-coll-hdr[aria-expanded="true"] .sec-coll-badge {
    background: linear-gradient(to bottom, #fee2e2, #fecaca);
    color: #b91c1c;
    border-color: rgba(185,28,28,.15);
    box-shadow: 0 1px 4px rgba(185,28,28,.1);
}
.sec-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    margin-top: 0;
}
.sec-body.is-open { margin-top: 14px; }

/* ── Dark Mode Toggle Button ── */
.btn-darkmode {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid #e3e8f0;
    background: #f8fafc;
    font-size: 16px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    flex-shrink: 0;
}
.btn-darkmode:hover { background: #f1f5f9; border-color: #cbd5e1; }

/* ── Dark Mode ── */
html.dark { color-scheme: dark; }
html.dark body {
    background: #0d1117;
    background-image:
        radial-gradient(ellipse 80% 50% at 0% 0%, rgba(29,111,164,.12) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(44,160,196,.08) 0%, transparent 50%);
    background-attachment: fixed;
    color: #e2e8f0;
}
html.dark .topbar {
    background: rgba(22,25,37,.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-color: #2d3148;
    box-shadow: 0 2px 20px rgba(0,0,0,.5);
}
html.dark .tb-title { color: #f1f5f9; }
html.dark .tb-sub   { color: #64748b; }
html.dark .badge-date { background: linear-gradient(to bottom,#1e2235,#181c2e); border-color: #2d3148; color: #94a3b8; }
html.dark .tb-weather { background: linear-gradient(to bottom,#0c1a2e,#0a1525); border-color: #1e3a5f; color: #7dd3fc; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
html.dark .tw-sep     { color: #1e3a5f; }
html.dark .tw-cloud   { color: #93c5fd; }
html.dark .cr-sub     { color: #3b82f6; }
html.dark .btn-upload-nav { background: #1e2a4a; border-color: #2d4a8a; color: #93c5fd; }
html.dark .btn-upload-nav:hover { background: #263561; }
html.dark .btn-refresh { background: #1e2235; border-color: #2d3148; color: #94a3b8; }
html.dark .btn-refresh:hover { background: #1e3352; border-color: #2d5080; color: #7dd3fc; }
html.dark .btn-darkmode { background: #1e2235; border-color: #2d3148; }
html.dark .badge-live { background: #0f2e1e; border-color: #166534; color: #4ade80; }
html.dark .badge-refresh { color: #64748b; }

html.dark .page { /* no change needed */ }
html.dark .kpi { background: #1a1d27; border-color: #2d3148; }
html.dark .kpi:hover { box-shadow: 0 10px 28px rgba(0,0,0,.45); border-color: rgba(44,160,196,.25); }
html.dark .kpi::after { background: radial-gradient(circle, rgba(44,160,196,.06) 0%, transparent 70%); }
html.dark .kpi-val { color: #f1f5f9; }
html.dark .kpi-label { color: #94a3b8; }
html.dark .kpi-unit  { color: #64748b; }

html.dark .card { background: #1a1d27; border-color: #252b3d; }
html.dark .card:hover { box-shadow: 0 20px 50px rgba(0,0,0,.5); }
html.dark .card-name { color: #f1f5f9; }
html.dark .card-vol  { color: #94a3b8; }
html.dark .card-vol strong { color: #e2e8f0; }
html.dark .card-date { color: #4b5563; }
html.dark .card-foot { background: linear-gradient(to bottom, #161923, #13151e); border-color: #2d3148; }
html.dark .cf-item + .cf-item { border-color: #2d3148; }
html.dark .cf-key { color: #64748b; }
html.dark .bar-wrap { background: #1e2538; }
html.dark .bar-fill { box-shadow: 0 0 8px rgba(44,160,196,.3); }
html.dark .pct-sym  { color: #64748b; }
html.dark .card-critical          { background: #2a1800; border-color: #78350f; color: #fb923c; }
html.dark .card-critical.crit-already { background: #200a0a; border-color: #7f1d1d; color: #f87171; }
html.dark .crit-date              { background: rgba(255,255,255,.08); }

html.dark .sys-bar-wrap { background: #0f2e1e; border-color: #166534; }
html.dark .sys-bar-label { color: #94a3b8; }
html.dark .sys-bar-track { background: #2d3148; }
html.dark .sys-bar-vol { color: #64748b; }

html.dark .warn-banner { background: linear-gradient(to right,#2d1a08,#261500); border-color: #92400e; border-left-color: #f97316; }
/* drought variants */
.drought-watch { background: linear-gradient(to right,#fefce8,#fffbeb) !important; border-color: #fde68a !important; border-left-color: #eab308 !important; box-shadow: 0 4px 16px rgba(234,179,8,.12) !important; }
.drought-watch .warn-body,.drought-watch .warn-close { color: #854d0e !important; }
.drought-watch .warn-body strong { color: #713f12 !important; }
.drought-high  { background: linear-gradient(to right,#fff5f5,#fff1f1) !important; border-color: #fecaca !important; border-left-color: #ef4444 !important; box-shadow: 0 4px 16px rgba(239,68,68,.12) !important; }
.drought-high .warn-body,.drought-high .warn-close { color: #991b1b !important; }
.drought-high .warn-body strong { color: #7f1d1d !important; }
.drought-crit  { background: linear-gradient(to right,#fff0f0,#ffe8e8) !important; border-color: #f87171 !important; border-left-color: #b91c1c !important; box-shadow: 0 4px 16px rgba(185,28,28,.18) !important; animation: droughtPulse 2s ease-in-out infinite !important; }
.drought-crit .warn-body,.drought-crit .warn-close { color: #7f1d1d !important; }
.drought-crit .warn-body strong { color: #450a0a !important; }
@keyframes droughtPulse {
    0%,100% { box-shadow: 0 4px 16px rgba(185,28,28,.18); }
    50%      { box-shadow: 0 6px 28px rgba(185,28,28,.38); }
}
.drought-note { font-size: 11.5px; opacity: .8; }
html.dark .drought-watch { background: linear-gradient(to right,#1c1a08,#171400) !important; border-color: #713f12 !important; border-left-color: #ca8a04 !important; }
html.dark .drought-watch .warn-body,.drought-watch .warn-close { color: #fde68a !important; }
html.dark .drought-high  { background: linear-gradient(to right,#200a0a,#1a0808) !important; border-color: #7f1d1d !important; border-left-color: #dc2626 !important; }
html.dark .drought-high .warn-body { color: #fca5a5 !important; }
html.dark .drought-crit  { background: linear-gradient(to right,#2d0606,#240505) !important; border-color: #991b1b !important; border-left-color: #b91c1c !important; }
html.dark .drought-crit .warn-body { color: #fca5a5 !important; }
html.dark .warn-body   { color: #fbbf24; }
html.dark .warn-body strong { color: #f59e0b; }

html.dark .sec-label { color: #475569; }
html.dark .sec-label::before { box-shadow: 0 2px 6px rgba(29,111,164,.2); }
html.dark .sec-label::after { background: linear-gradient(to right, #2d3148, transparent); }
html.dark .tbl-filters {
    background: rgba(26,29,39,.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-color: #2d3148;
}
html.dark .tbl-wrap { background: #1a1d27; border-color: #2d3148; }
html.dark thead th { background: linear-gradient(to bottom,#161923,#13151e); color: #64748b; border-color: #2d3148; }
html.dark tbody tr { border-color: #1e2235; }
html.dark tbody tr:nth-child(even) { background: #191d2b; }
html.dark tbody tr:nth-child(even):hover { background: #1e2235; }
html.dark tbody tr:hover { background: #1e2235; }
html.dark td { color: #cbd5e1; }
html.dark td:first-child { color: #64748b; }
html.dark .pct-pill { box-shadow: none; }
html.dark .sec-coll-hdr {
    background: rgba(26,29,39,.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-color: #2d3148;
}
html.dark .sec-coll-hdr:hover { background: rgba(34,38,58,.9); border-color: rgba(44,160,196,.25); box-shadow: 0 4px 14px rgba(0,0,0,.3); }
html.dark .sec-coll-title { color: #cbd5e1; }
html.dark .sec-coll-badge { background: #1e3a5f; color: #7dd3fc; }
html.dark .sec-coll-hdr[aria-expanded="true"] .sec-coll-badge { background: #450a0a; color: #fca5a5; }

html.dark .chart-filter-bar {
    background: rgba(26,29,39,.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-color: #2d3148;
}
html.dark .cfb-lbl { color: #94a3b8; }
html.dark .cfb-btn { background: #22263a; border-color: #2d3148; color: #94a3b8; }
html.dark .cfb-btn:hover { background: #1e2a4a; border-color: #2d4a8a; color: #93c5fd; }
html.dark .cfb-btn-active { background: linear-gradient(135deg,#1d6fa4,#2ca0c4) !important; border-color: #1d6fa4 !important; color: #fff !important; box-shadow: 0 3px 10px rgba(29,111,164,.45); }
html.dark .cfb-divider { background: #2d3148; }

html.dark .panel,
/* ── Forecast panel ── */
.forecast-ctrls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.forecast-tbl {
    width: 100%;
    border-collapse: collapse;
    margin-top: 22px;
    font-size: 12.5px;
}
.forecast-tbl thead th {
    background: #f8fafc;
    padding: 9px 14px;
    text-align: center;
    font-weight: 700;
    border-bottom: 2px solid #e3e8f0;
    color: #374151;
    white-space: nowrap;
}
.forecast-tbl thead th:first-child { text-align: left; }
.forecast-tbl tbody td {
    padding: 9px 14px;
    text-align: center;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.forecast-tbl tbody td:first-child { text-align: left; font-weight: 600; color: #374151; }
.forecast-tbl tbody tr:hover td { background: #f8fafc; }
.fc-days  { font-size: 15px; font-weight: 800; color: #1e293b; }
.fc-date  { font-size: 11px; font-weight: 600; }
.fc-na    { color: #16a34a; font-weight: 600; }
.fc-already { color: #ef4444; font-weight: 700; }
.fc-beyond  { color: #94a3b8; }

html.dark .panel-wide { background: #1a1d27; border-color: #2d3148; }
html.dark .panel-head { background: linear-gradient(to bottom, #161923, #141620); border-color: #2d3148; }
html.dark .flow-res-bar { background: #13151e; border-color: #2d3148; }
html.dark .forecast-tbl thead th { background: #161923; border-color: #2d3148; color: #94a3b8; }
html.dark .forecast-tbl tbody td { border-color: #2d3148; }
html.dark .forecast-tbl tbody td:first-child { color: #e2e8f0; }
html.dark .forecast-tbl tbody tr:hover td { background: #1e2235; }
html.dark .fc-days { color: #e2e8f0; }

/* ── Forecast trigger panel ── */
.forecast-trigger-panel {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    background: #fff;
    border: 1.5px solid #e3e8f0;
    border-radius: 16px;
    padding: 18px 24px;
    margin-bottom: 18px;
    cursor: pointer;
    transition: box-shadow .18s, border-color .18s, transform .12s;
    user-select: none;
}
.forecast-trigger-panel:hover {
    box-shadow: 0 6px 24px rgba(99,102,241,.13);
    border-color: #a5b4fc;
    transform: translateY(-1px);
}
.forecast-trigger-panel:active { transform: translateY(0); }
.ftp-icon { font-size: 28px; line-height: 1; flex-shrink: 0; }
.ftp-text  { flex: 1; min-width: 120px; }
.ftp-title { font-size: 14.5px; font-weight: 700; color: #1e293b; }
.ftp-sub   { font-size: 11.5px; color: #94a3b8; margin-top: 2px; }
.ftp-badge {
    display: flex; flex-direction: column; align-items: center;
    border: 2px solid; border-radius: 10px;
    padding: 5px 12px; font-size: 11px; font-weight: 700;
    background: rgba(255,255,255,.6);
}
.ftp-badge-name { font-size: 10px; font-weight: 600; opacity: .8; }
.ftp-badge-val  { font-size: 13px; font-weight: 800; }
.ftp-arrow { font-size: 26px; color: #94a3b8; font-weight: 300; margin-left: auto; }
html.dark .forecast-trigger-panel {
    background: #1a1d27; border-color: #2d3148;
}
html.dark .forecast-trigger-panel:hover { border-color: #6366f1; box-shadow: 0 6px 24px rgba(99,102,241,.22); }
html.dark .ftp-title { color: #e2e8f0; }
html.dark .ftp-sub   { color: #64748b; }
html.dark .ftp-badge { background: rgba(255,255,255,.04); }
html.dark .ftp-arrow { color: #475569; }

/* ── Forecast Modal ── */
.fc-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.fc-modal-overlay.is-open { display: flex; }
.fc-modal {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 28px 70px rgba(0,0,0,.22);
    width: min(1060px, 96vw);
    max-height: 94vh;
    overflow-y: auto;
    padding: 0;
    animation: fcModalIn .2s cubic-bezier(.4,0,.2,1) both;
}
@keyframes fcModalIn {
    from { opacity: 0; transform: scale(.95) translateY(10px); }
    to   { opacity: 1; transform: none; }
}
.fc-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 26px 32px 18px;
    border-bottom: 1px solid #e3e8f0;
}
.fc-modal-title { font-size: 19px; font-weight: 800; color: #111827; }
.fc-modal-sub   { font-size: 13px; color: #64748b; margin-top: 3px; }
.fc-modal-close {
    background: #f1f5f9;
    border: none;
    border-radius: 10px;
    width: 38px; height: 38px;
    font-size: 16px;
    cursor: pointer;
    color: #64748b;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
}
.fc-modal-close:hover { background: #e2e8f0; color: #111827; }
.fc-modal-ctrls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 32px;
    border-bottom: 1px solid #f1f5f9;
    flex-wrap: wrap;
}
.fc-modal-desc {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 32px;
    padding: 12px 16px;
    background: #f0f7ff;
    border-left: 4px solid #3b82f6;
    border-radius: 0 10px 10px 0;
    font-size: 12.5px;
    color: #374151;
    line-height: 1.65;
}
.fc-modal-desc-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.fc-modal-desc strong { color: #1d4ed8; }
.fc-modal-body { padding: 18px 32px 6px; }
#forecastModalTable { padding: 0 32px 26px; }
html.dark .fc-modal-desc { background: #1e2d45; border-color: #3b82f6; color: #94a3b8; }
html.dark .fc-modal-desc strong { color: #60a5fa; }

html.dark .fc-modal { background: #1a1d27; }
html.dark .fc-modal-head { border-color: #2d3148; }
html.dark .fc-modal-title { color: #f1f5f9; }
html.dark .fc-modal-close { background: #2d3148; color: #94a3b8; }
html.dark .fc-modal-close:hover { background: #3d4160; color: #f1f5f9; }
html.dark .fc-modal-ctrls { border-color: #2d3148; }
html.dark .forecast-tbl tbody td { border-color: #2d3148; }
html.dark .forecast-tbl tbody td:first-child { color: #e2e8f0; }
html.dark .forecast-tbl tbody tr:hover td { background: #1e2235; }
html.dark .fc-days { color: #e2e8f0; }
html.dark .panel-title { color: #f1f5f9; }
html.dark .panel-sub   { color: #64748b; }
html.dark .panel-body  { background: #1a1d27; }
html.dark .pct-legend-note { background: #141620; border-color: #2d3148; color: #94a3b8; }
html.dark .pln-item strong { color: #e2e8f0; }

html.dark .gauge-row { border-color: #2d3148; }
html.dark .g-name { color: #64748b; }

html.dark .tf-lbl { color: #94a3b8; }
html.dark .tf-div { background: #2d3148; }
html.dark .tf-count { color: #64748b; }
html.dark .btn-export { background: #052e16; border-color: #166534; color: #4ade80; }
html.dark .btn-export:hover { background: #14532d; }
html.dark select.sel { background-color: #22263a; border-color: #2d3148; color: #e2e8f0; }

html.dark .delta-up   { background: #0f2e1e; color: #4ade80; }
html.dark .delta-down { background: #2d0f0f; color: #f87171; }
html.dark .delta-flat { background: #1e2235; color: #64748b; }

html.dark .pill-g { background: #0f2e1e; color: #4ade80; border-color: #166534; }
html.dark .pill-w { background: #2d2007; color: #fbbf24; border-color: #92400e; }
html.dark .pill-r { background: #2d0f0f; color: #f87171; border-color: #7f1d1d; }

/* ── Responsive ── */
@media (max-width: 1050px) {
    .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .kpi-row  { grid-template-columns: repeat(3, 1fr); }
    .cards    { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
    .topbar { padding: 0 16px; }
    .page   { padding: 16px 12px 40px; }
    .cards  { grid-template-columns: 1fr; }
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .tw-cloud, .tw-cloud-sep { display: none; }
    .tb-weather { padding: 4px 10px; gap: 4px; font-size: 12px; }
}
