/* ============================================================
   FracNG Dashboard — Professional Light Theme
   High contrast, high readability
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-primary: #f5f6f8;
    --bg-card: #ffffff;
    --bg-card-alt: #fafbfc;
    --bg-card-hover: #f0f1f3;
    --bg-input: #ffffff;
    --border-color: #d8dce3;
    --border-subtle: #e8eaef;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --accent-green: #16a34a;
    --accent-green-dim: #15803d;
    --accent-cyan: #0891b2;
    --accent-purple: #7c3aed;
    --accent-blue: #2563eb;
    --accent-orange: #d97706;
    --accent-red: #dc2626;
    --accent-yellow: #ca8a04;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #ca8a04;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 6px;
    --radius-lg: 8px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* --- Base --- */
* { box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    padding: 16px;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
}

/* --- Header --- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

h1 {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

h2 {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- Tabs --- */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
    gap: 0;
    flex-wrap: wrap;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
    white-space: nowrap;
    transition: all 0.15s ease;
    user-select: none;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-card-alt);
}

.tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    font-weight: 700;
    background: var(--bg-card);
}

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

/* --- Cards --- */
.card, .hacker-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.card:hover, .hacker-card:hover {
    box-shadow: var(--shadow-md);
}

/* --- Grids --- */
.grid {
    display: grid;
    gap: 12px;
    margin-bottom: 20px;
}

.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }

/* --- Section Headers --- */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    margin-top: 24px;
    margin-bottom: 12px;
    border-left: 3px solid var(--accent-blue);
    padding-left: 12px;
}

.section-title {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* --- Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

th {
    text-align: left;
    padding: 8px 8px;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-card-alt);
}

td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-primary);
}

tr:nth-child(even) td {
    background: var(--bg-card-alt);
}

tr:hover td {
    background: var(--bg-card-hover);
}

.th-group {
    text-align: center;
    border-bottom: 2px solid var(--text-muted);
}

/* --- Metrics --- */
.metric-value {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 700;
    margin: 8px 0;
    color: var(--text-primary);
}

.metric-label {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.metric-sub {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Key Metric Cards */
.key-metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.key-metric-val {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 700;
    margin: 4px 0;
    color: var(--text-primary);
}

.key-metric-lbl {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* --- Text Colors --- */
.text-green { color: var(--accent-green) !important; }
.text-red { color: var(--accent-red) !important; }
.text-blue { color: var(--accent-blue) !important; }
.text-yellow { color: var(--accent-yellow) !important; }
.text-warning, .text-orange { color: var(--accent-orange) !important; }
.text-cyan { color: var(--accent-cyan) !important; }
.text-purple { color: var(--accent-purple) !important; }

/* Glow text — light theme: just bold color, no shadow */
.glow-green { color: var(--accent-green); font-weight: 700; }
.glow-red { color: var(--accent-red); font-weight: 700; }
.glow-cyan { color: var(--accent-cyan); font-weight: 700; }

/* --- System Section --- */
.system-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.system-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: stretch;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 12px;
}
.system-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.sys-group {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 16px;
    border-right: 1px solid var(--border-subtle);
}
.sys-group:last-child { border-right: none; padding-right: 0; }

/* Resource Cards */
.resources-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    width: 100%;
}

.res-card {
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: var(--radius);
    text-align: center;
}

.sys-label {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
}

/* Process Tags */
.proc-tag {
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
    justify-content: center;
}

.proc-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.dot-green {
    background: var(--accent-green);
    box-shadow: 0 0 4px rgba(22, 163, 74, 0.4);
}

.dot-red {
    background: var(--accent-red);
    box-shadow: 0 0 4px rgba(220, 38, 38, 0.4);
}

.dot-yellow {
    background: var(--accent-yellow);
    box-shadow: 0 0 4px rgba(202, 138, 4, 0.4);
}

.dot-orange {
    background: var(--accent-orange);
    box-shadow: 0 0 4px rgba(217, 119, 6, 0.4);
}

/* Stat Blocks */
.stat-block {
    text-align: center;
    min-width: 70px;
}

.stat-val {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: 4px;
    display: block;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    width: 100%;
}

/* Resource Bars */
.res-bar-bg {
    background: #e5e7eb;
    height: 5px;
    border-radius: 3px;
    margin-top: 8px;
    width: 100%;
    overflow: hidden;
}

.res-bar-fill {
    height: 100%;
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 3px;
}

.fill-green { background: var(--accent-green); }
.fill-blue { background: var(--accent-blue); }
.fill-purple { background: var(--accent-purple); }
.fill-orange { background: var(--accent-orange); }
.fill-red { background: var(--accent-red); }
.fill-cyan { background: var(--accent-cyan); }

/* Progress Bar */
.progress-bg {
    background: #e5e7eb;
    height: 6px;
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-green);
    width: 0%;
    transition: width 0.5s ease;
}

/* --- Strategy Performance Cards --- */
.strat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px 14px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.strat-card-name {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: 600;
}

.strat-card-val {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 700;
}

.strat-card-sub {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* --- Compact KPI Strip --- */
.kpi-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}

.kpi-item {
    flex: 1;
    min-width: 100px;
    padding: 10px 14px;
    text-align: center;
    border-right: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
}
.kpi-item:last-child { border-right: none; }

.kpi-val {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
    margin-bottom: 2px;
}

.kpi-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

@media (max-width: 768px) {
    .kpi-item { min-width: 80px; padding: 8px 8px; }
    .kpi-val { font-size: 13px; }
}

/* --- Strategy Zone Panels --- */
.strategy-panel {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    background: var(--bg-card);
}

.strategy-panel-header {
    background: var(--bg-card-alt);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
}

.strategy-panel-section {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
}
.strategy-panel-section:last-child { border-bottom: none; }

/* --- Log Viewer --- */
.log-container {
    background: #1e1e2e;
    color: #cdd6f4;
    font-family: var(--font-mono);
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    height: calc(100vh - 280px);
    min-height: 400px;
    overflow-y: auto;
    font-size: 11px;
    line-height: 1.6;
    scrollbar-width: thin;
    scrollbar-color: #45475a #1e1e2e;
}

.log-container::-webkit-scrollbar { width: 6px; }
.log-container::-webkit-scrollbar-track { background: #1e1e2e; }
.log-container::-webkit-scrollbar-thumb { background: #45475a; border-radius: 3px; }

.log-line {
    margin-bottom: 1px;
    padding: 2px 6px;
    border-radius: 2px;
    word-break: break-all;
}
.log-line:hover { background: rgba(255, 255, 255, 0.05); }

.log-err { color: #f38ba8; }
.log-warn { color: #fab387; }
.log-info { color: #89b4fa; }
.log-debug { color: #6c7086; }

/* Log filter bar */
.log-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.log-filter-btn {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 5px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
}

.log-filter-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.log-filter-btn.active {
    border-color: var(--accent-blue);
    color: #fff;
    background: var(--accent-blue);
}

.log-search {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 5px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    outline: none;
    flex: 1;
    min-width: 200px;
}

.log-search:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

/* --- SSE Status Indicator --- */
.sse-status {
    position: fixed;
    top: 10px;
    right: 16px;
    font-family: var(--font-mono);
    font-size: 10px;
    z-index: 100;
    padding: 4px 10px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* --- Status Indicator --- */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-ok { background: var(--accent-green); }
.status-err { background: var(--accent-red); }
.status-pulse { }

/* --- Badges --- */
.badge {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 3px 10px;
    border-radius: var(--radius);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.badge-green {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.badge-red {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.badge-yellow {
    background: #fefce8;
    color: #a16207;
    border: 1px solid #fef08a;
}

.badge-purple {
    background: #f3e8ff;
    color: #6d28d9;
    border: 1px solid #e9d5ff;
}

.badge-blue {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

/* --- Wallet Bar --- */
.wallet-bar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
}

.wallet-bar-total {
    background: var(--bg-card-alt);
    border: 1px solid var(--accent-blue);
    border-left: 4px solid var(--accent-blue);
}

/* --- Refresh Timer --- */
.refresh-timer {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}

/* --- PnL Flash Animations --- */
@keyframes pnl-flash-green {
    0% { background: rgba(22, 163, 74, 0.15); }
    100% { background: transparent; }
}
@keyframes pnl-flash-red {
    0% { background: rgba(220, 38, 38, 0.15); }
    100% { background: transparent; }
}
.pnl-flash-up { animation: pnl-flash-green 0.8s ease-out; }
.pnl-flash-down { animation: pnl-flash-red 0.8s ease-out; }

/* --- Horizontal Scroll Wrapper (mobile tables) --- */
.scroll-x {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
    -webkit-overflow-scrolling: touch;
}

.scroll-x::-webkit-scrollbar { height: 4px; }
.scroll-x::-webkit-scrollbar-track { background: transparent; }
.scroll-x::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* --- Alert Banners --- */
.alert-banner {
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-critical {
    background: #fef2f2;
    border: 1px solid #fca5a5;
}

/* --- Terminal Text (keep monospace styling in light) --- */
.terminal-text {
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* --- Responsive: Tablet --- */
@media (max-width: 1200px) {
    .grid-2 { grid-template-columns: 1fr; }
    .hl-grid-2, .hl-grid-split { grid-template-columns: 1fr !important; }
    .actions-grid { grid-template-columns: repeat(3, 1fr); }
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
    body { padding: 8px; font-size: 14px; }
    .container { max-width: 100%; }

    header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        gap: 0;
        padding-bottom: 2px;
    }
    .tabs::-webkit-scrollbar { display: none; }

    .tab {
        padding: 10px 14px;
        font-size: 12px;
    }

    .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .actions-grid { grid-template-columns: repeat(2, 1fr); }
    .resources-group { grid-template-columns: repeat(2, 1fr); }

    .section-header { margin-top: 16px; }
    .metric-value { font-size: 24px; }
    .key-metric-val { font-size: 20px; }
    .stat-val { font-size: 17px; }
    .kpi-val { font-size: 16px; }
    .kpi-label { font-size: 9px; }
    .metric-label { font-size: 11px; }
    .proc-tag { font-size: 12px; padding: 8px 10px; }

    th, td {
        padding: 7px 6px !important;
        font-size: 12px !important;
    }

    .card, .hacker-card, .system-section {
        padding: 10px;
    }

    .log-container {
        height: calc(100vh - 240px);
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .grid-4, .grid-3 { grid-template-columns: 1fr; }
    .actions-grid { grid-template-columns: 1fr 1fr; }
    .kpi-strip { flex-wrap: wrap; }
    .kpi-item { min-width: 45%; flex: 1 1 45%; }

    h1 { font-size: 16px; }
    .tab { padding: 8px 12px; font-size: 11px; }
    th, td { font-size: 11px !important; }
}
