* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f3f5f8;
    color: #17202a;
}

body {
    min-height: 100vh;
}


/* =========================
   HEADER
========================= */

.topbar {
    background: #17365d;
    color: white;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.title {
    font-size: 24px;
    font-weight: 800;
}

.event-name {
    font-size: 18px;
    font-weight: 600;
}


/* =========================
   TABS
========================= */

.race-tabs {
    display: flex;
    gap: 8px;
    padding: 10px;
    background: white;
    border-bottom: 1px solid #d5d9de;
    overflow-x: auto;
    position: sticky;
    top: 0;
    z-index: 100;
}

.tab {
    border: none;
    background: #e5e9ee;
    color: #263746;
    font-weight: 800;
    font-size: 15px;
    padding: 15px 20px;
    border-radius: 10px;
    min-height: 52px;
    white-space: nowrap;
    cursor: pointer;
    touch-action: manipulation;
}

.tab.active {
    background: #2f75b5;
    color: white;
}

.tab:hover {
    background: #28669e;
    color: white;
}


/* =========================
   MAIN
========================= */

main {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

.dashboard-header {
    margin-bottom: 20px;
}

.dashboard-header h1 {
    margin: 0 0 5px;
    font-size: 28px;
}

.dashboard-header p {
    margin: 0;
    color: #637381;
}


/* =========================
   SETTINGS
========================= */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.setting-card {
    background: white;
    padding: 18px;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,.08);
}

.setting-card label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 14px;
}

input,
select {
    width: 100%;
    height: 52px;
    border: 2px solid #ccd3da;
    border-radius: 9px;
    background: white;
    font-size: 20px;
    padding: 8px 12px;
}

input:focus,
select:focus {
    outline: none;
    border-color: #2f75b5;
}

.input-prefix,
.input-suffix {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-prefix span,
.input-suffix span {
    font-size: 22px;
    font-weight: 700;
}


/* =========================
   TOTAL CARDS
========================= */

.totals-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.total-card {
    padding: 22px;
    border-radius: 14px;
    color: white;
    text-align: center;
    min-height: 125px;
}

.total-card.tickets {
    background: #17365d;
}

.total-card.takings {
    background: #2f75b5;
}

.total-card.retained {
    background: #548235;
}

.total-card.prize {
    background: #c69214;
}

.total-label {
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 10px;
}

.total-value {
    font-size: 32px;
    font-weight: 900;
}


/* =========================
   PANEL
========================= */

.panel {
    background: white;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,.08);
    margin-bottom: 16px;
}

.panel-title {
    font-size: 21px;
    font-weight: 800;
    margin-bottom: 10px;
}


/* =========================
   TABLE
========================= */

.summary-table-wrapper {
    overflow-x: auto;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
}

.summary-table th {
    background: #17365d;
    color: white;
    padding: 12px;
    text-align: center;
}

.summary-table td {
    padding: 12px;
    text-align: center;
    border-bottom: 1px solid #ddd;
    font-size: 16px;
}

.summary-table tr:hover {
    background: #f5f7f9;
}


/* =========================
   RACE SCREEN
========================= */

.race-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    gap: 15px;
}

.race-header h1 {
    margin: 0;
    font-size: 28px;
}

.race-header p {
    margin: 4px 0 0;
    color: #637381;
    font-size: 15px;
}

.race-total {
    font-size: 17px;
    font-weight: 700;
}


/* =========================
   HORSE GRID
========================= */

.horse-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}


/* =========================
   HORSE CARD
========================= */

.horse-row {
    background: white;
    border-radius: 9px;
    padding: 8px 12px;

    display: grid;
    grid-template-columns: 1fr auto;

    align-items: center;
    gap: 12px;

    box-shadow: 0 1px 4px rgba(0,0,0,.06);

    min-height: 58px;
}


/* =========================
   HORSE NAME
========================= */

.horse-name {
    font-size: 18px;
    font-weight: 800;
}


/* =========================
   HORSE CONTROLS
========================= */

.horse-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}


/* =========================
   TICKET COUNT
========================= */

.ticket-count {
    width: 42px;
    min-width: 42px;

    text-align: center;

    font-size: 23px;
    font-weight: 900;
}


/* =========================
   PLUS / MINUS BUTTONS
========================= */

.count-button {
    width: 42px;
    height: 42px;

    padding: 0;

    border: none;
    border-radius: 9px;

    font-size: 23px;
    font-weight: 900;

    cursor: pointer;
    touch-action: manipulation;

    display: flex;
    align-items: center;
    justify-content: center;
}

.minus-button {
    background: #e5e9ee;
    color: #111;
}

.plus-button {
    background: #2f75b5;
    color: white;
}

.count-button:active {
    transform: scale(.94);
}


/* =========================
   RACE CALCULATIONS
========================= */

.race-calculations {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 14px;
}

.calculation-card {
    background: white;
    padding: 14px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.calculation-label {
    font-size: 12px;
    font-weight: 800;
    color: #637381;
    margin-bottom: 6px;
}

.calculation-value {
    font-size: 23px;
    font-weight: 900;
}


/* =========================
   WINNER
========================= */

.winner-panel {
    background: #fff8df;
    border: 2px solid #e5c65c;
    border-radius: 12px;
    padding: 16px;
    margin-top: 14px;
}

.winner-panel h2 {
    margin-top: 0;
}

.winner-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    align-items: end;
}

.winner-value {
    font-size: 26px;
    font-weight: 900;
}


/* =========================
   FOOTER
========================= */

footer {
    padding: 15px 20px;
    background: #17365d;
    color: white;
    display: flex;
    justify-content: space-between;
}


/* =========================
   MOBILE / IPAD
========================= */

@media (max-width: 900px) {

    .settings-grid,
    .totals-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .horse-grid {
        grid-template-columns: 1fr;
    }

    .race-calculations {
        grid-template-columns: repeat(2, 1fr);
    }

    .winner-grid {
        grid-template-columns: 1fr;
    }
}


@media (max-width: 600px) {

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .settings-grid,
    .totals-grid {
        grid-template-columns: 1fr;
    }

    main {
        padding: 12px;
    }

    .race-tabs {
        padding: 8px;
    }

    .tab {
        padding: 13px 16px;
    }

    .horse-row {
        grid-template-columns: 1fr auto;
        padding: 8px 10px;
    }

    .horse-name {
        font-size: 17px;
    }

    .horse-controls {
        gap: 4px;
    }

    .count-button {
        width: 40px;
        height: 40px;
        font-size: 21px;
    }

    .ticket-count {
        width: 38px;
        min-width: 38px;
        font-size: 21px;
    }

    .race-calculations {
        grid-template-columns: 1fr;
    }

    footer {
        flex-direction: column;
        gap: 5px;
    }
}


/* =========================================================
   DASHBOARD TOTAL CARDS
========================================================= */

.totals-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}


/* -----------------------------------------
   CARD CONTAINERS
----------------------------------------- */

.totals-grid > div {
    padding: 22px;
    border-radius: 14px;
    color: white;
    text-align: center;
    min-height: 125px;

    display: flex;
    flex-direction: column;
    justify-content: center;

    box-sizing: border-box;
}


/* -----------------------------------------
   TICKETS SOLD
----------------------------------------- */

.totals-grid > div:has(#totalTickets) {
    background: #17365d !important;
}


/* -----------------------------------------
   TOTE TAKINGS
----------------------------------------- */

.totals-grid > div:has(#totalTakings) {
    background: #2f75b5 !important;
}


/* -----------------------------------------
   OWNER INCOME
----------------------------------------- */

.totals-grid > div:has(#totalOwnerIncome) {
    background: #548235 !important;
}


/* -----------------------------------------
   TOTAL INCOME
----------------------------------------- */

.totals-grid > div:has(#totalIncome) {
    background: #7f6000 !important;
}


/* -----------------------------------------
   TOTE PAYOUTS
----------------------------------------- */

.totals-grid > div:has(#totalTotePayouts) {
    background: #7030a0 !important;
}


/* -----------------------------------------
   OWNER PAYOUTS
----------------------------------------- */

.totals-grid > div:has(#totalOwnerPayouts) {
    background: #c55a11 !important;
}


/* -----------------------------------------
   TOTAL PAYOUTS
----------------------------------------- */

.totals-grid > div:has(#totalPayouts) {
    background: #a61c00 !important;
}


/* -----------------------------------------
   TOTAL RETAINED / MADE
----------------------------------------- */

.totals-grid > div:has(#totalActualRetained) {
    background: #375623 !important;
}


/* -----------------------------------------
   TEXT
----------------------------------------- */

.totals-grid .total-label {
    color: #ffffff !important;
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 10px;
}

.totals-grid .total-value {
    color: #ffffff !important;
    font-size: 32px;
    font-weight: 900;
}