/* ==========================================================================
   Canadian Historic Places Explorer - Stylesheet
   ========================================================================== */

:root {
    --color-parchment: #f5f0e6;
    --color-cream: #faf8f3;
    --color-ink: #1a1612;
    --color-sepia: #8b7355;
    --color-rust: #a65d3f;
    --color-forest: #2d4a3e;
    --color-gold: #c9a227;
    --color-slate: #4a5568;
    --color-muted: #6b7280;
    --color-border: #d4cfc4;
    --shadow-soft: 0 2px 15px rgba(26, 22, 18, 0.08);
    --shadow-lifted: 0 8px 30px rgba(26, 22, 18, 0.12);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Source Sans 3', sans-serif;
    background: var(--color-parchment);
    color: var(--color-ink);
    line-height: 1.6;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 1000;
}

/* ==========================================================================
   Header
   ========================================================================== */

header {
    background: linear-gradient(135deg, var(--color-forest) 0%, #1e3329 100%);
    color: var(--color-cream);
    padding: 2.5rem 2rem;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0L60 30L30 60L0 30z' fill='%23ffffff' fill-opacity='0.02'/%3E%3C/svg%3E");
    pointer-events: none;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

h1 {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.1rem;
    font-weight: 300;
    opacity: 0.85;
    max-width: 600px;
}

.stats-bar {
    display: flex;
    gap: 2rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.stat-value {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-gold);
}

.stat-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.7;
}

/* ==========================================================================
   Main Content
   ========================================================================== */

main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

/* ==========================================================================
   Controls / Filters
   ========================================================================== */

.controls {
    background: var(--color-cream);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--color-border);
}

.controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.controls-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--color-forest);
}

.reset-btn {
    background: none;
    border: 1px solid var(--color-sepia);
    color: var(--color-sepia);
    padding: 0.4rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}

.reset-btn:hover {
    background: var(--color-sepia);
    color: white;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.filter-group label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    font-weight: 500;
}

.filter-group input,
.filter-group select {
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    background: white;
    transition: var(--transition);
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--color-forest);
    box-shadow: 0 0 0 3px rgba(45, 74, 62, 0.1);
}

/* ==========================================================================
   Dashboard Grid & Cards
   ========================================================================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--color-cream);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--color-border);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lifted);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-forest);
}

.chart-hint {
    font-size: 0.75rem;
    color: var(--color-muted);
    opacity: 0.7;
    transition: var(--transition);
}

.card:hover .chart-hint {
    opacity: 1;
    color: var(--color-rust);
}

.card-body {
    padding: 1.25rem;
}

/* Full-width cards */
.map-card, .timeline-card, .treemap-card, .topic-card {
    grid-column: 1 / -1;
}

/* Extended card class for plugins */
.extended-card {
    grid-column: 1 / -1;
}

/* ==========================================================================
   Map
   ========================================================================== */

#map {
    height: 450px;
    border-radius: 8px;
    z-index: 1;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    font-family: 'Source Sans 3', sans-serif;
}

.leaflet-popup-content {
    margin: 12px 16px;
    min-width: 200px;
}

.popup-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-forest);
    margin-bottom: 0.5rem;
}

.popup-location {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-bottom: 0.5rem;
}

.popup-type {
    display: inline-block;
    background: var(--color-forest);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.popup-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}

.popup-details-btn {
    background: var(--color-forest);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.popup-details-btn:hover {
    background: #1e3329;
    transform: translateY(-1px);
}

.popup-link {
    display: block;
    color: var(--color-rust);
    font-size: 0.85rem;
    text-decoration: none;
    text-align: center;
}

.popup-link:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Charts
   ========================================================================== */

.chart-container {
    position: relative;
    height: 280px;
    cursor: pointer;
}

.chart-container-wide {
    height: 220px;
}

.chart-container-tall {
    height: 350px;
}

/* ==========================================================================
   Data Table
   ========================================================================== */

.table-card {
    grid-column: 1 / -1;
}

.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-count {
    font-size: 0.9rem;
    color: var(--color-muted);
}

.results-count strong {
    color: var(--color-forest);
    font-weight: 600;
}

.pagination {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.page-btn {
    background: white;
    border: 1px solid var(--color-border);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--color-forest);
    color: var(--color-forest);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    font-size: 0.9rem;
    color: var(--color-muted);
    padding: 0 0.5rem;
}

.table-wrapper {
    overflow-x: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: var(--color-parchment);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    white-space: nowrap;
    border-bottom: 2px solid var(--color-border);
    cursor: pointer;
    transition: var(--transition);
}

th:hover {
    color: var(--color-forest);
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

tr:hover td {
    background: rgba(45, 74, 62, 0.03);
}

.place-name {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-forest);
    cursor: pointer;
    transition: var(--transition);
}

.place-name:hover {
    color: var(--color-rust);
}

.place-location {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-top: 0.2rem;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-province {
    background: rgba(45, 74, 62, 0.1);
    color: var(--color-forest);
}

.badge-type {
    background: rgba(166, 93, 63, 0.1);
    color: var(--color-rust);
}

/* ==========================================================================
   Modal
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 22, 18, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: var(--color-cream);
    border-radius: 16px;
    max-width: 800px;
    max-height: 85vh;
    width: 90%;
    overflow: hidden;
    z-index: 1002;
    box-shadow: var(--shadow-lifted);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal-header {
    padding: 1.5rem 2rem;
    background: var(--color-forest);
    color: white;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255,255,255,0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    color: white;
    font-size: 1.2rem;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(255,255,255,0.3);
}

.modal-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-right: 2rem;
}

.modal-subtitle {
    font-size: 0.95rem;
    opacity: 0.85;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    max-height: calc(85vh - 120px);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.detail-item {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.detail-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    margin-bottom: 0.3rem;
}

.detail-value {
    color: var(--color-ink);
}

.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-forest);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-gold);
}

.detail-section p {
    color: var(--color-slate);
    line-height: 1.7;
}

.detail-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-rust);
    text-decoration: none;
    font-weight: 500;
    margin-top: 1rem;
}

.detail-link:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Loading & Error States
   ========================================================================== */

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--color-muted);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-forest);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.upload-zone {
    border: 2px dashed var(--color-border);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    background: white;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--color-forest);
    background: rgba(45, 74, 62, 0.03);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.upload-text {
    font-size: 1.1rem;
    color: var(--color-ink);
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--color-muted);
}

#file-input {
    display: none;
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
    text-align: center;
    padding: 2rem;
    color: var(--color-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--color-border);
    margin-top: 2rem;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--color-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* ==========================================================================
   Filter Status
   ========================================================================== */

.filter-status {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(45, 74, 62, 0.08) 0%, rgba(45, 74, 62, 0.04) 100%);
    border-radius: 8px;
    margin-top: 1rem;
    border: 1px solid rgba(45, 74, 62, 0.15);
    flex-wrap: wrap;
}

.filter-status.active {
    display: flex;
}

.filter-status-icon {
    width: 32px;
    height: 32px;
    background: var(--color-forest);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.filter-status-text {
    flex: 1;
    min-width: 150px;
}

.filter-status-count {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-forest);
}

.filter-status-label {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex: 2;
    justify-content: flex-end;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--color-slate);
}

.filter-chip-label {
    color: var(--color-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
}

.filter-chip-remove {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-border);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--color-muted);
    transition: var(--transition);
    padding: 0;
    line-height: 1;
}

.filter-chip-remove:hover {
    background: var(--color-rust);
    color: white;
}

/* ==========================================================================
   Topic Modeling Card Styles
   ========================================================================== */

.topic-select {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    background: white;
    cursor: pointer;
    transition: var(--transition);
}

.topic-select:focus {
    outline: none;
    border-color: var(--color-forest);
}

.topic-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
    gap: 1rem;
}

.topic-control-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topic-control-group label {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.topic-control-group input[type="range"] {
    width: 100px;
    cursor: pointer;
}

.topic-control-value {
    font-weight: 600;
    color: var(--color-forest);
    min-width: 2ch;
}

.topic-run-btn {
    background: var(--color-forest);
    color: white;
    border: none;
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.topic-run-btn:hover {
    background: #1e3329;
}

.topic-run-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.topic-status.processing {
    color: var(--color-rust);
}

.language-stats {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--color-parchment);
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.language-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.language-stat-label {
    color: var(--color-muted);
}

.language-stat-value {
    font-weight: 600;
    color: var(--color-forest);
}

.topic-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

@media (max-width: 900px) {
    .topic-results {
        grid-template-columns: 1fr;
    }
}

.topic-column {
    background: var(--color-parchment);
    border-radius: 8px;
    padding: 1rem;
}

.topic-column-header {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-forest);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-gold);
}

.topic-item {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.topic-item:hover {
    border-color: var(--color-forest);
    box-shadow: var(--shadow-soft);
}

.topic-item.selected {
    border-color: var(--color-forest);
    background: rgba(45, 74, 62, 0.05);
}

.topic-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.topic-item-title {
    font-weight: 600;
    color: var(--color-forest);
}

.topic-item-weight {
    font-size: 0.8rem;
    color: var(--color-muted);
}

.topic-words {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.topic-word {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    background: rgba(45, 74, 62, 0.1);
    color: var(--color-forest);
    border-radius: 4px;
}

.topic-word.high-weight {
    background: var(--color-forest);
    color: white;
}

.topic-timeline {
    margin-top: 1rem;
}

.topic-timeline-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-slate);
    margin-bottom: 0.5rem;
}

.topic-details-panel {
    margin-top: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.topic-details-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-forest);
    margin-bottom: 0.75rem;
}

.topic-example-places {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.topic-example-place {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.85rem;
}

.topic-example-place:last-child {
    border-bottom: none;
}

.topic-example-name {
    font-weight: 500;
    color: var(--color-forest);
    cursor: pointer;
}

.topic-example-name:hover {
    color: var(--color-rust);
    text-decoration: underline;
}

.topic-example-year {
    color: var(--color-muted);
    font-size: 0.8rem;
    flex-shrink: 0;
    margin-left: 1rem;
}

.topic-empty-hint {
    color: var(--color-muted);
    font-size: 0.9rem;
    text-align: center;
    font-style: italic;
    padding: 2rem;
}

/* ==========================================================================
   Mobile Styles
   ========================================================================== */

@media (max-width: 768px) {
    header { padding: 1.5rem 1rem; }
    .subtitle { font-size: 0.95rem; }
    .stats-bar { gap: 1rem; }
    .stat { flex-direction: column; align-items: flex-start; gap: 0; }
    .stat-value { font-size: 1.5rem; }
    .stat-label { font-size: 0.7rem; }
    main { padding: 1rem; }
    .controls { padding: 1rem; }
    .controls-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .filters { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    .filter-group input, .filter-group select { padding: 0.7rem 0.6rem; font-size: 16px; }
    .dashboard-grid { gap: 1rem; }
    #map { height: 300px; }
    .card-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .chart-container { height: 250px; }
    .topic-controls { flex-direction: column; align-items: stretch; }
    .topic-control-group { justify-content: space-between; }
    .modal { width: 100%; height: 100%; max-height: 100%; border-radius: 0; top: 0; left: 0; transform: translateY(100%); }
    .modal.active { transform: translateY(0); }
    .modal-header { padding: 1.25rem 1rem; }
    .modal-title { font-size: 1.4rem; }
    .modal-body { padding: 1.25rem 1rem; max-height: calc(100vh - 100px); }
    .detail-grid { grid-template-columns: 1fr; gap: 1rem; }
}

@media (max-width: 480px) {
    h1 { font-size: 1.6rem; }
    .filters { grid-template-columns: 1fr; }
    #map { height: 250px; }
    .chart-container { height: 220px; }
}
