:root {
    --bg-main: #0b111e;
    --bg-card: #131c2e;
    --bg-card-alt: #182338;
    --border-color: #243451;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent-emerald: #10b981;
    --accent-emerald-bg: rgba(16, 185, 129, 0.14);
    --accent-blue: #3b82f6;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    line-height: 1.5;
    padding-bottom: 50px;
}

a {
    color: #60a5fa;
}

.topbar {
    background: linear-gradient(90deg, #0f172a 0%, #162238 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 50;
}

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

.brand-logo {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-weight: 800;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.topbar h1 {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.badge-fortress {
    font-size: 0.78rem;
    background: var(--accent-emerald-bg);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 600;
}

.subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

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

.status-pill {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.pill-safe {
    background: rgba(16, 185, 129, 0.16);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.clock-text {
    font-family: Consolas, monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.container {
    max-width: 1480px;
    margin: 20px auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.toast-banner {
    background: #1e293b;
    border-left: 4px solid var(--accent-emerald);
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 0.92rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.hidden {
    display: none !important;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 16px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px 20px;
}

.highlight-card {
    border-color: rgba(16, 185, 129, 0.5);
    background: linear-gradient(160deg, #132235 0%, #10292b 100%);
}

.shield-card {
    border-color: rgba(59, 130, 246, 0.45);
}

.kpi-label {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.kpi-main {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.kpi-sub {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.text-pos { color: #34d399 !important; }
.text-neg { color: #f87171 !important; }
.text-warn { color: #fbbf24 !important; }

/* Control Bar */
.control-bar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

.sentinel-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pulse-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-emerald);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 9px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.muted-small {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.control-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    color: #fff;
}

.btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary { background: var(--accent-emerald); color: #052e16; font-weight: 700; }
.btn-accent { background: var(--accent-blue); }
.btn-secondary { background: #334155; }
.btn-danger { background: #dc2626; }
.btn-ghost { background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); }
.btn-outline { background: rgba(59, 130, 246, 0.15); border: 1px solid rgba(59, 130, 246, 0.5); color: #93c5fd; }
.btn-sm { padding: 6px 11px; font-size: 0.78rem; }

/* 4 Belts Strip */
.belts-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.belt-item {
    background: rgba(19, 28, 46, 0.75);
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.82rem;
}

.belt-item strong {
    display: block;
    color: #e2e8f0;
}

.belt-item span {
    color: var(--text-secondary);
}

.belt-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Sections */
.section-block {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.section-header h2 {
    font-size: 1.1rem;
    margin-bottom: 3px;
}

.section-desc {
    font-size: 0.83rem;
    color: var(--text-secondary);
}

/* 7 Slots Grid */
.slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
    gap: 14px;
}

.slot-card {
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    position: relative;
}

.slot-card.slot-today {
    border: 2px solid var(--accent-blue);
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.2);
}

.slot-card.slot-active {
    border-color: rgba(16, 185, 129, 0.55);
}

.slot-card.slot-breakeven {
    border-color: #fbbf24;
    background: linear-gradient(180deg, #182338 0%, #22231c 100%);
}

.slot-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slot-day {
    font-weight: 800;
    font-size: 0.98rem;
}

.slot-badge {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
}

.badge-idle { background: #1e293b; color: #94a3b8; }
.badge-open { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.badge-lock { background: rgba(245, 158, 11, 0.22); color: #fbbf24; }

.slot-asset-box {
    background: rgba(11, 17, 30, 0.65);
    border-radius: 8px;
    padding: 10px;
    font-size: 0.84rem;
}

.slot-sym {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
}

.slot-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 8px;
    font-size: 0.78rem;
}

.slot-reason {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.35;
}

.slot-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 0.76rem;
}

/* Two column layout */
.two-col-layout {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 18px;
}

@media (max-width: 1050px) {
    .two-col-layout {
        grid-template-columns: 1fr;
    }
}

.right-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* AI Journal */
.journal-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 520px;
    overflow-y: auto;
    padding-right: 4px;
}

.journal-item {
    background: var(--bg-card-alt);
    border-left: 4px solid var(--accent-emerald);
    border-radius: 8px;
    padding: 12px 14px;
}

.journal-item.journal-hold {
    border-left-color: var(--accent-blue);
}

.journal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.76rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.journal-title {
    font-weight: 700;
    font-size: 0.94rem;
    margin-bottom: 6px;
    color: #f8fafc;
}

.journal-body {
    font-size: 0.83rem;
    color: #cbd5e1;
    white-space: pre-line;
    margin-bottom: 8px;
}

.journal-rules {
    font-size: 0.75rem;
    color: #34d399;
    background: rgba(16, 185, 129, 0.08);
    padding: 5px 8px;
    border-radius: 6px;
}

/* Chart */
.chart-box {
    width: 100%;
    height: 210px;
    background: #0d1526;
    border-radius: 8px;
    padding: 10px;
    border: 1px solid var(--border-color);
}

#equitySvg {
    width: 100%;
    height: 100%;
}

/* Info Alpaca Box */
.info-alpaca-box {
    border-color: rgba(16, 185, 129, 0.45);
    background: linear-gradient(145deg, #131c2e 0%, #112428 100%);
}

.info-alpaca-box h3 {
    font-size: 0.98rem;
    margin-bottom: 10px;
    color: #34d399;
}

.safe-list {
    padding-left: 18px;
    font-size: 0.83rem;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}

.data-table th, .data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.76rem;
    text-transform: uppercase;
    background: rgba(15, 23, 42, 0.5);
}

.data-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}

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

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
}

.modal-body {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-section {
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
}

.form-section h4 {
    font-size: 0.94rem;
    margin-bottom: 6px;
    color: #34d399;
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.form-row label {
    font-size: 0.78rem;
    color: #cbd5e1;
    font-weight: 600;
}

.form-row input, .form-row select {
    background: #0b111e;
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
}

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

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.checkbox-row {
    margin-top: 8px;
    font-size: 0.82rem;
    color: #cbd5e1;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
