:root {
    --bg: #ffffff;
    --text: #111;
    --muted: #666;
    --line: #e6e6e6;
    --sb-bg: #f7f9fc;
    --sb-accent: #e9eef6;
    --btn: #0a66c2;
    --btn-text: #fff;
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 system-ui, Segoe UI, Roboto, Arial;
}

.layout {
    display: flex;
    min-height: 100vh
}

/* Sidebar */
.sidebar {
    width: 280px;
    min-width: 240px;
    background: var(--sb-bg);
    border-right: 1px solid var(--line);
    padding: 14px 10px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
}

.sb-title {
    font-weight: 600;
    margin: 6px 8px 10px
}

.match-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 4px
}

.match-item {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
}

.match-item small {
    color: var(--muted)
}

.match-item:hover {
    background: var(--sb-accent)
}

.match-item.active {
    outline: 2px solid var(--btn);
    background: #fff
}

/* Content */
.content {
    flex: 1;
    min-width: 0;
    padding: 20px;
    transition: margin .15s ease
}

.toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px
}

.title {
    font-size: 18px;
    font-weight: 600
}

.actions {
    display: flex;
    gap: 8px
}

/* Buttons */
.btn {
    appearance: none;
    border: 0;
    border-radius: 8px;
    padding: 8px 12px;
    background: var(--btn);
    color: var(--btn-text);
    cursor: pointer;
    font-weight: 600;
}

.btn:hover {
    filter: brightness(.95)
}

.btn:active {
    transform: translateY(1px)
}

.btn.active {
    background: #ff7a00;
    color: #111;
    box-shadow: 0 0 0 2px rgba(255, 122, 0, .25) inset;
}

.btn.active:hover {
    filter: brightness(1.02)
}

.btn:not(.active):hover {
    filter: brightness(.95)
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line)
}

.btn-ghost:hover {
    background: #f5f7fb
}

/* Collapsible sidebar */
.sidebar.collapsed {
    width: 0;
    min-width: 0;
    padding: 0;
    border: none;
    overflow: hidden
}

/* Tables (default) */
table {
    border-collapse: collapse;
    width: 100%;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    margin: 10px 0;
}

th,
td {
    border: 1px solid var(--line);
    padding: .45rem .55rem;
    text-align: right
}

th:first-child,
td:first-child {
    text-align: left
}

h3 {
    margin: .9rem 0 .5rem
}

.muted {
    color: var(--muted)
}

table td:nth-child(2),
table td:nth-child(3) {
    text-align: center
}

/* Matrix compact */
table.matrix-compact {
    width: auto;
    margin: 10px auto;
    table-layout: fixed
}

table.matrix-compact th,
table.matrix-compact td {
    padding: .25rem .4rem;
    border: 1px solid var(--line)
}

table.matrix-compact td:nth-child(2),
table.matrix-compact td:nth-child(3),
table.matrix-compact td:nth-child(4),
table.matrix-compact td:nth-child(5),
table.matrix-compact td:nth-child(6),
table.matrix-compact td:nth-child(7) {
    min-width: 44px;
    text-align: center
}

table.matrix-compact th:first-child,
table.matrix-compact td:first-child {
    min-width: 140px
}

table.matrix-compact th:last-child,
table.matrix-compact td:last-child {
    min-width: 140px
}

/* Matrix tight */
table.matrix-tight {
    width: auto;
    margin: 10px auto;
    table-layout: fixed
}

table.matrix-tight th,
table.matrix-tight td {
    border: 1px solid var(--line);
    padding: .25rem .5rem;
    vertical-align: middle
}

table.matrix-tight th.left,
table.matrix-tight td.left {
    text-align: left;
    min-width: 140px
}

table.matrix-tight th.right,
table.matrix-tight td.right {
    text-align: right;
    min-width: 140px
}

table.matrix-tight .center {
    text-align: center;
    min-width: 56px
}

table.matrix-tight .small {
    font-size: 12px;
    color: var(--muted)
}

table.matrix-tight .bold {
    font-weight: 600
}

table.matrix-tight .strong-top {
    border-top: 2px solid var(--line)
}

table.matrix-tight .stack {
    line-height: 1.05
}

table.matrix-tight .stack .sub {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px
}

/* ==================== SCORE-CARD ==================== */
.score-card {
    max-width: 900px;
    margin: 0 auto;
}

/* Naslov timova */
.sc-title {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: center;
    margin-bottom: 4px;
}

.sc-team {
    font-size: 22px;
    font-weight: 800;
    text-align: center
}

/* Red igrača – kompaktni layout 5 kolona */
.sc-row.sc-row-compact {
    display: grid;
    grid-template-columns: 1fr 56px 72px 56px 1fr;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
}

.sc-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.sc-name.sc-left {
    text-align: left
}

.sc-name.sc-right {
    text-align: right
}

.sc-ukup,
.sc-sets {
    text-align: center;
    font-weight: 700
}

.sc-ukup.win {
    color: #1a7f37;
    font-weight: 800
}

/* Klik red (toggle) */
.sc-toggle {
    cursor: pointer
}

.sc-toggle.open {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, .04) inset
}

/* Footer */
.sc-footer {
    max-width: 900px;
    margin: 8px auto 0;
    display: grid;
    grid-template-columns: 220px auto 220px;
    justify-content: center;
    align-items: center;
    gap: 14px;
}

.sc-foot-left,
.sc-foot-right {
    text-align: center;
    font-weight: 700;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 10px;
}

.sc-foot-mid {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1
}

.sc-mid-sets {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 2px
}

.sc-mid-points {
    font-size: 28px;
    font-weight: 900
}

@media (max-width:900px) {
    .sc-footer {
        grid-template-columns: 150px auto 160px;
        gap: 10px
    }

    .sc-mid-points {
        font-size: 24px
    }
}

/* -------- Detalji po setovima (INLINE, ispod reda) -------- */
.sc-item {
    display: flex;
    flex-direction: column;
    gap: 6px
}

/* kutija detalja – CENTRIRANO i poravnato s karticom */
.sc-details {
    /* ključ: ne 100% od ekrana, nego centrirano unutar kartice */
    width: auto;
    /* ne razvlači se nepotrebno */
    max-width: 900px;
    /* ista širina kao kartica */
    margin: -6px auto 10px;
    /* auto = centar; -6px nalegne na red */
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 16px;
    box-sizing: border-box;
}

/* grid redova detalja (desktop) */
.sc-det-row {
    display: grid;
    grid-template-columns:
        56px 64px 56px 64px 48px 8px 48px 64px 56px 64px 56px;
    align-items: center;
    gap: 3px;
    padding: 6px 0;
    border-bottom: 1px dashed #eee;
}

.sc-det-row:last-child {
    border-bottom: 0
}

.sc-det-head {
    display: none
}

.sc-det-sum {
    font-weight: 700
}

.sc-det-col.mini {
    text-align: center;
    font-variant-numeric: tabular-nums
}

.sc-det-sep {
    width: 8px;
    height: 1px;
    background: transparent
}

/* responsive */
/* <=900px: sve kolone postoje, samo uže širine */
@media (max-width:900px) {
    .sc-det-row {
        grid-template-columns:
            28px 32px 28px 32px 24px 6px 24px 32px 28px 32px 28px;
        gap: 2px;
        justify-content: center;
    }
}

/* <=410px: MAKNi PR (lijevi i desni) */
@media (max-width:410px) {

    .sc-det-col.l-pr,
    .sc-det-col.r-pr {
        display: none;
    }

    .sc-det-row {
        /* L:  Pune  Čišć. Ukup  Set | sep | R: Set  Ukup  Čišć. Pune */
        grid-template-columns:
            32px 28px 32px 24px 6px 24px 32px 28px 32px;
        gap: 2px;
        justify-content: center;
    }
}

/* <=350px: dodatno MAKNi SET (lijevi i desni) */
@media (max-width:350px) {

    .sc-det-col.l-set,
    .sc-det-col.r-set {
        display: none;
    }

    .sc-det-row {
        /* L:  Pune  Čišć. Ukup | sep | R: Ukup  Čišć. Pune */
        grid-template-columns:
            32px 28px 32px 6px 32px 28px 32px;
        gap: 2px;
        justify-content: center;
    }
}


/* Centrira fiksne kolone unutar .sc-details */
.sc-det-row {
    justify-content: center;
    /* ključ */
}


/* 1) Globalno suzi karticu (isti width za sve sekcije) */
:root {
    --card-w: 760px;
    /* promijeni po želji (npr. 720–800) */
    --col-score: 48px;
    /* širina UKUP lijevo/desno */
    --set-min: 36px;
    /* min širina centra "L : R" */
    --row-gap: 6px;
    --row-pad: 10px;
}

.score-card,
.score-card .sc-title,
.score-card .sc-row,
.score-card .sc-details,
.score-card .sc-footer {
    max-width: var(--card-w);
    margin-left: auto;
    margin-right: auto;
}

/* 2) Suženi glavni redovi (5 kolona) */
.sc-row.sc-row-compact {
    grid-template-columns:
        1fr minmax(var(--col-score), max-content)
        /* UKUP L */
        minmax(var(--set-min), max-content)
        /* SETS (L:R) – skuplja se na sadržaj */
        minmax(var(--col-score), max-content)
        /* UKUP R */
        1fr;
    gap: var(--row-gap);
    padding: var(--row-pad);
}

/* 3) Minimalni padding u srednjoj ćeliji SETS */
.sc-sets {
    padding: 0 2px;
}

/* 4) (ako treba) malo stisni i brojke UKUP */
.sc-ukup {
    padding: 0 2px;
}

/* 5) Detaljni redovi ostaju centrirani */
.sc-det-row {
    justify-content: center;
}

/* ===== FOOTER: fiksni centar, bočne kutije fleks ===== */
:root {
    --foot-mid-w: 110px;
    /* širina centra (SETS/POEN) */
    --foot-gap: 14px;
}

.sc-footer {
    max-width: 900px;
    margin: 8px auto 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--foot-mid-w) minmax(0, 1fr);
    gap: var(--foot-gap);
    align-items: center;
}

.sc-foot-left,
.sc-foot-right {
    min-width: 0;
    /* dozvoli skupljanje okvira */
}

/* centar ostaje točno u sredini i fiksne širine */
.sc-foot-mid {
    width: var(--foot-mid-w);
    justify-self: center;
    text-align: center;
    white-space: nowrap;
    line-height: 1.05;
}

/* responsive podešavanja po želji */
@media (max-width: 600px) {
    :root {
        --foot-mid-w: 96px;
    }
}


/* <420px: full-bleed, bez bočnih margina */
@media (max-width:420px) {

    /* makni sidebar i sav padding oko sadržaja */
    .sidebar {
        display: none;
    }

    /* ili dodaj .collapsed klasu JS-om */
    .content {
        padding: 0;
    }

    /* score-card i sekcije neka idu 100% širine, bez auto margina */
    .score-card,
    .score-card .sc-title,
    .score-card .sc-row,
    .score-card .sc-details,
    .score-card .sc-footer {
        max-width: 100%;
        margin: 0;
    }

    /* toolbar neka se lomi u novi red, da ne gura širinu */
    .toolbar {
        flex-wrap: wrap;
    }

    .actions {
        flex-wrap: wrap;
        row-gap: 6px;
    }

    /* malo stisni glavne redove da stanu ljepše */
    .sc-row.sc-row-compact {
        padding: 10px 8px;
        gap: 8px;
    }

    .sc-details {
        margin: 6px 0 10px;
    }
}

/* detaljni redovi ostaju centrirani */
.sc-det-row {
    justify-content: center;
}


/* <420px: glavni red stane u viewport (bez prelijevanja) */
@media (max-width:420px) {
    .sc-row.sc-row-compact {
        box-sizing: border-box;
        width: 100%;
        grid-template-columns:
            minmax(0, 1fr)
            /* ime L - može se skroz stisnuti */
            48px
            /* UKUP L */
            44px
            /* SETS (L:R) - usko */
            48px
            /* UKUP R */
            minmax(0, 1fr);
        /* ime R */
        gap: 6px;
        padding: 10px 8px;
    }

    /* dozvoli koloni s imenom da se smanji bez forsiranja širine */
    .sc-name {
        min-width: 0;
    }

    /* sigurnosno */
    .content {
        overflow-x: hidden;
    }
}