/* ===== Reset & base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
    --bg-0:        #0b1120;
    --bg-1:        #111a2e;
    --bg-2:        #1a2540;
    --border:      #243155;
    --text:        #e6ecff;
    --text-dim:    #8a96b8;
    --text-muted:  #5d6a8a;
    --accent:      #06b6d4;
    --accent-2:    #0ea5e9;
    --accent-glow: rgba(6, 182, 212, 0.25);
    --ok:          #10b981;
    --warn:        #f59e0b;
    --err:         #ef4444;
    --pending:     #475569;
    --radius:      14px;
    --shadow:      0 10px 30px rgba(0,0,0,0.35);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(14, 165, 233, 0.18), transparent 60%),
        radial-gradient(900px 500px at -10% 30%, rgba(6, 182, 212, 0.12), transparent 60%),
        var(--bg-0);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 22px 80px;
}

/* ===== Header ===== */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.01em;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    display: grid;
    place-items: center;
    box-shadow: 0 6px 18px var(--accent-glow);
    font-size: 18px;
}

.site-tagline {
    color: var(--text-dim);
    font-size: 13px;
}

/* ===== Hero / search ===== */
.hero {
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.hero h1 {
    margin: 0 0 6px;
    font-size: 28px;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, #fff, #a5f3fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero p {
    margin: 0 0 22px;
    color: var(--text-dim);
    font-size: 14px;
    max-width: 640px;
}

.search-form {
    display: grid;
    grid-template-columns: 1fr 160px 140px;
    gap: 12px;
}

.search-input,
.search-select,
.search-button {
    height: 52px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-1);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s, transform .05s;
    padding: 0 16px;
}

.search-input:focus,
.search-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.search-input::placeholder { color: var(--text-muted); }

.search-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238a96b8' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
    cursor: pointer;
}

.search-button {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: none;
    color: #06121a;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 22px var(--accent-glow);
    letter-spacing: 0.02em;
}
.search-button:hover { transform: translateY(-1px); }
.search-button:active { transform: translateY(0); }
.search-button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ===== Status bar ===== */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 16px;
    padding: 14px 18px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 13.5px;
    color: var(--text-dim);
    min-height: 50px;
}

.status-bar.hidden { display: none; }

.status-text strong { color: var(--text); }

.status-pills {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg-2);
    font-size: 12.5px;
    border: 1px solid var(--border);
}

.pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.pill.ok   .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill.warn .dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.pill.err  .dot { background: var(--err); box-shadow: 0 0 8px var(--err); }

.progress-bar {
    height: 3px;
    width: 100%;
    background: var(--bg-2);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 8px;
}
.progress-bar .fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width .25s ease;
}

/* ===== Grid layout ===== */
.layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}

/* ===== Map ===== */
.map-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    height: 560px;
    position: sticky;
    top: 22px;
}

#map { width: 100%; height: 100%; background: #0b1120; }

.leaflet-tile-pane { filter: brightness(0.85) contrast(1.05); }

/* ===== Results panel ===== */
.results-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-card {
    display: grid;
    grid-template-columns: 30px 1fr auto;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color .2s, transform .15s;
    align-items: center;
}

.result-card:hover { border-color: #2f3f6b; transform: translateY(-1px); }

.result-card .status-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--bg-2);
    color: var(--pending);
    flex-shrink: 0;
    transition: all .25s ease;
}

.result-card[data-state="ok"]      .status-icon { background: rgba(16, 185, 129, 0.15); color: var(--ok); }
.result-card[data-state="diverge"] .status-icon { background: rgba(245, 158, 11, 0.15); color: var(--warn); }
.result-card[data-state="err"]     .status-icon { background: rgba(239, 68, 68, 0.15); color: var(--err); }
.result-card[data-state="pending"] .status-icon { animation: pulse 1.4s ease-in-out infinite; }

@keyframes pulse {
    0%,100% { opacity: 0.4; }
    50%     { opacity: 1; }
}

.result-card .meta {
    min-width: 0;
}
.result-card .meta-line-1 {
    font-weight: 600;
    font-size: 14.5px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.25;
}
.result-card .flag { font-size: 18px; }
.result-card .meta-line-2 {
    color: var(--text-dim);
    font-size: 12.5px;
    margin-top: 2px;
}
.result-card .records {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    grid-column: 2 / -1;
}
.result-card .record {
    display: inline-block;
    padding: 3px 8px;
    background: var(--bg-2);
    border-radius: 6px;
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    font-size: 12.5px;
    color: var(--text);
    border: 1px solid var(--border);
    word-break: break-all;
}
.result-card[data-state="ok"]      .record { border-color: rgba(16, 185, 129, 0.4); }
.result-card[data-state="diverge"] .record { border-color: rgba(245, 158, 11, 0.4); }

.result-card .right-meta {
    text-align: right;
    color: var(--text-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.empty-state {
    text-align: center;
    color: var(--text-dim);
    padding: 80px 20px;
    background: var(--bg-1);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty-state .ico { font-size: 42px; margin-bottom: 14px; opacity: 0.5; }
.empty-state h3 { margin: 0 0 6px; color: var(--text); font-weight: 600; }

/* ===== Footer ===== */
.site-footer {
    margin-top: 60px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 12.5px;
}
.site-footer .footer-legal {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 8px;
    margin-bottom: 10px;
}
.site-footer .footer-legal a {
    color: var(--text-dim);
    text-decoration: none;
    transition: color .15s;
}
.site-footer .footer-legal a:hover { color: var(--text); }
.site-footer .footer-legal span { color: var(--text-muted); }
.site-footer .footer-copy { color: var(--text-dim); margin-bottom: 14px; }
.site-footer .footer-partners {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px 10px;
    margin-bottom: 10px;
    font-size: 12.5px;
}
.site-footer .partners-label { color: var(--text-muted); }
.site-footer .partner-link {
    color: #22c55e;
    font-weight: 600;
    text-decoration: none;
    transition: color .15s;
}
.site-footer .partner-link:hover { color: #4ade80; text-decoration: underline; }
.site-footer .partners-sep { color: var(--text-muted); }
.site-footer .footer-tech { color: var(--text-muted); font-size: 11.5px; opacity: .7; }

/* ===== Legal pages ===== */
.legal-page {
    margin: 0 auto;
    max-width: 820px;
}
.legal-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 38px;
    box-shadow: var(--shadow);
    color: var(--text);
    line-height: 1.65;
}
.legal-card h1 {
    margin: 0 0 6px;
    font-size: 26px;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, #fff, #a5f3fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.legal-card .legal-date {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0 0 26px;
}
.legal-card h2 {
    color: var(--text);
    font-size: 17px;
    font-weight: 700;
    margin: 28px 0 8px;
    border-left: 3px solid var(--accent);
    padding-left: 10px;
}
.legal-card h3 {
    color: var(--text);
    font-size: 14.5px;
    font-weight: 600;
    margin: 18px 0 6px;
    color: var(--text-dim);
}
.legal-card p,
.legal-card ul,
.legal-card ol {
    color: var(--text-dim);
    font-size: 14px;
    margin: 0 0 12px;
}
.legal-card ul, .legal-card ol { padding-left: 22px; }
.legal-card li { margin-bottom: 6px; }
.legal-card strong { color: var(--text); font-weight: 600; }
.legal-card em { color: var(--text-dim); }
.legal-card a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dotted rgba(6, 182, 212, 0.4);
}
.legal-card a:hover { color: #67e8f9; border-bottom-color: var(--accent); }
.legal-card hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}
.legal-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 18px;
    color: var(--text-dim);
    font-size: 13px;
    text-decoration: none;
}
.legal-back:hover { color: var(--accent); }

/* ===== Responsive ===== */
@media (max-width: 980px) {
    .layout { grid-template-columns: 1fr; }
    .map-card { height: 380px; position: static; }
    .search-form { grid-template-columns: 1fr; }
    .search-input, .search-select, .search-button { width: 100%; }
    .hero { padding: 22px; }
    .hero h1 { font-size: 22px; }
}

/* ===== Leaflet popup overrides ===== */
.leaflet-popup-content-wrapper {
    background: var(--bg-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.leaflet-popup-tip { background: var(--bg-2); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.5; }
.leaflet-popup-content b { color: var(--text); }
.leaflet-control-attribution {
    background: rgba(11, 17, 32, 0.85) !important;
    color: var(--text-muted) !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }
