:root {
    --ink: #18211c;
    --muted: #66756c;
    --panel: rgba(255, 252, 241, 0.58);
    --panel-strong: rgba(255, 252, 241, 0.78);
    --line: rgba(37, 48, 41, 0.18);
    --moss: #395b42;
    --field: #b8c77a;
    --shadow: 0 20px 70px rgba(13, 24, 16, 0.22);
}

* {
    box-sizing: border-box;
}

html,
body,
.shell,
#map {
    width: 100%;
    height: 100%;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: "Archivo", sans-serif;
    background: #dbe6d2;
    overflow: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
}

#map {
    position: fixed;
    inset: 0;
    z-index: 0;
}

.leaflet-bottom.leaflet-left {
    bottom: 18px;
    left: 18px;
}

.leaflet-control-zoom {
    border: 1px solid var(--line) !important;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 12px 34px rgba(13, 24, 16, 0.18);
}

.leaflet-raster-layer {
    will-change: transform, opacity;
    image-rendering: auto;
}

.leaflet-raster-layer.is-interacting {
    opacity: 0.86;
}

.leaflet-popup-content {
    margin: 12px;
}

.point-popup {
    max-width: 280px;
    max-height: 230px;
    overflow: auto;
    color: var(--ink);
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    line-height: 1.35;
}

.point-popup-title {
    margin-bottom: 8px;
    font-family: "Archivo", sans-serif;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.point-popup-value {
    margin-bottom: 10px;
    padding: 8px 10px;
    border-radius: 14px;
    color: #fffaf0;
    background: linear-gradient(135deg, var(--moss), #1f3628);
    font-family: "Archivo", sans-serif;
    font-size: 22px;
    font-weight: 800;
}

.point-popup-value span {
    font-size: 13px;
}

.point-popup-row,
.point-popup-dataset {
    display: grid;
    gap: 3px;
    margin-top: 8px;
}

.point-popup-row span,
.point-popup-dataset span {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.point-popup-row strong,
.point-popup-dataset p {
    margin: 0;
    overflow-wrap: anywhere;
}

.point-time-series {
    margin: 10px 0;
}

.point-time-list {
    display: grid;
    gap: 4px;
    max-height: 132px;
    margin-top: 8px;
    padding: 7px;
    overflow: auto;
    border-radius: 14px;
    background: rgba(35, 51, 42, 0.07);
}

.point-time-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 7px;
    border-radius: 10px;
}

.point-time-row.active {
    color: #fffaf0;
    background: rgba(31, 54, 40, 0.92);
}

.point-time-row span {
    color: inherit;
}

.point-time-row strong {
    white-space: nowrap;
}

.yield-sparkline {
    display: block;
    width: 210px;
    height: 72px;
    margin-top: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 250, 0.72);
}

.shell {
    position: relative;
}

.overlay-panel {
    position: fixed;
    z-index: 500;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px) saturate(1.2);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

.sidebar {
    top: 18px;
    left: 18px;
    width: min(430px, calc(100vw - 36px));
    max-height: calc(100vh - 36px);
    overflow: auto;
    border-radius: 30px;
    padding: 18px;
    transition: transform 180ms ease, width 180ms ease, max-height 180ms ease;
}

.toolbar {
    top: 18px;
    right: 18px;
    width: min(780px, calc(100vw - 484px));
    min-width: 380px;
    border-radius: 28px;
    padding: 18px 20px;
    transition: transform 180ms ease, width 180ms ease;
}

.result-card {
    right: 18px;
    bottom: 18px;
    width: min(760px, calc(100vw - 36px));
    max-height: 36vh;
    border-radius: 28px;
    padding: 16px;
    transition: max-height 180ms ease, width 180ms ease;
}

.panel-header,
.brand,
.result-header,
.result-actions {
    display: flex;
    align-items: center;
}

.panel-header,
.result-header {
    justify-content: space-between;
    gap: 14px;
}

.brand {
    gap: 14px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border-radius: 16px;
    background:
        linear-gradient(135deg, transparent 45%, rgba(24, 33, 28, 0.18) 46%),
        linear-gradient(135deg, var(--moss), var(--field));
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--moss);
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    line-height: 0.95;
}

h1 {
    font-size: 29px;
    letter-spacing: -0.04em;
}

h2 {
    font-size: 24px;
    letter-spacing: -0.03em;
}

.panel-content {
    margin-top: 16px;
}

.field,
.controls label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    font-family: "IBM Plex Mono", monospace;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

select,
input,
textarea {
    width: 100%;
    border: 1px solid rgba(35, 51, 42, 0.22);
    border-radius: 14px;
    color: var(--ink);
    background: rgba(255, 255, 250, 0.62);
    outline: none;
}

select,
input {
    min-height: 42px;
    padding: 0 12px;
}

textarea {
    min-height: 190px;
    padding: 12px;
    resize: vertical;
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    text-transform: none;
    letter-spacing: 0;
}

.endpoint-meta {
    margin: 14px 0;
    padding: 13px;
    border-radius: 18px;
    color: var(--muted);
    background: rgba(57, 91, 66, 0.11);
    font-size: 13px;
    line-height: 1.45;
}

.auto-fetch-toggle {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
    padding: 11px 12px;
    border-radius: 16px;
    color: var(--ink);
    background: rgba(57, 91, 66, 0.11);
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
}

.auto-fetch-toggle input {
    width: auto;
    min-height: 0;
}

.request-form {
    display: grid;
    gap: 12px;
}

.body-editor-wrap {
    margin-top: 12px;
}

.hidden {
    display: none;
}

.primary-button,
.secondary-button,
.collapse-button {
    border: 0;
    cursor: pointer;
}

.primary-button,
.secondary-button {
    width: 100%;
    border-radius: 16px;
    min-height: 46px;
    margin-top: 14px;
}

.primary-button {
    color: #fffaf0;
    background: linear-gradient(135deg, var(--moss), #1f3628);
}

.secondary-button {
    color: var(--moss);
    background: rgba(57, 91, 66, 0.15);
}

.collapse-button {
    min-width: 54px;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    color: #fffaf0;
    background: rgba(31, 54, 40, 0.86);
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.floating-collapse {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
}

.loading-indicator,
.time-status-badge {
    position: absolute;
    top: 14px;
    left: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100% - 92px);
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    color: #fffaf0;
    background: rgba(31, 54, 40, 0.9);
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    z-index: 2;
    white-space: nowrap;
}

.time-status-badge {
    left: auto;
    right: 96px;
    max-width: min(360px, calc(100% - 210px));
    color: var(--ink);
    background: rgba(255, 255, 250, 0.86);
    border: 1px solid rgba(35, 51, 42, 0.14);
    box-shadow: 0 10px 24px rgba(31, 54, 40, 0.12);
}

.time-status-badge span {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.loading-indicator.hidden,
.time-status-badge.hidden {
    display: none;
}

.loading-indicator strong,
.time-status-badge strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spinner {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    border: 2px solid rgba(255, 250, 240, 0.35);
    border-top-color: #fffaf0;
    border-radius: 999px;
    animation: spin 750ms linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.is-loading .primary-button,
.is-loading .secondary-button,
.is-loading select,
.is-loading input,
.is-loading textarea {
    pointer-events: none;
    opacity: 0.55;
}

.controls {
    display: grid;
    grid-template-columns: repeat(5, minmax(110px, 1fr));
    gap: 12px;
    align-items: end;
    margin-top: 16px;
}

.time-controls {
    display: grid;
    grid-template-columns: auto minmax(220px, 1fr) minmax(150px, auto) auto 110px;
    gap: 12px;
    align-items: end;
    margin-top: 14px;
    padding: 12px;
    border: 1px solid rgba(35, 51, 42, 0.14);
    border-radius: 20px;
    background: rgba(255, 255, 250, 0.36);
}

.time-controls.hidden {
    display: none;
}

.adaptive-controls {
    display: grid;
    grid-template-columns: auto 120px auto minmax(180px, 1fr);
    gap: 12px;
    align-items: end;
    margin-top: 14px;
    padding: 12px;
    border: 1px solid rgba(35, 51, 42, 0.14);
    border-radius: 20px;
    background: rgba(255, 255, 250, 0.3);
}

.yield-forecast-controls {
    display: grid;
    grid-template-columns: 180px auto;
    gap: 12px;
    align-items: end;
    margin-top: 14px;
    padding: 12px;
    border: 1px solid rgba(35, 51, 42, 0.14);
    border-radius: 20px;
    background: rgba(255, 255, 250, 0.3);
}

.yield-forecast-controls label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.adaptive-controls label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.adaptive-status {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 14px;
    color: var(--ink);
    background: rgba(255, 255, 250, 0.52);
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
}

.time-button {
    min-height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    color: #fffaf0;
    background: linear-gradient(135deg, var(--moss), #1f3628);
    cursor: pointer;
}

.time-slider-wrap,
.time-speed,
.time-inline {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.time-inline {
    grid-template-columns: auto auto;
    align-items: center;
    min-height: 42px;
}

.time-inline input {
    width: auto;
    min-height: 0;
}

.time-label {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 14px;
    color: var(--ink);
    background: rgba(255, 255, 250, 0.52);
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
}

.legend {
    position: fixed;
    right: 18px;
    bottom: 96px;
    z-index: 500;
    width: min(280px, calc(100vw - 36px));
    max-height: min(220px, calc(100vh - 150px));
    overflow: auto;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 16px;
    color: var(--ink);
    background: var(--panel-strong);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(14px);
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    line-height: 1.35;
}

.legend strong {
    display: block;
    overflow: hidden;
    color: var(--moss);
    font-family: "Archivo", sans-serif;
    font-size: 14px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.legend div {
    overflow-wrap: anywhere;
}

.legend-gradient {
    height: 10px;
    border-radius: 99px;
    margin: 7px 0;
}

.legend-scale {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.forecast-panel {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 500;
    width: min(280px, calc(100vw - 36px));
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 16px;
    color: var(--ink);
    background: var(--panel-strong);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
    backdrop-filter: blur(14px);
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    line-height: 1.35;
}

.forecast-uncertainty {
    padding: 0;
}

.forecast-uncertainty-head,
.forecast-uncertainty-value,
.forecast-uncertainty-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.forecast-uncertainty-head span,
.forecast-uncertainty-value small,
.forecast-uncertainty-meta {
    color: var(--muted);
}

.forecast-uncertainty-value {
    margin-top: 8px;
    font-family: "Archivo", sans-serif;
    font-size: 18px;
    font-weight: 800;
}

.forecast-uncertainty-bar {
    height: 10px;
    margin-top: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(24, 33, 28, 0.14);
}

.forecast-uncertainty-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--moss);
}

.forecast-uncertainty.uncertainty-medium .forecast-uncertainty-bar span {
    background: #d29c2f;
}

.forecast-uncertainty.uncertainty-high .forecast-uncertainty-bar span {
    background: #b94a35;
}

.forecast-uncertainty-meta {
    margin-top: 7px;
    font-size: 11px;
}

.result-actions {
    gap: 10px;
}

.status-badge {
    padding: 8px 11px;
    border-radius: 999px;
    color: #fffaf0;
    background: var(--moss);
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
}

#responseOutput {
    height: 24vh;
    overflow: auto;
    margin: 14px 0 0;
    padding: 14px;
    border-radius: 18px;
    color: #173022;
    background: rgba(255, 255, 250, 0.62);
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    white-space: pre-wrap;
}

.collapsed {
    overflow: hidden;
}

.sidebar.collapsed {
    width: 118px;
    max-height: 76px;
}

.toolbar.collapsed {
    width: 98px;
    min-width: 98px;
    height: 66px;
}

.toolbar.collapsed:has(.loading-indicator:not(.hidden)),
.toolbar.collapsed:has(.time-status-badge:not(.hidden)) {
    width: min(560px, calc(100vw - 36px));
    min-width: min(560px, calc(100vw - 36px));
}

.toolbar.collapsed .time-status-badge {
    left: 18px;
    right: 164px;
    max-width: none;
    justify-content: flex-start;
    z-index: 1;
}

.toolbar.collapsed .time-status-badge strong {
    max-width: 100%;
}

.toolbar.collapsed .loading-indicator:not(.hidden) + .time-status-badge:not(.hidden) {
    display: none;
}

.result-card.collapsed {
    width: 102px;
    max-height: 58px;
    padding: 8px;
    border-radius: 999px;
}

.result-card.collapsed .result-header {
    justify-content: center;
}

.result-card.collapsed .result-header > div:first-child {
    display: none;
}

.result-card.collapsed .result-actions {
    justify-content: center;
}

.collapsed .panel-content,
.collapsed .endpoint-meta,
.collapsed .auto-fetch-toggle,
.collapsed .request-form,
.collapsed .body-editor-wrap,
.collapsed .primary-button,
.collapsed .secondary-button,
.collapsed .controls,
.collapsed .adaptive-controls,
.collapsed .yield-forecast-controls,
.collapsed .time-controls,
.collapsed h1,
.collapsed h2,
.collapsed .eyebrow,
.collapsed .brand-mark,
.collapsed #responseOutput,
.collapsed .status-badge {
    display: none;
}

@media (max-width: 1100px) {
    .toolbar {
        left: 18px;
        right: auto;
        top: auto;
        bottom: 18px;
        width: min(760px, calc(100vw - 36px));
    }

    .result-card {
        left: 18px;
        right: auto;
        bottom: 118px;
    }

    .legend {
        right: 18px;
        bottom: 104px;
        width: min(260px, calc(100vw - 36px));
        max-height: 180px;
    }

    .forecast-panel {
        right: 18px;
        bottom: 18px;
        width: min(260px, calc(100vw - 36px));
    }

    .controls {
        grid-template-columns: repeat(2, minmax(130px, 1fr));
    }

    .time-controls {
        grid-template-columns: auto 1fr;
    }

    .adaptive-controls {
        grid-template-columns: 1fr 1fr;
    }

    .time-label,
    .time-speed,
    .adaptive-status {
        grid-column: span 2;
    }
}

@media (max-width: 640px) {
    .sidebar,
    .toolbar,
    .result-card {
        left: 10px;
        right: 10px;
        width: auto;
        min-width: 0;
    }

    .sidebar {
        top: 10px;
        max-height: 56vh;
    }

    .toolbar {
        bottom: 10px;
    }

    .result-card {
        bottom: 92px;
    }

    .result-card.collapsed {
        left: auto;
        right: 10px;
        width: 102px;
        min-width: 102px;
    }

    .legend {
        right: 10px;
        bottom: 104px;
        width: min(250px, calc(100vw - 20px));
    }

    .forecast-panel {
        right: 10px;
        bottom: 10px;
        width: min(250px, calc(100vw - 20px));
    }

    .controls {
        grid-template-columns: 1fr;
    }

    .time-controls {
        grid-template-columns: 1fr;
    }

    .adaptive-controls {
        grid-template-columns: 1fr;
    }

    .time-label,
    .time-speed,
    .adaptive-status {
        grid-column: auto;
    }
}
