:root {
    color-scheme: dark;
    --bg: #07111f;
    --bg-soft: #0b1628;
    --panel: #0e1b2e;
    --panel-2: #10213a;
    --line: #20334f;
    --text: #edf4ff;
    --muted: #9fb0c8;
    --accent: #3b82f6;
    --accent-2: #60a5fa;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 14px;
    --shadow: 0 16px 40px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
    min-height: 100vh;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 12% 0%, rgba(59, 130, 246, .12), transparent 26rem),
        linear-gradient(180deg, #07111f 0%, #081321 100%);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; }
button, .button { cursor: pointer; }

.shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.narrow { width: min(760px, calc(100% - 32px)); margin: 0 auto; }

.skip-link {
    position: fixed;
    left: 12px;
    top: 12px;
    transform: translateY(-180%);
    background: #fff;
    color: #000;
    padding: 10px 14px;
    border-radius: 8px;
    z-index: 9999;
}
.skip-link:focus { transform: none; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255,255,255,.07);
    background: rgba(7, 17, 31, .88);
    backdrop-filter: blur(12px);
}
.header-inner {
    min-height: 66px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 750; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 31px;
    height: 31px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #2563eb, #1d4ed8 65%, #0f3b86);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
    font-size: 14px;
}
.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav a { color: var(--muted); font-size: 14px; }
.nav a:hover { color: var(--text); text-decoration: none; }

.site-main { min-height: calc(100vh - 136px); }
.site-footer { border-top: 1px solid rgba(255,255,255,.07); margin-top: 56px; color: var(--muted); font-size: 13px; }
.footer-inner { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.footer-inner nav { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-inner a { color: var(--muted); }

.hero { padding: 72px 0 36px; }
.hero h1 { margin: 0 0 12px; font-size: clamp(34px, 6vw, 62px); line-height: 1; letter-spacing: -.055em; }
.hero p { max-width: 680px; margin: 0; color: var(--muted); font-size: 17px; }
.eyebrow { margin-bottom: 10px; color: var(--accent-2); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.section { padding: 24px 0; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 18px; }
.section-head h1, .section-head h2 { margin: 0; letter-spacing: -.03em; }
.section-head p { margin: 5px 0 0; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.map-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.dashboard-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .5fr); gap: 20px; align-items: start; }

.card {
    background: linear-gradient(180deg, rgba(16,33,58,.92), rgba(12,27,47,.92));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.map-card { padding: 20px; display: flex; flex-direction: column; min-height: 190px; }
.map-card h3 { margin: 0 0 8px; font-size: 20px; }
.map-card p { margin: 0; color: var(--muted); flex: 1; }
.map-card .meta { margin-top: 20px; font-size: 13px; color: var(--muted); }
.stat { padding: 18px; }
.stat .value { font-size: 30px; font-weight: 800; letter-spacing: -.04em; }
.stat .label { color: var(--muted); font-size: 13px; }

.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 14px;
    background: var(--accent);
    color: white;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
}
.button:hover { filter: brightness(1.08); text-decoration: none; }
.button.secondary { background: var(--panel-2); border-color: var(--line); color: var(--text); }
.button.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.button.danger { background: var(--danger); }
.button.success { background: var(--success); color: #03120a; }
.button.small { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.button:disabled { opacity: .55; cursor: not-allowed; }

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 13px; font-weight: 700; color: #d8e4f5; }
.field small { color: var(--muted); }
.input, textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #091525;
    color: var(--text);
    padding: 11px 12px;
    outline: none;
}
.input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.14); }
textarea { min-height: 110px; resize: vertical; }
.checkbox { display: flex; align-items: center; gap: 9px; color: var(--muted); }
.checkbox input { width: 18px; height: 18px; }

.alert { margin: 16px 0; padding: 13px 15px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.035); }
.alert.error { border-color: rgba(239,68,68,.45); background: rgba(239,68,68,.08); }
.alert.success { border-color: rgba(34,197,94,.45); background: rgba(34,197,94,.08); }
.alert.warning { border-color: rgba(245,158,11,.45); background: rgba(245,158,11,.08); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.auth-wrap { min-height: calc(100vh - 138px); display: grid; place-items: center; padding: 50px 0; }
.auth-card { width: min(430px, calc(100% - 32px)); padding: 24px; }
.auth-card h1 { margin: 0 0 6px; }
.auth-card > p { margin: 0 0 20px; color: var(--muted); }

.map-shell { position: relative; }
.map-canvas { width: 100%; min-height: 520px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #0a1423; }
.map-canvas.tall { min-height: 660px; }
.map-toolbar {
    position: absolute;
    z-index: 500;
    left: 12px;
    bottom: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    max-width: calc(100% - 24px);
}
.map-toolbar .button { box-shadow: 0 7px 18px rgba(0,0,0,.25); }

.leaflet-container { background: #0a1423; font-family: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #0d1a2d; color: var(--text); }
.leaflet-popup-content { line-height: 1.45; }
.leaflet-popup-content strong { display: block; margin-bottom: 3px; }
.leaflet-control-attribution { font-size: 10px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.legal { padding: 54px 0; }
.legal h1 { font-size: clamp(34px, 5vw, 48px); letter-spacing: -.04em; margin: 0 0 8px; }
.legal .updated { color: var(--muted); margin-bottom: 32px; }
.legal h2 { margin-top: 32px; font-size: 21px; }
.legal p, .legal li { color: #c3d0e1; }
.legal ul { padding-left: 22px; }

.field-layout { padding: 24px 0; }
.field-panel { position: sticky; top: 86px; }
.location-readout { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #091525; font-variant-numeric: tabular-nums; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-actions .button { min-height: 52px; }

.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.kicker { display: inline-block; padding: 4px 8px; border-radius: 999px; background: rgba(59,130,246,.11); color: #99c2ff; font-size: 12px; }

@media (max-width: 820px) {
    .header-inner { align-items: flex-start; padding: 14px 0; flex-direction: column; gap: 10px; }
    .nav { gap: 14px; }
    .hero { padding-top: 44px; }
    .split { grid-template-columns: 1fr; }
    .field-panel { position: static; }
    .map-canvas.tall, .map-canvas { min-height: 58vh; }
    .footer-inner { align-items: flex-start; flex-direction: column; padding: 18px 0; }
}

@media (max-width: 520px) {
    .shell, .narrow { width: min(100% - 22px, 1120px); }
    .hero h1 { font-size: 40px; }
    .section-head { align-items: flex-start; flex-direction: column; }
    .quick-actions { grid-template-columns: 1fr; }
    .button-row .button { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* Full-width map editor */
.editor-page { padding: 16px 0 24px; }
.editor-page .editor-shell { width: calc(100% - 32px); max-width: none; }
.editor-page .section-head { margin-bottom: 12px; align-items: center; }
.editor-page .section-head h1 { font-size: clamp(22px, 2.5vw, 32px); }
.editor-page .section-head .eyebrow { margin-bottom: 2px; }
.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 350px;
    gap: 16px;
    align-items: start;
}
.editor-map-column { min-width: 0; }
.editor-page #edit-map {
    height: max(570px, calc(100dvh - 235px));
    min-height: 570px;
}
.editor-sidebar {
    max-height: calc(100dvh - 154px);
    overflow-y: auto;
    padding-right: 4px;
    min-width: 0;
    scrollbar-width: thin;
}
.editor-sidebar .card-pad { padding: 16px; }
.editor-sidebar h2 { font-size: 19px; }
.editor-sidebar .form { gap: 12px; }
.editor-sidebar textarea { min-height: 78px; }
@media (max-width: 950px) {
    .editor-layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; }
}
@media (max-width: 720px) {
    .editor-page .editor-shell { width: calc(100% - 20px); }
    .editor-layout { grid-template-columns: minmax(0, 1fr); }
    .editor-page #edit-map { height: 62dvh; min-height: 350px; }
    .editor-sidebar { max-height: none; overflow: visible; padding-right: 0; }
    .editor-page .section-head { align-items: flex-start; }
}
