[hidden] { display: none !important; }
:root {
  --bg: #f4f6fa; --card: #fff; --ink: #1c2333; --muted: #6b7489; --line: #dde2ec;
  --accent: #1f6feb; --accent-soft: #e8f0fe; --win: #0f7b3f; --win-soft: #e6f6ec;
  --danger: #c62828; --warn: #b26a00; --warn-soft: #fff4e0; --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
.topbar { background: #14213d; padding: 12px 24px; }
.brand { color: #fff; font-weight: 700; font-size: 17px; }
main { max-width: 1280px; margin: 0 auto; padding: 24px; }
h1 { margin: 0 0 4px; font-size: 24px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.btn { border: 0; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.ghost.danger { background: transparent; color: var(--danger); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

form.stack { display: grid; gap: 10px; }
label.f { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
label.f small { font-weight: 400; color: var(--muted); }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; width: 100%; }
textarea { min-height: 120px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 110px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 13px; }
.check input { width: auto; }

.t-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.t-item { display: block; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.t-item:hover { border-color: var(--accent); }
.t-item b { font-size: 15px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.badge.setup { background: #eef0f4; color: var(--muted); }
.badge.drawn, .badge.knockout { background: var(--warn-soft); color: var(--warn); }
.badge.finished { background: var(--win-soft); color: var(--win); }
.seed { display: inline-block; min-width: 20px; text-align: center; font-size: 10px; font-weight: 700; padding: 1px 4px; border-radius: 4px; background: #14213d; color: #fff; margin-right: 4px; }
.tag { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 4px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); margin-right: 4px; }
.region { color: var(--muted); font-size: 11px; }

.head { display: flex; justify-content: space-between; align-items: start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--accent); border-color: var(--accent); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: center; width: 42px; }
tr.q td { background: var(--win-soft); }
td input { padding: 4px 6px; }

.pools { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 18px; }
.mlist { display: grid; gap: 6px; margin-top: 12px; }
.mrow { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #fff; }
.mrow:hover { border-color: var(--accent); }
.mrow .l { text-align: right; }
.mrow .sc { font-weight: 700; min-width: 54px; text-align: center; background: #f0f2f6; border-radius: 6px; padding: 2px 6px; }
.mrow .w { font-weight: 700; color: var(--win); }
.round-title { font-size: 12px; font-weight: 700; color: var(--muted); margin: 14px 0 4px; text-transform: uppercase; letter-spacing: .04em; }

/* ---- Bagan ---- */
.bracket-wrap { overflow-x: auto; padding-bottom: 8px; }
.bracket { display: flex; min-width: max-content; }
.round { display: flex; flex-direction: column; width: 230px; }
.round h4 { text-align: center; margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.round .slots { flex: 1; display: flex; flex-direction: column; }
.slot { flex: 1; display: flex; align-items: center; position: relative; padding: 6px 18px; min-height: 76px; }
.round:not(:last-child) .slot::after { content: ''; position: absolute; right: 0; top: 50%; width: 18px; border-top: 2px solid #b7c0d1; }
.round:not(:last-child) .slot:nth-child(odd)::before { content: ''; position: absolute; right: 0; top: 50%; height: 50%; border-right: 2px solid #b7c0d1; }
.round:not(:last-child) .slot:nth-child(even)::before { content: ''; position: absolute; right: 0; top: 0; height: 50%; border-right: 2px solid #b7c0d1; }
.round:not(:first-child) .slot > .match::before { content: ''; position: absolute; left: -18px; top: 50%; width: 18px; border-top: 2px solid #b7c0d1; }
.match { position: relative; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.match.click { cursor: pointer; }
.match.click:hover { border-color: var(--accent); }
.match.clash { border-color: var(--danger); }
.match .p { display: flex; align-items: center; gap: 4px; padding: 5px 8px; min-height: 30px; }
.match .p + .p { border-top: 1px solid var(--line); }
.match .p .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match .p .s { font-weight: 700; min-width: 18px; text-align: right; }
.match .p.win { background: var(--win-soft); font-weight: 700; }
.match .p.lose { color: var(--muted); }
.match .p.bye { color: #aab; font-style: italic; }
.match .mno { position: absolute; top: -1px; right: 4px; font-size: 9px; color: #aab; }
.champion { display: flex; flex-direction: column; justify-content: center; padding-left: 18px; }
.champion .box { border: 2px solid #e0b100; background: #fffbea; border-radius: 10px; padding: 12px 16px; text-align: center; min-width: 180px; }
.champion .box b { font-size: 16px; display: block; }
.third { margin-top: 20px; max-width: 260px; }

.empty { text-align: center; padding: 40px; color: var(--muted); }
.note { background: var(--warn-soft); color: #6b4300; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.info { background: var(--accent-soft); color: #173f7a; border-radius: 8px; padding: 10px 12px; font-size: 13px; }

dialog { border: 0; border-radius: 12px; padding: 22px; width: min(420px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,33,61,.45); }
dialog h3 { margin: 0 0 14px; }
.score-grid { display: grid; grid-template-columns: 1fr 90px; gap: 10px; align-items: center; }
.score-grid label { font-weight: 600; }
.tie { margin-top: 14px; background: var(--warn-soft); padding: 10px; border-radius: 8px; }
.tie p { margin: 0 0 6px; font-size: 13px; }
.tie label { display: flex; gap: 8px; align-items: center; }
.tie input { width: auto; }
.actions { display: flex; gap: 8px; margin-top: 18px; }
.spacer { flex: 1; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #14213d; color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.err { background: var(--danger); }

.print-only { display: none; }
@media print {
  .print-only { display: block; }
  .no-print, .tabs, .toolbar, .topbar { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
  .bracket-wrap { overflow: visible; }
}

/* ---- Undian langsung ---- */
.badge.ceremony { background: #fde68a; color: #7a4a00; }
.cer { background: radial-gradient(circle at top, #1e3a8a, #07111f 50%, #020617); color: #f8fafc; border-radius: 18px; padding: 18px; }
.cer:fullscreen { overflow: auto; border-radius: 0; }
.cer-head { text-align: center; margin-bottom: 14px; }
.cer-head h1 { margin: 0; font-size: clamp(22px, 3vw, 38px); text-transform: uppercase; letter-spacing: .02em; }
.cer-head div { color: #cbd5e1; margin-top: 4px; }
.cer-grid { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .cer-grid { grid-template-columns: 1fr; } }
.c-card { background: rgba(17,24,39,.88); border: 1px solid rgba(255,255,255,.12); border-radius: 16px; padding: 12px; }
.c-card h3 { margin: 0 0 8px; color: #e0f2fe; }
.c-note { font-size: 12px; color: #cbd5e1; margin-bottom: 8px; }
.c-list { display: grid; gap: 6px; max-height: 62vh; overflow: auto; }
.c-item { display: grid; grid-template-columns: 28px 1fr 56px; gap: 7px; align-items: center; background: rgba(30,41,59,.8); border: 1px solid rgba(255,255,255,.08); border-radius: 9px; padding: 7px; font-size: 13px; }
.c-item small, .c-slot small { color: #94a3b8; font-size: 11px; }
.c-item .num { color: #facc15; font-weight: 900; }
.c-item .code { text-align: center; color: #bbf7d0; font-weight: 900; font-size: 15px; }
.c-item.done { background: rgba(34,197,94,.14); }
.c-item.pick { cursor: pointer; }
.c-item.pick:hover { border-color: rgba(250,204,21,.6); }
.c-item.active { outline: 2px solid #facc15; }
.c-result { text-align: center; background: linear-gradient(180deg, rgba(30,41,59,.96), rgba(15,23,42,.96)); border: 1px solid rgba(255,255,255,.12); border-radius: 16px; padding: 12px; }
.c-lbl { color: #cbd5e1; font-size: 13px; }
.c-name { min-height: 56px; display: flex; align-items: center; justify-content: center; font-size: clamp(18px, 2vw, 26px); font-weight: 800; }
.c-code { min-height: 90px; display: flex; align-items: center; justify-content: center; font-size: clamp(52px, 6.5vw, 92px); font-weight: 900; color: #facc15; text-shadow: 0 4px 22px rgba(250,204,21,.45); }
.c-msg { min-height: 26px; font-size: 18px; font-weight: 800; color: #fef3c7; }
.c-count { color: #cbd5e1; font-size: 14px; }
.c-balls { min-height: 140px; display: grid; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); gap: 10px; place-items: center; margin: 12px 0; }
.c-ball { width: 58px; height: 58px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 900; color: #111827; font-size: 15px;
  background: radial-gradient(circle at 30% 25%, #fff, #fff7ad 18%, #facc15 45%, #b45309); border: 3px solid #fff; box-shadow: inset -9px -11px 18px rgba(0,0,0,.25), 0 8px 18px rgba(0,0,0,.35); }
.c-ball.used { opacity: .12; filter: grayscale(1); transform: scale(.72); }
.c-ball.spin { animation: cbounce .18s infinite alternate, cspin .5s linear infinite; }
@keyframes cbounce { to { transform: translateY(-13px) scale(1.05); } }
@keyframes cspin { to { rotate: 360deg; } }
.c-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.c-btns button, .c-b { border: 0; border-radius: 10px; padding: 9px 10px; font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; color: #fff; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); text-align: center; }
.c-btns button:disabled { opacity: .45; cursor: not-allowed; }
.c-draw { grid-column: span 2; background: linear-gradient(135deg, #22c55e, #16a34a) !important; font-size: 22px !important; padding: 16px !important; }
.c-b.green { background: linear-gradient(135deg, #06b6d4, #0369a1); }
.c-b.red { background: linear-gradient(135deg, #ef4444, #b91c1c); grid-column: span 2; }
.c-secs { display: flex; align-items: center; justify-content: center; gap: 6px; }
.c-secs input { width: 56px; padding: 3px 5px; background: #0b1220; color: #fff; border: 1px solid rgba(255,255,255,.25); }
.c-right { max-height: 70vh; overflow: auto; display: grid; gap: 8px; }
.c-pool { border: 1px solid rgba(255,255,255,.16); border-radius: 12px; overflow: hidden; background: rgba(2,6,23,.35); }
.c-pt { background: rgba(56,189,248,.25); font-weight: 900; text-align: center; padding: 7px; color: #e0f2fe; }
.c-slot { display: grid; grid-template-columns: 52px 1fr; border-top: 1px solid rgba(255,255,255,.08); min-height: 36px; align-items: center; }
.c-slot b { text-align: center; color: #facc15; }
.c-slot span { padding: 6px 8px; font-size: 13px; }
.c-slot .empty { color: #64748b; font-style: italic; }
.c-slot.flash { background: rgba(250,204,21,.22); }
.c-match { border-top: 2px solid rgba(255,255,255,.18); }
.c-mno { font-size: 11px; color: #94a3b8; padding: 3px 8px 0; }

/* ---- Urutkan & filter ---- */
.fltbar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 10px; }
.flt { display: grid; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); }
.flt select { min-width: 190px; }
tr.grp td { background: #eef3fb; font-weight: 700; color: #173f7a; font-size: 12px; padding: 5px 8px; }
.c-flt { margin-bottom: 8px; }
.c-flt .flt { color: #cbd5e1; }
.c-flt select { width: 100%; background: #0b1220; color: #fff; border: 1px solid rgba(255,255,255,.25); }
@media print { .fltbar, .c-flt { display: none !important; } }

.c-banner { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; text-align: center; background: rgba(250,204,21,.15); border: 1px solid rgba(250,204,21,.5); border-radius: 14px; padding: 12px; margin-bottom: 14px; font-weight: 800; font-size: 16px; }
.c-banner.done { background: rgba(34,197,94,.15); border-color: rgba(34,197,94,.5); }
.c-banner .c-draw { grid-column: auto; border: 0; border-radius: 10px; color: #fff; cursor: pointer; font-size: 17px !important; padding: 10px 18px !important; }

/* ---- Daftar pemain ---- */
.plink { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); }
.plink:hover { background: #d6e4fd; }
table.roster td input, table.roster td select { padding: 4px 6px; }
@media print {
  table.roster input, table.roster select { display: none; }
  .grid2 { display: block; }
}
table.roster td:nth-child(2) input { min-width: 170px; }
.roster-wrap { overflow-x: auto; }

/* ---- Kartu turnamen & dialog edit ---- */
.t-item { cursor: pointer; }
.t-act { display: flex; gap: 6px; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
dialog.wide { width: min(620px, 94vw); }
dialog .row > * { min-width: 120px; }
#toast { z-index: 1000; }

/* Nama tim di judul kartu halaman tim */
.tname{display:inline-block;background:#e0ecff;color:#1d4ed8;border-radius:6px;padding:1px 8px;font-weight:700}
.tname.sport{background:#f1f5f9;color:#475569;font-weight:600;font-size:.85em}
@media print{.tname{background:none;padding:0;color:#000}}

/* ---------- Beregu (partai) ---------- */
dialog.xwide { width: min(860px, 96vw); max-height: 92vh; }
.rb-score { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; font-size: 17px; font-weight: 700; }
.rb-score span:first-child { text-align: right; }
.rb-score b { font-size: 26px; background: #14213d; color: #fff; border-radius: 10px; padding: 4px 16px; }
.rb { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
.rb.won1 { border-left: 5px solid var(--win); }
.rb.won2 { border-right: 5px solid var(--win); }
.rb-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.rb-st { font-size: 12px; color: var(--muted, #6b7280); }
.rb-st.done { color: var(--win); font-weight: 700; }
.rb-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: start; }
.rb-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rb-side select { width: 100%; }
.rb-team { font-size: 12px; font-weight: 700; color: #1d4ed8; }
.rb-sets { display: flex; flex-direction: column; gap: 5px; align-items: center; }
.rb-set { display: flex; gap: 5px; align-items: center; font-size: 12px; }
.rb-set span { width: 36px; color: #6b7280; }
.rb-set input { width: 54px; text-align: center; padding: 4px; }
.rb-wo { font-size: 11px; color: #6b7280; display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.rb-wo select { font-size: 12px; padding: 3px; }
.rline { grid-column: 1 / -1; font-size: 11.5px; color: #6b7280; text-align: center; }
.rline .rw1, .rline .rw2 { color: #374151; }
@media (max-width: 640px) { .rb-grid { grid-template-columns: 1fr; } .rb-sets { align-items: flex-start; } }

/* Partai: editor susunan & validasi set */
.rf-box { border: 1px dashed var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.rf-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rf-top select { max-width: 60%; font-size: 12px; }
.rf-row { display: grid; grid-template-columns: 30px 1fr 150px 36px; gap: 6px; align-items: center; }
.rf-no { font-weight: 700; color: #1d4ed8; font-size: 12px; }
.rb-set.bad input { border-color: #dc2626; background: #fef2f2; }
.rb-err { font-size: 10.5px; color: #dc2626; font-style: normal; min-width: 0; white-space: nowrap; }
.rb-set em:empty { display: none; }

/* ===== Login & pengguna ===== */
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar .spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.userbox .uname { color: #dfe6f5; font-size: 13px; }
.userbox .uname small { background: rgba(255,255,255,.15); padding: 1px 6px; border-radius: 999px; margin-left: 4px; }
.btn.ghost.light { color: #fff; border-color: rgba(255,255,255,.35); }
.btn.ghost.light:hover { background: rgba(255,255,255,.1); }
body.login-mode .topbar { display: none; }
body.login-mode { background: linear-gradient(135deg, #0f2a1d 0%, #14532d 45%, #1f6feb 140%); min-height: 100vh; }
body.login-mode main#app { max-width: none; padding: 0; }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; gap: 40px; align-items: center; max-width: 1080px; margin: 0 auto; padding: 32px 24px; box-sizing: border-box; }
.lg-hero { color: #fff; }
.lg-badge { width: 64px; height: 64px; border-radius: 18px; background: rgba(255,255,255,.14); display: grid; place-items: center; font-size: 34px; margin-bottom: 14px; }
.lg-hero h1 { font-size: 44px; line-height: 1.05; margin: 0 0 6px; letter-spacing: -.5px; }
.lg-org { margin: 0 0 18px; color: #bfe3cc; font-weight: 600; font-size: 15px; }
.lg-lead { font-size: 16px; line-height: 1.6; color: #e6efe9; margin: 0 0 20px; max-width: 520px; }
.lg-feat { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lg-feat li { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: 12px; padding: 12px 14px; }
.lg-feat b { display: block; margin-bottom: 3px; }
.lg-feat span { color: #d3e4da; font-size: 13px; }
.lg-card { background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.lg-card h2 { margin: 0 0 4px; font-size: 22px; }
.lg-card .muted { margin: 0 0 18px; }
.lg-btn { padding: 11px; font-size: 15px; background: #15803d; }
.lg-err { background: #fdecea; color: var(--danger); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
@media (max-width: 820px) {
  .login-wrap { grid-template-columns: 1fr; gap: 24px; }
  .lg-hero h1 { font-size: 34px; }
  .lg-feat { grid-template-columns: 1fr; }
}
dialog.wide { width: min(760px, 94vw); }

/* ===== Accordion daftar pemain ===== */
.acc-btn { border: 0; background: none; font: inherit; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px; border-radius: 6px; }
.acc-btn:hover { background: var(--accent-soft); color: var(--accent); }
.acc-btn .chev { display: inline-block; transition: transform .15s; color: var(--accent); font-size: 11px; }
tr.acc-head.open .chev { transform: rotate(90deg); }
tr.acc-head.open td { background: #f7f9fd; border-bottom-color: transparent; }
tr.acc-row td { background: #f7f9fd; padding-top: 0; }
.acc-body { padding: 4px 0 8px; }
.acc-list { margin: 0; padding-left: 22px; columns: 2; column-gap: 28px; }
.acc-list li { break-inside: avoid; padding: 2px 0; }
.acc-name { font-weight: 600; }
.role-tag { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: #eef0f4; color: var(--muted); }
.role-tag.r-Kapten { background: var(--warn-soft); color: var(--warn); }
.role-tag.r-Pelatih, .role-tag.r-Manajer, .role-tag.r-Official { background: var(--accent-soft); color: var(--accent); }
.acc-foot { margin-top: 6px; font-size: 12px; }
.fltbar .spacer { flex: 1; }
@media (max-width: 700px) { .acc-list { columns: 1; } }
