:root {
    color-scheme: dark;
    --bg: #090b1c;
    --panel: #0d1129;
    --map: #0c1233;
    --card: #141a3e;
    --border: #28366d;
    --text: #e8ecff;
    --muted: #a3b0da;
    --accent: #00e5ff;
    --good: #b5ff42;
    --warn: #ffb22f;
    --bad: #ff4076;
}

:root.light {
    color-scheme: light;
    --bg: #eef2ff;
    --panel: #fff;
    --map: #e1e9fa;
    --card: #f0f3ff;
    --border: #c9d2ef;
    --text: #192448;
    --muted: #4b5982;
    --accent: #006a82;
    --good: #416900;
    --warn: #865000;
    --bad: #ad0044;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0 auto;
    max-width: 1760px;
    padding: 26px clamp(16px, 2.25vw, 38px) 14px;
    font: 14px system-ui, sans-serif;
    color: var(--text);
    background:
        radial-gradient(ellipse at 100% 100%, #06394d55, transparent 45%),
        radial-gradient(ellipse at 5% 0%, #48218330, transparent 45%), var(--bg);
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: clamp(21px, 2vw, 28px);
    letter-spacing: .035em;
    text-transform: uppercase;
}

h2 {
    font-size: 15px;
}

small,
p {
    color: var(--muted);
}

button,
select {
    color: inherit;
    font: inherit;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 12px;
}

button,
summary {
    cursor: pointer;
}

button:hover {
    border-color: var(--accent);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:disabled {
    opacity: .5;
    cursor: default;
}

.top,
.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.top {
    gap: clamp(16px, 2vw, 28px);
    margin-bottom: 20px;
}

.brand {
    margin-right: auto;
}

.brand h1 {
    text-shadow: 0 0 14px #00cfff70;
}

.brand p {
    font-size: 12px;
    letter-spacing: .035em;
}

.logo {
    display: grid;
    place-items: center;
    flex: none;
    width: 50px;
    height: 50px;
    color: var(--accent);
    font-size: 25px;
    border: 2px solid var(--accent);
    border-radius: 14px;
    box-shadow: 0 0 18px #00dfff85, inset 0 0 12px #00dfff35;
}

.stats {
    display: flex;
}

.stat {
    border-left: 1px solid var(--border);
    padding: 4px clamp(10px, 1.5vw, 22px) 7px;
}

.stat strong {
    display: block;
    font-size: clamp(22px, 2.3vw, 33px);
}

.stat small {
    white-space: nowrap;
}

.stat:nth-child(2) strong {
    color: var(--bad);
    text-shadow: 0 0 15px #ff407680;
}

.stat:nth-child(3) strong {
    color: var(--good);
    text-shadow: 0 0 15px #aaff4660;
}

#routeButton {
    min-width: 160px;
    padding: 14px;
    color: white;
    font-weight: 750;
    border: 0;
    background: linear-gradient(105deg, #ff1dc5, #8825f5);
    box-shadow: 0 0 25px #dc27ed65;
}

#routeButton::before {
    content: ' ';
}

main {
    display: grid;
    grid-template-columns: minmax(230px, 1fr) minmax(0, 2.05fr) minmax(235px, 1fr);
    gap: 20px;
}

.panel {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 21px;
    background: var(--panel);
    overflow: hidden;
}

.inventory,
.sidebar {
    padding: 18px;
}

.inventory h2 {
    margin-bottom: 12px;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

nav button {
    border-radius: 24px;
    padding: 6px 11px;
    font-size: 12px;
}

nav button[aria-pressed="true"] {
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 10px #00dfff50;
}

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

.unit-filter nav {
    margin-top: 8px;
}

.bins {
    display: grid;
    gap: 8px;
    max-height: 64vh;
    overflow: auto;
    padding: 2px;
}

.bin {
    width: 100%;
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 0;
    text-align: left;
    background: var(--card);
    border-color: transparent;
    border-radius: 14px;
    padding: 11px;
}

.bin[aria-current="true"] {
    border-color: var(--accent);
    box-shadow: inset 0 0 10px #00dfff20;
}

.bin-body {
    min-width: 0;
    flex: 1;
    overflow-wrap: anywhere;
}

.bin small {
    display: block;
    margin-top: 3px;
}

.badge {
    display: grid;
    place-items: center;
    flex: none;
    width: 45px;
    height: 45px;
    border: 2px solid var(--tone);
    border-radius: 50%;
    color: var(--tone);
    font-weight: 750;
    font-size: 13px;
}

.full .badge {
    box-shadow: 0 0 12px #ff407680;
}

.level-bar {
    display: block;
    height: 5px;
    border-radius: 5px;
    background: var(--border);
    margin-top: 7px;
}

.level-bar::before {
    content: '';
    display: block;
    width: var(--level);
    height: 100%;
    border-radius: inherit;
    background: var(--tone);
}

.normal,
.base-pin {
    --tone: var(--good);
}

.medium {
    --tone: var(--warn);
}

.full {
    --tone: var(--bad);
}

.unknown {
    --tone: var(--muted);
}

.workspace {
    position: relative;
    background: var(--map);
}

.toolbar {
    position: absolute;
    top: 15px;
    left: 16px;
    z-index: 2;
}

.toolbar button,
.legend {
    background: var(--bg);
}

#mapView {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.map-frame {
    position: relative;
    flex: 1;
}

#map {
    min-height: max(490px, calc(100dvh - 208px));
    height: 100%;
    background: var(--map);
    z-index: 0;
}

:root:not(.light) #map .leaflet-tile-pane {
    filter: grayscale(1) invert(1) contrast(.8) brightness(.7) sepia(1) hue-rotate(185deg) saturate(3);
}

#map .leaflet-attribution-flag {
    display: none;
}

#map .leaflet-tooltip {
    font-weight: 700;
}

.map-pin {
    display: grid;
    place-items: center;
    border: 2px solid #101634;
    border-radius: 50%;
    background: var(--tone);
    color: #0b122a;
    font: 750 13px system-ui, sans-serif;
}

.map-pin.full {
    color: white;
    background: #e81955;
    border-color: white;
    box-shadow: 0 0 15px #ff4076;
}

.map-pin.base-pin {
    background: var(--map);
    border-color: var(--tone);
    color: var(--tone);
    font-size: 21px;
}

.map-pin.truck-pin {
    background: var(--map);
    border-color: var(--accent);
    font-size: 24px;
    pointer-events: none;
}

.map-pin.selected-pin {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.route-path {
    filter: drop-shadow(0 0 5px #00e5ff);
}

.legend {
    position: absolute;
    left: 16px;
    bottom: 14px;
    display: flex;
    gap: 12px;
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 12px;
}

.legend span::before,
.alert-heading small::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tone, var(--bad));
    margin-right: 5px;
}

.route-info {
    padding: 11px 16px;
    font-size: 13px;
    border-top: 1px solid var(--border);
}

.route-info ol {
    margin: 6px 0 0;
    padding-left: 24px;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.alerts {
    display: grid;
    gap: 9px;
    max-height: 52vh;
    overflow: auto;
    padding: 2px;
}

.alert-heading {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.alert-heading small {
    color: var(--bad);
    font-weight: 700;
}

.alerts .bin {
    border-color: color-mix(in srgb, var(--alert-tone) 70%, transparent);
    box-shadow: inset 3px 0 var(--alert-tone);
    --alert-tone: var(--tone);
}

.alerts .bin.unknown {
    --alert-tone: var(--warn);
}

.alerts .bin[aria-current="true"] {
    border-color: var(--accent);
}

.details {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

.details small {
    display: block;
    margin-top: 4px;
}

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

.reading strong {
    font-size: 19px;
}

.reading p {
    color: var(--tone);
}

.ring {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: conic-gradient(var(--tone) var(--level), var(--border) 0);
}

.ring::after {
    content: '';
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: var(--panel);
}

.details label {
    display: block;
    margin: 10px 0 5px;
    color: var(--muted);
    font-size: 12px;
}

.details select,
.details button {
    width: 100%;
}

.details button {
    margin-top: 12px;
    border-color: var(--good);
    color: var(--good);
    font-weight: 750;
    box-shadow: 0 0 14px #acff4533;
}

#message {
    padding: 10px 14px;
    margin-bottom: 14px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
}

footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

footer button {
    font-size: 12px;
}

@media (max-width: 1100px) {
    .top {
        flex-wrap: wrap;
    }

    .stats {
        order: 3;
        width: 100%;
    }

    main {
        grid-template-columns: minmax(210px, .85fr) minmax(0, 2fr);
    }

    .sidebar {
        grid-column: 2;
    }
}

@media (max-width: 650px) {
    body {
        padding: 14px;
    }

    main {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }

    .workspace {
        grid-row: 1;
    }

    .sidebar {
        grid-column: 1;
    }

    .stats {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .stat {
        padding: 5px;
    }

    .stat small {
        white-space: normal;
        font-size: 10px;
    }

    .brand p {
        font-size: 11px;
    }

    #routeButton {
        min-width: 0;
    }

    #map {
        min-height: 400px;
    }

    .bins {
        max-height: 310px;
    }
}