:root {
    --bg: #ffffff;
    --muted: #6b7280;
    --accent: #0ea5a4;
    --danger: #ef4444;
    --card: #fbfdff;
    --glass: rgba(15, 23, 42, 0.04);
    --radius: 12px;
    --shadow: 0 8px 30px rgba(2, 6, 23, 0.04);
    font-family: Inter, system-ui, Arial, sans-serif;
    color-scheme: light;
}

/* reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

html,
body {
    height: 100%
}

body {
    background: linear-gradient(180deg, #fbfcff, #fff);
    color: #071026;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale
}

/* layout */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh
}

.head {
    padding: 18px 22px;
    border-bottom: 1px solid rgba(7, 16, 38, 0.04);
    display: flex;
    flex-direction: column;
    gap: 12px
}

.head h1 {
    font-size: 20px;
    font-weight: 700;
    color: #071026
}

/* filters */
.filters {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap
}

.search {
    flex: 1;
    min-width: 280px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(7, 16, 38, 0.06);
    background: var(--card)
}

select {
    padding: 8px 10px;
    border-radius: 9px;
    border: 1px solid rgba(7, 16, 38, 0.06);
    background: #fff
}

.btn,
button {
    cursor: pointer;
    border-radius: 9px;
    padding: 8px 10px;
    border: 1px solid rgba(7, 16, 38, 0.06);
    background: #fff
}

.btn-danger {
    border-color: transparent;
    background: var(--danger);
    color: #fff
}

.btn-primary {
    border-color: transparent;
    background: var(--accent);
    color: #fff
}

.mini {
    padding: 8px;
    border-radius: 8px
}

/* chips */
.chips-inline {
    display: flex;
    gap: 8px;
    align-items: center
}

.chip {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(7, 16, 38, 0.06);
    background: rgba(255, 255, 255, 0.85);
    font-size: 13px
}

.chip.on {
    background: var(--accent);
    color: #fff;
    border-color: transparent
}

/* main / card */
main {
    padding: 18px;
    flex: 1
}

.card {
    background: linear-gradient(180deg, #fff, #fbfdff);
    border-radius: 14px;
    padding: 12px;
    box-shadow: var(--shadow)
}

/* table */
.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px
}

.results-table th,
.results-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(7, 16, 38, 0.03);
    vertical-align: middle;
    text-align: left
}

.results-table th {
    position: sticky;
    top: 0;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    text-align: center
}

.results-table tbody tr {
    transition: background .12s ease, transform .06s ease
}

.results-table tbody tr:hover {
    background: var(--glass);
    transform: translateY(-2px)
}

.name {
    font-weight: 700
}

.team {
    color: var(--muted);
    font-size: 13px
}

.team-inline {
    display: none;
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px
}

.small {
    width: 96px
}

.num {
    text-align: right
}

.highlight {
    font-weight: 800;
    color: #071026
}

.empty {
    text-align: center;
    padding: 20px;
    color: var(--muted)
}

/* badges */
.phase-badge {
    display: inline-block;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid #6b7280;
    background: #f8fafc;
    color: #374151;
    line-height: 1
}

.phase-f {
    border: 1px solid #ef4444;
    background: #ef4444;
    color: #fff
}

.cat-small {
    display: inline-block;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 12px;
    border: 2px solid transparent;
    line-height: 1
}

.cat-small.c-m {
    border-color: #2b6cb0;
    color: #1e3a8a;
    background: rgba(43, 108, 176, 0.08)
}

.cat-small.c-f {
    border-color: #dc2626;
    color: #7f1d1d;
    background: rgba(220, 38, 38, 0.08)
}

.cat-small.c-r {
    border-color: #059669;
    color: #065f46;
    background: rgba(5, 150, 105, 0.08)
}

/* Tooltip */
.has-tip {
    position: relative
}

.has-tip::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    top: 100%;
    background: #0f172a;
    color: #fff;
    font-size: 12px;
    line-height: 1;
    padding: 6px 8px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .12s ease, transform .12s ease;
    box-shadow: 0 6px 18px rgba(2, 6, 23, .18);
    z-index: 50;
}

.has-tip:hover::after,
.has-tip.tip-show::after {
    opacity: 1;
    transform: translateX(-50%) translateY(2px)
}

/* mobile FAB */
.mob-fab {
    display: none
}

@media (max-width:920px) {
    .mob-fab {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        position: fixed;
        right: 14px;
        bottom: 14px;
        z-index: 90;
        padding: 10px 14px;
        border-radius: 999px;
        border: 1px solid rgba(7, 16, 38, 0.08);
        background: var(--accent);
        color: #fff;
        border-color: transparent;
        box-shadow: 0 8px 24px rgba(2, 6, 23, 0.12)
    }
}

/* pager */
.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px
}

.pager-controls {
    display: flex;
    gap: 8px;
    align-items: center
}

/* drawer */
.drawer {
    position: fixed;
    top: 0;
    right: -360px;
    width: 320px;
    height: 100vh;
    background: #fff;
    box-shadow: -8px 0 28px rgba(2, 6, 23, 0.14);
    transition: right .18s ease;
    z-index: 85;
    padding: 14px 14px 64px;
    overflow: auto
}

.drawer.open {
    right: 0
}

.drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px
}

.drawer-head .x {
    border: 1px solid rgba(7, 16, 38, 0.08);
    background: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer
}

.drawer .fgroup {
    margin-bottom: 12px
}

.drawer .chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px
}

.drawer .frow {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap
}

/* footer gumbi za drawer */
.drawer-footer {
    display: none;
    position: fixed;
    right: 14px;
    bottom: 14px;
    gap: 8px;
    z-index: 86;
}



@media (max-width:920px) {
    .drawer.open .drawer-footer {
        display: flex;
    }

    /* vidi se samo kad je kliknut Filteri */
}



.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0);
    transition: background .18s ease;
    pointer-events: none;
    z-index: 84
}

.drawer-backdrop.show {
    background: rgba(15, 23, 42, 0.28);
    pointer-events: auto
}

/* desktop vs mobile table adjustments */
.th-mobile-scores {
    display: none
}

.td-mobile-scores {
    display: none
}

.col-pune,
.col-cisc,
.col-uk {
    display: table-cell
}

.thead-mobile {
    display: none
}

.thead-desktop {
    display: table-row
}

/* DESKTOP centriranje faza/pune/čišćenje/ukupno; ime lijevo */
@media (min-width:921px) {

    .results-table thead th.th-phase,
    .results-table thead th.th-prazne,
    .results-table thead th.th-pune,
    .results-table thead th.th-cisc,
    .results-table thead th.th-uk {
        text-align: center !important; vertical-align: middle;
    }

    .results-table tbody td.phase-cat {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .results-table tbody td.col-prazni,
    .results-table tbody td.col-pune,
    .results-table tbody td.col-cisc,
    .results-table tbody td.col-uk {
        text-align: center !important;
        vertical-align: middle;
    }

    .results-table tbody td:first-child {
        text-align: left !important;
    }
}

/* MOBILE rules */
@media (max-width:920px) {

    .filters {
        display: none
    }

    .head {
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 40
    }

    .card {
        padding: 10px
    }

    .results-table th,
    .results-table td {
        padding: 10px
    }

    .search {
        min-width: 140px
    }

    .desktop-team {
        display: none
    }

    .team-inline {
        display: block
    }

    .phase-cat {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 0;
        margin: 0
    }

    /* mobile scores & hide desktop pune/čišćenje */
    .th-mobile-scores {
        display: table-cell
    }

    .td-mobile-scores {
        display: table-cell !important;
        width: 84px;
        padding: 6px 8px;
        vertical-align: middle;
        text-align: center
    }

    .td-mobile-scores .m-score {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 6px;
        font-size: 13px;
        line-height: 1
    }

    .td-mobile-scores .m-score+.m-score {
        margin-top: 6px
    }

    .td-mobile-scores .m-label {
        color: var(--muted);
        font-size: 12px
    }

    .td-mobile-scores .m-val {
        font-weight: 700
    }

    .th-pune,
    .th-cisc,
    .col-pune,
    .col-cisc {
        display: none
    }

    .col-uk {
        display: table-cell !important;
        width: 84px;
        text-align: center;
        font-weight: 800
    }

    .results-table th,
    .results-table td {
        padding: 10px 8px
    }

    .results-table {
        font-size: 15px
    }

    /* header: mobile row on, desktop off */
    .thead-desktop {
        display: none !important
    }

    .thead-mobile {
        display: table-row !important
    }

    .thead-mobile th {
        display: table-cell !important;
        font-weight: 600;
        color: var(--muted);
        text-align: center
    }

    /* poravnanje: Natjecatelj lijevo, ostalo centar */
    .results-table tbody td:first-child {
        text-align: left !important;
    }

    .results-table tbody td:not(:first-child) {
        text-align: center !important;
    }

    .results-table tbody td:first-child .name,
    .results-table tbody td:first-child .team-inline {
        text-align: left !important;
    }
}

/* focus */
button:focus,
select:focus,
input:focus {
    outline: 3px solid rgba(14, 165, 164, 0.12);
    outline-offset: 2px
}

/* polish */
.results-table td .name {
    display: block
}

.results-table td .team {
    display: block;
    color: var(--muted)
}

/* sortable header */
.sortable {
    cursor: pointer;
    user-select: none;
}

.sort-ind {
    margin-left: 6px;
    font-size: 12px;
    color: var(--muted);
}

/* row details modal */
.row-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.36);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 350;
}

.row-modal {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    width: min(520px, 95%);
    max-height: calc(100vh - 80px);
    overflow: auto;
    box-shadow: 0 18px 46px rgba(2, 6, 23, 0.18);
    position: relative;
}

.row-modal-close {
    position: absolute;
    right: 10px;
    top: 8px;
    border: none;
    background: #fff;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.row-modal-body {
    display: block;
    gap: 10px;
}

.rm-row {
    margin-bottom: 12px;
}

.rm-row strong {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 6px;
}

/* natjecatelj + klub lijevo, ostalo centar */
.results-table tbody td:first-child,
.results-table tbody td.desktop-team,
.results-table tbody td:first-child .team-inline {
    text-align: left !important;
}

.results-table tbody td:not(:first-child):not(.desktop-team) {
    text-align: center !important;
}

@media (max-width:920px) {
    .row-modal {
        width: 95%;
        margin: 0 10px;
        max-height: calc(100vh - 100px);
        border-radius: 10px;
    }
}

/* plasman (rank) column — minimalno mjesta */
.th-rank,
.td-rank {
    width: 40px;
    min-width: 40px;
    max-width: 56px;
    padding: 8px 6px;
    text-align: center;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}

.td-rank {
    color: #071026;
    font-weight: 700;
}

/* mobile: zadrži isto, ne povećava visinu */
@media (max-width:920px) {

    .th-rank,
    .td-rank {
        width: 40px;
        min-width: 40px;
        max-width: 48px;
        font-size: 14px;
    }
}

/* modal: malo odmaka za vrijednosti radi čitljivosti */
.row-modal-body .rm-row>div {
    margin-left: 12px;
}