/* Identidade visual no estilo da transmissão oficial da F1 */
:root {
    --bg: #15151e;
    --bg2: #1d1d29;
    --surface: #23232f;
    --surface2: #2c2c3a;
    --line: #34344a;
    --red: #e10600;
    --text: #ffffff;
    --muted: #9a9ab2;
    --green: #2ecc71;
    --yellow: #ffd400;
    --purple: #b14fff;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Titillium Web", "Segoe UI", system-ui, Arial, sans-serif;
    font-size: 15px;
}

/* Cabeçalho */
header.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(90deg, #0a0a12 0%, #1d1d29 100%);
    border-bottom: 3px solid var(--red);
    padding: 10px 20px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-size: 20px;
    text-transform: uppercase;
}
.brand .mark {
    background: var(--red);
    color: #fff;
    padding: 2px 10px;
    border-radius: 4px;
    font-style: italic;
    font-weight: 900;
}
.brand small { color: var(--muted); font-weight: 400; font-size: 13px; text-transform: none; }

.status-pill {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 13px;
    color: var(--muted);
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: #555; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: var(--red); }

.overlay-link {
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
}
.overlay-link:hover { border-color: var(--red); }

/* Abas */
nav.tabs {
    display: flex;
    gap: 2px;
    background: var(--bg2);
    padding: 0 16px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 58px;
    z-index: 40;
}
nav.tabs button {
    background: none;
    border: none;
    color: var(--muted);
    padding: 14px 18px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}
nav.tabs button:hover { color: var(--text); }
nav.tabs button.active { color: var(--text); border-bottom-color: var(--red); }

main { padding: 20px; max-width: 1280px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }

h2.section { font-size: 16px; text-transform: uppercase; letter-spacing: 1px;
    color: var(--muted); margin: 0 0 14px; font-weight: 700; }

/* Controles */
select, .btn {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 14px;
}
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.btn { cursor: pointer; }
.btn:hover { border-color: var(--red); }
label.inline { color: var(--muted); font-size: 13px; display:flex; align-items:center; gap:6px; }

/* ---- Torre de tempos (leaderboard) estilo F1 ---- */
.tower { width: 100%; border-collapse: collapse; background: var(--bg2);
    border-radius: 8px; overflow: hidden; }
.tower th {
    text-align: left; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--muted); padding: 10px 8px;
    background: #101019; border-bottom: 1px solid var(--line); font-weight: 700;
}
.tower td { padding: 0; border-bottom: 1px solid #1a1a26; }
.tower tr.row td { height: 44px; vertical-align: middle; }
.tower tr.row:hover { background: var(--surface); }
.tower tr.player { background: rgba(225, 6, 0, 0.12); }
.tower tr.player:hover { background: rgba(225, 6, 0, 0.18); }

.pos-cell { display: flex; align-items: center; height: 44px; }
.pos-bar { width: 6px; height: 44px; flex: 0 0 6px; }
.pos-num { width: 34px; text-align: center; font-weight: 800; font-size: 17px; }
.driver { display: flex; flex-direction: column; line-height: 1.15; padding-left: 6px; }
.driver .name { font-weight: 700; font-size: 15px; text-transform: uppercase; }
.driver .team { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.num-badge { color: var(--muted); font-size: 12px; margin-left: 6px; }

.tyre {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    border: 3px solid var(--line); font-size: 11px; font-weight: 800;
    color: #fff; background: #15151e;
}
.tyre-age { color: var(--muted); font-size: 12px; margin-left: 6px; }

.mono { font-variant-numeric: tabular-nums; font-family: "Consolas", "Titillium Web", monospace; }
.gap-leader { font-weight: 700; }
.interval { color: var(--muted); }
.lastlap { font-weight: 600; }
.lastlap.purple { color: var(--purple); }

.badge { display:inline-block; font-size: 11px; font-weight: 700; padding: 2px 6px;
    border-radius: 4px; margin-right: 4px; }
.badge.pen { background: var(--red); color: #fff; }
.badge.pit { background: var(--surface2); color: var(--muted); border: 1px solid var(--line); }
.badge.dnf { background: #444; color: #ccc; }
.badge.wing { background: #5a2d00; color: #ffb066; }
.badge.warn { background: #4a3c00; color: var(--yellow); }
.badge.pen-serve { background: #6b1500; color: #ff9b6b; border: 1px solid var(--red); }
.badge.fastlap { background: var(--purple); color: #fff; margin-left: 6px; }

.wear-bar { width: 56px; height: 9px; background: #2a2a38; border-radius: 4px; overflow: hidden; display:inline-block; vertical-align: middle; flex: 0 0 auto; }
.wear-fill { height: 100%; }
.ers-bar { width: 56px; height: 9px; background: #2a2a38; border-radius: 4px; overflow: hidden; display:inline-block; vertical-align: middle; flex: 0 0 auto; }
.ers-fill { height: 100%; }
/* barra + percentual lado a lado (desgaste / bateria) */
.metric { display: flex; align-items: center; gap: 8px; }
.metric-val { font-size: 13px; font-weight: 700; min-width: 32px; font-variant-numeric: tabular-nums; }
/* coluna de avisos por último — encosta à direita, sem reservar espaço vazio */
th.avisos, td.avisos { text-align: right; white-space: nowrap; }

/* HUD ao vivo */
.hud { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.hud .cell {
    background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
    padding: 12px 18px; min-width: 110px;
}
.hud .cell .k { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 1px; }
.hud .cell .v { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hud .cell .v small { font-size: 14px; color: var(--muted); font-weight: 600; }
.drs-on { color: var(--green); }
.drs-ready { color: var(--yellow); }
.drs-off { color: var(--muted); }

/* Histórico por corrida / insights */
.ins-head { margin-bottom: 14px; }
.ins-head h3 { margin: 0; font-size: 22px; }
.ins-sub { color: var(--muted); font-size: 13px; }
.ins-highlights { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.ins-hl { display: flex; align-items: baseline; gap: 10px; background: var(--bg2);
    border: 1px solid var(--line); border-left: 3px solid var(--red);
    border-radius: 6px; padding: 9px 14px; font-size: 14px; }
.ins-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); flex: 0 0 auto; }
.ins-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px; margin-bottom: 16px; }
.ins-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.ins-card .ins-k { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 1px; }
.ins-card .ins-v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ins-card .ins-sub2 { font-size: 11px; color: var(--muted); }
.ins-card.ins-warn { border-color: var(--red); background: rgba(225, 6, 0, 0.12); }
.ins-h4 { margin: 18px 0 8px; }
.grid tr.row-warn td { background: rgba(225, 6, 0, 0.10); }

/* Configuração — painéis do overlay */
.config-list { display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.config-h3 { margin: 18px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.config-h3:first-child { margin-top: 0; }
.config-row { display: flex; align-items: center; gap: 18px; background: var(--bg2);
    border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; }
.config-row input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--red);
    cursor: pointer; flex: 0 0 auto; }
.config-info { display: flex; flex-direction: column; flex: 1; min-width: 150px; }
.config-name { font-weight: 700; font-size: 15px; }
.config-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.config-opacity { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.config-oplabel { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 1px; }
.config-opval { font-size: 18px; font-weight: 800; min-width: 52px; text-align: right;
    font-variant-numeric: tabular-nums; color: var(--text); }

/* slider grande e estilizado (padrão de navegador é minúsculo) */
.config-slider { -webkit-appearance: none; appearance: none; width: 240px; height: 10px;
    background: var(--surface2); border-radius: 6px; outline: none; cursor: pointer; }
.config-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none;
    width: 26px; height: 26px; border-radius: 50%; background: var(--red);
    border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); cursor: pointer; }
.config-slider::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%;
    background: var(--red); border: 3px solid #fff; cursor: pointer; }

.config-num { width: 96px; background: var(--surface); color: var(--text);
    border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
    font-size: 22px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums;
    flex: 0 0 auto; }
.config-numwrap { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.config-numunit { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

/* Legendas do engenheiro de pista */
.radio-strip { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.radio-row { display: flex; align-items: baseline; gap: 10px; background: var(--bg2);
    border: 1px solid var(--line); border-left: 4px solid var(--green);
    border-radius: 6px; padding: 8px 14px; }
.radio-tag { font-size: 11px; text-transform: uppercase; color: var(--muted);
    letter-spacing: 1px; flex: 0 0 auto; }
.radio-text { font-size: 15px; font-weight: 600; }

/* Spotter: carro ao lado (esquerda/direita) */
.spotter-bar { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 8px;
    align-items: stretch; margin-bottom: 14px; }
.spotter-bar .sp-side { display: flex; align-items: center; justify-content: center;
    gap: 8px; background: #13231b; border: 1px solid var(--line); border-radius: 8px;
    padding: 10px 12px; font-weight: 800; letter-spacing: 1px; color: #2e5e44; }
.spotter-bar .sp-side.on { background: #3a1210; border-color: #ff3b30; color: #fff; }
.spotter-bar .sp-arrow { font-size: 22px; line-height: 1; }
.spotter-bar .sp-txt { font-size: 14px; }
.spotter-bar .sp-mid { display: flex; align-items: center; justify-content: center;
    border-radius: 8px; font-weight: 800; letter-spacing: 1px; font-size: 15px; }
.spotter-bar .sp-mid.free { background: var(--bg2); border: 1px solid var(--line);
    color: var(--green); }
.spotter-bar .sp-mid.warn { background: #3a1210; border: 1px solid #ff3b30; color: #ff6b61; }

/* Estratégia recomendada */
.strat-model { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.sm-chip { display: flex; align-items: center; gap: 6px; background: var(--bg2);
    border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font-size: 13px; }
.sm-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.strat-plan { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
    padding: 8px 14px; margin: 6px 0; }
.strat-plan.best { border-left: 4px solid var(--green); }
.sp-title { font-weight: 700; }
.sp-seq { font-size: 15px; margin: 3px 0; }
.sp-pit { font-size: 13px; color: var(--muted); }

/* Rivais: estratégia (stints) + comparação de pilotagem */
.riv-status { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
    padding: 8px 14px; margin-bottom: 12px; font-size: 14px; font-weight: 600; }
.riv-status .hint { font-weight: 400; margin-top: 4px; }
table.strat { width: 100%; border-collapse: collapse; }
table.strat th { text-align: left; font-size: 12px; color: var(--muted);
    padding: 4px 8px; border-bottom: 1px solid var(--line); }
table.strat td { padding: 4px 8px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
table.strat tr.me { background: rgba(225, 6, 0, .10); }
.strat-laps { display: flex; flex-wrap: wrap; gap: 2px; }
.strat-cell { width: 10px; height: 16px; border-radius: 2px; display: inline-block; }
#riv-line-wrap { margin-top: 8px; }
#riv-line { width: 100%; max-width: 900px; height: auto; border: 1px solid var(--line);
    border-radius: 8px; background: #0e0e16; }

/* Feed de avisos e punições */
.feed { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.feed-row {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg2); border: 1px solid var(--line); border-left-width: 3px;
    border-radius: 6px; padding: 7px 12px; font-size: 14px;
}
.feed-row.penalty { border-left-color: var(--red); }
.feed-row.warning { border-left-color: var(--yellow); }
.feed-row.retire { border-left-color: var(--muted); opacity: .85; }
.feed-row.info { border-left-color: var(--green); }
.feed-ico { font-size: 15px; }
.feed-lap { font-size: 11px; font-weight: 700; color: var(--muted); min-width: 26px; }
.feed-car { display: flex; align-items: center; gap: 6px; font-weight: 700; min-width: 130px; }
.feed-bar { width: 4px; height: 14px; border-radius: 2px; display: inline-block; }
.feed-msg { color: #d6d6e6; }

/* Faixa de clima / previsão do tempo */
.weather-strip {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
    padding: 10px 16px; margin-bottom: 14px;
}
.weather-strip .wx-now { display: flex; flex-direction: column; padding-right: 14px; border-right: 1px solid var(--line); }
.weather-strip .wx-label { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 1px; }
.weather-strip .wx-cond { font-size: 16px; font-weight: 700; }
.weather-strip .wx-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.weather-strip .wx-chip {
    display: flex; flex-direction: column; align-items: center; line-height: 1.25;
    background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
    padding: 4px 10px; font-size: 13px; font-weight: 600;
}
.weather-strip .wx-chip .wx-t { font-size: 10px; color: var(--muted); }
.weather-strip .wx-chip.wet { border-color: #0067b1; background: rgba(0,103,177,.18); }
.weather-strip .wx-alert {
    background: rgba(0,103,177,.25); border: 1px solid #0067b1; color: #8fd0ff;
    border-radius: 6px; padding: 6px 12px; font-weight: 700; font-size: 14px;
}

/* Cards / tabelas genéricas */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card .sub { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.kv { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #1a1a26; font-size: 13px; }
.kv .label { color: var(--muted); }
.kv .val { font-weight: 600; font-variant-numeric: tabular-nums; }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #1a1a26; font-size: 14px; }
table.grid th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
table.grid td.mono, table.grid th.mono { font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--surface); }

.chart-wrap { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 16px; }
.chart-wrap h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; color: var(--muted); letter-spacing: .8px; }
canvas { width: 100%; display: block; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 6px 0 0; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.legend i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }

.empty { color: var(--muted); text-align: center; padding: 40px; font-style: italic; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }
.purpletime { color: var(--purple); font-weight: 700; }

/* Contador de voltas no cabeçalho da torre */
.race-status { font-size: 14px; font-weight: 600; color: var(--yellow); text-transform: none; letter-spacing: 0; }

/* Avisos como marcação flutuante na linha (sem coluna na tabela) */
.tower tr.row { position: relative; }
.row-avisos { position: absolute; right: 8px; top: 0; height: 44px;
    display: flex; align-items: center; gap: 4px; pointer-events: none; z-index: 3; }
.row-avisos .badge { margin-right: 0; box-shadow: 0 1px 4px rgba(0,0,0,.5); }

/* Banner de voltas em destaque */
.race-banner { display: flex; align-items: baseline; gap: 12px;
    background: linear-gradient(90deg, #1d1d29, #15151e);
    border: 1px solid var(--line); border-left: 4px solid var(--red);
    border-radius: 8px; padding: 10px 20px; margin-bottom: 14px; }
.rb-label { font-size: 13px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); }
.rb-cur { font-size: 36px; font-weight: 900; color: var(--yellow); font-variant-numeric: tabular-nums; line-height: 1; }
.rb-tot { font-size: 22px; font-weight: 700; color: var(--text); }
.rb-left { margin-left: auto; font-size: 15px; font-weight: 600; color: var(--muted); }

/* ---------------- setups de referência + assistente de setup --------------- */
.refset-head { display: flex; gap: 6px; margin-bottom: 6px; }
.badge.alt { background: var(--surface2); color: var(--text); border: 1px solid var(--line); }
.card-active { border-color: var(--green); box-shadow: 0 0 0 1px var(--green) inset; }
.card .btn { margin-top: 10px; width: 100%; text-align: center; }
.btn.on { border-color: var(--green); color: var(--green); }
.btn.small { width: auto; padding: 4px 10px; font-size: 12px; }

.setup-compare { background: var(--bg2); border: 1px solid var(--line);
    border-radius: 8px; padding: 14px; margin-bottom: 16px; }
.sc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.sc-title { font-weight: 700; margin-right: 8px; }
.sc-count { font-weight: 700; color: var(--yellow); }
.sc-count.all { color: var(--green); }
.sc-head .btn { margin-left: auto; }
.sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px 16px; }
.sc-row { display: grid; grid-template-columns: 1fr auto 14px auto; align-items: center;
    gap: 8px; padding: 5px 8px; border-radius: 5px; font-size: 13px;
    font-variant-numeric: tabular-nums; }
.sc-row.ok { background: rgba(46, 204, 113, 0.12); }
.sc-row.off { background: rgba(225, 6, 0, 0.10); }
.sc-label { color: var(--muted); }
.sc-row.ok .sc-label { color: var(--text); }
.sc-cur { text-align: right; font-weight: 700; }
.sc-row.off .sc-cur { color: var(--red); }
.sc-row.ok .sc-cur { color: var(--green); }
.sc-arrow { color: var(--muted); text-align: center; }
.sc-tgt { text-align: right; font-weight: 700; color: var(--text); }
.sc-row.ok .sc-tgt { color: var(--green); }

/* ---- relatório por corrida: gráficos e decisões ---- */
.ins-chartwrap { background: var(--panel2, #1c1c28); border: 1px solid #2a2a3a;
    border-radius: 10px; padding: 8px 10px; margin: 6px 0 4px; }
.ins-chart { width: 100%; height: auto; display: block; }
.ins-legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 2px 0 12px;
    font-size: 12px; color: var(--muted, #9a9ab2); }
.ins-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.ins-legend .lg::before { content: ""; width: 14px; height: 3px; border-radius: 2px;
    display: inline-block; }
.ins-legend .lg-you::before { background: #e10600; }
.ins-legend .lg-grid::before { background: #8a8a9c; height: 0; border-top: 2px dashed #8a8a9c; }
.ins-legend .lg-inc::before { background: #ffcc00; width: 8px; height: 8px; border-radius: 50%; }
.ins-decision { background: var(--panel2, #1c1c28); border: 1px solid #2a2a3a;
    border-left: 3px solid var(--red, #e10600); border-radius: 8px;
    padding: 10px 12px; margin: 8px 0; }
.ins-dec-title { font-weight: 700; margin-bottom: 6px; color: var(--text, #fff); }
.ins-dec-line { font-size: 13px; line-height: 1.5; }
.ins-dec-line.pro { color: #2ecc71; }
.ins-dec-line.con { color: #ff8a8a; }
.ins-dec-line.verdict { color: var(--text, #fff); margin-top: 4px; font-weight: 600; }

/* ---- atalho por painel (na linha de cada janela) ---- */
.config-hotkey { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.config-keylabel { font-size: 11px; color: var(--muted, #9a9ab2); }
.config-key { background: var(--panel2, #1c1c28); color: var(--text, #fff);
    border: 1px solid #2a2a3a; border-radius: 6px; padding: 3px 6px; font-size: 12px; }
