:root {
    --bg: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --card: #ffffff;
    --chip: #f3f4f6;
    --focus: #2563eb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans KR", Arial, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    color: var(--text);
    background: var(--bg);
}

header {
    border-bottom: 1px solid var(--line);
    padding: 18px 18px 14px;
}

header .title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

header h1 {
    margin: 0;
    font-size: 18px;
    letter-spacing: -0.2px;
}

header .subtitle {
    color: var(--muted);
    font-size: 12px;
}

.wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 18px 24px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.tab {
    border: 1px solid var(--line);
    background: var(--chip);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    user-select: none;
}

.tab[aria-selected="true"] {
    background: #111827;
    color: white;
    border-color: #111827;
}

.tab:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.25);
    outline-offset: 2px;
}

/* Layout */
.grid {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 14px;
    align-items: start;
}

@media (max-width: 900px) {
    .grid {
        grid-template-columns: 1fr;
    }
}

.card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--card);
    padding: 14px;
}

.card h2 {
    margin: 0 0 10px;
    font-size: 14px;
    letter-spacing: -0.2px;
}

.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 10px;
}

.toolbar .group {
    display: flex;
    gap: 8px;
    align-items: center;
}

label {
    font-size: 12px;
    color: var(--muted);
}

select,
button {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: white;
    padding: 8px 10px;
    font-size: 13px;
}

button {
    cursor: pointer;
    font-weight: 700;
}

button:active {
    transform: translateY(1px);
}

button:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.25);
    outline-offset: 2px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 12px;
    color: var(--muted);
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9ca3af;
    display: inline-block;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* "Map" area (replaced with table) */
.map-wrap {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fafafa;
    padding: 12px;
}

/* Tooltip */
.tooltip {
    position: absolute;
    inset: auto auto auto auto;
    transform: translate(-50%, -110%);
    background: rgba(17, 24, 39, 0.92);
    color: white;
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.3;
    pointer-events: none;
    opacity: 0;
    transition: opacity .12s ease;
    white-space: nowrap;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
    z-index: 10;
}

.tooltip.show {
    opacity: 1;
}

.tooltip .t-title {
    font-weight: 800;
}

.tooltip .t-sub {
    color: rgba(255, 255, 255, 0.85);
    font-size: 11px;
}

/* Table */
.region-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--line);
}

.region-table thead th {
    text-align: left;
    font-size: 12px;
    color: var(--muted);
    padding: 10px 12px;
    background: #f9fafb;
    border-bottom: 1px solid var(--line);
}

.region-table tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    vertical-align: middle;
}

.region-table tbody tr:last-child td {
    border-bottom: none;
}

.region-table tbody tr {
    cursor: pointer;
    transition: background .12s ease;
}

.region-table tbody tr:hover {
    background: #f8fafc;
}

.region-table tbody tr[aria-selected="true"] {
    outline: 2px solid rgba(37, 99, 235, 0.35);
    outline-offset: -2px;
    background: #eef2ff;
}

.swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    border: 1px solid rgba(17, 24, 39, 0.12);
    display: inline-block;
    vertical-align: middle;
    margin-right: 10px;
}

.row-flex {
    display: flex;
    align-items: center;
    gap: 0;
}

.val {
    font-weight: 800;
}

.hint {
    color: var(--muted);
    font-size: 12px;
}

/* Legend */
.legend {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 10px;
}

.legend-bar {
    width: 220px;
    height: 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    overflow: hidden;
    background: linear-gradient(90deg,
            #eff6ff 0%,
            #93c5fd 25%,
            #60a5fa 50%,
            #2563eb 75%,
            #0b3b8b 100%);
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    width: 220px;
    font-size: 11px;
    color: var(--muted);
}

/* Side panel */
.kv {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 8px 10px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
}

.kv:first-of-type {
    border-top: none;
    padding-top: 0;
}

.k {
    color: var(--muted);
    font-size: 12px;
}

.v {
    font-size: 13px;
    font-weight: 700;
}

.small {
    font-size: 12px;
    color: var(--muted);
}

.list {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid var(--line);
    font-size: 13px;
}

.badge {
    border: 1px solid var(--line);
    background: #fff;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.muted {
    color: var(--muted);
}