/* EO Web App Styles — Festive Nomics dark theme.
   Palette from the brand site: pure black canvas, white text, and the
   signature orange→yellow→cyan gradient (#FF8A47 → #FFFE7B → #64EEFF →
   #FFFA34) used as glowing borders and accents. */

:root {
    color-scheme: dark;
    --bg: #000000;
    --surface: #0e0e11;
    --surface-2: #17171c;
    --border: #26262b;
    --text: #f5f5f5;
    --text-muted: #8f8f96;
    --primary: #64EEFF;
    --on-primary: #001318;
    --brand-orange: #FF8A47;
    --brand-pale: #FFFE7B;
    --brand-cyan: #64EEFF;
    --brand-yellow: #FFFA34;
    --brand-gradient: linear-gradient(170deg, #FF8A47 0%, #FFFE7B 30%, #64EEFF 55%, #FFFA34 100%);
    --glow: 0 0 14px rgba(100, 238, 255, 0.35), 0 0 28px rgba(255, 138, 71, 0.20);
    --highlight: rgba(100, 238, 255, 0.10);
    --success: #4ade80;
    --danger: #ff6b6b;
    --warning: #FF8A47;
    --warning-bg: rgba(255, 138, 71, 0.12);
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.6);
}

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

/* Bare content links (classed links style themselves) */
a:not([class]) { color: var(--primary); }
a:not([class]):hover { color: var(--brand-pale); }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Navigation — black bar with the brand site's faint gray-to-transparent
   header gradient */
.nav {
    background: linear-gradient(180deg, rgba(126,126,126,0.16) 0%, rgba(126,126,126,0.0) 100%), var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.nav-links { display: flex; gap: 0.25rem; }
.nav-link {
    text-decoration: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--primary); background: var(--highlight); }

/* Main area */
.main { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }

/* Flash messages */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.flash-success { background: rgba(74,222,128,0.10); color: var(--success); border: 1px solid rgba(74,222,128,0.35); }
.flash-error { background: rgba(255,107,107,0.10); color: var(--danger); border: 1px solid rgba(255,107,107,0.35); }
.flash-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(255,138,71,0.35); }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.card-header {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.25rem; }
.tab {
    padding: 0.6rem 1.25rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-weight: 500;
    transition: all 0.15s;
    text-decoration: none;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--text);
    border-bottom: 2px solid;
    border-image: var(--brand-gradient) 1;
}

/* Tables */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}
tr:hover td { background: rgba(255,255,255,0.03); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--highlight); }
td.num, th.num { text-align: right; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
/* Primary action — the brand site's login button: dark fill, gradient
   border, glow on hover */
.btn-primary {
    border: 2px solid transparent;
    background: linear-gradient(var(--surface), var(--surface)) padding-box,
                var(--brand-gradient) border-box;
    color: #fff;
}
.btn-primary:hover {
    background: linear-gradient(var(--surface-2), var(--surface-2)) padding-box,
                var(--brand-gradient) border-box;
    box-shadow: var(--glow);
}
.btn-success { background: #14532d; color: #dcfce7; border-color: #166534; }
.btn-success:hover { background: #166534; box-shadow: 0 0 12px rgba(74,222,128,0.25); }
.btn-danger { background: #58151c; color: #fecaca; border-color: #7f1d1d; }
.btn-danger:hover { background: #7f1d1d; box-shadow: 0 0 12px rgba(255,107,107,0.25); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-sm.btn-primary { padding: 0.3rem 0.6rem; }

/* Forms */
.form-group { margin-bottom: 0.75rem; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--surface-2);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(100,238,255,0.15); }
select.form-control { background: var(--surface-2); }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; }

/* Metrics grid */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.metric {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}
.metric-value { font-size: 1.5rem; font-weight: 700; }
.metric-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.metric-value.pos { color: var(--success); }
.metric-value.neg { color: var(--danger); }

/* Bar chart (CSS) */
.bar-chart { margin: 0.5rem 0; }
.bar-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.bar-label { width: 160px; text-align: right; font-size: 0.8rem; color: var(--text-muted); flex-shrink: 0; }
.bar-track { flex: 1; background: var(--surface-2); border-radius: 4px; height: 20px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--brand-gradient); transition: width 0.3s; min-width: 2px; }
.bar-value { width: 80px; font-size: 0.8rem; font-weight: 600; flex-shrink: 0; }

/* Collapsible sections */
.collapsible { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.5rem; overflow: hidden; }
.collapsible-header {
    padding: 0.75rem 1rem;
    background: var(--surface);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}
.collapsible-header:hover { background: var(--surface-2); }
.collapsible-header::after { content: '▼'; font-size: 0.7rem; color: var(--text-muted); transition: transform 0.2s; }
.collapsible.open .collapsible-header::after { transform: rotate(180deg); }
.collapsible-body { display: none; padding: 1rem; }
.collapsible.open .collapsible-body { display: block; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* Spinner */
.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Two-column layout */
.layout-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
/* Grid items refuse to shrink below their content by default (min-width:
   auto), which pushes the whole page wide; wide content scrolls inside
   .table-wrap instead */
.layout-2col > * { min-width: 0; }
@media (max-width: 900px) { .layout-2col { grid-template-columns: 1fr; } }

/* Pagination */
.pagination { display: flex; gap: 0.25rem; justify-content: center; margin-top: 1rem; }
.pagination a, .pagination span {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
    text-decoration: none;
    color: var(--text);
}
.pagination a:hover { background: var(--surface-2); }
.pagination .current { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

/* Workflow steps (home dashboard) */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.step-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.step-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--glow); }
.step-card.done { border-left: 3px solid var(--success); }
.step-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--on-primary);
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}
.step-card.done .step-num { background: var(--success); color: #052e16; }
.step-title { font-weight: 700; font-size: 0.95rem; }
.step-status { font-size: 0.85rem; font-weight: 600; color: var(--primary); margin-bottom: 0.35rem; }
.step-card.done .step-status { color: var(--success); }
.step-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.45; }

/* Nav step numbers */
.nav-brand { text-decoration: none; }
.nav-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    margin-right: 0.15rem;
}
.nav-link.active .nav-step { background: var(--primary); color: var(--on-primary); }

/* Running-task count badge in the nav */
.nav-task-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--warning);
    color: #2a1104;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 0.15rem;
}

/* Search Space panel (optimize page) */
.vs-row {
    display: grid;
    grid-template-columns: 210px 128px 1fr;
    gap: 0.75rem;
    align-items: center;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
}
.vs-row:last-of-type { border-bottom: none; }
.vs-name { font-weight: 600; font-size: 0.85rem; }
.vs-hint { font-size: 0.72rem; color: var(--text-muted); line-height: 1.3; }
.vs-modes { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.vs-mode {
    padding: 0.3rem 0.6rem;
    border: none;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}
.vs-mode + .vs-mode { border-left: 1px solid var(--border); }
.vs-mode.active { background: var(--primary); color: var(--on-primary); }
.vs-vals { display: flex; gap: 0.4rem; align-items: center; margin-top: 0.15rem; }
.vs-vals .form-control { width: 110px; padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.vs-vals select.form-control { width: auto; min-width: 200px; }
.vs-dash { font-size: 0.75rem; color: var(--text-muted); }
.vs-cat-read { font-size: 0.8rem; }

/* Dual-handle slider: two stacked range inputs over a shared track */
.vs-dual { position: relative; height: 22px; }
.vs-dual .vs-track {
    position: absolute; top: 9px; left: 0; right: 0;
    height: 4px; background: var(--border); border-radius: 2px;
}
.vs-dual input[type=range] {
    position: absolute; left: 0; top: 0; width: 100%; height: 22px; margin: 0;
    -webkit-appearance: none; appearance: none;
    background: none; pointer-events: none;
}
.vs-dual input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    pointer-events: auto;
    width: 15px; height: 15px; border-radius: 50%;
    background: var(--primary); border: 2px solid var(--bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.5); cursor: pointer;
}
.vs-dual input[type=range]::-moz-range-thumb {
    pointer-events: auto;
    width: 13px; height: 13px; border-radius: 50%;
    background: var(--primary); border: 2px solid var(--bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.5); cursor: pointer;
}
.vs-dual input[type=range]::-moz-range-track { background: none; }
@media (max-width: 900px) {
    .vs-row { grid-template-columns: 1fr; gap: 0.3rem; }
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-success { background: rgba(74,222,128,0.12); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-danger { background: rgba(255,107,107,0.12); color: var(--danger); }

/* Report chart images are rendered on white — give them a white frame so
   they don't float as bare rectangles on the black canvas */
.report-img { background: #fff; }

/* Utility */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.section-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); font-size: 0.85rem; }
.text-sm { font-size: 0.85rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
