:root {
    font-family: system-ui, sans-serif;
    line-height: 1.5;
    color: #162b29;
    background: #f2f7f5;
}

* { box-sizing: border-box; }
body { margin: 0; }
a, .link-button { color: #07594e; text-underline-offset: .2em; }

.site-header {
    border-bottom: 1px solid #ceded9;
    background: #fff;
    padding: .85rem max(1rem, calc((100vw - 64rem) / 2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.site-header > a { font-weight: 750; text-decoration: none; }

.card {
    max-width: 31rem;
    margin: clamp(1.5rem, 8vw, 5rem) auto;
    width: calc(100% - 2rem);
    border: 1px solid #ceded9;
    border-radius: 1rem;
    background: #fff;
    padding: clamp(1.25rem, 4vw, 2rem);
}

h1 { font-size: clamp(1.45rem, 5vw, 1.9rem); line-height: 1.2; margin: 0 0 1rem; }
form.stack { display: grid; gap: 1rem; margin: 1rem 0; }
label { display: grid; gap: .25rem; font-weight: 600; }

input, select, button {
    font: inherit;
    border-radius: .45rem;
    min-height: 2.75rem;
    padding: .5rem .7rem;
}

input, select { color: #162b29; border: 1px solid #76948d; width: 100%; }
button { background: #07594e; color: #fff; border: 1px solid transparent; font-weight: 650; cursor: pointer; }
.link-button { background: none; text-decoration: underline; }
:focus-visible { outline: 3px solid #156aa2; outline-offset: 3px; }
.errors { color: #8a241f; background: #fff0ed; border-radius: .45rem; padding: .65rem 1.8rem; }
.qr { display: inline-flex; border: 1px solid #ceded9; padding: .7rem; margin: .5rem 0; }
.qr svg { max-width: 100%; height: auto; }

.card--wide { max-width: 64rem; }
.card--map {
    max-width: 88rem;
    margin: clamp(.75rem, 3vw, 2rem) auto;
}

.device-layout {
    display: grid;
    grid-template-areas: "map" "devices";
    gap: 1.25rem;
}
.map-sidebar { grid-area: devices; min-width: 0; }
.map-sidebar h2, .map-toolbar h2 {
    font-size: 1.1rem;
    line-height: 1.3;
    margin: 0;
}
.map-sidebar h2 { margin-bottom: .8rem; }
.map-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .35rem .75rem;
    margin-bottom: .75rem;
}
.map-toolbar a, .map-device-note { font-size: .875rem; color: #42615b; }

.management-layout { display: grid; gap: 1.5rem; align-items: start; }
.management-list, .management-workflow { min-width: 0; }
.management-workflow { display: grid; gap: 1rem; }
.management-panel {
    padding: 1rem;
    border: 1px solid #ceded9;
    border-radius: .65rem;
    background: #f7faf9;
    scroll-margin-top: 1rem;
}
.management-layout h2 { margin: 0 0 .75rem; font-size: 1.1rem; }
.management-panel form.stack:last-child { margin-bottom: 0; }

.site-header--admin {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .3rem .75rem;
    padding: .5rem max(1rem, calc((100vw - 87rem) / 2));
}
.site-header--admin > form { grid-column: 2; grid-row: 1; }
.site-header--admin > form button { white-space: nowrap; }
.site-nav {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: .2rem;
}
.site-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 2.35rem;
    padding: .3rem .6rem;
    border-radius: .45rem;
    color: #294640;
    text-decoration: none;
    font-size: .9rem;
    font-weight: 650;
}
.site-nav a:hover { background: #eff6f3; }
.site-nav a[aria-current='page'] { color: #064e44; background: #e0f0e9; }
.device-entry { border-top: 1px solid #ceded9; padding: .7rem 0; overflow-wrap: anywhere; }
.device-entry h3, .device-entry p { margin: .2rem 0; }
.pairing-code { font-size: clamp(1.25rem, 6vw, 1.85rem); letter-spacing: .06em; font-weight: 750; }
.paging { display: flex; gap: .75rem; }

@media (min-width: 46rem) {
    .site-header--admin { grid-template-columns: auto 1fr auto; column-gap: 1.5rem; }
    .site-header--admin > form { grid-column: 3; }
    .site-nav { grid-column: 2; grid-row: 1; }
    .device-layout {
        grid-template-areas: "devices map";
        grid-template-columns: minmax(14rem, 19rem) minmax(0, 1fr);
        column-gap: clamp(1rem, 3vw, 2rem);
    }
    .management-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .card--map .device-map { height: clamp(27rem, calc(100dvh - 14rem), 54rem); }
    .map-sidebar { max-height: clamp(27rem, calc(100dvh - 14rem), 54rem); overflow: auto; padding: 0 .25rem .25rem 0; }
}

.device-map {
    z-index: 0;
    height: clamp(18rem, 55vh, 30rem);
    border: 1px solid #ceded9;
    border-radius: .65rem;
    margin-bottom: .8rem;
}
.position-panel { grid-area: map; min-width: 0; }
.map-choice { display: flex; align-items: center; gap: .5rem; }
.map-choice input { min-height: 0; width: auto; height: 1.1rem; accent-color: #07594e; }

.map-device h3 { font-size: 1rem; }
.map-device-location {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .25rem .55rem;
    margin: .35rem 0 0;
}
.map-device-location p { font-size: .875rem; font-variant-numeric: tabular-nums; }
.map-button { min-height: 2.2rem; padding: .3rem .55rem; font-size: .875rem; }
.map-actions { margin-top: .9rem; }
.map-actions p { margin: .35rem 0 0; font-size: .9rem; }
.map-actions p:empty { display: none; }
.map-actions button:disabled, .map-button:disabled { opacity: .55; cursor: default; }
