:root{
  --bg:#f7f7f8; --fg:#0f172a;
  --muted:#64748b; --line:#e5e7eb;
  --brand:#0ea5e9; --danger:#ef4444;
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--fg);font:16px/1.45 system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif}

.topbar{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;background:#0f172a;color:#fff}
.topbar .actions { display:flex; gap:6px; align-items:center; }
.topbar button.small { padding:8px 12px; }

.wrap{max-width:900px;margin:16px auto;padding:0 14px}
.tabs{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:12px}
.tab{padding:8px 12px;border-radius:10px;background:#e2e8f0;color:#0f172a;text-decoration:none;cursor:pointer;border:1px solid var(--line)}
.tab.active{background:var(--brand);color:#fff;border-color:transparent}
.panel{display:none;background:#fff;border:1px solid var(--line);border-radius:12px;padding:8px 14px}

.panel { overflow: visible; }

.panel.active{display:block}
h3{margin:2px 0 2px}
.note{color:var(--muted);font-size:13px}
.results-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px}
.results-head h3{margin:0}
.row{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin:10px 0}
textarea{width:100%;min-height:220px;font-family:ui-monospace,consolas,monaco,monospace}
button{padding:8px 12px;border:0;border-radius:10px;background:var(--brand);color:#fff;cursor:pointer}
button.ghost{background:#e5e7eb;color:#0f172a}
button.secondary{background:var(--muted)}
button.danger{background:var(--danger)}
button.small{padding:6px 8px;font-size:14px}
.table{width:100%;border-collapse:collapse;background:#fff}
.table th,.table td{padding:4px 10px;border-bottom:1px solid #eceff3;text-align:left}
.board{border:1px solid var(--line);border-radius:10px;padding:8px;margin:8px 0;background:#fff;display:flex;align-items:center;justify-content:space-between;gap:8px}
.names{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.badge{display:inline-block;padding:2px 8px;border-radius:999px;background:#e5e7eb;color:#0f172a;font-size:12px}
.result{min-width:70px;text-align:center;font-weight:600}
.resbtns button{margin-left:4px}
.dlg-head{display:flex;gap:8px;align-items:center;padding:12px;border-bottom:1px solid var(--line)}
.dlg-body{padding:12px;max-height:70vh;overflow:auto}
.actions{display:flex;gap:8px;align-items:center}

/* Kārtas iestatīšanas dialogs */
.round-setup-dlg{border:0;border-radius:12px;padding:0;max-width:min(520px,96vw);box-shadow:0 12px 40px rgba(15,23,42,.18)}
.round-setup-dlg::backdrop{background:rgba(15,23,42,.35)}
.rs-list{max-height:42vh;overflow:auto;border:1px solid var(--line);border-radius:10px;padding:8px;margin:8px 0;background:#fafafa}
.rs-row{display:flex;align-items:flex-start;gap:10px;padding:6px 4px;border-bottom:1px solid #eceff3;cursor:pointer}
.rs-row:last-child{border-bottom:0}
.rs-row input{margin-top:3px;flex-shrink:0}
.rs-row span{flex:1;word-break:break-word}
.rs-row.pluss-row{background:#f0f9ff;border-radius:8px;padding:8px;margin-top:6px;border:1px dashed #bae6fd}
.rs-sub{margin:12px 0 6px;font-size:14px;font-weight:600}
.rs-footnote{margin-top:8px;min-height:1.2em}
.rs-actions{justify-content:flex-end;margin-top:12px;margin-bottom:0}
#taRoundSetupNew{min-height:88px;font-family:inherit}

/* V2 — Pairing board as 4-column grid */
.gridwrap{
  margin-top:8px;
  border:1px solid var(--line);
  border-radius:10px;
  overflow:hidden;
  background:#fff;
}

/* Vienāds izkārtojums visām rindām (Baltie | Rez. | Melnie | Pogas) */
.gridrow{
  display:grid;
  grid-template-columns: 290px 80px 300px 152px;
  align-items:center;
  column-gap:8px;
}
.gridrow.header{
  background:#f1f5f9;
  font-weight:600;
}
.gridrow.header > div{ text-align:center; }
.gridrow.header > div:first-child,
.gridrow.header > div:nth-child(3){ text-align:left; } /* Baltie un Melnie */

.gridrow > div{ padding:6px 12px; border-bottom:1px solid #eceff3; }
.gridrow:last-child > div{ border-bottom:none; }

/* Šūnas */
.cell-name{ display:flex; align-items:center; gap:8px; min-height:34px; text-align:left; }
.cell-result{ font-weight:700; text-align:center; }
.cell-actions{ display:flex; justify-content:flex-start; gap:3px; flex-wrap:nowrap; }
.cell-actions .resbtn{ min-width:30px; padding:3px 7px; font-size:.82em; }
.cell-actions .resbtn-ghost{ background:#e5e7eb;color:#0f172a; }
.cell-actions .resbtn-z{ min-width:26px; padding:2px 5px; font-size:.75em; opacity:.95; }

/* BYE rinda */
.row-bye .cell-name{ opacity:.9; }
.row-bye .cell-result{ background:#f8fafc; border-radius:8px; }

/* Horizontālais scroll mobilajā, lai nenogriež malas */
.hscroll{
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  margin:0 -14px;   /* izstumjam ārpus .panel padding */
  padding:0 18px;   /* mazliet bufera labajā malā (“M” poga) */
}

/* Grid korpusa minimālais platums = kolonnu summa */
.gridwrap.gridwide{ min-width: 822px; } /* 290 + 80 + 300 + 152 */

/* Panelim ļaujam saturam iziet līdz hscroll malām */
.panel{ overflow:visible; }

/* Mazākiem ekrāniem var palikt tās pašas kolonnas; ja gribi kompaktāk, šeit vari samazināt */
@media (max-width: 600px){
  .cell-actions{ gap:2px; }
  .cell-actions .resbtn{ min-width:28px; padding:2px 5px; font-size:.78em; }
  .cell-actions .resbtn-z{ min-width:24px; padding:2px 4px; font-size:.72em; }
}
