:root {
    --bg: #f4f6f8;
    --panel: rgba(255, 255, 255, 0.94);
    --text: #1f2933;
    --muted: #5c6b76;
    --line: #d9e2ec;
    --orange: #e67e22;
    --green: #2ecc71;
    --danger: #c0392b;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, sans-serif;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.top {
    padding: 12px 16px 8px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

h1 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
}

.desc {
    margin: 8px 0 10px;
    max-width: 1100px;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.stats-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

#mapWrap {
    position: relative;
    flex: 1;
    min-height: 420px;
}

#map {
    position: absolute;
    inset: 0;
    background: #fff;
}

.panel {
    position: absolute;
    z-index: 500;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

#legend {
    top: 12px;
    left: 12px;
    width: 230px;
    padding: 10px 12px;
}

.legend-toggle {
    display: none;
    width: 100%;
    border: 0;
    background: transparent;
    font-weight: 700;
    cursor: pointer;
}

.legend-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}

.legend-section {
    margin-top: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 5px 0;
    font-size: 0.92rem;
    font-weight: 500;
}

.legend-item input { margin: 0; }

.swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.2);
    flex: 0 0 12px;
}

.map-chrome {
    left: 12px;
    bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    min-width: 160px;
}

.map-chrome button,
.btn {
    border: 0;
    border-radius: 8px;
    padding: 8px 12px;
    font-weight: 700;
    cursor: pointer;
}

.map-chrome button {
    background: #fff;
    border: 1px solid var(--line);
}

#cursorPos, #adminHint {
    font-size: 0.85rem;
    color: var(--muted);
}

.detail {
    left: 12px;
    bottom: 168px;
    width: min(280px, calc(100% - 24px));
    padding: 12px 14px 14px;
}

.detail h2 {
    margin: 0 28px 8px 0;
    font-size: 1.05rem;
}

.detail p { margin: 0 0 8px; }

.detail-close {
    position: absolute;
    top: 8px;
    right: 8px;
    border: 0;
    background: transparent;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--muted);
}

.detail-actions {
    display: flex;
    gap: 8px;
}

.btn-export { background: #f3f4f6; }
.btn-copy { background: var(--orange); color: #fff; }
.btn-found { background: var(--green); color: #fff; }
.btn-found.is-off { background: #95a5a6; }
.btn-primary { background: #2563eb; color: #fff; width: 100%; }
.btn-ghost {
    background: transparent;
    border: 1px solid var(--line);
    text-decoration: none;
    color: inherit;
}
.link-danger {
    border: 0;
    background: transparent;
    color: var(--danger);
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}
.muted { color: var(--muted); font-size: 0.85rem; }
.credit {
    margin: 0;
    padding: 6px 16px;
    font-size: 0.78rem;
    color: var(--muted);
    background: #fff;
    border-top: 1px solid var(--line);
}

.login-body {
    display: grid;
    place-items: center;
    min-height: 100%;
    background: linear-gradient(180deg, #eef2f6, #d9e2ec);
}

.login-card {
    width: min(380px, calc(100% - 32px));
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-card h1 { font-size: 1.4rem; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.login-card input {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
}
.login-error { color: var(--danger); margin: 0; }
.login-back { text-align: center; color: var(--muted); }

.leaflet-container { background: #fff; font-family: inherit; }

@media (max-width: 720px) {
    h1 { font-size: 1.1rem; }
    .desc { font-size: 0.82rem; }
    #legend {
        width: auto;
        max-width: calc(100% - 24px);
        padding: 8px;
    }
    .legend-toggle { display: block; }
    #legend:not(.open) #legendBody { display: none; }
    .detail { bottom: 12px; left: 12px; right: 12px; width: auto; }
    .map-chrome { left: auto; right: 12px; min-width: 120px; }
}
