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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f2f0ec;
    color: #2d2d2d;
    overflow: hidden;
    height: 100vh;
}

/* Full-width layout: map fills viewport, sidebar overlays */
#layout {
    position: relative;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar as overlay drawer */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
}

#sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

/* Sidebar toggle button */
#sidebar-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    width: 32px;
    height: 36px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    color: #4a6741;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s, border-color 0.2s, border-radius 0.3s;
    line-height: 1;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* When open: glue to sidebar edge, square off left corners */
#sidebar.open ~ #sidebar-toggle {
    left: 320px;
    border-radius: 0 8px 8px 0;
    border-left: none;
}

#sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: #4a6741;
}

/* Overlay to close sidebar on click */
#sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    background: transparent;
}

#sidebar.open ~ #sidebar-overlay {
    display: block;
}

#header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid #e0dbd4;
}

#header h1 {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 22px;
    font-weight: 600;
    color: #4a6741;
    margin-bottom: 4px;
}

#header .subtitle {
    font-size: 12px;
    color: #8a857e;
    margin-bottom: 2px;
}

#header .subtitle a {
    color: #4a6741;
    text-decoration: none;
    border-bottom: 1px dotted #4a6741;
}

/* Resource cards in sidebar */
#resources {
    padding: 10px 12px;
    border-bottom: 1px solid #e0dbd4;
}

#resources h3 {
    font-size: 11px;
    color: #8a857e;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.resource-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.15s;
    margin-bottom: 2px;
}

.resource-card:hover {
    background: rgba(74, 103, 65, 0.08);
}

.rc-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.rc-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.rc-title {
    font-size: 13px;
    font-weight: 600;
    color: #4a6741;
    line-height: 1.3;
}

.rc-desc {
    font-size: 10px;
    color: #8a857e;
    line-height: 1.3;
}

#global-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #e0dbd4;
    font-size: 12px;
}

#global-stats .stat {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

#global-stats .stat-value {
    font-weight: 700;
    color: #4a6741;
    font-size: 15px;
}

#global-stats .stat-label {
    color: #6b6660;
    font-size: 11px;
}

#controls {
    padding: 12px 16px;
    border-bottom: 1px solid #e0dbd4;
}

#controls h3 {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 14px;
    font-weight: 600;
    color: #4a6741;
    margin-bottom: 8px;
}

.scan-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.scan-form input[type="text"] {
    width: 100%;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid #e0dbd4;
    border-radius: 4px;
    color: #2d2d2d;
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
}

.scan-form input[type="text"]::placeholder {
    color: #8a857e;
}

.scan-row {
    display: flex;
    gap: 6px;
}

.scan-form input[type="number"] {
    width: 70px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid #e0dbd4;
    border-radius: 4px;
    color: #2d2d2d;
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
}

.scan-form button {
    flex: 1;
    padding: 7px 16px;
    background: #4a6741;
    border: 1px solid #4a6741;
    border-radius: 4px;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    transition: background 0.2s, box-shadow 0.2s;
}

.scan-form button:hover {
    background: #3a5333;
    box-shadow: 0 2px 8px rgba(74, 103, 65, 0.25);
}

.scan-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#scan-status {
    font-size: 11px;
    color: #b8860b;
    margin-top: 6px;
}

#legend {
    padding: 12px 16px;
    border-bottom: 1px solid #e0dbd4;
    font-size: 12px;
    color: #2d2d2d;
}

#legend h3 {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #4a6741;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
}

.legend-color {
    display: inline-block;
    width: 14px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Scan results in sidebar */
#scan-results {
    flex: 1;
    padding: 12px 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#scan-results h3 {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #4a6741;
    flex-shrink: 0;
}

#results-wrap {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

#results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

#results-table th {
    background: rgba(74, 103, 65, 0.08);
    padding: 5px 6px;
    text-align: left;
    font-weight: 600;
    color: #4a6741;
    position: sticky;
    top: 0;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e0dbd4;
}

#results-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #e8e4de;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
    color: #2d2d2d;
}

#results-table tr:hover {
    background: rgba(74, 103, 65, 0.05);
}

#results-table tbody tr {
    cursor: pointer;
}

/* Main area: map + timeline — always full width */
#main {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#map-container {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

#map {
    flex: 1;
    min-height: 0;
    background: #f2f0ec;
}

/* Timeline slider */
#timeline {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

#timeline-play {
    flex-shrink: 0;
    padding: 4px 12px;
    border: 1px solid #4a6741;
    border-radius: 4px;
    background: #4a6741;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    font-family: 'DM Sans', sans-serif;
}

#timeline-play.inactive {
    background: transparent;
    color: #4a6741;
}

#timeline-play:hover {
    opacity: 0.85;
}

#timeline-slider-wrap {
    flex: 1;
    position: relative;
}

#timeline-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #e0dbd4;
    outline: none;
    cursor: pointer;
}

#timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4a6741;
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    transition: box-shadow 0.2s;
}

#timeline-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 1px 8px rgba(74, 103, 65, 0.5);
}

#timeline-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4a6741;
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

#timeline-ticks {
    display: flex;
    justify-content: space-between;
    padding: 4px 2px 0;
    font-size: 10px;
    color: #8a857e;
    pointer-events: none;
    user-select: none;
}

#timeline-label {
    flex-shrink: 0;
    min-width: 140px;
    text-align: right;
    font-size: 12px;
    color: #4a6741;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

#export-controls {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
    margin-left: 8px;
    border-left: 1px solid #e0dbd4;
    padding-left: 12px;
}

.export-btn {
    padding: 4px 10px;
    border: 1px solid #c5bfb6;
    border-radius: 3px;
    background: transparent;
    color: #6b6660;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'DM Sans', sans-serif;
}

.export-btn:hover {
    border-color: #4a6741;
    color: #4a6741;
    background: rgba(74, 103, 65, 0.06);
}

.export-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* light map tiles */
.leaflet-container {
    background: #f2f0ec;
}

/* PQC status classes */
.pqc-yes {
    color: #3a7a2e;
    font-weight: 700;
}

.pqc-no {
    color: #c0392b;
}

.pqc-error {
    color: #b8860b;
    font-size: 11px;
}

.sec-ok {
    color: #3a7a2e;
}

.sec-warning {
    color: #b8860b;
}

.sec-critical {
    color: #c0392b;
    font-weight: 600;
}

/* Host Detail Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 12px;
    width: 700px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.78);
    border-bottom: 1px solid #e0dbd4;
    border-radius: 12px 12px 0 0;
    position: sticky;
    top: 0;
    z-index: 1;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.modal-header h2 {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 20px;
    font-weight: 600;
    color: #4a6741;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: #8a857e;
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-close:hover {
    color: #2d2d2d;
}

.modal-body {
    padding: 20px;
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section h3 {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 15px;
    font-weight: 600;
    color: #4a6741;
    margin-bottom: 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e0dbd4;
}

.modal-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 6px 12px;
    font-size: 13px;
}

.modal-grid .label {
    color: #8a857e;
}

.modal-grid .value {
    color: #2d2d2d;
    word-break: break-all;
}

/* Custom scrollbar for sidebar */
#sidebar::-webkit-scrollbar,
#results-wrap::-webkit-scrollbar {
    width: 6px;
}

#sidebar::-webkit-scrollbar-track,
#results-wrap::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
}

#sidebar::-webkit-scrollbar-thumb,
#results-wrap::-webkit-scrollbar-thumb {
    background: #d5cfc7;
    border-radius: 3px;
}

#sidebar::-webkit-scrollbar-thumb:hover,
#results-wrap::-webkit-scrollbar-thumb:hover {
    background: #b8b2a8;
}

/* Modal scrollbar */
.modal::-webkit-scrollbar {
    width: 6px;
}

.modal::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
}

.modal::-webkit-scrollbar-thumb {
    background: #d5cfc7;
    border-radius: 3px;
}

.modal::-webkit-scrollbar-thumb:hover {
    background: #b8b2a8;
}

/* Sidebar footer logos */
.sidebar-footer {
    padding: 16px 20px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    text-align: center;
}

.sidebar-footer-label {
    font-size: 10px;
    color: #8a857e;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 10px;
}

.sidebar-footer-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.sidebar-footer-logos a {
    display: inline-flex;
    align-items: center;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.sidebar-footer-logos a:hover {
    opacity: 1;
}

.sidebar-footer-logos img {
    height: 24px;
    width: auto;
}

.sidebar-footer-logos .qd-logo {
    height: 18px;
    width: auto;
    color: #8a857e;
}

.sidebar-footer-logos a:hover .qd-logo {
    color: #2d2d2d;
}

/* Leaflet popup overrides for light theme */
.leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    color: #2d2d2d;
}

.leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.92);
}

.leaflet-popup-content {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    color: #2d2d2d;
    line-height: 1.5;
}

.leaflet-popup-content b {
    color: #2d2d2d;
}
