/* --------------------------------------------------------------------------
   PitControl — pitwall u trati.

   Návrh se drží N7: velká písma, vysoký kontrast, minimum kliků. Tablet se drží
   v rukavicích, často na slunci, a rozhoduje se podle něj do několika sekund.
   Tmavé pozadí je záměr — displej na přímém světle i v noci v boxech.
   -------------------------------------------------------------------------- */

:root {
    --bg: #12141a;
    --panel: #1b1f28;
    --line: #2c3240;
    --text: #eef1f6;
    --muted: #97a0b3;
    --green: #35c46b;
    --yellow: #f5c231;
    --red: #e8523f;
    --accent: #4a9eff;
    --our-car: #1f3350;
}

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

main { padding: 12px 16px 32px; }
h1 { font-size: 1.4rem; margin: 0; }
.error { color: var(--red); }
.count { color: var(--muted); font-size: 0.9rem; }

.nav-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.nav-bar .brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.nav-bar nav a { color: var(--muted); text-decoration: none; margin-right: 16px; }

/* --- výběr eventu a session --------------------------------------------- */

.event-filter, .lap-filter { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; align-items: center; }

.event-filter input, .event-filter select, .event-filter button, .lap-filter select {
    padding: 10px 12px;
    font-size: 1rem;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.event-filter input { min-width: 280px; }

.event-list, .session-list { list-style: none; padding: 0; margin: 0; }
.event-list li, .session-list li { margin-bottom: 8px; }

.event-list button.event {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
}

.event-list li.event-row { display: flex; gap: 8px; align-items: stretch; }
.event-list li.event-row button.event { flex: 1; min-width: 0; }

/* Proklik na Speedhive — otevírá se v nové záložce, výběr eventu zůstává. */
.mylaps-link {
    color: var(--accent);
    font-size: 0.9rem;
    white-space: nowrap;
    text-decoration: none;
}
.mylaps-link:hover { text-decoration: underline; }
.event-list .mylaps-link {
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
}
.event-id .mylaps-link { margin-left: 8px; }

.event-list .name { font-weight: 600; }
.event-list .meta, .session-list .info { color: var(--muted); font-size: 0.9rem; }

.session-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.session-list li.active { border-color: var(--green); }
.session-list .name { color: var(--text); font-weight: 600; }

.tag {
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    background: var(--line);
    color: var(--muted);
}

.tag.live { background: var(--green); color: #06240f; }
.tag.recording { background: var(--accent); color: #041428; }

button.record, button.open, button.confirm, button.dismiss {
    padding: 10px 16px;
    font-size: 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
}

button.record, button.confirm { background: var(--accent); color: #041428; font-weight: 600; }
button.open { background: var(--green); color: #06240f; font-weight: 600; }
button.dismiss { background: var(--line); color: var(--text); }

/* --- hlavička pitwallu --------------------------------------------------- */

.pitwall-header {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
}

.pitwall-header .session { color: var(--muted); }

/* Zbývající čas patří do hlavičky — je to údaj, podle kterého se rozhoduje o zastávce.
   Když chybí, je to varování, ne poznámka. */
.pitwall-header .race-end { display: block; margin-top: 2px; font-variant-numeric: tabular-nums; color: var(--text); }
.pitwall-header .race-end.missing { color: var(--yellow); font-weight: 600; }
.pitwall-header .race-end a { margin-left: 8px; color: var(--accent); }
.pitwall-header .laps-link { color: var(--accent); margin-left: auto; }

/* Přepínač statusu: velká tlačítka, aktivní stav nepřehlédnutelný. */
.status-switch { display: flex; gap: 8px; }

.status-switch button {
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 6px;
    border: 2px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    cursor: pointer;
}

.status-switch button.green.active { background: var(--green); color: #06240f; border-color: var(--green); }
.status-switch button.yellow.active { background: var(--yellow); color: #2b2100; border-color: var(--yellow); }
.status-switch button.red.active { background: var(--red); color: #2b0703; border-color: var(--red); }

/* Návrh automatiky — nápadný, ale je to návrh k potvrzení, ne změna (F2.2). */
.suggestion-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-basis: 100%;
    padding: 10px 14px;
    background: #3a2f08;
    border: 1px solid var(--yellow);
    border-radius: 6px;
}

.suggestion-banner .text { flex: 1; }

/* --- stáří dat (N4, F6.4) ------------------------------------------------ */

.data-age { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.data-age .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.data-age.live .dot { background: var(--green); }
.data-age.warn .dot { background: var(--yellow); }
.data-age.stale .dot { background: var(--red); }
.data-age.finished .dot { background: var(--text); }
.data-age.stale .label { color: var(--red); font-weight: 600; }
.data-age .detail { color: var(--muted); }
.data-age .failures { color: var(--yellow); }

/* --- Live table ---------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

/* Zašednutí, když data nejsou živá. Tabulka nesmí tiše zobrazovat stará čísla (N4). */
.table-wrap.stale { opacity: 0.45; filter: grayscale(0.6); }

.live-table, .lap-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }

.live-table th, .lap-table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.live-table th.sortable { cursor: pointer; }

.live-table td, .lap-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #22262f;
    white-space: nowrap;
}

.live-table .number, .lap-table .number { font-weight: 700; }
.live-table .name, .lap-table .name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

/* Náš vůz je připnutý nahoru a zvýrazněný — hledat ho v poli 170 vozů nejde. */
.live-table tr.our-car { background: var(--our-car); font-size: 1.05rem; }
.live-table tr.in-pit { color: var(--muted); font-style: italic; }
.live-table tr.in-window { box-shadow: inset 3px 0 0 var(--green); }

.live-table .lap-green { color: var(--text); }
.live-table .lap-sc { color: var(--yellow); }
.live-table .lap-red { color: var(--red); }
.live-table .lap-pit { color: var(--muted); }
.live-table .better { color: var(--green); }
.live-table .worse { color: var(--yellow); }

/* Nejlepší hodnota mezi všemi vozy — fialová jako v časomíře. Musí přebít barvu typu
   kola i trendu, proto víc specifický selektor. */
.live-table td.purple { color: #c77dff; font-weight: 700; }
.live-table .window-open { color: var(--green); font-weight: 600; }
.live-table .warning { color: var(--yellow); font-size: 1.1rem; cursor: help; }
.live-table .class-pos, .live-table .sub { margin-left: 4px; font-size: 0.78rem; color: var(--muted); }

/* PIT / STAY OUT pod safety carem — musí být čitelné na první pohled. */
.sc-call { display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline; padding: 12px 16px; margin: 0 0 12px; border-radius: 6px; font-size: 1.1rem; }
.sc-call strong { font-size: 1.3rem; }
.sc-call.pit { background: var(--yellow); color: #041428; }
.sc-call.pit .estimate { color: #3b3210; }
.sc-call.stay { background: var(--panel); border: 2px solid var(--yellow); }
.live-table .sc-pit { color: #041428; background: var(--yellow); font-weight: 700; text-align: center; cursor: help; }
.live-table .sc-stay { color: var(--text); font-weight: 700; text-align: center; cursor: help; }

/* Hodnota z odhadu, ne z měření (F6.5, 6.12). */
.estimate { color: var(--muted); font-style: italic; }
.unreliable { color: var(--muted); }

/* --- log kol ------------------------------------------------------------- */

.lap-table-wrap { height: calc(100vh - 220px); overflow: auto; }
.lap-table tr.estimated { background: #2a2413; }
.lap-table tr.derived { background: #1d2530; }

/* --- chybová hláška Blazoru ---------------------------------------------- */

/*
   Skryté, dokud nenastane neošetřená výjimka. Pravidlo je povinné: element je
   v index.html vždycky, a bez display:none svítí hláška o chybě i tehdy, když
   je všechno v pořádku.
*/
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 12px 16px;
    background: var(--red);
    color: #2b0703;
    font-weight: 600;
    box-shadow: 0 -2px 12px rgb(0 0 0 / 40%);
}

#blazor-error-ui .reload { color: #2b0703; text-decoration: underline; margin-left: 12px; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; padding: 0 8px; }

.loading-progress-text { color: var(--muted); text-align: center; padding-top: 40vh; }

/* --- setup a pitstopy ---------------------------------------------------- */

.page-header { display: flex; align-items: baseline; gap: 20px; margin-bottom: 16px; }
.page-header .link { color: var(--accent); }
.pitwall-links { margin-left: auto; display: flex; gap: 16px; }
.pitwall-links a { color: var(--accent); text-decoration: none; }

.setup-block {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    max-width: 900px;
}

.setup-block h2 { font-size: 1.05rem; margin: 0 0 8px; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 4px 0 12px; }

/* Co aplikace o konci závodu ví a odkud. Odhad z kol se hýbe, takže se to nesmí
   tvářit jako pevný čas. */
.race-end-state { margin: 0 0 12px; font-weight: 600; }

button.secondary { padding: 12px 16px; font-size: 0.95rem; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; }

.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.field-row { display: flex; gap: 12px; align-items: flex-end; }

.setup-block label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }

.setup-block input, .setup-block select {
    padding: 10px 12px;
    font-size: 1.05rem;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 6px;
}

/* Nevyplněná pole musí být vidět — aplikace na nich staví (F8.3). */
.missing { color: var(--yellow); margin: 12px 0 0; }

.computed {
    display: flex;
    gap: 12px;
    align-items: baseline;
    margin: 16px 0;
    padding: 12px;
    background: var(--bg);
    border-radius: 6px;
}

.computed .label { color: var(--muted); }
.computed .value { font-size: 1.15rem; font-weight: 600; }

button.save { padding: 12px 20px; font-size: 1rem; border: none; border-radius: 6px; background: var(--accent); color: #041428; font-weight: 600; cursor: pointer; }
.saved { color: var(--green); margin-left: 12px; }

/* Fronta neodeslaných zápisů — musí být vidět, jinak si tankovač myslí, že je hotovo. */
.pending-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: #3a2f08;
    border: 1px solid var(--yellow);
    border-radius: 6px;
}

.pending-banner button { padding: 6px 12px; border: none; border-radius: 4px; background: var(--yellow); color: #2b2100; font-weight: 600; cursor: pointer; }

.pit-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.pit-table th { text-align: left; padding: 8px 10px; font-size: 0.8rem; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
.pit-table td { padding: 8px 10px; border-bottom: 1px solid #22262f; }
.pit-table tr.our-car { background: var(--our-car); }
.pit-table .muted { color: var(--muted); }

/* F7.1: zadání litrů na dva doteky. Předvolby jsou velké, protože se do nich
   trefuje v rukavicích uprostřed stopu. */
.fuel-entry { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.fuel-entry .preset {
    min-width: 52px;
    padding: 12px 10px;
    font-size: 1.05rem;
    font-weight: 600;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
}

.fuel-entry .preset.active { background: var(--green); color: #06240f; border-color: var(--green); }
.fuel-entry input { width: 84px; padding: 12px 8px; font-size: 1.05rem; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; }

button.discard { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; }
button.discard:hover { color: var(--red); }

/* --- stav eventu ve výběru ------------------------------------------------ */

.event-list button.event { flex-direction: row; align-items: center; gap: 12px; }
.event-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

/*
   Ikona i barva zároveň. Samotná barva nestačí — na slunci u trati a lidem
   s poruchou barvocitu splyne zelená s šedou.
*/
.state-icon {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.95rem;
    background: var(--bg);
    border: 1px solid var(--line);
}

.state-icon.state-running { color: var(--green); border-color: var(--green); }
.state-icon.state-pending { color: var(--yellow); border-color: var(--yellow); }
.state-icon.state-finished { color: var(--muted); }
.state-icon.state-unknown { color: var(--muted); }

.tag.state-running { background: var(--green); color: #06240f; }
.tag.state-pending { background: var(--yellow); color: #2b2100; }
.tag.state-finished { background: var(--line); color: var(--muted); }
.tag.state-unknown { background: var(--line); color: var(--muted); }

.page-hint { color: var(--muted); max-width: 720px; margin: 0 0 16px; line-height: 1.5; }
.page-hint strong { color: var(--text); }

/* --- výběr našich vozů ---------------------------------------------------- */

.car-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 6px;
}

.car-option {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    cursor: pointer;
}

.car-option.selected { background: var(--our-car); border-color: var(--accent); }
.car-option input { width: 18px; height: 18px; }
.car-option .number { font-weight: 700; min-width: 42px; }
.car-option .name { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.car-option.selected .name { color: var(--text); }

/* --- log race statusu ----------------------------------------------------- */

.status-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; max-width: 900px; }
.status-table th { text-align: left; padding: 8px 10px; font-size: 0.8rem; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
.status-table td { padding: 10px; border-bottom: 1px solid #22262f; }
.status-table .status-cell { font-weight: 700; }
.status-table .muted { color: var(--muted); }

/* Barevný pruh vlevo — stav úseku musí být poznat bez čtení. */
.status-table tr.status-green .status-cell { box-shadow: inset 4px 0 0 var(--green); padding-left: 14px; }
.status-table tr.status-yellow .status-cell { box-shadow: inset 4px 0 0 var(--yellow); padding-left: 14px; }
.status-table tr.status-red .status-cell { box-shadow: inset 4px 0 0 var(--red); padding-left: 14px; }

.field-row label .hint { display: inline; margin-left: 4px; font-size: 0.75rem; }

/* Čas zastávky a výměna kol se zadávají u trati, v rukavicích, na dotykovém displeji
   (N7) — proto velké terče, ne drobná pole a zaškrtávátka. */
.time-cell input {
    width: 108px;
    padding: 10px 8px;
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.tyres-cell button.toggle,
.fuel-mode button.toggle {
    min-width: 88px;
    padding: 12px 10px;
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--bg);
    color: var(--muted);
    border: 2px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
}

.tyres-cell button.toggle.active,
.fuel-mode button.toggle.active { background: var(--accent); color: #041428; border-color: var(--accent); }

/* Co znamená zapisované číslo litrů — natankováno, nebo obsah nádrže. */
.fuel-mode { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px; }
.fuel-mode .hint { margin: 0; }

/* Předpoklad, ne měření — a v tabulce, podle které se rozhoduje, to musí být vidět. */
.fuel-cell .assumed {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 6px;
    font-size: 0.78rem;
    color: var(--yellow);
    border: 1px dashed var(--yellow);
    border-radius: 4px;
}

/* Administrace: čísla vedle sebe se čtou v číselném sloupci, ne v textovém. */
.admin-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; font-size: 0.92rem; }
.admin-table th, .admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.admin-table th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.04em; }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.db-total { font-size: 1.6rem; font-weight: 700; margin: 0 0 12px; font-variant-numeric: tabular-nums; }

.admin-event { margin-bottom: 24px; }
.admin-event h3 { margin: 0 0 2px; font-size: 1.05rem; }
.admin-event h3 .muted { font-weight: 400; font-size: 0.85rem; margin-left: 8px; }
.event-summary { margin: 0 0 8px; font-size: 0.85rem; }

/* Kolik ušetřilo nezakládání opakovaných odpovědí. */
.admin-table .saved { margin-left: 6px; color: var(--green); font-size: 0.8rem; }

/* Mazání snapshotů je nevratné, takže se potvrzuje na řádku, ne v dialogu. */
.confirm-row td { background: var(--panel); line-height: 1.6; }
.confirm-row button { margin-left: 8px; }

/* Přehled uloženého má hodně sloupců — na užším displeji se roluje tabulka, ne stránka. */
.table-scroll { overflow-x: auto; }

/* Z přehledu se chodí dál — do session eventu i rovnou na pitwall. */
.admin-event h3 a, .admin-table td a { color: var(--accent); text-decoration: none; }
.admin-event h3 a:hover, .admin-table td a:hover { text-decoration: underline; }

/* --- logger: log kol ----------------------------------------------------- */

.lap-filter .check { display: flex; gap: 6px; align-items: center; }
.lap-table .name a { color: inherit; text-decoration: none; }
.lap-table .name a:hover { text-decoration: underline; }

/* Barvy řádků podle dokumentu: fastest fialově, green, safety žlutě, pit, fuel. */
.lap-table tr.safety { background: #2b2610; }
.lap-table tr.refuel-candidate { background: #3a2410; }
.lap-table tr.refuelled { background: #123222; }
.lap-table td.purple { color: #c77dff; font-weight: 700; }
.lap-table td.personal-best { color: var(--green); font-weight: 600; }
.lap-table .sc-label { color: var(--yellow); font-weight: 700; letter-spacing: 0.03em; }
.lap-table .fuel-negative { color: var(--red); font-weight: 600; }
.lap-table .refuel-cell { white-space: nowrap; }
.lap-table .refuel-tag { color: var(--green); font-weight: 600; margin-right: 6px; }

.lap-legend { display: flex; gap: 12px; flex-wrap: wrap; margin: -8px 0 12px; font-size: 0.85rem; color: var(--muted); }
.lap-legend .swatch::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.lap-legend .fastest::before { background: #c77dff; }
.lap-legend .green::before { background: var(--panel); border: 1px solid var(--line); }
.lap-legend .safety::before { background: #6b5a14; }
.lap-legend .pit::before { background: #8a5316; }
.lap-legend .fuel::before { background: #1f6b43; }

.refuel-button {
    padding: 2px 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: none;
    color: var(--muted);
    cursor: pointer;
}

.refuel-button.suggested { border-color: #f0923a; color: #f0923a; font-weight: 600; }
.link-button { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0 4px; }
.fuel-entry.compact .preset { min-width: 40px; padding: 4px 8px; font-size: 0.95rem; }
.fuel-entry.compact input { width: 64px; padding: 4px 6px; font-size: 0.95rem; }

/* --- logger: profil vozu ------------------------------------------------- */

.car-profile { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; }
.car-profile.our-car { border-color: var(--accent); }
.car-profile .profile-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.car-profile h2 { margin: 0; font-size: 1.2rem; }
.car-profile .muted { color: var(--muted); }
.car-profile .tag.our { background: var(--accent); color: #041428; }
.profile-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px 16px; margin: 12px 0; }
.profile-stats dt { font-size: 0.8rem; color: var(--muted); }
.profile-stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.field-grid.compact { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.car-profile label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.car-profile input { padding: 8px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; }

.live-table .name a { color: inherit; text-decoration: none; }
.live-table .name a:hover { text-decoration: underline; color: var(--accent); }

/* --- křivka spotřeby ----------------------------------------------------- */

.curve-chart { width: 100%; max-width: 560px; height: auto; }
.curve-chart .axis { stroke: var(--line); }
.curve-chart .tick { fill: var(--muted); font-size: 11px; }
.curve-chart .fit { stroke: var(--accent); stroke-width: 2; }
.curve-chart .point { fill: var(--green); }

/* --- TV screen ----------------------------------------------------------- */

.tv { display: flex; flex-direction: column; gap: 16px; }
.tv-header { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.tv-header h1 { margin: 0; font-size: 1.6rem; }
.tv-header .muted { color: var(--muted); }
.tv-status { padding: 8px 20px; border-radius: 6px; font-size: 1.4rem; font-weight: 800; letter-spacing: 0.05em; }
.tv-status.green { background: var(--green); color: #06240f; }
.tv-status.yellow { background: var(--yellow); color: #2b2100; }
.tv-status.red { background: var(--red); color: #fff; }
.tv-status.finished { background: var(--text); color: var(--bg); }
.tv-clock { margin-left: auto; font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.tv-cars { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.tv-car { background: var(--our-car); border: 1px solid var(--accent); border-radius: 10px; padding: 16px 20px; }
.tv-car-title { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.tv-number { font-size: 2rem; font-weight: 800; }
.tv-name { font-size: 1.4rem; font-weight: 600; }
.tv-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 20px; margin: 0; }
.tv-stats dt { font-size: 0.85rem; color: var(--muted); }
.tv-stats dd { margin: 0; font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tv-stats .big dd { font-size: 2.4rem; }
.tv-stats small { font-size: 0.9rem; color: var(--muted); }

.tv-body { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.tv-standings { font-size: 1.05rem; }
.tv-standings tr.our-car { background: var(--our-car); font-weight: 700; }
.tv-standings td.purple { color: #c77dff; font-weight: 700; }
.tv-stream .track-map { margin-bottom: 12px; }
.tv-stream iframe, .tv-stream-empty, .tv-stream-twitch { width: 100%; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 8px; background: #000; }
.tv-stream-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); }

@media (max-width: 900px) {
    .tv-body { grid-template-columns: 1fr; }
    .tv-cars { grid-template-columns: 1fr; }
    .tv-stats { grid-template-columns: repeat(2, 1fr); }
}

/* --- Race setup: tabulka všech vozů --------------------------------------- */

.bulk-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; padding: 10px; margin-bottom: 12px; border: 1px dashed var(--line); border-radius: 6px; }
.bulk-row label { width: 110px; }
.bulk-row label:first-child { width: 150px; }
.bulk-row button { padding: 8px 12px; }

.setup-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.setup-table th { text-align: left; font-size: 0.8rem; color: var(--muted); font-weight: 600; padding: 6px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.setup-table td { padding: 3px 6px; border-bottom: 1px solid var(--line); }
.setup-table td input[type=number] { width: 80px; padding: 4px 6px; }
.setup-table td input[type=checkbox] { width: 18px; height: 18px; }
.setup-table .name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setup-table tr.our-car { background: var(--our-car); box-shadow: inset 4px 0 0 var(--accent); font-weight: 600; }
.setup-table tr.incomplete .computed-cell { color: var(--muted); }
.setup-table .computed-cell { white-space: nowrap; }

.save-bar { display: flex; gap: 16px; align-items: center; margin-top: 12px; position: sticky; bottom: 0; background: var(--panel); padding: 8px 0; }
.save-bar.dirty .save { box-shadow: 0 0 0 2px var(--yellow); }
.save-bar .unsaved { color: var(--yellow); font-weight: 600; }
.save-bar .hint { margin: 0; }

/* Naše vozy v Live table: pruh vlevo a tučné písmo, ať se v poli 70 vozů nedají přehlédnout. */
.live-table tr.our-car { box-shadow: inset 5px 0 0 var(--accent); font-weight: 700; }
.live-table tr.our-car td { border-bottom-color: var(--accent); }

/* Návrh zastávky z detekce — čeká na potvrzení, do paliva nevstupuje. */
.lap-table .refuel-proposal { color: #f0923a; font-weight: 600; margin-right: 6px; }
.pit-table tr.unconfirmed td { color: var(--muted); font-style: italic; }
.pit-table tr.unconfirmed td.confirm-cell { font-style: normal; }

/* Řidič po zastávce. */
.pit-table .driver-cell input { width: 130px; padding: 6px 8px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; }
.tv-driver { font-size: 1.3rem; color: var(--text); }

/* Počasí na TV. */
.tv-weather { display: flex; align-items: center; gap: 12px; font-variant-numeric: tabular-nums; }
.tv-weather .icon { font-size: 2rem; }
.tv-weather .temp { font-size: 1.6rem; font-weight: 700; }
.tv-weather .rain { color: var(--accent); font-weight: 600; }
.tv-weather .forecast { display: flex; gap: 10px; color: var(--muted); font-size: 0.9rem; }

/* Race setup: sekce s tabulkou všech vozů je široká jako stránka a tabulka se
   posouvá uvnitř rámečku, místo aby z něj vytékala. */
.setup-block.wide { max-width: none; }
.setup-table-wrap { overflow-x: auto; max-width: 100%; }
.setup-table td input[type=number] { width: 72px; padding: 4px 6px; font-size: 0.95rem; box-sizing: border-box; }
.bulk-row input, .bulk-row select { width: 100%; box-sizing: border-box; padding: 6px 8px; font-size: 0.95rem; }
.bulk-row label { min-width: 0; }
.setup-block .field-row { flex-wrap: wrap; }
.setup-block .field-row input, .setup-block .field-row select { max-width: 100%; box-sizing: border-box; }

/* Log sběru dat. */
.collector-log tr.log-error td { color: var(--red); }
.collector-log tr.log-warning td { color: var(--yellow); }
.collector-log td a { color: var(--accent); }
.data-age { flex-wrap: wrap; }
.data-age .collector-reason { flex-basis: 100%; font-size: 0.8rem; color: var(--muted); text-decoration: none; }
.data-age .collector-reason.error { color: var(--red); }
.data-age .collector-reason.warning { color: var(--yellow); }

/* --- mapa okruhu --------------------------------------------------------- */

.track-map { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.track-map svg { width: 100%; height: auto; display: block; max-height: 60vh; }
.track-map.empty { color: var(--muted); padding: 16px; }
.track-map .track-outline { fill: none; stroke: #0c0e13; stroke-width: 26; stroke-linejoin: round; stroke-linecap: round; }
.track-map .track-line { fill: none; stroke: #7d8494; stroke-width: 14; stroke-linejoin: round; stroke-linecap: round; }
.track-map .track-finish { font-size: 40px; }
.track-map .track-name { position: absolute; left: 12px; bottom: 8px; color: var(--muted); font-size: 0.85rem; }

/* Plynulý posun mezi sekundovými aktualizacemi. */
.track-map .car-marker { transition: transform 1s linear; }
.track-map .car-marker circle { fill: #e6e9ef; stroke: #0c0e13; stroke-width: 3; }
.track-map .car-marker text { fill: #0c0e13; font-size: 16px; font-weight: 800; font-family: "Segoe UI", system-ui, sans-serif; }
.track-map .car-marker.leader circle { fill: #f0923a; }
.track-map .car-marker.ours circle { fill: var(--accent); stroke: #fff; stroke-width: 4; }
.track-map .car-marker.ours text { fill: #fff; font-size: 20px; }

/* --- tankování: přehled --------------------------------------------------- */

.pit-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; margin-bottom: 16px; }
.pit-summary-card { background: var(--our-car); border: 1px solid var(--accent); border-radius: 8px; padding: 12px 16px; }
.pit-summary-card .title { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.pit-summary-card .number { font-size: 1.4rem; font-weight: 800; }
.pit-summary-card .name { font-size: 1.1rem; font-weight: 600; }
.pit-summary-card .driver { color: var(--muted); }
.pit-summary-card dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 16px; margin: 0; }
.pit-summary-card dt { font-size: 0.8rem; color: var(--muted); }
.pit-summary-card dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.pit-summary-card .proposals { display: inline-block; margin-top: 10px; color: #f0923a; font-weight: 600; }
.page-hint a { color: var(--accent); }

/* --- logger: zápis zastávky ---------------------------------------------- */

.refuel-editor { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.refuel-editor-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.refuel-editor .driver-input { width: 150px; padding: 4px 6px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; }
.refuel-editor .toggle { padding: 4px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--text); cursor: pointer; }
.refuel-editor .toggle.active { background: var(--accent); color: #041428; border-color: var(--accent); }
.refuel-editor .save { padding: 4px 12px; }
.lap-table .refuel-driver, .lap-table .refuel-tyres { margin-right: 6px; }

/* --- třídy a predikce cíle ----------------------------------------------- */

.class-toggle { display: flex; gap: 6px; align-items: center; font-size: 0.9rem; color: var(--muted); cursor: pointer; }
.class-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--class-color);
    border: 1px solid var(--class-color);
    background: color-mix(in srgb, var(--class-color) 15%, transparent);
    white-space: nowrap;
}
.class-pos-big {
    display: inline-block;
    min-width: 26px;
    text-align: center;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 800;
    color: #0c0e13;
    background: var(--class-color);
}
.live-table .finish-cell { white-space: nowrap; }
.live-table .finish-pos { display: inline-block; min-width: 2.2em; font-size: 1.05rem; }
.tv-stream-twitch iframe { width: 100%; height: 100%; border: 0; border-radius: 8px; }
.tv-stream-empty a { color: var(--accent); margin-left: 4px; }

/* Race setup: stream na TV. */
.setup-block .field-row label.grow { flex: 1; min-width: 220px; }
.setup-block .field-row label.grow input { width: 100%; box-sizing: border-box; }
.stream-preview { margin: 10px 0 0; color: var(--muted); }
