.map-page {
    width: 100%;
}

.map-toolbar {
    display: grid;
    grid-template-columns: repeat(5, minmax(130px, 1fr)) minmax(220px, 1.4fr) repeat(2, minmax(130px, 0.8fr)) repeat(3, auto);
    gap: 8px;
    align-items: end;
    margin-bottom: 10px;
}

.map-toolbar label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: 0;
    font-size: 0.82rem;
    color: #334155;
}

.map-toolbar select,
.map-toolbar input,
.map-toolbar button {
    height: 34px;
    margin: 0;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
    font-size: 0.9rem;
}

.map-toolbar button {
    min-width: 38px;
    padding: 0 10px;
    cursor: pointer;
}

.map-unit-filter {
    position: relative;
}

.map-unit-filter label {
    margin: 0;
}

.map-unit-filter input[type="search"] {
    padding-right: 30px;
}

.map-unit-clear {
    position: absolute;
    right: 4px;
    top: 21px;
    width: 24px;
    min-width: 24px;
    height: 24px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.map-unit-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 20;
    display: grid;
    gap: 4px;
    width: min(430px, 86vw);
    max-height: 320px;
    overflow: auto;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}

.map-unit-results[hidden],
.map-unit-preview[hidden] {
    display: none;
}

.map-unit-result {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    width: 100%;
    min-height: 36px;
    border: 0;
    border-radius: 5px;
    padding: 5px 7px;
    background: #fff;
    color: #0f172a;
    cursor: pointer;
    text-align: left;
}

.map-unit-result:hover,
.map-unit-result:focus {
    background: #e2e8f0;
}

.map-unit-result img,
.map-unit-preview img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.map-unit-preview {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 7px;
    align-items: center;
    margin-top: 5px;
    color: #475569;
    font-size: 0.78rem;
}

.map-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 10px;
    min-height: calc(100vh - 210px);
}

#casualty-map {
    min-height: calc(100vh - 210px);
    height: 100%;
    border: 1px solid #cbd5e1;
    background: #e9eef3;
}

.map-panel {
    min-height: calc(100vh - 210px);
    max-height: calc(100vh - 210px);
    overflow: auto;
    border: 1px solid #cbd5e1;
    background: #fff;
    padding: 12px;
}

.map-summary-title,
.map-selected-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: #0f172a;
}

.map-summary-line,
.map-selected-line {
    color: #334155;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

#map-top-list {
    margin: 12px 0 0 18px;
}

#map-top-list li {
    margin-bottom: 7px;
    color: #0f172a;
}

#map-top-list button {
    width: 100%;
    text-align: left;
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #0f172a;
    cursor: pointer;
}

.map-drilldown-item {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 8px;
    padding: 8px 0;
    border-top: 1px solid #e2e8f0;
}

.map-drilldown-item img {
    width: 42px;
    height: 42px;
    object-fit: cover;
    background: #e2e8f0;
}

.map-drilldown-name {
    font-weight: 700;
    line-height: 1.2;
}

.map-drilldown-meta {
    color: #475569;
    font-size: 0.84rem;
}

.map-drilldown-pager {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.map-drilldown-pager button {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #f8fafc;
    color: #0f172a;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.map-drilldown-pager button:hover:not(:disabled),
.map-drilldown-pager button:focus:not(:disabled) {
    border-color: #94a3b8;
    background: #e2e8f0;
    color: #0f172a;
}

.map-drilldown-pager button:focus-visible {
    outline: 2px solid #64748b;
    outline-offset: 2px;
}

.map-drilldown-pager button:active:not(:disabled) {
    background: #cbd5e1;
    color: #0f172a;
}

.map-drilldown-pager button:disabled {
    background: #f8fafc;
    color: #64748b;
    cursor: not-allowed;
    opacity: 0.55;
}

.map-drilldown-page-indicator {
    min-width: 54px;
    color: #475569;
    font-size: 0.84rem;
    text-align: center;
}

#map-selected.is-loading {
    opacity: 0.72;
}

.map-error {
    padding: 12px;
    background: #fff1f2;
    color: #9f1239;
    border: 1px solid #fecdd3;
}

.map-legend {
    min-width: 118px;
    padding: 8px 9px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.7);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.16);
    color: #0f172a;
    font-size: 0.78rem;
}

.map-legend-title {
    margin-bottom: 5px;
    font-weight: 700;
}

.map-legend-row {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 6px;
    align-items: center;
    margin-top: 3px;
}

.map-legend-row span {
    width: 18px;
    height: 10px;
    border: 1px solid rgba(15, 23, 42, 0.22);
}

.maplibregl-popup-content {
    border-radius: 4px;
    color: #0f172a;
}

@media (max-width: 980px) {
    .map-toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .map-layout {
        grid-template-columns: 1fr;
    }

    #casualty-map,
    .map-panel {
        min-height: 460px;
        max-height: none;
    }
}
