* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: #0f1220;
    color: #e8eaf0;
    line-height: 1.5;
}
.wrap {
    max-width: 480px;
    margin: 40px auto;
    padding: 0 16px;
}
.wrap.wide { max-width: 1000px; }

h1 { margin: 0 0 4px; font-size: 1.6rem; }
h2 { margin: 0 0 2px; font-size: 1.2rem; }
.sub { color: #9aa0b5; margin-top: 0; }
.muted { color: #9aa0b5; font-size: .9rem; }
.green { color: #4ade80; }
.red { color: #f87171; }

.card {
    background: #191d2e;
    border: 1px solid #262b40;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 16px 0;
}
.card.row { flex-direction: row; align-items: center; }
.card.row input { flex: 1; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
input, select {
    padding: 11px 12px;
    border-radius: 8px;
    border: 1px solid #363c58;
    background: #0f1220;
    color: #e8eaf0;
    font-size: 1rem;
}
input:focus, select:focus { outline: 2px solid #6366f1; border-color: #6366f1; }

button {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    padding: 11px 16px;
    font-size: .95rem;
    font-weight: 600;
    background: #6366f1;
    color: #fff;
}
button:hover { background: #4f52e0; }

.btn-ghost { background: #262b40; color: #cfd3e6; text-decoration: none; display: inline-block; }
.btn-ghost:hover { background: #313753; }
.btn-danger { background: #7f1d1d; }
.btn-danger:hover { background: #991b1b; }
.btn-danger.sm { padding: 6px 10px; }

.chk { background: #262b40; color: #cfd3e6; }
.chk.on { background: #166534; color: #dcfce7; }

.alert { padding: 12px 14px; border-radius: 8px; margin: 12px 0; font-weight: 600; }
.alert.ok  { background: #14321f; color: #86efac; border: 1px solid #166534; }
.alert.bad { background: #331515; color: #fca5a5; border: 1px solid #7f1d1d; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Prekidač jezika */
.langsw { display: inline-flex; gap: 2px; background: #191d2e; border: 1px solid #262b40; border-radius: 8px; padding: 3px; }
.langlink { padding: 4px 9px; border-radius: 6px; text-decoration: none; color: #9aa0b5; font-size: .8rem; font-weight: 700; }
.langlink:hover { background: #262b40; color: #cfd3e6; }
.langlink.active { background: #6366f1; color: #fff; }

.tournament {
    background: #191d2e;
    border: 1px solid #262b40;
    border-radius: 12px;
    padding: 18px;
    margin: 16px 0;
}
.t-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.t-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.t-actions form { margin: 0; }

table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #262b40; font-size: .92rem; }
th { color: #9aa0b5; font-weight: 600; }
tr.paid { background: #10231a; }
td form { margin: 0; }

/* Kreiranje turnira */
.create-form .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

/* Badge kategorije / formata */
.badge { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; vertical-align: middle; margin-left: 6px; }
.badge.blue { background: #1e3a8a; color: #dbeafe; }
.badge.pink { background: #831843; color: #fce7f3; }
.badge.gray { background: #334155; color: #e2e8f0; }

/* Details/summary za listu timova */
details { margin-top: 14px; }
summary { cursor: pointer; font-weight: 600; color: #cfd3e6; padding: 6px 0; }

/* Grupe / poule */
.group-title { margin: 22px 0 6px; border-bottom: 2px solid #363c58; padding-bottom: 4px; }
.poule { background: #191d2e; border: 1px solid #262b40; border-radius: 12px; padding: 16px; margin: 14px 0; }
.poule h3 { margin: 0 0 10px; }
.poule-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 820px) { .poule-grid { grid-template-columns: 1fr; } }

.standings th, .standings td { padding: 6px 8px; font-size: .9rem; }
.standings tr.qual { background: #10231a; }
tr.me { outline: 2px solid #6366f1; }
tr.me td { background: #1a1f3a; }
.qbadge { background: #166534; color: #dcfce7; font-weight: 700; font-size: .72rem; padding: 1px 7px; border-radius: 999px; }

.matches th, .matches td { padding: 5px 8px; font-size: .88rem; }
.matches td.sc, .matches th.sc { text-align: center; white-space: nowrap; }
.matches input { width: 46px; padding: 5px; text-align: center; }

.save-bar { position: sticky; bottom: 0; background: #0f1220; padding: 14px 0; margin-top: 10px; border-top: 1px solid #262b40; text-align: right; }

/* Bracket */
.bracket-section { margin: 20px 0 30px; }
.bracket-scroll { overflow-x: auto; padding-bottom: 8px; }
.bracket { display: flex; gap: 26px; min-width: min-content; align-items: stretch; }
.bround { display: flex; flex-direction: column; min-width: 160px; }
.bround-title { height: 18px; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #9aa0b5; text-align: center; margin-bottom: 10px; }
.bmatches { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: space-around; }
.bmatch { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; background: #191d2e; border: 1px solid #262b40; border-radius: 8px; padding: 4px; }
.bteamform { margin: 0; }
.bteam { display: block; width: 100%; text-align: left; padding: 7px 9px; font-size: .85rem; border-radius: 5px;
         background: #0f1220; color: #e8eaf0; border: 1px solid transparent; cursor: pointer; }
button.bteam:hover { border-color: #6366f1; background: #1a1f36; }
.bteam.won { background: #166534; color: #dcfce7; font-weight: 700; }
.bteam.lost { color: #6b7280; text-decoration: line-through; cursor: pointer; }
.bteam.bye { color: #6b7280; font-style: italic; cursor: default; }
.bteam.tbd { color: #4b5163; cursor: default; }

.third-match { margin: 16px 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.third-match .bteamform { display: inline-block; }
.third-match .bteam { display: inline-block; width: auto; min-width: 120px; }

.placements td { padding: 7px 10px; }
.placements .pl-place { font-weight: 700; white-space: nowrap; color: #a5b4fc; }

@media print {
    body { background: #fff; color: #000; }
    .noprint, .topbar .t-actions, .langsw, .save-bar { display: none !important; }
    .wrap, .wrap.wide { max-width: none; margin: 0; }
    .bteam { color: #000; background: #fff; }
    .bteam.won { background: #d1fae5; color: #000; }
    .bmatch, .poule, .tournament { border-color: #999; }

    /* Svaka grupa (poule) na zasebnom papiru */
    .poule {
        break-before: page;
        page-break-before: always;
        break-inside: avoid;
        background: #fff;
        color: #000;
        border: 1px solid #999;
    }
    .poule:first-of-type { break-before: auto; page-break-before: avoid; }
    .poule h3, .standings th, .standings td, .matches th, .matches td { color: #000; }
    .standings tr.qual { background: #e7f6ec; }
    .matches input { border: 1px solid #666; color: #000; }
    .group-title { break-before: page; page-break-before: always; }
    .group-title:first-of-type { break-before: auto; page-break-before: avoid; }
}

.draw-box { margin-top: 18px; padding-top: 14px; border-top: 1px dashed #363c58; }
.auto-line { background: #1a1f36; border: 1px solid #313a63; border-radius: 8px; padding: 8px 12px; display: inline-block; }
.settings-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.settings-row label { flex-direction: row; align-items: center; gap: 6px; font-size: .85rem; }
.settings-row input { width: 64px; }
.draw-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.draw-head h3 { margin: 0; font-size: 1.05rem; }
.draw-head form { margin: 0; }
.draw-table td.drawnum { text-align: center; font-weight: 700; color: #a5b4fc; width: 44px; }
.draw-table { margin-top: 10px; }

.foot { margin-top: 24px; text-align: center; }
.foot a, a { color: #a5b4fc; }
