/* ── Design tokens ─────────────────────────────────────────────────────────── */
:root {
    --ink:           #1b2433;
    --ink-mid:       #3c4f68;
    --ink-light:     #637488;
    --slate:         #253347;
    --slate-mid:     #3d5470;
    --sky:           #4a7fa5;
    --sky-light:     #dceef7;
    --copper:        #a0522d;
    --copper-light:  #f5e8df;
    --green:         #2e6b4f;
    --green-light:   #dff0e8;
    --red:           #8b2020;
    --red-light:     #fde8e8;
    --bg:            #eef0f4;
    --surface:       #ffffff;
    --surface-dim:   #f6f7f9;
    --border:        #d8dde6;
    --border-strong: #b8c0cc;
    --radius-sm:     3px;
    --radius:        6px;
    --radius-lg:     10px;
    --shadow-sm:     0 1px 3px rgba(27,36,51,.07), 0 1px 2px rgba(27,36,51,.05);
    --shadow:        0 3px 10px rgba(27,36,51,.09), 0 1px 4px rgba(27,36,51,.06);
    --shadow-lg:     0 8px 28px rgba(27,36,51,.12), 0 3px 10px rgba(27,36,51,.08);
    --font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono:     'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Body ──────────────────────────────────────────────────────────────────── */
body {
    font-family: var(--font);
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--ink);
    background: var(--bg);
    padding: 28px 20px;
    min-height: 100vh;
}

/* ── Container ─────────────────────────────────────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.header {
    background:
        linear-gradient(160deg, #1b2d44 0%, #253347 55%, #1e3a52 100%);
    color: #fff;
    padding: 40px 36px 32px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.header-text { flex: 1; min-width: 0; }

.header-logo {
    height: 36px;
    width: auto;
    flex-shrink: 0;
    filter: brightness(0) invert(1);
    opacity: 0.85;
    transition: opacity 0.15s;
}
.header-logo:hover { opacity: 1; }

/* Subtle seismogram wave decoration */
.header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        transparent 0%, #a0522d 20%, #c87941 35%,
        #e8a060 50%, #c87941 65%, #a0522d 80%, transparent 100%);
    opacity: 0.9;
}

.header h1 {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
    color: #f0f4f8;
}

.header p {
    font-size: 0.95rem;
    color: #8dadc8;
    letter-spacing: 0.01em;
}

/* ── Loading ───────────────────────────────────────────────────────────────── */
.loading-status {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    background: var(--sky);
    border-bottom: 1px solid #3a6e92;
    transition: background 0.8s ease, border-color 0.8s ease,
                color 0.8s ease, font-weight 0.4s ease;
}

.loading-status.ready {
    background: var(--surface-dim);
    border-bottom-color: var(--border);
    color: var(--ink-light);
    font-weight: normal;
}

/* bar fills the background of the status row */
.loading-bar {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0%;
    background: linear-gradient(90deg,
        rgba(255,255,255,.10) 0%,
        rgba(255,255,255,.28) 50%,
        rgba(255,255,255,.10) 100%);
    background-size: 200% 100%;
    transition: width 0.4s ease;
    animation: shimmer 1.8s infinite linear;
    z-index: 0;
}

/* text/dot sit above the bar */
.loading-status > :not(.loading-bar) { position: relative; z-index: 1; }

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.loading-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    animation: pulse 1.2s ease-in-out infinite;
    flex-shrink: 0;
}

.loading-status.ready .loading-status-dot { display: none; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.75); }
}

/* ── Tabs ──────────────────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    background: var(--surface-dim);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 8px;
    gap: 2px;
}

.tab {
    flex: 1;
    min-width: 0;
    padding: 13px 16px;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    border: none;
    background: none;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ink-light);
    letter-spacing: 0.02em;
    transition: color 0.2s, background 0.2s;
    position: relative;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab:hover {
    color: var(--ink-mid);
    background: rgba(74,127,165,.06);
}

.tab.active {
    color: var(--sky);
    border-bottom-color: var(--sky);
    background: var(--surface);
    font-weight: 600;
}

/* ── Tab content ───────────────────────────────────────────────────────────── */
.tab-content {
    display: none;
    padding: 28px 32px;
    animation: fadeIn 0.2s ease;
}

.tab-content.active { display: block; }

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

/* ── Status box ────────────────────────────────────────────────────────────── */
.status-box {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-size: 0.875rem;
    color: var(--ink-mid);
    border: 1px solid transparent;
}

.status-box.info {
    background: var(--sky-light);
    border-color: #b3d4e8;
    border-left: 3px solid var(--sky);
}

.status-box.success {
    background: var(--green-light);
    border-color: #aad4be;
    border-left: 3px solid var(--green);
}

.status-box.error {
    background: var(--red-light);
    border-color: #e8b8b8;
    border-left: 3px solid var(--red);
}

/* ── Form ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--ink-mid);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    color: var(--ink);
    background: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--sky);
    box-shadow: 0 0 0 3px rgba(74,127,165,.15);
}

select.form-control {
    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 d='M1 1l5 5 5-5' stroke='%23637488' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 12px 0;
}

.checkbox-group input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--sky);
    cursor: pointer;
}

.checkbox-group label {
    font-size: 0.875rem;
    font-weight: normal;
    text-transform: none;
    letter-spacing: 0;
    color: var(--ink);
    cursor: pointer;
    margin: 0;
}

/* ── Button ────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: var(--slate);
    color: #e8edf3;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.06);
}

.btn:hover:not(:disabled) {
    background: var(--slate-mid);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.08);
    transform: translateY(-1px);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn:disabled {
    background: var(--border-strong);
    color: var(--ink-light);
    cursor: not-allowed;
    box-shadow: none;
}

/* ── Output container ──────────────────────────────────────────────────────── */
.output-container {
    margin-top: 24px;
    background: var(--surface-dim);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.output-container h3 {
    padding: 14px 20px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-light);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.output-content {
    padding: 16px 20px;
    white-space: pre-wrap;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--ink-mid);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.plot-container {
    padding: 16px 20px;
}

.plot-container h4 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-light);
    margin: 16px 0 10px;
}

.plot-container h4:first-child { margin-top: 0; }

.plot-container img {
    max-width: 100%;
    display: block;
    margin: 0 auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* ── Layout helpers ────────────────────────────────────────────────────────── */
.two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 28px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.card h4 {
    color: var(--slate);
    margin-bottom: 10px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}

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

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
    body { padding: 12px 8px; }
    .tab-content { padding: 20px 16px; }
    .two-column { grid-template-columns: 1fr; gap: 12px; }
    .header { padding: 28px 20px 24px; }
    .header h1 { font-size: 1.5rem; }
    .tabs { padding: 0 4px; }
    .tab { flex: 0 0 auto; font-size: 0.8rem; padding: 11px 12px; }
}

.hidden { display: none !important; }

/* ── Download bar ───────────────────────────────────────────────────────────── */
.download-bar {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.download-bar .form-group { margin-bottom: 0; }
.download-bar .form-group label { margin-bottom: 4px; }
.download-bar select.form-control { min-width: 160px; }
.dl-error {
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--red-light);
    border: 1px solid #e8b8b8;
    border-left: 3px solid var(--red);
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-family: var(--font-mono);
    color: var(--red);
    white-space: pre-wrap;
}

/* ── Events & Stations tab ─────────────────────────────────────────────────── */
.events-controls {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 12px;
}

.events-controls .form-group { margin-bottom: 0; flex: 1; min-width: 110px; }


.events-pipeline {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 12px;
}

.events-pipeline-step {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.evt-pipe-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink-light);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 6px;
}

#eventsMap {
    height: 480px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin: 12px 0;
}

.events-status {
    font-size: 0.82rem;
    color: var(--ink-light);
    padding: 4px 0 8px;
}

/* ── Network pill panel ─────────────────────────────────────────────────────── */
.evt-network-panel {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: var(--surface-dim);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.evt-network-panel-label {
    font-size: 0.8rem;
    color: var(--ink-light);
    font-weight: 600;
    white-space: nowrap;
}

.evt-network-pills { display: flex; flex-wrap: wrap; gap: 6px; }

.evt-net-pill {
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink-light);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.evt-net-pill.active {
    background: var(--slate);
    border-color: var(--slate);
    color: #e8edf3;
}

.evt-net-pill:hover { opacity: 0.8; }

/* ── Event & station detail cards ───────────────────────────────────────────── */
.events-cards {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.evt-card {
    flex: 1;
    min-width: 260px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    box-shadow: var(--shadow-sm);
}

.evt-event-card   { border-left: 3px solid var(--sky); }
.evt-station-card { border-left: 3px solid var(--green); }

.evt-card-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--slate);
    margin-bottom: 3px;
}

.evt-card-meta {
    font-size: 0.8rem;
    color: var(--ink-light);
    font-family: var(--font-mono);
    margin-bottom: 10px;
    line-height: 1.5;
}

.evt-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.evt-card-actions .btn { padding: 7px 14px; font-size: 0.8rem; }

/* Station triangle marker */
.sta-marker {
    width: 0; height: 0;
    border-left:  7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 13px solid #999;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.35));
}

.sta-no-data { color: #cc3333; font-size: 0.8rem; }

/* Channel pills inside station card reuse .evt-net-pill */
.sta-channels { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

@media (max-width: 720px) {
    #eventsMap { height: 320px; }
    .events-controls { gap: 12px; }
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 14px 36px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--ink-light);
}
.footer a { color: var(--ink-light); }
.footer a:hover { color: var(--slate); }

/* ── About tab ─────────────────────────────────────────────────────────────── */
.about-section {
    margin-bottom: 28px;
}
.about-section h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--slate);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.about-section p {
    font-size: 0.9rem;
    color: var(--ink);
    line-height: 1.65;
    margin-bottom: 8px;
}
.about-section a { color: var(--slate); }
.about-list {
    font-size: 0.9rem;
    color: var(--ink);
    line-height: 1.65;
    padding-left: 1.4em;
}
.about-list li { margin-bottom: 4px; }
.about-acks {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    margin-bottom: 12px;
}
.about-acks td {
    padding: 5px 12px 5px 0;
    vertical-align: top;
    color: var(--ink);
    border-bottom: 1px solid var(--border);
}
.about-acks td:first-child { font-weight: 600; white-space: nowrap; min-width: 120px; }
.about-acks td a { color: var(--slate); }
.about-note {
    font-size: 0.82rem;
    color: var(--ink-light);
    font-style: italic;
}

