:root {
    --bg: #f6f8fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --border: #e5e7eb;
    --error: #dc2626;
    --success: #059669;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
}

* { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

header {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 20px 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-logo {
    width: 140px;
    height: auto;
    flex-shrink: 0;
}

.brand-text {
    min-width: 0;
}

header h1 {
    margin: 0 0 8px;
    font-size: 28px;
    line-height: 1.1;
}

.subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.subtitle a { color: var(--primary); }

@media (max-width: 560px) {
    .brand { gap: 12px; }
    .brand-logo { width: 88px; }
    header h1 { font-size: 22px; }
}

main {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px 40px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card h2 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 600;
}

.field {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    flex: 1;
}

.field label {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.field input,
.field select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field input[readonly] {
    background: #f9fafb;
    color: var(--text);
}

.row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.row .field {
    min-width: 200px;
}

.muted {
    color: var(--muted);
    font-size: 13px;
    margin: 8px 0 0;
}

.autocomplete {
    position: relative;
}

.suggestions {
    position: absolute;
    z-index: 20;
    top: 100%;
    left: 0;
    right: 0;
    margin: 4px 0 0;
    padding: 4px;
    list-style: none;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.suggestions li {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.suggestions li:hover,
.suggestions li.active {
    background: #eff6ff;
}

.suggestions li .meta {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 6px 12px;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 0;
}

.check input { margin: 0; }

.radio-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-row.compact {
    gap: 6px;
}

.radio {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: border-color 0.15s, background 0.15s;
}

.radio:has(input:checked) {
    border-color: var(--primary);
    background: #eff6ff;
}

.radio input { margin-top: 3px; }
.radio span { display: flex; flex-direction: column; gap: 2px; }
.radio em { font-style: normal; font-size: 13px; }

select#station-select {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    padding: 6px;
}

select#station-select option {
    padding: 4px 6px;
}

.windrose-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
}

.windrose-header h2 { margin: 0; }

.windrose-chart {
    width: 100%;
    height: 520px;
    min-height: 480px;
}

.windrose-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 0 0 12px;
}

.radio.inline {
    padding: 6px 10px;
}

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-top: 8px;
}

button {
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

button:hover { background: #f3f4f6; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

button.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.status {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
}

.status.info { background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; }
.status.error { background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }
.status.success { background: #ecfdf5; color: var(--success); border: 1px solid #a7f3d0; }
.status.loading { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th, td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

th {
    background: #f9fafb;
    font-weight: 600;
    position: sticky;
    top: 0;
}

tr:last-child td { border-bottom: none; }
tr:nth-child(even) { background: #fafbfc; }

footer {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 20px 32px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

footer a { color: var(--primary); }

/* The HTML `hidden` attribute must always win against our flex/grid layouts. */
[hidden] { display: none !important; }

/* Auth bar in header */
.auth-bar {
    position: relative;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--muted);
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.auth-bar #auth-label {
    display: none;
}

.link-button {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 13px;
    border-radius: 4px;
    text-decoration: none;
}

.link-button:hover { background: rgba(37, 99, 235, 0.08); }

.profile-button {
    padding: 7px 12px;
    color: #ffffff;
    background: #0f766e;
    border: 1px solid #0f766e;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.profile-menu {
    position: absolute;
    z-index: 40;
    top: calc(100% + 10px);
    right: 0;
    width: min(320px, calc(100vw - 32px));
    padding: 16px;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    text-align: left;
}

.profile-menu strong {
    display: block;
    margin-bottom: 8px;
}

.profile-caption {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.profile-menu .link-button {
    display: block;
    width: 100%;
    margin-top: 8px;
    text-align: left;
}

/* Login card */
.login-card { max-width: 520px; margin: 24px auto; }
.login-card .actions { margin-top: 16px; }

/* Admin panel */
.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.card-header-row h2 { margin: 0; }

.token-display {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
    background: #f3f4f6;
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 4px;
    word-break: break-all;
    user-select: all;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge.good { background: #d1fae5; color: #065f46; }
.badge.bad  { background: #fee2e2; color: #991b1b; }
.badge.muted { background: #e5e7eb; color: #4b5563; }

.status.info { background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; }
.status.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.status.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.status.loading { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* Tabs (Cari Nama / Pilih di Peta) */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}
.tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--primary); }
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.map-canvas {
    width: 100%;
    height: 380px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 8px;
}
.map-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.coordinate-panel {
    padding: 14px;
    margin: 10px 0 12px;
    background: rgba(39, 39, 42, 0.48);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 8px;
}

.coordinate-fields {
    margin-top: 4px;
}

.dms-grid {
    display: grid;
    grid-template-columns: 86px repeat(3, minmax(74px, 1fr)) minmax(76px, 0.7fr);
    gap: 8px;
    align-items: center;
}

.dms-grid label {
    color: #e4e4e7;
    font-size: 13px;
    font-weight: 700;
}

.dms-grid input,
.dms-grid select {
    min-width: 0;
    padding: 9px 10px;
    color: #fafafa;
    background: rgba(15, 15, 17, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 7px;
}

.coordinate-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.coordinate-actions .primary {
    min-width: 170px;
}

.climate-chart-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    height: auto;
    min-height: 0;
}

.climate-chart-card {
    padding: 14px;
    background: rgba(15, 15, 17, 0.40);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 8px;
}

.climate-chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.climate-chart-card-header h3 {
    margin: 0;
    color: #ffffff;
    font-size: 14px;
}

.climate-plot {
    width: 100%;
    height: 430px;
    min-height: 380px;
}
.mode-toggle {
    display: flex;
    gap: 8px;
}
.radio-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.radio-inline:has(input:checked) {
    border-color: var(--primary);
    background: #eff6ff;
    color: var(--primary);
}

/* Override Leaflet's default z-index so popups don't punch through other UI. */
.leaflet-pane, .leaflet-top, .leaflet-bottom { z-index: 100; }

@media (max-width: 600px) {
    header { padding: 20px 16px 8px; }
    main { padding: 0 16px 24px; }
    .card { padding: 16px; }
    .actions { justify-content: stretch; }
    .actions button { flex: 1; }
    .map-canvas { height: 320px; }
    .dms-grid { grid-template-columns: 1fr; }
    .climate-plot { height: 380px; }
}

/* Professional dashboard refresh */
:root {
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #0f766e;
    --primary-hover: #115e59;
    --navy: #0f172a;
    --panel: #f1f5f9;
    --border: #dbe3ea;
    --shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

body {
    background:
        linear-gradient(180deg, #ffffff 0, #f8fafc 260px),
        var(--bg);
}

header,
main,
footer {
    max-width: 1360px;
}

header {
    padding: 24px 28px 16px;
    border-bottom: 1px solid rgba(219, 227, 234, 0.9);
}

.brand-logo {
    width: 108px;
}

header h1 {
    color: var(--navy);
    font-size: 24px;
    letter-spacing: 0;
}

.subtitle {
    max-width: 760px;
    color: #475569;
}

main#app-view {
    padding: 22px 28px 48px;
}

.dashboard-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.dashboard-workspace {
    min-width: 0;
}

.workflow-sidebar {
    position: sticky;
    top: 16px;
    min-height: 620px;
    padding: 22px;
    color: #334155;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: none;
}

.workflow-kicker {
    margin: 0 0 10px;
    color: #0f766e;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.workflow-sidebar h2 {
    margin: 0 0 18px;
    color: var(--navy);
    font-size: 22px;
    line-height: 1.15;
}

.workflow-steps {
    display: flex;
    flex-direction: column;
    gap: 13px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.workflow-steps li {
    margin: 0;
}

.workflow-link {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    width: 100%;
    padding: 0;
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: 8px;
    text-align: left;
    text-decoration: none;
}

.workflow-link:hover {
    background: rgba(16, 185, 129, 0.08);
}

.workflow-link > span {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    color: #0f766e;
    background: #ecfdf5;
    border: 1px solid #99f6e4;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 800;
}

.workflow-link strong {
    display: block;
    color: #0f172a;
    font-size: 14px;
}

.workflow-link small {
    display: block;
    color: #64748b;
    font-size: 12px;
    line-height: 1.45;
}

.sidebar-panel {
    margin-top: 22px;
    padding: 14px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.sidebar-panel strong {
    display: block;
    color: #0f172a;
    font-size: 13px;
}

.sidebar-panel p {
    margin: 6px 0 0;
    color: #64748b;
    font-size: 12px;
    line-height: 1.55;
}

#weather-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

#weather-form > .card,
#weather-form > .output-access-grid,
#weather-form > .actions,
#weather-form > .status {
    margin: 0;
}

#weather-form > .card:nth-of-type(1),
#weather-form > .card:nth-of-type(2),
#weather-form > .output-access-grid,
#weather-form > .actions,
#weather-form > .status {
    grid-column: 1 / -1;
}

.card {
    border-radius: 8px;
    border-color: var(--border);
    box-shadow: none;
}

.card h2 {
    color: var(--navy);
    font-size: 15px;
    font-weight: 800;
}

.field label {
    color: #334155;
    font-weight: 700;
}

.field input,
.field select {
    border-radius: 7px;
    border-color: #cbd5e1;
    color: #0f172a;
}

.field input:focus,
.field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.radio {
    border-radius: 8px;
    background: #ffffff;
}

.radio:has(input:checked),
.radio-inline:has(input:checked) {
    border-color: #0f766e;
    background: #ecfdf5;
    color: #0f766e;
}

.tabs {
    border-color: var(--border);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.actions {
    align-items: center;
    padding: 4px 0 0;
}

button {
    border-radius: 7px;
    border-color: #cbd5e1;
    color: #0f172a;
    font-weight: 700;
}

button.primary {
    background: #0f766e;
    border-color: #0f766e;
    box-shadow: 0 8px 18px rgba(15, 118, 110, 0.18);
}

button.primary:hover {
    background: #115e59;
    border-color: #115e59;
}

#download-btn {
    min-width: 176px;
}

.status {
    border-radius: 8px;
    font-weight: 700;
}

#weather-form > .status {
    border-left-width: 5px;
}

.status.info {
    color: #164e63;
    background: #ecfeff;
    border-color: #a5f3fc;
}

.status.success {
    color: #065f46;
    background: #ecfdf5;
    border-color: #99f6e4;
}

.status.loading {
    color: #713f12;
    background: #fffbeb;
    border-color: #fde68a;
}

.status.error {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fecaca;
}

#climate-chart-section,
#windrose-section,
#preview-section {
    margin-top: 16px;
}

.windrose-header {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.windrose-chart {
    min-height: 440px;
    height: 500px;
}

.windrose-chart.climate-chart-grid {
    height: auto;
    min-height: 0;
    overflow: visible;
}

#preview-info {
    margin-bottom: 14px;
    padding: 13px 14px;
    color: #334155;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.preview-summary-text {
    font-size: 13px;
    line-height: 1.55;
}

.source-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.source-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    color: #334155;
    background: #ffffff;
    font-size: 12px;
    font-weight: 800;
}

.source-badge.observed,
.source-badge.audit-good {
    color: #065f46;
    background: #ecfdf5;
    border-color: #99f6e4;
}

.source-badge.aggregated {
    color: #164e63;
    background: #ecfeff;
    border-color: #a5f3fc;
}

.source-badge.reanalysis,
.source-badge.audit-warn {
    color: #92400e;
    background: #fffbeb;
    border-color: #fde68a;
}

.table-wrap {
    border-radius: 8px;
    background: white;
}

table {
    font-size: 12px;
}

th {
    color: #0f172a;
    background: #eaf1f7;
    font-size: 12px;
    text-transform: none;
}

td {
    color: #1e293b;
}

tr:nth-child(even) {
    background: #f8fafc;
}

footer {
    padding-top: 0;
}

@media (max-width: 980px) {
    header,
    main#app-view,
    footer {
        padding-left: 18px;
        padding-right: 18px;
    }

    .dashboard-shell,
    #weather-form {
        grid-template-columns: 1fr;
    }

    .workflow-sidebar {
        position: static;
        min-height: auto;
    }

    #weather-form > .card,
    #weather-form > .actions,
    #weather-form > .status {
        grid-column: 1;
    }
}

/* Hard override for cached/dark sidebar variants. */
main#app-view .workflow-sidebar {
    color: #334155 !important;
    background: #ffffff !important;
    border-color: #dbe3ea !important;
    box-shadow: none !important;
}

main#app-view .workflow-kicker {
    color: #0f766e !important;
}

main#app-view .workflow-sidebar h2,
main#app-view .workflow-steps strong,
main#app-view .sidebar-panel strong {
    color: #0f172a !important;
}

main#app-view .workflow-steps small,
main#app-view .sidebar-panel p {
    color: #64748b !important;
}

main#app-view .sidebar-panel {
    background: #f8fafc !important;
    border-color: #dbe3ea !important;
}

/* Planter-inspired premium dark/glass theme. */
:root {
    --bg: #0f0f11;
    --card: rgba(24, 24, 27, 0.78);
    --text: #fafafa;
    --muted: #a1a1aa;
    --primary: #10b981;
    --primary-hover: #059669;
    --accent: #34d399;
    --navy: #fafafa;
    --panel: rgba(39, 39, 42, 0.65);
    --border: rgba(255, 255, 255, 0.09);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 50% -12%, rgba(16, 185, 129, 0.20), rgba(15, 15, 17, 0) 42%),
        linear-gradient(rgba(39, 39, 42, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(39, 39, 42, 0.08) 1px, transparent 1px),
        #0f0f11;
    background-size: auto, 40px 40px, 40px 40px, auto;
}

header {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

header h1 {
    color: #ffffff;
    text-shadow: 0 0 32px rgba(16, 185, 129, 0.24);
}

.subtitle,
.muted {
    color: #a1a1aa;
}

.subtitle a,
footer a,
.link-button {
    color: #34d399;
}

.dashboard-shell {
    gap: 24px;
}

.card,
.workflow-sidebar,
.login-card {
    color: #fafafa;
    background: rgba(24, 24, 27, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.09);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(10px);
}

.workflow-sidebar,
main#app-view .workflow-sidebar {
    color: #fafafa !important;
    background: rgba(24, 24, 27, 0.78) !important;
    border-color: rgba(255, 255, 255, 0.09) !important;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28) !important;
}

.workflow-kicker,
main#app-view .workflow-kicker {
    color: #34d399 !important;
}

.workflow-sidebar h2,
.card h2,
main#app-view .workflow-sidebar h2,
main#app-view .workflow-steps strong,
main#app-view .sidebar-panel strong {
    color: #ffffff !important;
}

.workflow-steps small,
main#app-view .workflow-steps small,
main#app-view .sidebar-panel p {
    color: #a1a1aa !important;
}

.workflow-steps li > span {
    color: #34d399;
    background: rgba(16, 185, 129, 0.16);
    border-color: rgba(52, 211, 153, 0.34);
}

.sidebar-panel,
main#app-view .sidebar-panel {
    background: rgba(39, 39, 42, 0.65) !important;
    border-color: rgba(255, 255, 255, 0.09) !important;
}

.field label {
    color: #e4e4e7;
}

.field input,
.field select,
select#station-select {
    color: #fafafa;
    background: rgba(15, 15, 17, 0.72);
    border-color: rgba(255, 255, 255, 0.10);
}

.field input::placeholder {
    color: #71717a;
}

.field input:focus,
.field select:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

.suggestions,
.radio,
.radio-inline,
.table-wrap {
    background: rgba(15, 15, 17, 0.72);
    border-color: rgba(255, 255, 255, 0.10);
}

.suggestions li:hover,
.suggestions li.active,
.radio:has(input:checked),
.radio-inline:has(input:checked) {
    color: #ffffff;
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(52, 211, 153, 0.55);
}

.tabs {
    border-color: rgba(255, 255, 255, 0.10);
}

.tab {
    color: #a1a1aa;
}

.tab:hover,
.tab.active {
    color: #34d399;
    border-bottom-color: #10b981;
}

button {
    color: #fafafa;
    background: rgba(39, 39, 42, 0.80);
    border-color: rgba(255, 255, 255, 0.10);
}

button:hover {
    background: rgba(255, 255, 255, 0.10);
}

button.primary {
    background: #10b981;
    border-color: #10b981;
    box-shadow: 0 0 22px rgba(16, 185, 129, 0.26);
}

button.primary:hover {
    background: #059669;
    border-color: #059669;
}

.status.info,
.status.success,
.status.loading,
.status.error {
    background: rgba(39, 39, 42, 0.76);
    border-color: rgba(255, 255, 255, 0.10);
}

.status.info { color: #67e8f9; }
.status.success { color: #34d399; }
.status.loading { color: #fbbf24; }
.status.error { color: #fca5a5; }

#preview-info,
.source-badge {
    color: #d4d4d8;
    background: rgba(39, 39, 42, 0.66);
    border-color: rgba(255, 255, 255, 0.09);
}

.source-badge.observed,
.source-badge.audit-good {
    color: #34d399;
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(52, 211, 153, 0.32);
}

.source-badge.aggregated {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(96, 165, 250, 0.30);
}

.source-badge.reanalysis,
.source-badge.audit-warn {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.12);
    border-color: rgba(251, 191, 36, 0.28);
}

th {
    color: #fafafa;
    background: rgba(39, 39, 42, 0.92);
}

td {
    color: #d4d4d8;
}

tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

footer {
    color: #71717a;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 6px 11px;
    color: #fafafa;
    background: rgba(39, 39, 42, 0.80);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.theme-icon {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    color: #34d399;
    background: rgba(16, 185, 129, 0.14);
    border-radius: 999px;
}

html[data-theme="dark"] .field input[readonly] {
    color: #fafafa;
    background: rgba(15, 15, 17, 0.72);
    border-color: rgba(52, 211, 153, 0.35);
}

html[data-theme="dark"] .field input[readonly]::selection,
html[data-theme="dark"] .token-display::selection {
    color: #0f172a;
    background: #34d399;
}

html[data-theme="dark"] .token-display {
    color: #d1fae5;
    background: rgba(16, 185, 129, 0.14);
    border: 1px solid rgba(52, 211, 153, 0.28);
}

html[data-theme="light"] {
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #0f766e;
    --primary-hover: #115e59;
    --accent: #14b8a6;
    --navy: #0f172a;
    --panel: #f1f5f9;
    --border: #dbe3ea;
    --shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] body {
    color: #0f172a;
    background:
        radial-gradient(circle at 50% -12%, rgba(20, 184, 166, 0.16), rgba(248, 250, 252, 0) 42%),
        linear-gradient(rgba(15, 23, 42, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.035) 1px, transparent 1px),
        #f8fafc;
    background-size: auto, 40px 40px, 40px 40px, auto;
}

html[data-theme="light"] header {
    border-bottom-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] header h1 {
    color: #0f172a;
    text-shadow: none;
}

html[data-theme="light"] .subtitle,
html[data-theme="light"] .muted {
    color: #64748b;
}

html[data-theme="light"] .subtitle a,
html[data-theme="light"] footer a,
html[data-theme="light"] .link-button {
    color: #0f766e;
}

html[data-theme="light"] .card,
html[data-theme="light"] .workflow-sidebar,
html[data-theme="light"] .login-card,
html[data-theme="light"] main#app-view .workflow-sidebar {
    color: #0f172a !important;
    background: rgba(255, 255, 255, 0.92) !important;
    border-color: #dbe3ea !important;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.08) !important;
}

html[data-theme="light"] .workflow-kicker,
html[data-theme="light"] main#app-view .workflow-kicker {
    color: #0f766e !important;
}

html[data-theme="light"] .workflow-sidebar h2,
html[data-theme="light"] .card h2,
html[data-theme="light"] main#app-view .workflow-sidebar h2,
html[data-theme="light"] main#app-view .workflow-steps strong,
html[data-theme="light"] main#app-view .sidebar-panel strong {
    color: #0f172a !important;
}

html[data-theme="light"] .workflow-steps small,
html[data-theme="light"] main#app-view .workflow-steps small,
html[data-theme="light"] main#app-view .sidebar-panel p {
    color: #64748b !important;
}

html[data-theme="light"] .workflow-steps li > span {
    color: #0f766e;
    background: #ecfdf5;
    border-color: #99f6e4;
}

html[data-theme="light"] .sidebar-panel,
html[data-theme="light"] main#app-view .sidebar-panel,
html[data-theme="light"] #preview-info,
html[data-theme="light"] .source-badge {
    color: #334155;
    background: #f8fafc !important;
    border-color: #dbe3ea !important;
}

html[data-theme="light"] .field label {
    color: #334155;
}

html[data-theme="light"] .field input,
html[data-theme="light"] .field select,
html[data-theme="light"] select#station-select,
html[data-theme="light"] .suggestions,
html[data-theme="light"] .radio,
html[data-theme="light"] .radio-inline,
html[data-theme="light"] .table-wrap,
html[data-theme="light"] .coordinate-panel,
html[data-theme="light"] .climate-chart-card {
    color: #0f172a;
    background: #ffffff;
    border-color: #cbd5e1;
}

html[data-theme="light"] .field input[readonly] {
    color: #0f172a;
    background: #f8fafc;
}

html[data-theme="light"] .token-display {
    color: #065f46;
    background: #d1fae5;
    border: 1px solid #99f6e4;
}

html[data-theme="light"] .dms-grid label {
    color: #334155;
}

html[data-theme="light"] .dms-grid input,
html[data-theme="light"] .dms-grid select {
    color: #0f172a;
    background: #ffffff;
    border-color: #cbd5e1;
}

html[data-theme="light"] .climate-chart-card-header h3 {
    color: #0f172a;
}

html[data-theme="light"] .field input::placeholder {
    color: #94a3b8;
}

html[data-theme="light"] .suggestions li:hover,
html[data-theme="light"] .suggestions li.active,
html[data-theme="light"] .radio:has(input:checked),
html[data-theme="light"] .radio-inline:has(input:checked) {
    color: #0f766e;
    background: #ecfdf5;
    border-color: #0f766e;
}

html[data-theme="light"] .tabs {
    border-color: #dbe3ea;
}

html[data-theme="light"] .tab {
    color: #64748b;
}

html[data-theme="light"] .tab:hover,
html[data-theme="light"] .tab.active {
    color: #0f766e;
    border-bottom-color: #0f766e;
}

html[data-theme="light"] button,
html[data-theme="light"] .theme-toggle {
    color: #0f172a;
    background: #ffffff;
    border-color: #cbd5e1;
}

html[data-theme="light"] button:hover {
    background: #f1f5f9;
}

html[data-theme="light"] button.primary {
    color: #ffffff;
    background: #0f766e;
    border-color: #0f766e;
    box-shadow: 0 10px 22px rgba(15, 118, 110, 0.18);
}

html[data-theme="light"] .theme-icon {
    color: #0f766e;
    background: #ecfdf5;
}

html[data-theme="light"] .status.info,
html[data-theme="light"] .status.success,
html[data-theme="light"] .status.loading,
html[data-theme="light"] .status.error {
    background: #ffffff;
    border-color: #dbe3ea;
}

html[data-theme="light"] .status.info { color: #164e63; }
html[data-theme="light"] .status.success { color: #065f46; }
html[data-theme="light"] .status.loading { color: #92400e; }
html[data-theme="light"] .status.error { color: #991b1b; }

html[data-theme="light"] th {
    color: #0f172a;
    background: #eaf1f7;
}

html[data-theme="light"] td {
    color: #1e293b;
}

html[data-theme="light"] tr:nth-child(even) {
    background: #f8fafc;
}

html[data-theme="light"] footer {
    color: #64748b;
}

/* Dashboard input-token refinement */
.dashboard-overview {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.guide-section {
    scroll-margin-top: 18px;
}

.dashboard-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
    align-items: end;
    gap: 18px;
    margin-bottom: 0;
}

.dashboard-topbar h2 {
    margin: 0 0 6px;
    font-size: 20px;
}

.beginner-guide {
    margin-bottom: 0;
}

.guide-heading h2 {
    margin-bottom: 6px;
    font-size: 18px;
}

.guide-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.guide-cards article {
    min-height: 154px;
    padding: 14px;
    background: rgba(39, 39, 42, 0.66);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 8px;
}

.guide-cards article span {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    margin-bottom: 12px;
    color: #34d399;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(52, 211, 153, 0.34);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 800;
}

.guide-cards article strong {
    display: block;
    color: #ffffff;
    font-size: 14px;
}

.guide-cards article p,
.step-help {
    margin: 7px 0 0;
    color: #a1a1aa;
    font-size: 13px;
    line-height: 1.55;
}

.step-help {
    padding: 11px 12px;
    margin: -4px 0 15px;
    color: #d4d4d8;
    background: rgba(39, 39, 42, 0.54);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
}

.quick-search {
    display: grid;
    gap: 6px;
}

.quick-search label,
.access-form label {
    color: #e4e4e7;
    font-size: 12px;
    font-weight: 800;
}

.quick-search input,
.token-input-row input {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    color: #fafafa;
    background: rgba(15, 15, 17, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 7px;
    font: inherit;
}

.quick-search input:focus,
.token-input-row input:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.metric-card {
    min-height: 116px;
    padding: 16px;
    color: #fafafa;
    background: rgba(24, 24, 27, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 8px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.20);
    backdrop-filter: blur(10px);
}

.metric-card span {
    display: block;
    margin-bottom: 10px;
    color: #a1a1aa;
    font-size: 12px;
    font-weight: 800;
}

.metric-card strong {
    display: block;
    color: #ffffff;
    font-size: 22px;
    line-height: 1.15;
    word-break: break-word;
}

.metric-card small {
    display: block;
    margin-top: 8px;
    color: #a1a1aa;
    font-size: 12px;
    line-height: 1.45;
}

.download-access-card {
    display: grid;
    grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr);
    gap: 20px;
    align-items: start;
    margin-bottom: 0;
}

.download-access-card h2 {
    margin-bottom: 6px;
    font-size: 18px;
}

.access-form {
    display: grid;
    gap: 9px;
}

.token-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
}

.token-input-row button {
    min-height: 42px;
    white-space: nowrap;
}

.token-quota-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    color: #d4d4d8;
    background: rgba(39, 39, 42, 0.66);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 8px;
    font-size: 12px;
}

.token-quota-panel strong {
    color: #34d399;
    white-space: nowrap;
}

.download-access-card .status {
    margin-top: 0;
}

.source-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.source-grid .radio {
    min-height: 112px;
    align-items: flex-start;
}

.source-grid .radio em {
    line-height: 1.55;
}

.output-access-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
}

.output-access-grid > .card {
    min-height: 214px;
    margin-bottom: 0;
}

.output-access-grid .download-access-card {
    grid-template-columns: 1fr;
    align-content: start;
}

.period-preset-actions {
    justify-content: center;
}

.year-actions {
    display: grid;
    grid-template-columns: repeat(5, minmax(82px, 1fr));
    gap: 12px;
    max-width: 760px;
    margin: 18px auto 0;
}

.range-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 14px;
    max-width: 420px;
    margin: 14px auto 8px;
}

.year-preset-btn,
#baseline-5yr-btn,
#baseline-btn {
    min-height: 48px;
    justify-content: center;
    color: #fafafa;
    background: rgba(39, 39, 42, 0.80);
    border-color: rgba(255, 255, 255, 0.10);
    font-size: 15px;
    font-weight: 800;
}

.year-preset-btn.preset-active,
#baseline-5yr-btn.preset-active,
#baseline-btn.preset-active {
    color: #ffffff;
    background: rgba(16, 185, 129, 0.20);
    border-color: rgba(52, 211, 153, 0.55);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.table-wrap {
    max-width: 100%;
    overflow-x: auto;
}

#preview-table {
    min-width: 860px;
    table-layout: auto;
}

#preview-table th {
    vertical-align: bottom;
    white-space: normal;
    line-height: 1.35;
}

#preview-table td {
    vertical-align: middle;
}

#preview-table th:first-child,
#preview-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: inherit;
}

#preview-table th:first-child {
    z-index: 2;
}

#preview-table .numeric-col {
    text-align: right;
}

#preview-table .empty-cell {
    color: #71717a;
    font-weight: 700;
    text-align: center;
}

.sidebar-title-row {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
}

.sidebar-collapse-btn {
    min-width: 54px;
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
}

.dashboard-shell.sidebar-collapsed {
    grid-template-columns: 86px minmax(0, 1fr);
}

.dashboard-shell.sidebar-collapsed .workflow-sidebar {
    padding: 14px 10px;
}

.dashboard-shell.sidebar-collapsed .workflow-kicker,
.dashboard-shell.sidebar-collapsed .workflow-sidebar h2,
.dashboard-shell.sidebar-collapsed .workflow-steps div,
.dashboard-shell.sidebar-collapsed .sidebar-panel {
    display: none;
}

.dashboard-shell.sidebar-collapsed .workflow-link {
    grid-template-columns: 1fr;
    justify-items: center;
}

.dashboard-shell.sidebar-collapsed .workflow-link > span {
    width: 40px;
    height: 40px;
}

html[data-theme="light"] .dashboard-topbar,
html[data-theme="light"] .download-access-card,
html[data-theme="light"] .metric-card,
html[data-theme="light"] .beginner-guide {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.92);
    border-color: #dbe3ea;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .guide-cards article,
html[data-theme="light"] .step-help {
    color: #334155;
    background: #f8fafc;
    border-color: #dbe3ea;
}

html[data-theme="light"] .guide-cards article strong {
    color: #0f172a;
}

html[data-theme="light"] .guide-cards article p,
html[data-theme="light"] .step-help {
    color: #64748b;
}

html[data-theme="light"] .guide-cards article span {
    color: #0f766e;
    background: #ecfdf5;
    border-color: #99f6e4;
}

html[data-theme="light"] .quick-search label,
html[data-theme="light"] .access-form label {
    color: #334155;
}

html[data-theme="light"] .quick-search input,
html[data-theme="light"] .token-input-row input {
    color: #0f172a;
    background: #ffffff;
    border-color: #cbd5e1;
}

html[data-theme="light"] .metric-card span,
html[data-theme="light"] .metric-card small {
    color: #64748b;
}

html[data-theme="light"] .metric-card strong {
    color: #0f172a;
}

html[data-theme="light"] .token-quota-panel {
    color: #334155;
    background: #f8fafc;
    border-color: #dbe3ea;
}

html[data-theme="light"] .token-quota-panel strong {
    color: #0f766e;
}

html[data-theme="light"] .year-preset-btn,
html[data-theme="light"] #baseline-5yr-btn,
html[data-theme="light"] #baseline-btn {
    color: #0f172a;
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: none;
}

html[data-theme="light"] .year-preset-btn.preset-active,
html[data-theme="light"] #baseline-5yr-btn.preset-active,
html[data-theme="light"] #baseline-btn.preset-active {
    color: #0f766e;
    background: #ecfdf5;
    border-color: #99f6e4;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

html[data-theme="light"] #preview-table .empty-cell {
    color: #94a3b8;
}

@media (max-width: 1180px) {
    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .output-access-grid {
        grid-template-columns: 1fr;
    }

    .download-access-card {
        grid-template-columns: 1fr;
    }

    .guide-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .dashboard-topbar,
    .summary-grid,
    .source-grid,
    .year-actions,
    .range-actions,
    .token-input-row {
        grid-template-columns: 1fr;
    }

    .token-quota-panel {
        align-items: flex-start;
        flex-direction: column;
    }

    .guide-cards {
        grid-template-columns: 1fr;
    }

    .dashboard-shell.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .dashboard-shell.sidebar-collapsed .workflow-sidebar {
        display: none;
    }
}
