:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e2e5ef;
  --text: #1d2233;
  --muted: #6b7285;
  --accent: #3949ab;
  --accent-2: #5c6bc0;
  --accent-soft: #e8eaf6;
  --ok: #2e7d32;
  --ok-soft: #e8f5e9;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --danger: #c62828;
  --danger-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 25, 50, 0.06), 0 2px 8px rgba(20, 25, 50, 0.05);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); font-size: 15px; line-height: 1.45; min-height: 100vh; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 17px; color: var(--accent); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand .logo { width: 26px; height: 26px; border-radius: 6px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 14px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; }
.topbar nav a.active, .topbar nav a:hover { background: var(--accent-soft); color: var(--accent); }
.topbar .spacer { flex: 1; }

main { max-width: 1280px; margin: 0 auto; padding: 20px; }
.narrow { max-width: 720px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { flex: 1; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.session-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .session-grid { grid-template-columns: 300px minmax(0, 1fr); } .session-grid .col-right { grid-column: 1 / -1; } }
@media (max-width: 760px) { .session-grid { grid-template-columns: 1fr; } main { padding: 12px; } }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 10px; }

/* ---------- forms ---------- */
label.field { display: block; font-size: 13px; color: var(--muted); font-weight: 500; }
label.field > input, label.field > select, label.field > textarea { margin-top: 4px; }
input[type=text], input[type=number], input[type=password], input[type=url], input[type=email], select, textarea {
  width: 100%; padding: 8px 10px; font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 70px; font-family: inherit; }
input.inline, select.inline { width: auto; padding: 5px 8px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; font: inherit; font-weight: 600; font-size: 14px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover:not(:disabled), .btn:hover { background: var(--surface-2); border-color: #cfd4e3; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: #303f9f; }
button.success { background: var(--ok); border-color: var(--ok); color: #fff; }
button.success:hover:not(:disabled) { background: #256b29; }
button.danger { color: var(--danger); }
button.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: #f2b8b5; }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover:not(:disabled) { background: var(--surface-2); }
button.sm, .btn.sm { padding: 4px 9px; font-size: 13px; }
button.lg { padding: 11px 20px; font-size: 15px; }
button.icon { padding: 4px 8px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }
.table-wrap { overflow-x: auto; }

/* ---------- badges / chips ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.pending { }
.badge.voting { background: var(--accent-soft); color: var(--accent); border-color: #c5cae9; }
.badge.revealed { background: var(--warn-soft); color: var(--warn); border-color: #ffd699; }
.badge.done { background: var(--ok-soft); color: var(--ok); border-color: #b9dfbb; }
.badge.open { background: var(--ok-soft); color: var(--ok); border-color: #b9dfbb; }
.badge.closed { }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.chip.voted { background: var(--ok-soft); border-color: #b9dfbb; color: var(--ok); font-weight: 600; }
.chip .dot, .dot { width: 8px; height: 8px; border-radius: 50%; background: #c3c7d4; display: inline-block; flex: none; }
.dot.on { background: #43a047; box-shadow: 0 0 0 2px #c8e6c9; }

.group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; margin: 12px 0 6px; }
.group-title:first-child { margin-top: 0; }

/* ---------- poker cards ---------- */
.cards { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; padding: 8px 0; }
.pcard {
  width: 84px; height: 116px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface);
  font-size: 26px; font-weight: 700; color: var(--accent); display: grid; place-items: center;
  cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; box-shadow: var(--shadow);
  padding: 0;
}
.pcard:hover:not(:disabled) { transform: translateY(-4px); border-color: var(--accent-2); background: var(--surface); }
.pcard.selected, .pcard.selected:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); transform: translateY(-8px); box-shadow: 0 8px 18px rgba(57, 73, 171, .35); }
@media (max-width: 520px) { .pcard { width: 64px; height: 90px; font-size: 20px; } .cards { gap: 8px; } }

/* revealed votes */
.votes { display: flex; flex-wrap: wrap; gap: 10px; }
.vote { min-width: 86px; text-align: center; }
.vote .vcard { border: 2px solid var(--border); border-radius: 10px; padding: 10px 6px; font-weight: 700; font-size: 20px; color: var(--accent); background: var(--surface); }
.vote.min .vcard { border-color: #64b5f6; background: #e3f2fd; color: #1565c0; }
.vote.max .vcard { border-color: #ffb74d; background: var(--warn-soft); color: var(--warn); }
.vote .vname { font-size: 12px; color: var(--muted); margin-top: 4px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vote.novote .vcard { color: #b0b5c3; border-style: dashed; font-weight: 500; }

.result-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: var(--surface-2); }
.result-group h4 { margin: 0 0 8px; font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.stats b { color: var(--text); }

.alert { padding: 10px 14px; border-radius: 8px; border: 1px solid; font-size: 14px; margin: 10px 0; }
.alert.warn { background: var(--warn-soft); border-color: #ffd699; color: #7a4800; }
.alert.ok { background: var(--ok-soft); border-color: #b9dfbb; color: #1b5e20; }
.alert.info { background: var(--accent-soft); border-color: #c5cae9; color: #283593; }
.alert.danger { background: var(--danger-soft); border-color: #f2b8b5; color: #8e1c1c; }

.task-hero { text-align: center; padding: 6px 0 4px; }
.task-hero .key { font-size: 26px; font-weight: 800; letter-spacing: .02em; }
.task-hero .key a { text-decoration: none; }
.task-hero .title { font-size: 16px; color: var(--muted); margin-top: 2px; }
.task-hero .round { margin-top: 8px; }

.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--ok); transition: width .3s; }

.dist { display: flex; gap: 6px; align-items: flex-end; height: 64px; margin-top: 8px; }
.dist .bar { flex: 1; max-width: 46px; text-align: center; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.dist .bar > div { background: var(--accent-2); border-radius: 4px 4px 0 0; min-height: 2px; }

/* task list (PO) */
.tasklist { list-style: none; margin: 0; padding: 0; }
.tasklist li { padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; background: var(--surface); }
.tasklist li.active { border-color: var(--accent-2); box-shadow: 0 0 0 2px var(--accent-soft); }
.tasklist .tkey { font-weight: 700; }
.tasklist .ttitle { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tasklist .tmeta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }

/* participant picker */
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.pick-list button { justify-content: flex-start; padding: 12px 14px; font-weight: 500; }
.pick-list button .sub { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 400; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(20, 25, 50, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; max-width: 560px; width: 100%; max-height: 90vh; overflow: auto; padding: 20px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }

/* toast */
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #263238; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 360px; font-size: 14px; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

.empty { text-align: center; padding: 28px 10px; color: var(--muted); }

.checklist { columns: 2; column-gap: 16px; }
.checklist label { display: flex; gap: 8px; align-items: center; padding: 3px 0; break-inside: avoid; }
@media (max-width: 520px) { .checklist { columns: 1; } }

/* ---------- report / print ---------- */
.report h1 { margin-bottom: 4px; }
.report .meta { color: var(--muted); margin-bottom: 16px; }
.report table { font-size: 14px; }
.report .task-block { break-inside: avoid; }
.report td.vote-cell { text-align: center; font-weight: 600; }
.report td.vote-cell.changed { background: var(--warn-soft); }
.report tr.statrow td { font-size: 12px; color: var(--muted); background: var(--surface-2); }

@media print {
  body { background: #fff; font-size: 12px; }
  .topbar, .no-print, #toasts { display: none !important; }
  main { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; padding: 10px; margin-bottom: 10px; break-inside: avoid; }
  th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* =================== v2: nalozi, sesije po datumu, mobilni prikaz =================== */
input, select, textarea { font-size: 16px; } /* iOS ne zumira na fokus */
.sep { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
button.block, .btn.block { width: 100%; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }

.auth-card { max-width: 400px; margin: 48px auto; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.team-select { font-weight: 600; border-color: var(--accent-soft); background: var(--accent-soft); color: var(--accent); max-width: 220px; }
.team-label { font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: 8px; font-size: 14px; }
.pin-input { font-size: 20px; font-weight: 700; letter-spacing: .2em; font-variant-numeric: tabular-nums; }

/* lista sesija */
.session-cards .session-card { display: flex; align-items: center; gap: 18px; padding: 14px 18px; margin-bottom: 10px; }
.session-card.closed { opacity: .85; }
.session-card.open { border-left: 4px solid var(--ok); }
.sc-date { min-width: 120px; }
.sc-day { font-size: 18px; font-weight: 700; }
.sc-main { flex: 1; min-width: 0; }
.sc-name { font-weight: 600; margin-bottom: 4px; }
.sc-actions { display: flex; gap: 6px; align-items: center; }
@media (max-width: 640px) {
  .session-cards .session-card { flex-wrap: wrap; gap: 8px; }
  .sc-actions { width: 100%; justify-content: flex-end; }
}

/* PIN dugme u zaglavlju sesije + poziv */
.pin-box { background: var(--accent-soft); border-color: #c5cae9; color: var(--accent); }
.pin-box b { font-size: 20px; letter-spacing: .12em; }
.modal.wide { max-width: 640px; }
.invite { text-align: center; }
.invite-url { font-size: 20px; font-weight: 600; word-break: break-all; }
.invite-pin { font-size: 64px; font-weight: 800; letter-spacing: .15em; color: var(--accent); line-height: 1.1; }
.invite-qr { width: 260px; max-width: 80vw; margin: 12px auto 4px; }
.invite-qr svg { width: 100%; height: auto; display: block; }

/* potvrda vremena po podtimu */
.confirm-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.result-group h4 .badge { font-weight: 600; }

/* ---------- učesnici (telefon) ---------- */
body.participant { background: var(--bg); }
.p-main { max-width: 720px; margin: 0 auto; padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.session-chip { display: inline-block; font-size: 13px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; margin-bottom: 12px; }

.pin-screen { max-width: 360px; margin: 6vh auto 0; text-align: center; }
.logo-big { width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 18px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 30px; font-weight: 800; box-shadow: 0 8px 24px rgba(57,73,171,.3); }
.pin-entry { text-align: center; font-size: 36px !important; font-weight: 800; letter-spacing: .3em; padding: 14px !important; border-radius: 14px !important; font-variant-numeric: tabular-nums; }
.pin-entry::placeholder { letter-spacing: .05em; font-weight: 500; font-size: 22px; color: #b0b5c3; }

.who-screen h1 { font-size: 26px; margin-bottom: 8px; }
.name-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.name-btn { justify-content: flex-start; gap: 12px; padding: 12px 14px; min-height: 56px; font-weight: 500; font-size: 16px; text-align: left; }
.name-btn .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.lg { width: 72px; height: 72px; font-size: 28px; margin: 0 auto; display: grid; }
.me-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }
.me-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sheet { text-align: center; }
@media (max-width: 640px) {
  .sheet-back { place-items: end center; padding: 0; }
  .sheet { border-radius: 18px 18px 0 0; max-width: none; padding: 24px 20px calc(20px + env(safe-area-inset-bottom)); animation: sheetUp .18s ease-out; }
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

.room-card { padding: 18px 16px; }
.waiting { text-align: center; padding: 30px 8px; }
.waiting h2 { margin-top: 18px; }
.pulse { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); margin: 0 auto; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(57,73,171,.45); } 70% { box-shadow: 0 0 0 22px rgba(57,73,171,0); } 100% { box-shadow: 0 0 0 0 rgba(57,73,171,0); } }
.vote-hint { text-align: center; margin: 14px 0 8px; }
.vote-hint b { color: var(--accent); }

.p-tasks { list-style: none; margin: 0; padding: 0; }
.p-tasks li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.p-tasks li:last-child { border-bottom: none; }
.p-tasks li.active { background: var(--accent-soft); margin: 0 -10px; padding: 10px; border-radius: 8px; }

@media (max-width: 640px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand-text, .user-name { display: none; }
  main { padding: 12px; }
  .cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .pcard { width: 100%; height: 88px; font-size: 24px; }
  .pcard.selected { transform: translateY(-4px); }
  .task-hero .key { font-size: 24px; }
  .vote { min-width: 72px; }
  .vote .vcard { font-size: 18px; padding: 8px 4px; }
  .result-group { padding: 10px; }
  .card { padding: 14px; }
  .card-head h2 { font-size: 17px; }
}

.spacer { flex: 1; }
input[type=date] { display: block; width: 100%; padding: 8px 10px; font: inherit; font-size: 16px; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; outline: none; margin-top: 4px; }
