:root {
    --warsaw-red: #c8102e;
    --warsaw-red-dark: #9a0c24;
    --gold: #ffc72c;
    --ink: #1a1a1f;
    --muted: #5c5f66;
    --surface: #f4f1ec;
    --card: #ffffff;
    --map-bg: #dce6df;
    --border: rgba(26, 26, 31, 0.12);
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
    --radius: 16px;
    --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
    --font-display: "Playfair Display", Georgia, serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(ellipse 120% 80% at 50% -20%, rgba(200, 16, 46, 0.08), transparent 55%),
        var(--surface);
    line-height: 1.5;
}

.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0;
}

.brand-text {
    margin-left: 1rem;
}

.brand-logo--um {
    display: block;
    height: 88px;
    width: 88px;
    object-fit: contain;
    object-position: center;
    flex-shrink: 0;
    border-radius: 50%;
}

.brand-logo--volista {
    display: block;
    height: 88px;
    width: auto;
    object-fit: contain;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

.brand-kicker {
    margin: 0 0 0.15rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--warsaw-red);
}

.brand-text h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.35rem, 2.5vw, 1.85rem);
    font-weight: 700;
    line-height: 1.15;
    color: var(--ink);
}

.brand-text h1 span {
    color: var(--warsaw-red-dark);
}

.header-bar {
    height: 4px;
    background: linear-gradient(90deg, var(--warsaw-red) 0%, var(--gold) 45%, var(--warsaw-red) 100%);
}

.main {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 1.75rem 1.5rem 2rem;
}

.main-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.main-tab {
    font: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.65rem 1.1rem;
    margin-bottom: -1px;
    border: 1px solid transparent;
    border-radius: var(--radius) var(--radius) 0 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.main-tab:hover {
    color: var(--ink);
}

.main-tab.is-active {
    color: var(--warsaw-red);
    background: var(--card);
    border-color: var(--border);
    border-bottom-color: var(--card);
}

.tab-panel[hidden] {
    display: none !important;
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(280px, 340px) 1fr minmax(240px, 280px);
    gap: 1.25rem;
    align-items: start;
}

.editor-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 140px);
    position: sticky;
    top: 0.75rem;
    overflow: hidden;
    padding: 0;
}

.editor-panel__sticky {
    flex-shrink: 0;
    padding: 1rem 1.15rem 0.65rem;
    border-bottom: 1px solid var(--border);
    background: var(--card);
}

.editor-panel__scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.65rem 1.15rem 1rem;
}

.editor-panel__actions {
    margin-top: 0.65rem;
}

.btn--block {
    width: 100%;
}

.editor-status--compact {
    min-height: 1.25rem;
    margin: 0.45rem 0 0;
    font-size: 0.78rem;
}

.editor-block {
    margin-bottom: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.editor-block summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.55rem 0.75rem;
    list-style: none;
}

.editor-block summary::-webkit-details-marker {
    display: none;
}

.editor-block__body {
    padding: 0 0.75rem 0.75rem;
}

.editor-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.editor-field--wide {
    grid-column: 1 / -1;
}

.editor-group-box--flat {
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
}

.editor-label-list {
    max-height: min(36vh, 260px);
}

.layers-panel--editor {
    position: sticky;
    top: 0.75rem;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

.editor-title {
    margin: 0 0 0.5rem;
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
}

.editor-mode-tabs {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.editor-mode {
    flex: 1;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.45rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
}

.editor-mode.is-active {
    background: var(--warsaw-red);
    border-color: var(--warsaw-red);
    color: #fff;
}

.editor-mode-panel[hidden] {
    display: none !important;
}

.editor-global-save {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.district-name-icon {
    background: transparent !important;
    border: none !important;
    overflow: visible !important;
}

.district-name-icon .district-name {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
    text-align: center;
}

.district-vertex-handle {
    width: 14px !important;
    height: 14px !important;
    margin: 0 !important;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--warsaw-red);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    cursor: grab;
}

.district-vertex-handle:active {
    cursor: grabbing;
}

.district-name {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: #1a1a1a;
    text-shadow:
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff,
        1px 1px 0 #fff,
        0 0 6px rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    pointer-events: none;
}

.editor-subtitle {
    margin: 1.25rem 0 0.5rem;
    font-size: 0.95rem;
}

.editor-intro {
    margin: 0 0 1rem;
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.45;
}

.editor-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
    font-size: 0.875rem;
}

.editor-field input,
.editor-field select {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}

.editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.editor-actions--secondary {
    margin-bottom: 0.5rem;
}

.btn {
    font: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    cursor: pointer;
}

.btn--primary {
    background: var(--warsaw-red);
    border-color: var(--warsaw-red);
    color: #fff;
}

.btn--primary.is-active {
    box-shadow: 0 0 0 2px rgba(206, 17, 38, 0.35);
}

.btn--ghost {
    background: transparent;
}

.btn--file {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.editor-status {
    min-height: 2.5rem;
    margin: 0.5rem 0 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.editor-label-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 280px;
    overflow-y: auto;
}

.editor-empty {
    font-size: 0.85rem;
    color: var(--muted);
    padding: 0.5rem 0;
}

.editor-section-label {
    margin: 0 0 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.editor-field--range input[type="range"] {
    width: 100%;
    margin-top: 0.25rem;
}

.editor-edit-box {
    margin: 1rem 0;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.editor-label-row.is-selected .editor-label-row__pick {
    outline: 2px solid var(--warsaw-red);
    outline-offset: 2px;
}

.editor-label-row__pick {
    flex: 1;
    min-width: 0;
    text-align: left;
    font: inherit;
    background: transparent;
    border: none;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
    cursor: pointer;
}

.editor-label-row__pick:hover {
    background: rgba(0, 0, 0, 0.04);
}

.editor-label-row {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.editor-row-check {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding-top: 0.35rem;
    cursor: pointer;
}

.editor-row-badge {
    display: inline-block;
    margin-top: 0.2rem;
    padding: 0.1rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 4px;
    background: rgba(206, 17, 38, 0.12);
    color: var(--warsaw-red-dark);
}

.editor-group-box {
    margin: 1rem 0;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.editor-intro--tight {
    margin-bottom: 0.75rem;
}

.editor-group-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
}

.editor-group-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.editor-group-row__name {
    font-weight: 600;
    flex: 1;
    min-width: 120px;
}

.editor-group-row__meta {
    color: var(--muted);
    font-size: 0.75rem;
}

.editor-group-row__del {
    margin-left: auto;
}

.editor-label-row__main {
    display: none;
}

.editor-label-row__meta {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
}

.editor-label-row__del {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: rgba(206, 17, 38, 0.1);
    color: var(--warsaw-red);
    font-size: 1.1rem;
    cursor: pointer;
}

.city-map--placing {
    cursor: crosshair;
}

.map-label-icon {
    background: transparent !important;
    border: none !important;
}

.um-labels-layer {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 1;
    pointer-events: none;
}

.um-labels-layer.um-labels-layer--draggable {
    pointer-events: auto;
}

.leaflet-pane .map-base-layer {
    z-index: 1 !important;
}

.map-label-pin {
    position: absolute;
    pointer-events: none;
}

.map-label-pin--draggable {
    pointer-events: auto;
}

.map-label-pin--draggable .map-label-inner {
    pointer-events: auto;
    cursor: grab;
    display: inline-block;
}

.map-label-pin--draggable .map-label-inner:active {
    cursor: grabbing;
}

.map-label-inner {
    display: inline-block;
    transform-origin: 0 0;
    pointer-events: none;
}

.map-label {
    display: inline-block;
    padding: 0;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.15;
    color: #ffffff;
    white-space: nowrap;
    text-shadow:
        0 0 4px rgba(0, 0, 0, 0.95),
        0 0 8px rgba(0, 0, 0, 0.85),
        1px 1px 2px rgba(0, 0, 0, 1),
        -1px -1px 2px rgba(0, 0, 0, 1);
}

.map-label--street,
.map-label--poi,
.map-label--other {
    color: #ffffff;
}

.layers-hint code {
    font-size: 0.8em;
}

.map-layout {
    display: grid;
    grid-template-columns: 1fr minmax(240px, 300px);
    gap: 1.25rem;
    align-items: start;
}

.map-shell {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    background: var(--map-bg);
}

.map-shell--loading::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.12) 50%, transparent 60%);
    background-size: 200% 100%;
    animation: map-shimmer 1.1s linear infinite;
    z-index: 600;
}

@keyframes map-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.city-map {
    height: min(72vh, 720px);
    min-height: 360px;
    width: 100%;
    background: var(--map-bg);
}

.map-toolbar {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.map-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--ink);
    font-size: 1.25rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    transition: background 0.15s, transform 0.1s;
}

.map-btn--wide {
    width: auto;
    padding: 0 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.map-btn--icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.map-btn__svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.map-btn.is-busy {
    opacity: 0.55;
    pointer-events: none;
}

.map-btn:hover {
    background: #fff;
    transform: translateY(-1px);
}

.map-btn:active {
    transform: translateY(0);
}

.map-toolbar--hidden {
    visibility: hidden;
}

.layers-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem 1.1rem 1.25rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
}

.layers-panel h3 {
    margin: 0 0 0.35rem;
    font-size: 1.05rem;
}

.layers-hint {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.layers-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.layer-item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.65rem 0.7rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fafafa;
    transition: border-color 0.15s, background 0.15s;
}

.layer-item.is-on {
    border-color: rgba(200, 16, 46, 0.35);
    background: rgba(200, 16, 46, 0.04);
}

.layer-item.is-disabled {
    opacity: 0.72;
}

.layer-item input[type="checkbox"] {
    margin-top: 0.2rem;
    accent-color: var(--warsaw-red);
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

.layer-item input:disabled {
    cursor: not-allowed;
}

.layer-body {
    flex: 1;
    min-width: 0;
}

.layer-title {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
}

.layer-desc {
    display: block;
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 0.1rem;
}

.layer-badge {
    display: inline-block;
    margin-top: 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: #eee;
    color: #666;
}

.layer-badge--soon {
    background: rgba(255, 199, 44, 0.25);
    color: #7a5a00;
}

.site-footer {
    text-align: center;
    padding: 1.25rem 1rem 1.75rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.leaflet-container {
    background: var(--map-bg);
    font-family: var(--font);
}

.leaflet-image-layer img,
.leaflet-tile {
    image-rendering: auto;
    outline: 1px solid transparent;
    box-sizing: content-box;
}

.leaflet-control-attribution {
    display: none !important;
}

@media (max-width: 900px) {
    .map-layout,
    .editor-layout {
        grid-template-columns: 1fr;
    }

    .brand-logo--volista {
        height: 64px;
    }

    .city-map {
        min-height: 300px;
        height: 55vh;
    }
}
