/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f1117;
    color: #e1e4e8;
    line-height: 1.5;
    font-size: 14px;
}
a { color: #58a6ff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 52px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
}
.nav-brand { font-weight: 700; font-size: 16px; color: #58a6ff; }
.nav-links { display: flex; gap: 16px; }
.nav-link { color: #8b949e; font-size: 13px; }
.nav-link:hover { color: #e1e4e8; text-decoration: none; }

/* Container */
.container { max-width: 1280px; margin: 0 auto; padding: 20px 24px; }

/* Auth Pages */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #0f1117;
}
.auth-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 40px;
    width: 400px;
    text-align: center;
}
.auth-card h1 { font-size: 24px; margin-bottom: 4px; }
.subtitle { color: #8b949e; margin-bottom: 24px; }

/* Forms */
.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; font-size: 13px; color: #8b949e; margin-bottom: 4px; }
.form-group small { color: #6e7681; font-size: 11px; }
input[type="text"], input[type="password"], input[type="number"], select {
    width: 100%;
    padding: 8px 12px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e1e4e8;
    font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: #58a6ff; }

/* Buttons */
.btn {
    padding: 8px 16px;
    border: 1px solid #30363d;
    border-radius: 6px;
    background: #21262d;
    color: #e1e4e8;
    cursor: pointer;
    font-size: 13px;
}
.btn:hover { background: #30363d; }
.btn-primary { background: #238636; border-color: #238636; color: #fff; }
.btn-primary:hover { background: #2ea043; }
.btn-full { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-active { background: #238636; border-color: #238636; color: #fff; }
.sortable-header:hover { background: #30363d; }
.sort-arrow { font-size: 10px; margin-left: 2px; }
.pagination .btn-active { background: #238636; border-color: #238636; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.alert-error { background: #3d1117; border: 1px solid #f85149; color: #f85149; }
.alert-success { background: #12261e; border: 1px solid #238636; color: #3fb950; }

/* Summary Bar */
.summary-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: nowrap;
    overflow-x: auto;
}
.summary-card {
    flex: 1 1 0;
    min-width: 0;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
    white-space: nowrap;
}
.summary-label { display: block; font-size: 10px; color: #8b949e; text-transform: uppercase; letter-spacing: 0.5px; }
.summary-value { display: block; font-size: 18px; font-weight: 700; margin-top: 2px; }
.summary-value.profit { color: #3fb950; }
.summary-value.loss { color: #f85149; }
.profit { color: #3fb950; }
.loss { color: #f85149; }
.mode-paper { color: #d29922; }
.mode-live { color: #f85149; }

/* Tabs */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid #30363d;
    margin-bottom: 16px;
}
.tab {
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: #8b949e;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 2px solid transparent;
}
.tab:hover { color: #e1e4e8; }
.tab.active { color: #e1e4e8; border-bottom-color: #58a6ff; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Data Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #30363d;
}
.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #21262d;
    font-size: 13px;
}
.data-table tbody tr:hover { background: #161b22; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-new, .badge-signal { background: #1f3a5f; color: #58a6ff; }
.badge-pending { background: #2d2a1e; color: #f0c040; border: 1px solid #f0c04044; }
.badge-accepted, .badge-decision { background: #12261e; color: #3fb950; }
.badge-rejected { background: #3d1117; color: #f85149; }
.badge-expired { background: #2d2a1e; color: #d29922; }
.badge-paper { background: #2d2a1e; color: #d29922; }
.badge-live { background: #3d1117; color: #f85149; }
.badge-order { background: #1c2541; color: #79c0ff; }
.badge-config { background: #27203a; color: #bc8cff; }
.badge-auth { background: #2d2a1e; color: #d29922; }
.badge-system { background: #1f2d1f; color: #7ee787; }
.badge-active { background: #1f3a5f; color: #58a6ff; }
.badge-triggered { background: #12261e; color: #3fb950; }
.badge-cancelled { background: #2d2a1e; color: #6e7681; }
.badge-orphaned { background: #3d1117; color: #f85149; }

/* Confidence */
.confidence { font-weight: 600; }
.confidence-high { color: #3fb950; }
.confidence-med { color: #d29922; }
.confidence-low { color: #f85149; }

/* Signal types */
.buy { color: #3fb950; font-weight: 600; }
.avoid { color: #f85149; font-weight: 600; }

/* Reasoning */
.reasoning-cell, .detail-cell { max-width: 500px; white-space: normal; word-wrap: break-word; color: #8b949e; line-height: 1.4; }
.reasoning-cell details summary { cursor: pointer; }
.rejection-reason { display: block; color: #f85149; font-size: 11px; white-space: normal; word-wrap: break-word; max-width: 250px; }

/* Health Grid */
.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.health-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 14px;
}
.health-card.health-ok { border-left: 3px solid #3fb950; }
.health-card.health-degraded { border-left: 3px solid #d29922; }
.health-card.health-down { border-left: 3px solid #f85149; }
.health-name { font-weight: 600; font-size: 13px; }
.health-status { font-size: 12px; margin-top: 4px; }
.health-msg { font-size: 11px; color: #8b949e; margin-top: 4px; }
.health-time { font-size: 11px; color: #6e7681; margin-top: 4px; }

/* Settings Form */
.settings-form fieldset {
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
}
.settings-form legend { font-weight: 600; font-size: 14px; padding: 0 8px; color: #58a6ff; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }
.checkbox-group label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: #e1e4e8; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 12px; margin-top: 12px; justify-content: center; }

/* Audit Filters */
.audit-filters { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }

/* Empty State */
.empty-state { text-align: center; padding: 40px; color: #6e7681; font-size: 14px; }
.loading { text-align: center; padding: 20px; color: #6e7681; }

/* Responsive */
@media (max-width: 768px) {
    .summary-bar { flex-direction: column; }
    .form-row { flex-direction: column; }
    .form-row .form-group { min-width: 100%; }
}
