/*
 * Identidade visual "terminal de trading": tema único e escuro (não é dark
 * mode opcional — é a única opção, decisão deliberada para o gênero),
 * componentes densos com borda fina (sem glass/blur), inspirado nos
 * terminais profissionais que os usuários já usam ao lado deste painel.
 * Paleta validada com o script de contraste/daltonismo do skill de dataviz
 * contra a superfície --surface (#0f131a).
 */
:root {
    color-scheme: dark;
    --bg: #090c11;
    --surface: #0f131a;
    --surface-2: #151a22;
    --border: #212733;
    --border-strong: #2c3341;
    --text: #dbe0e8;
    --muted: #838b9a;
    --dim: #4d5566;
    --accent: #3d8bff;
    --accent-dim: rgba(61, 139, 255, 0.14);
    --good: #16a34a;
    --good-dim: rgba(22, 163, 74, 0.14);
    --bad: #e14c4c;
    --bad-dim: rgba(225, 76, 76, 0.14);
    --warn: #c98500;
    --warn-dim: rgba(201, 133, 0, 0.14);
    --font-ui: -apple-system, "Segoe UI", system-ui, Roboto, sans-serif;
    --font-mono: ui-monospace, "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── topbar ── */
header.topbar {
    height: 46px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand img.mark { width: 22px; height: 22px; border-radius: 5px; }
.brand .name { font-size: 13.5px; font-weight: 700; color: var(--text); letter-spacing: 0.01em; }
.brand .tag { font-size: 11px; color: var(--dim); margin-left: 4px; }

.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 2px; gap: 2px; }
.tab-btn {
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    background: transparent;
    border: none;
    border-radius: 5px;
    padding: 5px 14px;
    cursor: pointer;
}
.tab-btn.active { background: var(--accent-dim); color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.topnav { display: flex; align-items: center; gap: 4px; }
.topnav a {
    font-family: var(--font-ui);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    padding: 5px 12px;
    border-radius: 6px;
}
.topnav a:hover { color: var(--text); }
.topnav a.active { background: var(--accent-dim); color: var(--accent); }

header.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.user-chip .avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); }

a.ghost-btn, button.btn-ghost {
    display: inline-block;
    font-family: var(--font-ui);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    text-decoration: none;
}
a.ghost-btn:hover, button.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }
button.btn-ghost.bad-o { border-color: var(--bad); color: var(--bad); background: var(--bad-dim); }
button.btn-ghost.bad-o:hover { background: rgba(225, 76, 76, 0.24); }

/* ── flash messages ── */
.flash-wrap { max-width: 1180px; margin: 10px auto 0; padding: 0 18px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 9px 14px; border-radius: 8px; font-size: 12.5px; border: 1px solid; }
.flash.error { border-color: var(--bad); background: var(--bad-dim); color: #ffc9c9; }
.flash.info { border-color: var(--accent); background: var(--accent-dim); color: var(--text); }

/* ── page shells ── */
.dash-body { padding: 14px 18px 30px; max-width: 1180px; margin: 0 auto; }
.admin-body { padding: 14px 18px 30px; max-width: 900px; margin: 0 auto; }

/* ── stat tiles ── */
.tile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.tile .tile-label { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); margin-bottom: 6px; }
.tile .tile-value { font-size: 18px; font-weight: 700; }
.tile .tile-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.tile.good .tile-value { color: var(--good); }
.tile.bad .tile-value { color: var(--bad); }
.tile.warn .tile-value { color: var(--warn); }
.tile.accent .tile-value { color: var(--accent); }

/* ── panels ── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}
.panel-head .hint { font-weight: 400; color: var(--dim); font-size: 11px; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 14px 16px; }

/* ── toggle switch ── */
.switch { position: relative; display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); cursor: pointer; user-select: none; }
.switch .track { width: 28px; height: 16px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); position: relative; }
.switch .track::after { content: ""; position: absolute; top: 1px; left: 1px; width: 12px; height: 12px; border-radius: 50%; background: var(--dim); transition: transform .15s, background .15s; }
.switch input { display: none; }
.switch input:checked + .track { border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(12px); background: var(--accent); }

/* ── último sinal ── */
.signal-title { font-size: 22px; font-weight: 800; margin: 0 0 14px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.info-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.info-tile .k { font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
.info-tile .v { font-family: var(--font-mono); font-size: 15px; font-weight: 700; color: var(--text); }

/* ── buttons ── */
button, .btn, a.btn, button.btn-primary {
    display: inline-block;
    cursor: pointer;
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 12.5px;
    border-radius: 7px;
    padding: 9px 16px;
    border: 1px solid var(--accent);
    color: #eaf2ff;
    background: var(--accent);
    text-decoration: none;
}
button:hover, .btn:hover, a.btn:hover { background: #2f7de0; }
button.full { width: 100%; margin-top: 4px; }
.btn.magenta { border-color: var(--bad); color: #eaf2ff; background: var(--bad); }
.btn.magenta:hover { background: #c93f3f; }

/* ── forms ── */
form .field { margin-bottom: 14px; }
label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 5px;
}
input[type="text"], input[type="email"], input[type="password"], input[type="date"], select {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: var(--font-ui);
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

/* ── filtro (histórico) ── */
.filter-bar { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.filter-bar .field { margin: 0; }
.filter-bar .field label { font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
.filter-bar .field input, .filter-bar .field select { font-family: var(--font-mono); font-size: 12.5px; padding: 6px 8px; }
.filter-bar .field select { min-width: 130px; }
.filter-bar button { padding: 7px 14px; }
.push-group { margin-left: auto; display: flex; gap: 22px; }
.push { text-align: right; }
.push .lbl { font-size: 10.5px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.05em; }
.push .val { font-size: 17px; font-weight: 700; }
.push .val.accent { color: var(--accent); }

/* ── gráfico de patrimônio ── */
#equity-chart-wrap { position: relative; width: 100%; height: 220px; }
#equity-chart { width: 100%; height: 100%; display: block; overflow: visible; }
.equity-tooltip, .chart-tip {
    position: absolute;
    pointer-events: none;
    background: #05070a;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 11.5px;
    color: var(--text);
    white-space: nowrap;
    transform: translate(-50%, -115%);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
    z-index: 5;
}
.equity-tooltip .eq-value { font-family: var(--font-mono); font-weight: 700; font-size: 13px; }
.equity-tooltip .eq-meta { color: var(--dim); margin-top: 2px; }

/* ── tabela de operações ── */
table.trades { width: 100%; border-collapse: collapse; font-size: 12px; }
table.trades th {
    text-align: center;
    font-size: 10.5px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--dim);
    font-weight: 600;
    padding: 8px 6px;
    border-bottom: 1px solid var(--border);
}
table.trades td { text-align: center; padding: 7px 6px; border-bottom: 1px solid var(--border); font-family: var(--font-mono); }
table.trades tbody tr:hover { background: var(--surface-2); }
table.trades tr.win { background: rgba(22, 163, 74, 0.07); }
table.trades tr.loss { background: rgba(225, 76, 76, 0.07); }

.pill { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-ui); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.pill.good { color: var(--good); background: var(--good-dim); }
.pill.bad { color: var(--bad); background: var(--bad-dim); }
.pill.warn { color: var(--warn); background: var(--warn-dim); }
.pill.accent { color: var(--accent); background: var(--accent-dim); }

.dir-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--dim); }
.dir-dot.good { background: var(--good); }
.dir-dot.bad { background: var(--bad); }

.res.good { color: var(--good); font-weight: 700; }
.res.bad { color: var(--bad); font-weight: 700; }

/* ── tabela de usuários (admin) ── */
table.users { width: 100%; border-collapse: collapse; font-size: 12px; }
table.users th {
    background: transparent;
    text-align: left;
    font-size: 10.5px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--dim);
    font-weight: 600;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
table.users td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.users tbody tr:hover { background: var(--surface-2); }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.active { background: var(--good-dim); color: var(--good); }
.badge.blocked { background: var(--bad-dim); color: var(--bad); }

/* ── autenticação (login / cadastro / recuperar / redefinir) ── */
.auth-wrap { min-height: calc(100vh - 46px); display: flex; align-items: center; justify-content: center; padding: 30px 16px; }
.auth-card { width: 100%; max-width: 320px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 26px 24px; }
.auth-card h1.title { font-size: 15px; text-align: center; margin: 0 0 2px; color: var(--text); font-weight: 700; }
.auth-card p.hint { font-size: 11.5px; text-align: center; color: var(--dim); margin: 0 0 20px; }
.auth-card button.full { padding: 9px; text-align: center; }
p.below { text-align: center; margin: 14px 0 0; font-size: 11.5px; color: var(--dim); }
p.below a { color: var(--accent); text-decoration: none; }
p.below a:hover { text-decoration: underline; }
