/* ==========================================================================
   Penilaian Lomba — tanpa dependensi eksternal (aman dipakai offline / jaringan lokal)
   ========================================================================== */
:root {
  --brand: #0f766e;
  --brand-ink: #fff;
  --gold: #c99a2e;
  --bg: #f4f2ec;
  --card: #ffffff;
  --ink: #1d2a27;
  --muted: #66736f;
  --line: #e1ddd2;
  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: var(--brand); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: .95rem; margin-top: 1.25rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
p { margin: 0 0 .75rem; }
code { background: #efece3; padding: .1em .35em; border-radius: 5px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.spacer { flex: 1; }

/* ---------- top bar & nav ---------- */
.topbar { background: var(--brand); color: var(--brand-ink); position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.topbar-in { max-width: 1200px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; min-width: 0; }
.brand-logo { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { opacity: .8; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.user-name { font-size: .9rem; opacity: .95; max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; gap: .25rem; overflow-x: auto; padding: 0 1rem .5rem; max-width: 1200px; margin: 0 auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: rgba(255,255,255,.85); text-decoration: none; padding: .45rem .8rem; border-radius: 999px; white-space: nowrap; font-size: .92rem; }
.nav a:hover { background: rgba(255,255,255,.14); }
.nav a.active { background: #fff; color: var(--brand); font-weight: 600; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }
.page-head { margin-bottom: 1rem; }
.page-head p { color: var(--muted); margin: 0; }
.crumb { margin-bottom: .25rem !important; font-size: .9rem; }

/* ---------- cards, forms ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 460px; }
.card-pad { padding: 1rem 1.25rem 0; }
.card-title { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.empty-card { text-align: center; padding: 2rem 1rem; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: .9rem; margin-bottom: .9rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .9rem; }
.grid2.top { align-items: start; }

label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 600; color: #3a4844; }
.label { font-size: .88rem; font-weight: 600; color: #3a4844; }
input, select, textarea, button { font: inherit; }
input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid #cfcabb; border-radius: 10px; background: #fff; color: var(--ink); font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); border-color: var(--brand); }
input[type=file] { font-weight: 400; font-size: .9rem; }
input[type=color].color { width: 64px; height: 42px; padding: 2px; border-radius: 10px; border: 1px solid #cfcabb; background: #fff; }
.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; color: var(--ink); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.checks { display: flex; flex-direction: column; gap: .4rem; margin-top: .4rem; }
.checks.row { flex-direction: row; flex-wrap: wrap; gap: .4rem 1.25rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.inline-form > label { flex: 1 1 180px; }
.inline-form > label.w-sm { flex: 0 1 110px; }
.inline-form > label.w-xs { flex: 0 1 90px; }
.inline-form > label.check { flex: 0 0 auto; padding-bottom: .55rem; }
.logo-prev { display: flex; align-items: center; gap: 1rem; margin-top: .5rem; }
.logo-prev img { height: 56px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: #fff; }
.filter { display: flex; gap: .5rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.filter select, .filter input { width: auto; flex: 1 1 160px; }

/* ---------- buttons, badges ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1rem; border-radius: 10px; border: 1px solid #cfcabb; background: #fff; color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: #f4f1e8; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--brand); }
.btn.danger { color: var(--err); border-color: #e8b4b4; background: #fff; }
.btn.danger:hover { background: #fdeeee; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.45); color: inherit; }
.topbar .btn.ghost:hover { background: rgba(255,255,255,.15); }
.btn.small { padding: .35rem .7rem; font-size: .85rem; border-radius: 8px; }
.btn.big { padding: .8rem 1.4rem; font-size: 1.05rem; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.disabled { opacity: .45; pointer-events: none; }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #ece9de; color: #5b6762; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }

.alert { padding: .8rem 1rem; border-radius: 12px; margin-bottom: 1rem; border: 1px solid; }
.alert ul { margin: .3rem 0 0 1.1rem; padding: 0; }
.alert.ok { background: #ecfdf3; border-color: #a7e3bd; color: #14532d; }
.alert.err { background: #fef2f2; border-color: #f2b8b8; color: #7f1d1d; }
.alert.warn { background: #fffbeb; border-color: #f0d58a; color: #78350f; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .75rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); font-size: .92rem; }
th { background: #f7f5ee; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
td input, td select { padding: .4rem .55rem; font-size: .9rem; min-width: 90px; }
td .check input { min-width: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th.w-sm, th.w-xs { width: 1%; }
.add-row td { background: #faf8f1; }
tr.hl td { background: #fffbea; }
.rekap td, .rekap th { padding: .6rem .8rem; }

/* ---------- rank medals ---------- */
.rk { display: inline-grid; place-items: center; min-width: 30px; height: 30px; border-radius: 50%; background: #ece9de; font-weight: 700; font-size: .85rem; color: #4a5753; }
.rk.top { color: #fff; }
.rk.top1 { background: #d4a017; }
.rk.top2 { background: #8a97a0; }
.rk.top3 { background: #b5703a; }
.rk.top:not(.top1):not(.top2):not(.top3) { background: var(--brand); }
.rk.none { background: transparent; color: #9aa5a1; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--brand) 30%, transparent), transparent), linear-gradient(160deg, #0b2b26, #11413a); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 2rem 1.75rem; box-shadow: 0 25px 60px rgba(0,0,0,.35); }
.login-card h1 { font-size: 1.3rem; text-align: center; margin-bottom: .2rem; }
.login-card > .muted { text-align: center; margin-bottom: 1.25rem; }
.login-logo { display: block; margin: 0 auto .75rem; max-height: 84px; max-width: 160px; object-fit: contain; }

/* ---------- penilaian (juri) ---------- */
.lomba-card { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.lomba-info { flex: 1 1 260px; }
.bar { height: 10px; background: #e7e3d6; border-radius: 99px; overflow: hidden; margin: .4rem 0; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--gold)); border-radius: 99px; transition: width .6s ease; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.chip { padding: .45rem .95rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600; font-size: .9rem; }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.plist { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; align-items: center; gap: .9rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); }
.plist li:last-child { border-bottom: 0; }
.pno { min-width: 64px; text-align: center; background: #f1eee3; border-radius: 10px; padding: .35rem .4rem; font-weight: 700; font-size: .85rem; color: #4a5753; }
.pno.big { font-size: 1.1rem; padding: .7rem .9rem; background: var(--brand); color: var(--brand-ink); }
.pinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pinfo small { color: var(--muted); }
.peserta-head { display: flex; align-items: center; gap: 1rem; }
.peserta-head h3 { margin: 0; font-size: 1.25rem; }
.peserta-head p { margin: 0; }
.criteria { display: grid; gap: .9rem; margin-bottom: 1rem; }
.crit { display: grid; grid-template-columns: 1fr 150px; gap: .75rem; align-items: center; padding: .75rem; background: #faf8f1; border: 1px solid var(--line); border-radius: 12px; }
.crit label { flex-direction: column; gap: 0; }
.crit-name { font-size: 1.05rem; color: var(--ink); }
.crit-max { font-weight: 400; color: var(--muted); font-size: .82rem; }
.crit input { font-size: 1.5rem !important; text-align: center; font-weight: 700 !important; padding: .6rem !important; }
.crit input.bad { border-color: var(--err); background: #fef2f2; outline-color: var(--err); }
.total-box { display: flex; align-items: baseline; gap: .75rem; justify-content: flex-end; padding: .5rem .25rem 1rem; }
.total-box strong { font-size: 2.4rem; color: var(--brand); line-height: 1; }
.total-box span { font-weight: 600; color: var(--muted); }
.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1rem; }
.form-actions .btn.primary { flex: 1 1 260px; }
.danger-zone { border-color: #efc0c0; background: #fffafa; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem; }
.mini { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .75rem 1rem; display: flex; flex-direction: column; }
.mini b { font-size: 1.5rem; color: var(--brand); }
.mini span { color: var(--muted); font-size: .82rem; }
.pager { display: flex; gap: .75rem; align-items: center; justify-content: center; padding: .9rem; }
.print-title { display: none; }

@media (max-width: 760px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .user-name { display: none; }
  .crit { grid-template-columns: 1fr 120px; }
  .plist li { flex-wrap: wrap; }
  .pstat { order: 4; }
}

/* ==========================================================================
   DASHBOARD (layar besar / proyektor) — tema gelap
   ========================================================================== */
body.dash {
  --d-bg: #07201c; --d-panel: #0e2f29; --d-line: rgba(255,255,255,.1); --d-ink: #f2f7f5; --d-muted: #9fb8b1;
  background: radial-gradient(1400px 700px at 85% -10%, color-mix(in srgb, var(--brand) 45%, transparent), transparent), var(--d-bg);
  color: var(--d-ink); min-height: 100vh; display: flex; flex-direction: column; padding: 1rem 1.25rem .75rem; gap: .9rem;
}
.dash-head { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.dash-brand { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.dash-logo { height: 72px; width: auto; max-width: 140px; object-fit: contain; background: #fff; border-radius: 16px; padding: 6px; }
.dash-brand h1 { font-size: clamp(1.4rem, 2.6vw, 2.6rem); margin: 0; letter-spacing: -.01em; }
.dash-brand p { margin: .1rem 0 0; color: var(--d-muted); font-size: clamp(.85rem, 1.1vw, 1.15rem); }
.dash-brand .dash-tema { color: var(--gold); font-style: italic; }
.dash-tools { display: flex; flex-direction: column; align-items: flex-end; gap: .5rem; }
.clock { text-align: right; line-height: 1.1; }
.clock span { font-size: clamp(1.6rem, 2.6vw, 2.8rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.clock small { display: block; color: var(--d-muted); font-size: .9rem; }
.tool-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.conn { font-size: .8rem; color: #6ee7a8; }
.conn.off { color: #fca5a5; }
.dbtn { background: rgba(255,255,255,.08); color: var(--d-ink); border: 1px solid var(--d-line); padding: .5rem .9rem; border-radius: 10px; cursor: pointer; text-decoration: none; font-weight: 600; font-size: .9rem; }
.dbtn:hover { background: rgba(255,255,255,.16); }
.dbtn.primary { background: var(--gold); color: #1c1503; border-color: var(--gold); }
.dbtn.active { border-color: var(--gold); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr) 2fr; gap: .75rem; }
.stat { background: var(--d-panel); border: 1px solid var(--d-line); border-radius: 16px; padding: .7rem 1.1rem; display: flex; flex-direction: column; justify-content: center; }
.stat b { font-size: clamp(1.6rem, 3vw, 3rem); line-height: 1.05; color: #fff; font-variant-numeric: tabular-nums; }
.stat span { color: var(--d-muted); font-size: clamp(.8rem, 1vw, 1.05rem); }
.stat.wide .bar { background: rgba(255,255,255,.12); height: 12px; margin-bottom: 0; }
.stat.warn { background: #5a3b05; }
.dash .bar { background: rgba(255,255,255,.12); }

.tabs { display: flex; gap: .6rem; flex-wrap: wrap; }
.tab { background: var(--d-panel); color: var(--d-ink); border: 1px solid var(--d-line); border-radius: 14px; padding: .6rem 1.4rem; font-size: clamp(1rem, 1.6vw, 1.6rem); font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.tab small { font-weight: 400; color: var(--d-muted); font-size: .72em; }
.tab.on { background: var(--brand); border-color: color-mix(in srgb, var(--brand) 60%, #fff); box-shadow: 0 0 0 2px var(--gold) inset; }

.dash-body { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 1fr); gap: .9rem; flex: 1; min-height: 0; }
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: .9rem; align-content: start; }
.kelas { background: var(--d-panel); border: 1px solid var(--d-line); border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; }
.kelas header { display: flex; justify-content: space-between; align-items: baseline; padding: .8rem 1.1rem; background: color-mix(in srgb, var(--brand) 55%, #000); }
.kelas header h2 { margin: 0; font-size: clamp(1rem, 1.5vw, 1.5rem); }
.kelas header span { color: #cfe3de; font-size: .85rem; }
.list { list-style: none; margin: 0; padding: 0; max-height: 58vh; overflow-y: auto; }
.row { display: flex; align-items: center; gap: .8rem; padding: .6rem 1.1rem; border-bottom: 1px solid var(--d-line); }
.row:last-child { border-bottom: 0; }
.row.hl { background: rgba(201,154,46,.14); }
.dash .rk { background: rgba(255,255,255,.1); color: #fff; width: 38px; min-width: 38px; height: 38px; font-size: 1rem; }
.dash .rk.top1 { background: #d4a017; color: #1c1503; }
.dash .rk.top2 { background: #aab4bb; color: #111; }
.dash .rk.top3 { background: #c47f45; color: #fff; }
.dash .rk.top:not(.top1):not(.top2):not(.top3) { background: var(--brand); }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.who b { font-size: clamp(.95rem, 1.35vw, 1.4rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--d-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc { font-weight: 800; font-size: clamp(1rem, 1.5vw, 1.55rem); font-variant-numeric: tabular-nums; color: #ffe08a; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #475b56; flex: none; }
.dot.lengkap { background: #34d399; }
.dot.sebagian { background: #fbbf24; }
.empty { grid-column: 1 / -1; padding: 3rem; text-align: center; color: var(--d-muted); font-size: 1.2rem; background: var(--d-panel); border-radius: 18px; }

.side { display: flex; flex-direction: column; gap: .9rem; min-height: 0; }
.panel { background: var(--d-panel); border: 1px solid var(--d-line); border-radius: 18px; padding: 1rem 1.1rem; }
.panel.grow { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.panel h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--d-muted); }
.prog { margin-bottom: .6rem; }
.prog > div:first-child { display: flex; justify-content: space-between; font-size: .95rem; }
.prog em { font-style: normal; color: var(--d-muted); font-size: .85rem; }
.feed { list-style: none; margin: 0; padding: 0; overflow-y: auto; max-height: 38vh; }
.feed li { display: flex; gap: .7rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--d-line); }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--gold); font-variant-numeric: tabular-nums; font-size: .85rem; min-width: 2.8rem; }
.feed li > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.feed small { color: var(--d-muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed .sc { font-size: 1.05rem; }
.dash .muted { color: var(--d-muted); }

.ticker { overflow: hidden; background: var(--gold); color: #1c1503; border-radius: 12px; font-weight: 700; padding: .45rem 0; white-space: nowrap; }
.ticker-track { display: inline-flex; animation: marquee 30s linear infinite; }
.ticker-track span { padding: 0 3rem; font-size: clamp(.95rem, 1.3vw, 1.3rem); }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* Mode layar penuh: lebih besar, tanpa tombol navigasi */
body.dash.is-full { padding: 1.25rem 1.75rem 1rem; }
body.dash.is-full [data-hide-full] { display: none; }
body.dash.is-full .list { max-height: 62vh; }
body.dash.is-full { cursor: default; }

@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .dash-body { grid-template-columns: 1fr; }
  .dash-tools { align-items: flex-start; }
  .clock { text-align: left; }
  .tool-row { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
  .bar > i { transition: none; }
}

/* ---------- cetak ---------- */
@media print {
  body { background: #fff; }
  .topbar, .foot, .no-print, .btn, .nav { display: none !important; }
  .container { max-width: none; padding: 0; }
  .card { border: 1px solid #bbb; break-inside: avoid; }
  .print-title { display: block; text-align: center; margin-bottom: 1rem; }
  .print-title h2 { margin: 0; }
  tr.hl td { background: #fff7d6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
