/* Admin panel: phone first, light theme (see docs/mockups/admin-*.png). Also used by the login page. */
:root {
  --bg: #f3f6fb; --card: #fff; --ink: #13213a; --muted: #6b7894; --line: #dde4ef;
  --blue: #2f6fcf; --blue-soft: #e4eefb; --red: #d21034; --red-soft: #fde8ec; --green: #1e9e5a;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: var(--ink); background: var(--bg); font-size: 15px; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; touch-action: manipulation; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.bar { position: sticky; top: 0; z-index: 10; height: 56px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; padding: 0 10px; }
.bar .flag { width: 30px; height: 30px; flex: none; }
.bar h1 { font-size: 17px; font-weight: 800; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); display: grid; place-items: center; font-size: 18px; background: #fff; flex: none; }
.iconbtn:disabled { color: #c3cbd8; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-size: 12px; font-weight: 700; flex: none; }
.lang button { padding: 6px 7px; color: var(--muted); }
.lang button.on { background: var(--blue); color: #fff; }
@media (max-width: 380px) { /* three languages must fit next to the title on small phones */
  .bar { gap: 6px; }
  .bar .flag { width: 24px; height: 24px; }
  .iconbtn { width: 34px; height: 34px; }
  .lang button { padding: 6px 5px; }
}
.offline { background: var(--red-soft); color: var(--red); font-size: 13px; font-weight: 600; text-align: center; padding: 6px; }
.offline.sending { background: var(--blue-soft); color: var(--blue); }

/* ---------- layout ---------- */
main.page { padding: 14px 14px 96px; display: grid; gap: 12px; max-width: 640px; margin: 0 auto; }
.h2 { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1.2px; margin-top: 4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.card.note { background: var(--blue-soft); border-color: #c9daf4; font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; color: var(--blue); background: var(--blue-soft); padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.tag.red { color: var(--red); background: var(--red-soft); }
.tag.grey { color: var(--muted); background: #eef1f6; }
.row { display: flex; align-items: center; gap: 8px; }
.row .grow { flex: 1; min-width: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.btn { display: block; text-decoration: none; color: var(--ink); width: 100%; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 15px; padding: 12px; text-align: center; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 800; font-size: 17px; padding: 15px; }
.btn:disabled { color: #b4bdcb; }
.btn.primary:disabled { background: #a9c1e8; border-color: #a9c1e8; color: #fff; }
.btn.danger { color: var(--red); border-color: #f3c2cc; }
.btn.dashed { border-style: dashed; color: var(--blue); }
.btn.small { width: auto; display: inline-block; font-size: 13px; padding: 7px 10px; color: var(--blue); font-weight: 700; }

input.text, select.text { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; font-size: 16px; background: #fff; min-width: 0; }
input.text:focus, select.text:focus { outline: 2px solid var(--blue); outline-offset: -1px; }

/* ---------- result entry ---------- */
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.who button { border: 2px solid var(--line); border-radius: 14px; padding: 12px 8px; text-align: center; font-weight: 800; font-size: 16px; line-height: 1.2; min-height: 74px; background: #fff; overflow-wrap: anywhere; }
.who button small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); margin-top: 3px; }
.who button.sel { border-color: var(--blue); background: var(--blue); color: #fff; }
.who button.sel small { color: #dce8fb; }
.ask { margin-top: 14px; font-size: 14px; color: var(--muted); }
.ask b { color: var(--ink); }
.balls { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: 8px; }
.balls button { aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--line); font-weight: 800; font-size: 16px; background: #fff; }
.balls button.sel { background: var(--red); border-color: var(--red); color: #fff; }
.vsline { font-weight: 700; overflow-wrap: anywhere; }
.vsline i { font-style: normal; color: var(--red); margin: 0 5px; font-size: 13px; font-weight: 700; }
.vsline .w { color: var(--green); }

/* ---------- lists ---------- */
.list { display: grid; gap: 8px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; display: flex; align-items: center; gap: 10px; }
.item .grip { color: #b5bfcf; font-size: 20px; width: 22px; text-align: center; touch-action: none; cursor: grab; flex: none; padding: 6px 0; }
.item .n { color: var(--muted); width: 18px; font-variant-numeric: tabular-nums; flex: none; }
.item .m { flex: 1; min-width: 0; font-weight: 600; line-height: 1.3; }
.item .m small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.item .act { font-size: 12px; font-weight: 700; color: var(--blue); border: 1px solid var(--line); border-radius: 9px; padding: 8px 9px; white-space: nowrap; background: #fff; flex: none; }
.item.now { border-color: var(--blue); background: var(--blue-soft); }
.item.drag { position: relative; z-index: 5; box-shadow: 0 12px 28px rgba(19,33,58,.22); border-color: var(--blue); }
.item.placeholder { border: 2px dashed #b9cbe8; background: rgba(47,111,207,.05); }
.item.placeholder > * { visibility: hidden; }

/* ---------- groups ---------- */
.grp h3 { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.grp h3 .grow { flex: 1; }
.grp .prow { display: flex; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); gap: 8px; }
.grp .prow .nm { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.grp .add { display: flex; gap: 8px; margin-top: 8px; }
.grp .add input { flex: 1; }
.pen { color: var(--muted); font-size: 16px; padding: 4px 6px; }
table.std { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.std th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--line); }
table.std td { padding: 10px 4px; text-align: center; border-bottom: 1px solid var(--line); }
table.std tr:last-child td { border-bottom: none; }
table.std .name { text-align: left; overflow-wrap: anywhere; }
table.std tr.leader td { font-weight: 800; }
table.std tr.out td { color: #a8b2c4; }
table.std tr.out td.name { text-decoration: line-through; }
table.std tbody tr { cursor: pointer; }

/* ---------- play-off ---------- */
.slot .t { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.slot.final { border: 2px solid var(--blue); }
.slot.final .t { color: var(--blue); }
.slot .p { padding: 8px 0; border-top: 1px solid var(--line); font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.slot .p.tbd { color: #a8b2c4; font-style: italic; font-weight: 500; }
.slot .p.win { color: var(--green); }
.slot .p.lose { color: #a8b2c4; }
.podium { display: grid; gap: 8px; }
.podium .place { display: flex; gap: 12px; align-items: center; font-weight: 800; font-size: 18px; }
.podium .place span { font-size: 26px; }

/* ---------- journal ---------- */
.log { display: grid; gap: 8px; }
.log .e { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; }
.log .e .t { font-size: 12px; color: var(--muted); width: 42px; font-variant-numeric: tabular-nums; flex: none; }
.log .e .d { flex: 1; font-size: 14px; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.log .e .d small { display: block; color: var(--muted); font-size: 12px; }
.log .e.undone, .log .e.discarded { opacity: .55; border-style: dashed; }
.log .e.undone .d > span, .log .e.discarded .d > span { text-decoration: line-through; }

/* ---------- bottom tabs ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); }
.tabs button { display: grid; justify-items: center; align-content: center; gap: 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
.tabs button b { font-size: 20px; font-weight: 400; line-height: 1.1; }
.tabs button.on { color: var(--blue); }

/* ---------- bottom sheet ---------- */
.dim { position: fixed; inset: 0; z-index: 20; background: rgba(19,33,58,.45); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: #fff; border-radius: 22px 22px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 12px; max-height: 88vh; overflow-y: auto; max-width: 640px; margin: 0 auto; }
.sheet .handle { width: 42px; height: 5px; border-radius: 3px; background: #d5dce7; margin: 0 auto 4px; }
.sheet h3 { font-size: 18px; font-weight: 800; }
.field { display: grid; gap: 5px; }
.field > label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.seg button { padding: 11px 6px; text-align: center; font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.seg button.on { background: var(--blue); color: #fff; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--red); }

/* ---------- login page ---------- */
main.login { max-width: 380px; margin: 0 auto; padding: 14vh 18px 24px; display: grid; gap: 16px; }
.login .brand { display: flex; align-items: center; gap: 10px; }
.login .brand svg { width: 40px; height: 40px; }
.login h1 { font-size: 22px; font-weight: 800; }
.login form { display: grid; gap: 14px; }
.login label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.login input { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 12px; font-size: 16px; background: #fff; }
.login button { margin-top: 6px; background: var(--blue); color: #fff; font-weight: 800; font-size: 17px; padding: 14px; border-radius: 12px; }
.login button:disabled { opacity: .6; }
.error { color: var(--red); font-size: 14px; }
