/* Kupon — wygląd inspirowany historią zakładów Superbet */
:root {
  --bg: #F0F1F3;
  --card: #FFFFFF;
  --text: #1A1A1A;
  --muted: #6B7280;
  --muted-2: #9CA3AF;
  --line: #E5E7EB;
  --line-2: #EEF0F3;
  --accent: #E10019;
  --accent-press: #C40016;
  --green: #22A34A;
  --green-soft: #E8F7ED;
  --red-soft: #FDECEE;
  --void: #6B7280;
  --void-bg: #EEF0F3;
  --yellow: #C9A227;
  --yellow-bg: #F8F1D8;
  --shadow: 0 1px 3px rgba(17, 24, 39, 0.06), 0 1px 2px rgba(17, 24, 39, 0.04);
  --radius: 16px;
  --radius-sm: 12px;
  --nav-h: 64px;
  --slip-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: Inter, Roboto, "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;
}

html[data-theme="dark"] {
  --bg: #121316;
  --card: #1E1F24;
  --text: #F3F4F6;
  --muted: #9CA3AF;
  --muted-2: #6B7280;
  --line: #2A2C33;
  --line-2: #26272C;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --void-bg: #2A2C33;
  --green-soft: #16351f;
  --red-soft: #3a1518;
  --yellow-bg: #3a3318;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
html { height: 100%; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.35;
  min-height: 100%;
  min-height: 100dvh;
  color: var(--text);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { max-width: 100%; }

#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
}

#view {
  padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 20px);
  min-height: 100dvh;
}
#app.has-slip #view {
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + var(--slip-h) + 20px);
}

/* ——— typography helpers ——— */
h1.page-title {
  margin: 0 0 14px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ——— cards ——— */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 12px; }
.coupon-wrap { margin-bottom: 20px; }
.coupon-wrap .card + .card { margin-top: 12px; }

/* ——— match card ——— */
.match-card { padding: 16px 20px 18px; overflow: hidden; }
.match-top {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-bottom: 8px;
  min-width: 0;
}
.match-top .sport-ic {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: var(--muted);
  display: block;
}
.match-top .league-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.match-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  min-width: 0;
  font-size: 14px;
  color: var(--text);
}
.match-meta .time {
  font-weight: 600;
  white-space: nowrap;
}
.match-meta .dot { color: var(--muted-2); }
.match-meta .mstatus {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.match-meta .m-mark {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--muted-2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.team-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 26px;
}
.team-row .tname {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
  word-break: keep-all;
  word-wrap: normal;
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  line-height: 26px;
}
.team-row.winner .tname { font-weight: 700; }
.team-row .score {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  min-width: 28px;
  text-align: right;
  line-height: 26px;
}
.team-row.winner .score { color: var(--text); font-weight: 700; }
.team-row .score.empty { color: var(--muted-2); font-weight: 400; }

.btn-ghost-mini {
  color: var(--muted);
  font-size: 12px;
  padding: 4px 0 0;
}

/* ——— bet box ——— */
.bet-box {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--card);
}
.bet-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}
.bet-mid {
  flex: 1 1 auto;
  min-width: 0;
}
.bet-title {
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.bet-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bet-odds {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
  color: var(--text);
}

/* status circle */
.status-btn {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
}
.status-btn svg { width: 24px; height: 24px; display: block; }
.status-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.void-pill {
  display: inline-block;
  margin-top: 6px;
  background: var(--void-bg);
  color: var(--void);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 18px;
}

/* Bet Builder */
.bb-box { padding: 14px 14px 10px; }
.bb-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  min-width: 0;
}
.bb-head .bb-title {
  font-style: italic;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 1;
  min-width: 0;
}
.bb-head .bet-odds { color: var(--muted); font-style: normal; font-size: 16px; }

.bb-timeline { position: relative; padding: 0; margin: 0; list-style: none; }
.bb-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0 10px;
  min-width: 0;
}
.bb-item:last-child { padding-bottom: 4px; }
.bb-rail {
  position: relative;
  flex: 0 0 22px;
  width: 22px;
  align-self: stretch;
}
.bb-item:not(:last-child) .bb-rail::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 22px;
  bottom: -10px;
  border-left: 1.5px dashed var(--line);
}
.bb-item .status-btn { margin-top: 0; }
.bb-item .bet-mid { padding-top: 1px; }
.bb-box.is-settled,
.bb-box.is-settled .bb-head .bb-title,
.bb-box.is-settled .bb-head .bet-odds,
.bb-box.is-settled .bet-title,
.bb-box.is-settled .bet-sub {
  color: var(--muted);
}
.bb-box.is-settled .bet-title { font-weight: 600; }

/* coupon header + summary */
.coupon-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  min-width: 0;
}
.coupon-head .ctype {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-pill {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  line-height: 16px;
}
.status-pill.won { background: var(--green-soft); color: var(--green); }
.status-pill.lost { background: var(--red-soft); color: var(--accent); }
.status-pill.void { background: var(--void-bg); color: var(--void); }
.status-pill.pending { background: var(--void-bg); color: var(--muted); }

.sum-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  min-width: 0;
}
.sum-row + .sum-row { border-top: 1px solid var(--line-2); }
.sum-row .slabel { color: var(--muted); font-size: 14px; }
.sum-row .sval {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.sum-row button.sval {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: right;
}
.coupon-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.btn-quiet {
  flex: 1;
  background: var(--line-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
}
.btn-quiet.danger { color: var(--accent); }

/* ——— filters ——— */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 0 14px;
  padding: 0 0 2px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.active {
  background: var(--text);
  color: var(--card);
  border-color: var(--text);
}
html[data-theme="dark"] .chip.active { background: #F3F4F6; color: #121316; }

.league-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.league-chips .chip { flex: 1 1 calc(20% - 8px); text-align: center; min-width: 56px; }

.subject-tabs {
  display: flex;
  background: var(--line-2);
  border-radius: 12px;
  padding: 3px;
  margin: 0 0 16px;
}
.subject-tabs button {
  flex: 1;
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.subject-tabs button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

/* ——— forms ——— */
.field { margin-bottom: 14px; position: relative; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input[type="text"],
.field input[type="number"],
.field input[type="time"],
.field input[type="url"],
.field select,
.input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  min-width: 0;
}
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .input {
  background: #18191D;
  border-color: #2A2C33;
}
.field input:focus, .field select:focus, .input:focus {
  border-color: #C5C7CC;
  box-shadow: 0 0 0 3px rgba(225, 0, 25, 0.08);
}
.row-2 { display: flex; gap: 10px; }
.row-2 .field { flex: 1; min-width: 0; }

.ac-list {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% - 6px);
  z-index: 40;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(17,24,39,0.12);
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
}
.ac-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  min-width: 0;
}
.ac-item:hover, .ac-item.active { background: var(--line-2); }
.ac-item .ac-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-item .ac-meta {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-empty { padding: 10px 12px; font-size: 13px; color: var(--muted); }

.btn-primary {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}
.btn-primary:active { background: var(--accent-press); }
.btn-primary:disabled { opacity: 0.5; }
.btn-secondary {
  display: block;
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
.stack-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

/* ——— betslip ——— */
#betslip-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  bottom: calc(var(--nav-h) + var(--safe-b));
  z-index: 30;
  padding: 0 16px 8px;
}
#betslip-bar[hidden] { display: none !important; }
.slip-handle {
  width: 100%;
  background: var(--text);
  color: var(--card);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  font-weight: 700;
}
html[data-theme="dark"] .slip-handle { background: #F3F4F6; color: #121316; }
.slip-handle .left, .slip-handle .right { white-space: nowrap; }

.sheet-backdrop, #sheet {
  /* #sheet is the host */
}
#sheet[hidden] { display: none !important; }
#sheet:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 16, 20, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-panel {
  width: 100%;
  max-width: 430px;
  max-height: min(88dvh, 760px);
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(16px + var(--safe-b));
  overflow-y: auto;
  animation: sheetUp 0.22s ease;
}
@keyframes sheetUp {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}
.sheet-grab {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--line); margin: 6px auto 12px;
}
.sheet-title {
  font-size: 18px; font-weight: 700; margin: 0 0 14px;
}
.sheet-opt {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: var(--card);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 8px;
  font-weight: 600;
  box-shadow: var(--shadow);
}
.sheet-opt .dot {
  width: 22px; height: 22px; border-radius: 50%;
  flex: 0 0 22px;
}
.sheet-opt.won .dot { background: var(--green); }
.sheet-opt.lost .dot { background: var(--accent); }
.sheet-opt.void .dot { background: var(--yellow); }
.sheet-opt.pending .dot { background: transparent; border: 2px solid var(--muted-2); }

.stake-quick { display: flex; gap: 8px; margin: 4px 0 14px; }
.stake-quick button {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 0;
  font-weight: 700;
  font-size: 13px;
}
.stake-quick button.active { border-color: var(--accent); color: var(--accent); }

.slip-leg {
  background: var(--card);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.slip-leg .top {
  display: flex; align-items: flex-start; gap: 8px; min-width: 0;
}
.slip-leg .info { flex: 1; min-width: 0; }
.slip-leg .teams {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slip-leg .title {
  font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slip-leg .odds-in { width: 72px; text-align: right; padding: 8px 10px; }
.icon-btn {
  flex: 0 0 32px; width: 32px; height: 32px;
  border-radius: 8px; color: var(--muted);
  display: grid; place-items: center;
}

/* ——— nav ——— */
#tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  bottom: 0;
  z-index: 40;
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  padding: 6px 4px calc(6px + var(--safe-b));
  height: calc(var(--nav-h) + var(--safe-b));
}
#tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  min-width: 0;
  padding: 4px 0 0;
}
#tabbar button svg { width: 22px; height: 22px; }
#tabbar button.active { color: var(--accent); }

/* ——— settings / stats ——— */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  min-width: 0;
}
.setting-row + .setting-row { border-top: 1px solid var(--line-2); }
.setting-row .slabel { font-weight: 600; min-width: 0; }
.setting-row .shint { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }

.toggle {
  position: relative;
  width: 48px; height: 28px; flex: 0 0 48px;
  border-radius: 999px;
  background: #D1D5DB;
  border: 0;
  transition: background 0.15s;
}
.toggle.on { background: var(--accent); }
.toggle i {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
  display: block;
}
.toggle.on i { transform: translateX(20px); }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.stat-box {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  min-width: 0;
}
.stat-box .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-box .v {
  font-size: 20px; font-weight: 800; margin-top: 4px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.02em;
}
.stat-box .v.pos { color: var(--green); }
.stat-box .v.neg { color: var(--accent); }
.chart-card { padding: 16px 12px 12px; }
.chart-card h2 { margin: 0 12px 8px; font-size: 14px; font-weight: 700; }
.chart-card svg { width: 100%; height: 160px; display: block; }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 36px 16px;
  font-size: 14px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  transform: translateX(-50%);
  z-index: 80;
  background: #1A1A1A;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
#toast[hidden] { display: none !important; }

.hint { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.section-label {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin: 18px 0 8px;
}
.muted { color: var(--muted); }

/* long names never wrap letter-by-letter, even in tight 360px */
.nowrap-ellipsis {
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  word-break: keep-all;
  overflow-wrap: normal;
}
