/* ─────────── Reset & Layout ─────────── */
* { box-sizing: border-box; }
/* `hidden`-Attribut hart durchsetzen: verhindert, dass display-Regeln
   (z.B. .login-overlay { display:flex }) das Verstecken aushebeln. */
[hidden] { display: none !important; }
html, body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f1419;
    color: #e7eaee;
    min-height: 100vh;
}

/* ─────────── Header ─────────── */
header {
    background: linear-gradient(180deg, #1a73e8 0%, #1558b0 100%);
    color: white;
    padding: 14px 20px;
    position: sticky; top: 0; z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.header-inner {
    display: flex; align-items: center; justify-content: space-between;
    max-width: 1200px; margin: 0 auto;
}
header h1 { margin: 0; font-size: 1.25rem; }
.header-right { display: flex; align-items: center; gap: 12px; }
#installApp {
    background: rgba(255,255,255,0.15);
    color: white; border: 1px solid rgba(255,255,255,0.3);
    padding: 6px 12px; border-radius: 6px; cursor: pointer;
    font-size: 0.85rem;
}
#installApp:hover { background: rgba(255,255,255,0.25); }

.conn-pill {
    font-size: 0.75rem; padding: 4px 10px; border-radius: 12px;
    background: rgba(255,255,255,0.2);
}
.conn-pill.online  { background: #28a745; }
.conn-pill.offline { background: #dc3545; }

/* ─────────── Nav ─────────── */
nav {
    display: flex; gap: 4px;
    background: #1a1f26;
    padding: 8px 16px;
    border-bottom: 1px solid #2a323d;
    overflow-x: auto;
}
.nav-btn {
    background: transparent;
    color: #aab2bd;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.15s;
}
.nav-btn:hover { color: white; background: #2a323d; }
.nav-btn.active { color: white; background: #1a73e8; }

/* ─────────── Main ─────────── */
main {
    max-width: 1200px; margin: 0 auto;
    padding: 24px 16px 80px;
}
.view { display: none; }
.view.active { display: block; }
h2 { margin-top: 0; color: white; }
h3 { color: white; margin-top: 0; }

/* ─────────── KPIs ─────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px; margin-bottom: 24px;
}
.kpi {
    background: #1a1f26;
    border: 1px solid #2a323d;
    border-radius: 10px;
    padding: 16px;
}
.kpi-label { color: #8a93a0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { color: white; font-size: 1.6rem; font-weight: 600; margin: 6px 0; }
.kpi-sub { color: #6c757d; font-size: 0.78rem; }
.kpi-value.positive { color: #28a745; }
.kpi-value.negative { color: #dc3545; }

/* ─────────── Cards ─────────── */
.card {
    background: #1a1f26;
    border: 1px solid #2a323d;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}
.card .hint { color: #8a93a0; font-size: 0.85rem; margin-top: 8px; }

/* ─────────── Buttons ─────────── */
button {
    background: #2a323d; color: white;
    border: none; padding: 10px 16px;
    border-radius: 6px; cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s;
}
button:hover:not(:disabled) { background: #3a4250; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: #1a73e8; }
button.primary:hover:not(:disabled) { background: #1558b0; }
button.secondary { background: #2a323d; }
button.danger { background: #dc3545; }
button.danger:hover:not(:disabled) { background: #c82333; }
button.small { padding: 4px 10px; font-size: 0.8rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row + label { margin-top: 12px; }

/* ─────────── Forms ─────────── */
label {
    display: block;
    color: #aab2bd;
    font-size: 0.85rem;
    margin-top: 12px;
    margin-bottom: 4px;
}
input[type="text"], input[type="password"], input[type="number"] {
    width: 100%;
    background: #0f1419;
    color: white;
    border: 1px solid #2a323d;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.95rem;
}
input:focus, select:focus { outline: none; border-color: #1a73e8; }
select {
    background: #0f1419;
    color: white;
    border: 1px solid #2a323d;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.9rem;
}
input[type="checkbox"] {
    accent-color: #1a73e8;
    width: 16px; height: 16px;
}

/* ─────────── Badges ─────────── */
.badge {
    display: inline-block;
    padding: 4px 10px; border-radius: 12px;
    font-size: 0.75rem; font-weight: 600;
    background: #2a323d; color: white;
}
.badge.online, .badge.running  { background: #28a745; }
.badge.offline, .badge.stopped  { background: #6c757d; }
.badge.long                     { background: #28a745; }
.badge.short                    { background: #dc3545; }
.badge.open                     { background: #ffc107; color: #1a1f26; }
.badge.closed                   { background: #2a323d; }
.badge.live                     { background: #1a73e8; }
.badge.won                      { background: #28a745; }
.badge.lost                     { background: #dc3545; }

/* ─────────── Data Table ─────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: 8px;
}
.data-table {
    width: 100%; border-collapse: collapse;
    background: #1a1f26;
    border-radius: 8px; overflow: hidden;
    min-width: 700px;
}
.data-table th, .data-table td {
    text-align: left; padding: 10px 12px;
    border-bottom: 1px solid #2a323d;
    font-size: 0.88rem;
    white-space: nowrap;
}
.data-table th {
    background: #0f1419; color: #aab2bd;
    font-weight: 500;
    position: sticky; top: 0;
}
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .center { text-align: center; }
.data-table tbody tr:hover { background: #242c36; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .pnl-pos { color: #28a745; font-weight: 500; }
.data-table .pnl-neg { color: #dc3545; font-weight: 500; }
.data-table .chg-pos { color: #28a745; }
.data-table .chg-neg { color: #dc3545; }

/* ─────────── Markets ─────────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }

/* ─────────── Tabs ─────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tab-btn {
    background: transparent; color: #aab2bd;
    border: 1px solid #2a323d;
    padding: 8px 14px; border-radius: 6px;
    font-size: 0.85rem; cursor: pointer;
}
.tab-btn:hover { background: #2a323d; color: white; }
.tab-btn.active { background: #1a73e8; color: white; border-color: #1a73e8; }

/* ─────────── Signals ─────────── */
.signal-list { list-style: none; padding: 0; margin: 0; }
.signal-list li {
    background: #0f1419;
    border: 1px solid #2a323d;
    border-left: 3px solid #1a73e8;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}
.signal-list li.buy { border-left-color: #28a745; }
.signal-list li.sell { border-left-color: #dc3545; }

/* ─────────── Equity Chart ─────────── */
.equity-chart {
    background: #0f1419;
    border: 1px solid #2a323d;
    border-radius: 6px;
    padding: 12px;
    min-height: 80px;
    display: flex; align-items: flex-end; gap: 4px;
    overflow-x: auto;
}
.equity-bar {
    flex: 0 0 auto;
    width: 8px; min-height: 4px;
    background: #1a73e8;
    border-radius: 2px;
    transition: height 0.3s ease;
}
.equity-bar.neg { background: #dc3545; }
.equity-bar.pos { background: #28a745; }

/* ─────────── KV List ─────────── */
.kv-list { list-style: none; padding: 0; margin: 0; }
.kv-list li {
    display: flex; justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #2a323d;
    font-size: 0.9rem;
}
.kv-list li:last-child { border-bottom: none; }
.kv-list li span:first-child { color: #8a93a0; }

/* ─────────── Toast ─────────── */
.toast {
    position: fixed; bottom: 24px; left: 50%;
    transform: translateX(-50%);
    background: #2a323d; color: white;
    padding: 12px 20px; border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    z-index: 100;
    max-width: 90vw;
}

/* ─────────── Login Overlay ─────────── */
.login-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
}
.login-box {
    background: #1a1f26;
    border: 1px solid #2a323d;
    border-radius: 10px;
    padding: 24px;
    width: 90vw; max-width: 400px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.login-box h3 { margin-top: 0; }

/* ─────────── Config Grid ─────────── */
.cfg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}
.cfg-grid label { margin-top: 0; }

/* ─────────── Error Banner ─────────── */
.error-banner {
    background: rgba(220, 53, 69, 0.15);
    border: 1px solid #dc3545;
    border-radius: 6px;
    padding: 10px 14px;
    color: #f5a3a8;
    font-size: 0.85rem;
}

/* ─────────── Misc ─────────── */
.muted { color: #6c757d; font-style: italic; }
code {
    background: #0f1419; padding: 2px 6px;
    border-radius: 4px; font-size: 0.85em;
}
.hint { color: #8a93a0; font-size: 0.85rem; }

@media (max-width: 600px) {
    header h1 { font-size: 1rem; }
    .nav-btn { padding: 8px 12px; font-size: 0.85rem; }
    .kpi-value { font-size: 1.3rem; }
    .data-table th, .data-table td { padding: 6px 8px; font-size: 0.78rem; }
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}
