* { box-sizing: border-box; }
html {
    margin: 0;
    padding: 0;
    scroll-behavior: smooth;
    min-height: 100%;
    background: #0b1118;
}
body { margin: 0; padding: 0; min-height: 100vh; }
:root {
    --page-max-width: 1600px;
    --page-padding: 18px;
    --header-offset: 18px;
    --panel-surface: linear-gradient(180deg, rgba(22,32,45,0.95), rgba(14,21,30,0.95));
    --panel-border: #223246;
}
body {
    position: relative;
    font-family: Arial, Helvetica, sans-serif;
    color: #e8eef6;
    background: transparent;
}
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-color: #0b1118;
    background-image:
        radial-gradient(circle at top, rgba(48, 90, 132, 0.24), transparent 38%),
        linear-gradient(180deg, #16283c 0%, #0f1b29 24%, #0b1118 58%, #091018 100%);
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed;
}
.page-shell {
    max-width: var(--page-max-width);
    margin: 0 auto;
    padding: calc(var(--header-offset) + 2px) var(--page-padding) 18px;
}
[id] {
    scroll-margin-top: calc(var(--header-offset) + 8px);
}
.panel {
    background: var(--panel-surface);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.2);
}
.bare-panel {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin-bottom: 0;
}
.global-header {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    padding: 0;
    background: linear-gradient(180deg, rgba(12, 19, 29, 0.98), rgba(13, 22, 34, 0.94));
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}
.global-header-inner {
    width: 100%;
}
.top-bar {
    position: relative;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    width: 100%;
    padding: 12px var(--page-padding);
    border-bottom: 1px solid rgba(61, 84, 109, 0.5);
    background:
        linear-gradient(180deg, rgba(14, 24, 35, 0.95), rgba(10, 18, 27, 0.9)),
        radial-gradient(circle at top left, rgba(75, 122, 170, 0.22), transparent 34%);
}
.top-bar-copy {
    max-width: 780px;
}
.eyebrow {
    display: inline-block;
    margin-bottom: 5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.7rem;
    color: #8fbde0;
}
.top-bar h1 { margin: 0 0 6px; font-size: 1.15rem; line-height: 1.15; }
.top-bar p { margin: 0; color: #a5b4c7; font-size: 0.78rem; line-height: 1.35; }
.sub-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    margin: 0;
    padding: 8px var(--page-padding);
    border-bottom: 1px solid rgba(124, 163, 194, 0.14);
    background: rgba(15, 24, 36, 0.52);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.sub-bar a {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 12px;
    border-radius: 999px;
    color: #d9ebfb;
    text-decoration: none;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(135, 170, 198, 0.14);
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    font-size: 0.84rem;
}
.sub-bar a:hover,
.sub-bar a:focus-visible {
    background: rgba(39, 89, 126, 0.34);
    border-color: rgba(121, 188, 232, 0.38);
    transform: translateY(-1px);
}
.sub-bar a.is-active,
.sub-bar a[aria-current="page"] {
    background: rgba(40, 109, 157, 0.42);
    border-color: rgba(121, 188, 232, 0.42);
    color: #f4fbff;
}
.panel { padding: 16px; margin-bottom: 16px; }
.error-panel { color: #ffd3d3; background: linear-gradient(180deg, rgba(65,21,28,0.98), rgba(38,14,18,0.98)); border-color: #7a3440; }
.filters-grid {
    display: grid;
    grid-template-columns: 2fr 1fr repeat(2, 120px) 1.3fr;
    gap: 10px 12px;
    align-items: end;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field:has(#mapPresetDisplay) {
    display: none;
}
.field label { font-size: 0.82rem; color: #aec0d5; }
.field input, .field select {
    width: 100%; min-height: 36px; border-radius: 10px; border: 1px solid #31465f;
    background: #09121b; color: #f2f7fc; padding: 8px 10px; font-size: 0.9rem;
}
.chip {
    border: 1px solid #2f78a9; background: #0d3147; color: #dff4ff; border-radius: 999px;
    padding: 8px 14px; cursor: pointer; font-weight: 700; font-size: 0.84rem;
}
.chip.active { background: #1c79b6; border-color: #4bb4ff; }
.chip-secondary { border-color: #485f75; background: #15202b; color: #d7e5f2; }
.map-results-shell {
    background: var(--panel-surface);
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.2);
    overflow: hidden;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.85fr);
    gap: 0;
    align-items: stretch;
}
.map-pane {
    padding: 0;
    border-right: 1px solid #223246;
}
.results-pane {
    border-left: 0;
    background: rgba(10, 16, 24, 0.42);
    display: flex;
    flex-direction: column;
}
.table-panel {
    min-width: 0;
}
.table-panel .table-wrap {
    flex: 1 1 auto;
    max-height: none;
    overflow: hidden;
    border: 0;
}
.bare-panel .table-wrap {
    border-radius: 0;
}
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-top: 0;
    background: rgba(12, 19, 29, 0.72);
}
.pagination-meta {
    color: #9eb0c4;
    font-size: 0.82rem;
}
.pagination-bar .chip[disabled] {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}
.panel-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.panel-heading h2 { margin: 0; font-size: 0.98rem; }
.panel-heading span { color: #90a0b4; font-size: 0.82rem; }
.heatmap-stage {
    position: relative;
    width: 100%;
    min-height: 300px;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 0;
    border: 0;
    background: radial-gradient(circle at 20% 20%, #112236, #0f1520 50%, #0a1018 100%);
}
.heatmap-stage.has-map {
    aspect-ratio: 1 / 1;
    max-width: 100%;
}
.heatmap-stage::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(5, 10, 16, 0.08), rgba(5, 10, 16, 0.18));
}
.heatmap-stage.generic-stage::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 48px 48px;
}
.map-background,
#heatmapCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.map-background {
    z-index: 0;
    object-fit: contain;
    object-position: center;
    opacity: 0.24;
    filter: grayscale(0.06) saturate(0.95) brightness(0.92) contrast(1.02);
}
#heatmapCanvas {
    z-index: 1;
}
.heatmap-empty-note {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 3;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid #324b67;
    background: rgba(7, 14, 22, 0.78);
    color: #cdd8e6;
    font-size: 0.76rem;
}
.species-table-wrap, .table-wrap { overflow: auto; border-radius: 14px; border: 1px solid #25374b; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid #1f3142; text-align: left; vertical-align: top; }
th { background: #132130; color: #d8e5f4; white-space: nowrap; }
#spawnTable th[data-sort], #speciesTable tbody tr { cursor: pointer; }
#spawnTable th,
#spawnTable td {
    text-align: center;
}
#spawnTable th:first-child,
#spawnTable td:first-child {
    text-align: left;
}
#spawnTable tbody tr:hover, #speciesTable tbody tr:hover { background: #142433; }
.empty-row { text-align: center; color: #95a6ba; padding: 18px; }
.filler-row td {
    color: transparent;
    user-select: none;
}
.filler-row:hover {
    background: transparent !important;
}
.mono { font-family: Consolas, Monaco, monospace; font-size: 0.78rem; }
.placeholder-copy {
    margin: 0;
    color: #aab7c8;
    font-size: 0.9rem;
}
.settings-list {
    display: grid;
    gap: 10px;
}
.settings-row {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    gap: 14px;
    align-items: start;
    padding: 10px 0;
    border-top: 1px solid #223246;
}
.settings-row:first-child {
    border-top: 0;
    padding-top: 0;
}
.settings-label {
    color: #90a0b4;
    font-size: 0.82rem;
}
.settings-value {
    color: #e8eef6;
    font-size: 0.92rem;
    word-break: break-word;
}
.source-pill {
    display: inline-block; margin-left: 6px; padding: 2px 6px; border-radius: 999px; font-size: 0.66rem; font-weight: 700;
}
.derived-pill { background: #1f5f45; color: #d9ffed; }
.native-pill { background: #2e5578; color: #e4f2ff; }
.blank-pill { background: #4a3840; color: #ffdfe9; }
@media (max-width: 1200px) {
    :root { --header-offset: 18px; }
    .filters-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .results-pane { border-left: 0; border-top: 1px solid #223246; }
    .top-bar { flex-direction: column; }
    .hero-badges { width: 100%; }
}
@media (max-width: 760px) {
    :root {
        --page-padding: 14px;
        --header-offset: 14px;
    }
    .page-shell { padding-bottom: 14px; }
    .top-bar {
        padding: 12px 14px;
    }
    .top-bar h1 { font-size: 1rem; }
    .sub-bar {
        padding: 8px 14px;
    }
    .hero-badges { grid-template-columns: 1fr; width: 100%; }
    .filters-grid { grid-template-columns: 1fr; }
    .settings-row { grid-template-columns: 1fr; gap: 6px; }
    th, td { padding: 10px; }
}
