/* ========== Modern Premium Design System ========== */
:root {
    /* Base Colors (Zinc/Neutral palette) */
    --bg-base: #000000;
    --bg-surface: #09090b;
    --bg-card: #18181b;
    --bg-card-hover: #27272a;
    --bg-input: #09090b;
    
    /* Borders */
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --border-strong: rgba(255, 255, 255, 0.2);

    /* Text Colors */
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    /* Accent Colors (Indigo / Violet) */
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --accent-gradient: linear-gradient(135deg, #6366f1, #a855f7);
    
    /* Semantic Colors */
    --green: #22c55e;
    --green-soft: rgba(34, 197, 94, 0.15);
    --red: #ef4444;
    --red-soft: rgba(239, 68, 68, 0.15);
    --yellow: #f59e0b;
    --yellow-soft: rgba(245, 158, 11, 0.15);
    --blue: #3b82f6;
    --blue-soft: rgba(59, 130, 246, 0.15);

    /* Dimensions & FX */
    --radius: 16px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 24px -4px var(--accent-glow);
    
    /* Typography */
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Layout */
    --max-width: 1280px;
}

/* Base Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }
::selection { background: var(--accent-glow); color: var(--text-primary); }

body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    background-image: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
                      radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.05) 0%, transparent 40%);
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #27272a; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3f3f46; }

/* ========== Header ========== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 20px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 12px var(--accent-glow));
}

.logo-text {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.logo-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    letter-spacing: 0.5px;
}

.logo-desc {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Status Indicator */
.status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--yellow);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
    animation: pulse-dot 2s ease-in-out infinite;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2); animation: none; }

@keyframes pulse-dot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(1.1); } }

.status-text {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--mono);
    font-weight: 500;
}

/* ========== Navigation ========== */
.nav-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
    padding: 4px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    width: fit-content;
}

.nav-link {
    padding: 8px 16px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.nav-link.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

/* ========== Main Layout ========== */
.main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 40px 32px;
}

/* ========== Panels & Cards ========== */
.panel {
    background: var(--bg-surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    position: relative;
}

.panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: rgba(24, 24, 27, 0.3);
}

.panel-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.panel-body {
    padding: 24px;
}

/* Analysis Card Grid */
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}
@media (max-width: 900px) { .analysis-grid { grid-template-columns: 1fr; } }

.analysis-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.analysis-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.analysis-card.full-width { grid-column: 1 / -1; }
.analysis-card h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 20px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.alias-review-row {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.alias-review-row:last-child {
    border-bottom: none;
}

.alias-review-row.alias-highlight {
    margin: 0 -10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: var(--yellow-soft);
}

/* ========== Stats Cards ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}
.pf-stats { grid-template-columns: repeat(5, 1fr); }

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(255,255,255,0.03), transparent 60%);
    pointer-events: none;
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    font-size: 22px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.5px;
}
.stat-value.positive { color: var(--green); }
.stat-value.negative { color: var(--red); }
.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--mono);
}

/* ========== Inputs & Buttons ========== */
.input-group, .search-section {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    align-items: center;
}

input[type="text"], .query-input, .search-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    transition: all 0.2s;
    outline: none;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
}

input[type="text"]::placeholder { color: var(--text-muted); }
input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow), inset 0 1px 2px rgba(0,0,0,0.2);
    background: var(--bg-surface);
}

select, .report-select {
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    outline: none;
    min-width: 140px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    transition: all 0.2s;
}

select:focus { border-color: var(--accent); }

button, .btn-analyze, .search-btn, .btn-primary, .btn-import, .btn-refresh {
    padding: 12px 24px;
    background: var(--text-primary);
    color: var(--bg-base);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    text-decoration: none;
}

button:hover, .btn-analyze:hover, .search-btn:hover {
    transform: translateY(-1px);
    background: #e4e4e7;
    box-shadow: 0 4px 12px rgba(255,255,255,0.1);
}

button:active { transform: translateY(0); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* Secondary Buttons */
.panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn-refresh, .btn-back, .btn-secondary, .search-btn.tech-only {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 10px 16px;
}
.btn-refresh:hover, .btn-back:hover, .btn-secondary:hover, .search-btn.tech-only:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-delete {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
    padding: 8px 16px;
}
.btn-delete:hover {
    background: var(--red-soft);
    border-color: var(--red);
}

/* ========== Progress Bar ========== */
.progress-container {
    padding: 24px;
    border-top: 1px solid var(--border);
    background: rgba(255,255,255,0.01);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.progress-phase {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

.progress-pct {
    font-size: 13px;
    color: var(--text-muted);
    font-family: var(--mono);
}

.progress-bar, .progress {
    height: 6px;
    background: var(--bg-card);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}

.progress-fill, .progress-bar {
    height: 100%;
    background: var(--text-primary);
    border-radius: 999px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress-steps {
    display: flex;
    justify-content: space-between;
}

.step {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.step-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    transition: all 0.3s;
}

.step.active .step-dot {
    background: var(--text-primary);
    border-color: var(--text-primary);
    box-shadow: 0 0 8px rgba(255,255,255,0.4);
}
.step.done .step-dot {
    background: var(--text-secondary);
    border-color: var(--text-secondary);
}
.step.done { color: var(--text-secondary); }
.step.active { color: var(--text-primary); }

/* ========== Tables ========== */
.table-wrap {
    max-height: 520px;
    overflow-y: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

table, .trade-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th, .trade-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    position: sticky;
    top: 0;
    z-index: 10;
}

td, .trade-table td {
    padding: 14px 16px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card); }

.name-cell {
    font-family: var(--font) !important;
    font-weight: 500;
    color: var(--text-primary) !important;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========== Badges & tags ========== */
.badge-buy { background: var(--green-soft); color: var(--green); }
.badge-sell { background: var(--red-soft); color: var(--red); }
.badge-buy, .badge-sell, .status-badge {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.status-badge.badge-ok { background: var(--green-soft); color: var(--green); border: 1px solid rgba(34, 197, 94, 0.2); }
.status-badge.badge-fail { background: var(--red-soft); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.2); }

.rating-badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 16px;
    border-radius: 999px; font-size: 13px; font-weight: 600;
}
.rating-badge.bullish { background: var(--green-soft); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.rating-badge.bearish { background: var(--red-soft); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.rating-badge.neutral { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border); }
.rating-badge.strong-bullish { background: rgba(34,197,94,0.2); color: #4ade80; border: 1px solid var(--green); box-shadow: 0 0 12px rgba(34,197,94,0.2); }
.rating-badge.strong-bearish { background: rgba(239,68,68,0.2); color: #f87171; border: 1px solid var(--red); box-shadow: 0 0 12px rgba(239,68,68,0.2); }

/* ========== Tab Controls (Sub-navigation) ========== */
.tab-bar {
    display: flex;
    gap: 2px;
    padding: 4px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    width: fit-content;
    border: 1px solid var(--border);
}
.tab-btn {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    box-shadow: none;
    border-radius: 6px;
}
.tab-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
    transform: none;
    box-shadow: none;
}
.tab-btn.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

/* ========== Report Items (index.html) ========== */
.report-boundary {
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--mono);
}
.report-boundary.warning { color: var(--yellow); }
.reports-list { max-height: 480px; overflow-y: auto; }
.report-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px; border-radius: var(--radius-sm);
    cursor: pointer; transition: all 0.2s;
    border: 1px solid transparent;
}
.report-item:hover {
    background: var(--bg-card);
    border-color: var(--border-strong);
    transform: translateX(2px);
}
.report-icon { font-size: 20px; opacity: 0.9; }
.report-name { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.report-meta { font-size: 12px; color: var(--text-muted); font-family: var(--mono); margin-top: 4px; }
.report-size { font-size: 11px; color: var(--text-secondary); font-family: var(--mono); padding: 4px 8px; background: var(--bg-card); border-radius: 6px; border: 1px solid var(--border); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 14px; }

/* ========== Report Viewer (Markdown styling) ========== */
.viewer-header { display: flex; justify-content: space-between; margin-bottom: 24px; align-items: center;}
.viewer-title { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.viewer-meta {
    padding: 12px 16px; background: var(--bg-card); border-radius: var(--radius-sm);
    border: 1px solid var(--border); margin-bottom: 24px; font-size: 12px;
    color: var(--text-muted); font-family: var(--mono);
}
.viewer-content {
    background: var(--bg-surface); border-radius: var(--radius); border: 1px solid var(--border);
    padding: 40px 48px; line-height: 1.7; font-size: 15px; color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
}

.viewer-content h1, .viewer-content h2, .viewer-content h3 { color: var(--text-primary); font-weight: 600; }
.viewer-content h1 { font-size: 24px; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border); letter-spacing: -0.5px; }
.viewer-content h2 { font-size: 18px; margin: 32px 0 16px 0; }
.viewer-content h3 { font-size: 16px; margin: 24px 0 12px 0; }
.viewer-content p { margin-bottom: 16px; }
.viewer-content strong { color: var(--text-primary); font-weight: 600; }
.viewer-content ul, .viewer-content ol { padding-left: 20px; margin-bottom: 16px; }
.viewer-content li { margin-bottom: 8px; }
.viewer-content hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }
.viewer-content blockquote {
    border-left: 2px solid var(--border-strong); padding: 12px 20px; margin: 20px 0;
    background: var(--bg-card); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic; color: var(--text-muted);
}
.viewer-content code {
    font-family: var(--mono); background: var(--bg-card); padding: 2px 6px;
    border-radius: 4px; border: 1px solid var(--border); font-size: 13px; color: var(--text-primary);
}

/* ========== Custom Metrics & Grids (portfolio/analysis) ========== */
.metric-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.metric-row:last-child { border-bottom: none; }
.metric-label { color: var(--text-secondary); font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.metric-value { font-family: var(--mono); font-weight: 500; font-size: 14px; color: var(--text-primary); min-width: 0; overflow-wrap: anywhere; text-align: right; }
.metric-value.positive { color: var(--green); }
.metric-value.negative { color: var(--red); }

.pnl-pos { color: var(--green); font-weight: 500; }
.pnl-neg { color: var(--red); font-weight: 500; }

.pnl-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.pnl-box {
    text-align: center; padding: 20px; background: var(--bg-surface);
    border-radius: var(--radius-sm); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.pnl-box-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; font-weight: 500;}
.pnl-box-value { font-size: 24px; font-weight: 700; font-family: var(--mono); color: var(--text-primary);}

.flow-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.flow-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px; background: var(--bg-surface); border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.flow-label { font-size: 14px; color: var(--text-primary); font-weight: 500;}
.flow-amount { font-size: 15px; font-family: var(--mono); font-weight: 600; }
.flow-count { font-size: 12px; color: var(--text-muted); margin-left: 8px; background: var(--bg-card); padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border); }

.top-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.top-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.top-item:last-child { border-bottom: none; }
.top-name { font-size: 13px; color: var(--text-primary); font-weight: 500; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-detail { font-size: 13px; font-family: var(--mono); text-align: right; }

.quick-items { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.quick-item {
    padding: 8px 16px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 999px; color: var(--text-secondary); font-size: 13px; cursor: pointer;
    transition: all 0.2s; font-weight: 500;
}
.quick-item:hover { border-color: var(--text-primary); color: var(--text-primary); background: var(--bg-card-hover); }

/* Gauge */
.gauge-container { text-align: center; padding: 16px 0; }
.gauge-bar {
    height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--red), var(--yellow), var(--green));
    margin: 16px 0; position: relative; opacity: 0.8;
}
.gauge-marker {
    position: absolute; top: -6px; width: 18px; height: 18px; border-radius: 50%;
    background: var(--bg-surface); border: 3px solid #fff; transform: translateX(-50%);
    transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: var(--shadow-sm);
}
.gauge-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); font-weight: 500; }
.gauge-score { font-size: 40px; font-weight: 700; font-family: var(--mono); color: var(--text-primary); letter-spacing: -1px; }

/* Daily bars */
.daily-bars { display: flex; gap: 4px; align-items: flex-end; height: 100px; padding-top: 20px;}
.daily-bar { flex: 1; border-radius: 2px 2px 0 0; position: relative; transition: opacity 0.2s; min-width: 14px; }
.daily-bar.up { background: var(--green); opacity: 0.8; }
.daily-bar.down { background: var(--red); opacity: 0.8; }
.daily-bar:hover { opacity: 1; }
.daily-bar .bar-tip {
    position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.8); border: 1px solid var(--border-strong); border-radius: 6px;
    padding: 6px 10px; font-size: 11px; font-family: var(--mono); white-space: nowrap;
    display: none; z-index: 10; color: #fff; backdrop-filter: blur(4px); pointer-events: none;
}
.daily-bar:hover .bar-tip { display: block; }

/* Loading */
.loading { display: flex; justify-content: center; align-items: center; padding: 60px; color: var(--text-muted); font-size: 14px;}
.spinner {
    width: 20px; height: 20px; border: 2px solid var(--border);
    border-top-color: var(--text-secondary); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin-right: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Utility */
.platform-stats { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px;}
.platform-tag {
    padding: 6px 12px; border-radius: 6px; font-size: 12px;
    background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary);
}
.platform-tag .count { font-weight: 600; color: var(--text-primary); }

/* Signals */
.signal-list { list-style: none; }
.signal-item {
    display: flex; align-items: flex-start; gap: 12px; padding: 12px 0;
    font-size: 14px; color: var(--text-secondary); border-bottom: 1px solid var(--border);
}
.signal-item:last-child { border-bottom: none; }
.signal-icon { font-size: 16px; flex-shrink: 0;}

/* Scroll Log (Backfill) */
#log {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 16px; font-family: var(--mono); font-size: 13px; max-height: 300px;
    overflow-y: auto; line-height: 1.6; min-height: 80px; color: var(--text-muted);
}
.log-ok { color: var(--green); }
.log-err { color: var(--red); }
.log-info { color: var(--text-primary); }
.log-warn { color: var(--yellow); }

/* Signal closure shell primitives */
.page-shell {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 32px;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    background: var(--bg-card);
}

.status-chip.positive,
.readiness-pill.positive {
    color: var(--green);
    border-color: rgba(34, 197, 94, 0.28);
    background: var(--green-soft);
}

.status-chip.negative,
.readiness-pill.negative {
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.28);
    background: var(--red-soft);
}

.status-chip.warning,
.readiness-pill.warning {
    color: var(--yellow);
    border-color: rgba(245, 158, 11, 0.28);
    background: var(--yellow-soft);
}

/* Daily brief first screen */
.daily-brief-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-top: 1px solid var(--border);
}

.daily-decision-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
    gap: 20px;
    align-items: start;
}

.daily-stance {
    margin-top: 6px;
    font-size: 28px;
    line-height: 1.15;
    font-weight: 700;
    color: var(--text-primary);
}

.daily-thesis {
    margin-top: 10px;
    max-width: 840px;
    color: var(--text-secondary);
    font-size: 14px;
}

.daily-confidence {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.daily-priority-actions {
    padding-top: 4px;
}

.daily-readiness-strip {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.readiness-compact-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.readiness-compact-chip {
    max-width: 100%;
    text-decoration: none;
    white-space: normal;
}

.readiness-compact-chip strong {
    color: currentColor;
}

.readiness-pill {
    display: flex;
    min-height: 78px;
    flex-direction: column;
    justify-content: space-between;
    gap: 6px;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    text-decoration: none;
}

.readiness-pill strong {
    font-size: 13px;
    color: currentColor;
}

.readiness-pill small {
    color: var(--text-muted);
    line-height: 1.35;
}

.readiness-reason {
    display: inline-block;
    color: currentColor;
    font-size: 11px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.readiness-freshness {
    color: var(--text-muted);
    line-height: 1.35;
}

.source-age {
    display: inline-block;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.35;
}

.source-age.stale {
    color: var(--red);
}

.source-age.fresh {
    color: var(--green);
}

.daily-brief-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.panel-subtitle {
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.brief-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.brief-row > div:first-child {
    min-width: 0;
}

.brief-row:last-child {
    border-bottom: none;
}

.task-row-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    min-width: 150px;
}

.task-action-link {
    font-weight: 700;
    text-decoration: none;
}

.action-row {
    margin-bottom: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.action-row.positive {
    border-left-color: var(--green);
}

.action-row.warning {
    border-left-color: var(--yellow);
}

.action-row.negative {
    border-left-color: var(--red);
}

.operator-next-step {
    display: block;
    margin: 12px 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--yellow);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    text-decoration: none;
}

.operator-next-step strong {
    display: block;
    margin-top: 4px;
    color: var(--text-primary);
    line-height: 1.4;
}

.operator-next-step.positive {
    border-left-color: var(--green);
}

.operator-next-step.negative {
    border-left-color: var(--red);
}

.operator-task-summary {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.brief-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.compact-grid {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

/* Responsive tweaks */
@media (max-width: 768px) {
    .main { padding: 24px 16px; }
    .stats-grid, .pf-stats { grid-template-columns: repeat(2, 1fr); }
    .viewer-content { padding: 24px; }
    .pnl-summary { grid-template-columns: repeat(2, 1fr); }
    .top-grid { grid-template-columns: 1fr; }
    .flow-grid { grid-template-columns: 1fr; }
    .header { padding: 12px 16px; }
    input[type="text"], select, button { width: 100%; }
    .daily-brief-panel .task-resolution-button,
    .daily-brief-panel .operator-task-filter-button,
    .daily-brief-panel .task-action-link {
        width: auto;
    }
    .daily-priority-actions .action-row {
        flex-direction: column;
    }
    .daily-priority-actions .task-row-actions {
        min-width: 0;
        justify-content: flex-start;
    }
    .input-group, .search-section { flex-direction: column; align-items: stretch; }
    .daily-decision-header,
    .daily-brief-grid {
        grid-template-columns: 1fr;
    }
}
