/* ─── RESET & BASE ─────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: #0d1117;
    color: #e6edf3;
    line-height: 1.5;
    font-size: 15px;
}

/* ─── NAV ──────────────────────────────────────────────────── */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand { font-weight: 700; font-size: 17px; color: #58a6ff; }
.nav-links { display: flex; gap: 16px; }
.nav-links a { color: #8b949e; text-decoration: none; font-size: 14px; }
.nav-links a:hover { color: #e6edf3; }

/* ─── MAIN ─────────────────────────────────────────────────── */
main { padding: 16px; max-width: 700px; margin: 0 auto; }
h2 { font-size: 22px; margin-bottom: 16px; }
h3 { font-size: 16px; margin-bottom: 12px; color: #c9d1d9; }
.subtitle { color: #8b949e; margin-top: -12px; margin-bottom: 16px; }

/* ─── CARDS ────────────────────────────────────────────────── */
.card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

/* ─── BUTTONS ──────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}
.btn-primary { background: #238636; color: #fff; }
.btn-primary:hover { background: #2ea043; }
.btn-secondary { background: #21262d; color: #c9d1d9; border: 1px solid #30363d; }
.btn-secondary:hover { background: #30363d; }
.btn-danger { background: #da3633; color: #fff; }
.btn-danger:hover { background: #f85149; }
.btn-large { width: 100%; padding: 14px; font-size: 17px; }
.btn-small { padding: 4px 10px; font-size: 13px; }

/* ─── FORMS ────────────────────────────────────────────────── */
input, select {
    width: 100%;
    padding: 10px 12px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e6edf3;
    font-size: 15px;
    margin-bottom: 10px;
}
input:focus, select:focus { border-color: #58a6ff; outline: none; }
.input-sm { max-width: 120px; }
.input-xs { width: 60px; display: inline; margin: 0; }
.hint { color: #8b949e; font-size: 13px; margin-top: 8px; }

/* ─── EVENT ROWS ───────────────────────────────────────────── */
.event-row {
    display: grid;
    grid-template-columns: 1fr 80px 100px 100px 1fr;
    gap: 8px;
    margin-bottom: 8px;
    align-items: start;
}
@media (max-width: 600px) {
    .event-row { grid-template-columns: 1fr; }
}

/* ─── STATUS BADGES ────────────────────────────────────────── */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}
.status-pending, .status-loading_models, .status-fetching_market_data,
.status-scanning_options, .status-consulting_claude { background: #1f2937; color: #9ca3af; }
.status-awaiting_approval { background: #78350f; color: #fbbf24; }
.status-executing { background: #1e3a5f; color: #60a5fa; }
.status-monitoring { background: #1e3a5f; color: #60a5fa; animation: pulse 2s infinite; }
.status-complete { background: #064e3b; color: #34d399; }
.status-error, .status-cancelled { background: #450a0a; color: #f87171; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ─── P&L ──────────────────────────────────────────────────── */
.pnl-positive { color: #3fb950; }
.pnl-negative { color: #f85149; }
.pnl { font-size: 24px; font-weight: 700; margin-top: 12px; }
.pnl-large { font-size: 32px; font-weight: 700; margin-top: 12px; text-align: center; }

/* ─── TRADE CARDS (APPROVAL PAGE) ──────────────────────────── */
.trade-card {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}
.trade-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.trade-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.trade-checkbox { width: auto; margin: 0; }
.trade-title { font-weight: 600; font-size: 16px; }
.trade-cost { font-weight: 700; color: #58a6ff; }
.trade-details { font-size: 13px; color: #8b949e; }
.detail-row { display: flex; justify-content: space-between; padding: 3px 0; }
.reasoning { font-style: italic; text-align: right; max-width: 60%; }
.win-rate-high { color: #3fb950; font-weight: 700; }
.win-rate-low { color: #f0883e; }
.edit-row { margin-top: 6px; }

/* ─── TOTAL BAR ────────────────────────────────────────────── */
.total-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    margin-top: 12px;
    border-top: 1px solid #30363d;
    font-size: 18px;
    font-weight: 700;
}
.budget-limit { color: #8b949e; font-weight: 400; font-size: 14px; }
.over-budget { color: #f85149; }

/* ─── ACTION BAR ───────────────────────────────────────────── */
.action-bar { display: flex; gap: 12px; flex-direction: column; }

/* ─── COLLAPSIBLE ──────────────────────────────────────────── */
.collapsible h3 { cursor: pointer; }
.collapsible-content { display: none; margin-top: 12px; }
.collapsible.open .collapsible-content { display: block; }
.chevron::after { content: ' +'; }
.collapsible.open .chevron::after { content: ' -'; }

/* ─── TABLES ───────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #21262d; font-size: 14px; }
th { color: #8b949e; font-weight: 600; }
.options-table { font-size: 13px; }

/* ─── POSITIONS (MONITOR) ──────────────────────────────────── */
.position-row {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
}
.pos-header { display: flex; justify-content: space-between; align-items: center; }
.pos-title { font-weight: 600; }
.pos-details { display: flex; gap: 16px; font-size: 13px; color: #8b949e; margin-top: 6px; }

/* ─── LOG BOX ──────────────────────────────────────────────── */
.log-box {
    max-height: 400px;
    overflow-y: auto;
    background: #010409;
    border-radius: 6px;
    padding: 10px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
}
.log-line { padding: 2px 0; white-space: pre-wrap; word-break: break-all; }
.log-time { color: #484f58; margin-right: 8px; }
.log-info .log-msg { color: #c9d1d9; }
.log-warning .log-msg { color: #f0883e; }
.log-error .log-msg { color: #f85149; }

/* ─── SPINNER ──────────────────────────────────────────────── */
.spinner {
    width: 24px; height: 24px;
    border: 3px solid #30363d;
    border-top-color: #58a6ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 12px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── LOGIN PAGE ───────────────────────────────────────────── */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}
.login-box {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 32px;
    width: 320px;
    text-align: center;
}
.login-box h1 { margin-bottom: 20px; font-size: 22px; color: #58a6ff; }
.login-box button { width: 100%; margin-top: 8px; }

/* ─── FLASH ────────────────────────────────────────────────── */
.flash { background: #78350f; border: 1px solid #92400e; padding: 10px; border-radius: 6px; margin: 16px; }
.flash p { color: #fbbf24; font-size: 14px; }

/* ─── SESSION INFO ─────────────────────────────────────────── */
.session-info { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status-card { text-align: center; }
.analysis-text { color: #c9d1d9; font-size: 14px; line-height: 1.6; }
.analysis-text.small { font-size: 13px; color: #8b949e; }

/* ─── HISTORY ──────────────────────────────────────────────── */
.history-card .trades-table { margin-top: 12px; }

/* ─── ADMIN FORMS ──────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: block; font-size: 13px; color: #8b949e; margin-bottom: 4px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

/* ─── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 480px) {
    main { padding: 12px; }
    .pos-details { flex-direction: column; gap: 4px; }
    .detail-row { flex-direction: column; gap: 2px; }
    .reasoning { max-width: 100%; text-align: left; }
    .trade-header { flex-direction: column; align-items: flex-start; gap: 4px; }
}
