@page {
    size: auto;
    margin: 5mm;
}

/* Avoid page breaks inside rows when printing */
@media print {
    tr, td, th {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .no-print {
        display: none !important;
    }

    .back-button {
        display: none !important;
    }
}

body {
    font-family: Arial, sans-serif;
    padding: 20px;
    margin: 0;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #444;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.header img {
    height: 80px;
}

.header-center {
    text-align: center;
    flex-grow: 1;
}

.header-center h1 {
    margin: 0;
    font-size: 24px;
}

.header-center h2 {
    margin: 4px 0 0;
    font-size: 18px;
    color: #444;
}

.outer-wrapper {
    display: flex;
    justify-content: center;
}

.container {
    display: flex;
    flex-direction: column;
    gap: 2px;           /* from first template – tight, race-report style */
}

table {
    border-collapse: collapse;
    width: 100%;        /* full width, as in the first layout */
}

h3.class-subtitle {
    margin: 0;
    margin-top: 60px;
    top: 0;
    padding: 2px 2px;
    font-size: 16px;
    font-weight: bold;
    text-align: left;
    border-bottom: 1px solid #ccc;
}

h4.class-subtitle2 {
    margin: 0;
    margin-top: 20px;
    top: 0;
    padding: 2px 2px;
    font-size: 14px;
    font-weight: bold;
    text-align: left;
    color: grey;
    border-bottom: 1px solid #ccc;
}

th, td {
    border: 1px solid #aaa;
    padding: 2px;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
}

th {
    background-color: #f0f0f0;
    font-size: 11px;
    height: 1.5em;
}

td.ss {
    font-size: 8px;
    line-height: 1.1;
    text-align: center;
}

.simpleheader {
    text-align: center;
    font-size: 10px;
    font-weight: bold;
    padding: 1px;
    background: #ddd;
}

.rank,
.no {
    font-size: 11px;
    font-weight: bold;
}

/* Total + diffs inside time cell */
.time .Total,
.time .total_time {
    font-weight: bold;
    font-size: 9px;
    display: block;
}

.time .diff_prev,
.time .diff_first {
    font-size: 8px;
    color: gray;
    display: block;
}

.time {
    font-size: 8px;
}

/* CREW block (driver / codriver / team) */
.crew .driver,
.crew .codriver {
    font-weight: bold;
    font-size: 9px;
    display: block;
}

.crew .team {
    font-size: 8px;
    color: gray;
    display: block;
}

/* Generic spans (used by both pages) */
span.team {
    display: block;
    color: gray;
    font-size: 10px;
}
span.driver {
    display: block;
    font-weight: bold;
}
span.codriver {
    display: block;
}

/* κ/ο basic style */
.ko {
    font-size: 9px;
}

/* Emphasize class */
.ko .class {
    font-size: 10px;
    font-weight: bold;
}

/* From second CSS: top/bottom row layout inside κ/ο */
/* NEW κ/ο style: normal table cell with 4 stacked lines */
td.ko {
    padding: 2px;
    text-align: center;
    vertical-align: middle;   /* match row height */
}

/* make each value go on its own line */
td.ko span {
    display: block;
    line-height: 1.1;
}

/* keep HCat gray by default (LEGEND overridden inline to red) */
.ko .hcat {
    color: gray;
}


.ko .hcat {
    color: gray;
}

/* car text-only fallback */
.car {
    font-size: 9px;
}

.disq {
    font-size: 9px;
}

/* Left/right helper labels if used */
.left-time {
    font-weight: bold;
    font-size: 10px;
    display: block;
}

.left-speed {
    font-size: 9px;
    color: gray;
    display: block;
}

.right-penalty {
    font-weight: bold;
    font-size: 8px;
    display: block;
}

.right-time {
    font-weight: bold;
    font-size: 8px;
    display: block;
}

.right-total {
    font-weight: bold;
    font-size: 10px;
    display: block;
}

/* Controls bar at top */
#controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 14px;
    margin-bottom: 0;
    margin-left: 0;
}

#timestamp-display {
    font-weight: bold;
    font-size: 14px;
}

#resultMode {
    font-size: 14px;
    margin-left: auto;
}

#timestamp-wrapper {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.print-only {
    display: none;
}

/* Zebra rows on all tables */
.outer-wrapper table tbody tr:nth-child(even) {
    background-color: #f2f2f2;
}

/* CAR LOGO + MODEL (used by renderCarWithBrandIcon) */
.car-cell {
    text-align: center;
    vertical-align: middle;
}

.car-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.car-model {
    font-size: 10px;
}

/* FINAL CORRECT SIZE */
.car-logo {
    width: 30px !important;
    max-width: 30px !important;
    height: auto !important;
    margin-bottom: 4px;
}

/* BACK BUTTON from second CSS, kept as-is */
.back-button {
    position: fixed;
    top: 120px;
    left: 20px;
    background: #39ff14;
    color: #000;
    font-weight: bold;
    padding: 10px 20px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 18px;
    box-shadow: 0 0 10px #39ff14;
    transition: background 0.3s ease;
    z-index: 999;
}

.back-button:hover {
    background: #5cff2d;
}

.class-block {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    /* for Firefox */
    -moz-column-break-inside: avoid !important;
    /* for old WebKit */
    -webkit-column-break-inside: avoid !important;
    /* for good measure */
    display: block;
}
.class-block.first-block {
    page-break-inside: auto !important;
    break-inside: auto !important;
}
