/* ---- Surebet · mobile-first ---- */
:root {
  --bg: #0e1116;
  --bg-elev: #161b22;
  --bg-elev2: #1d242e;
  --border: #2a323d;
  --text: #e6edf3;
  --muted: #8b97a7;
  --accent: #22c55e;
  --accent-2: #0d9488;
  --danger: #ef4444;
  --warn: #f59e0b;
  --win: #22c55e;
  --lose: #ef4444;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.4;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); font-size: 14px; margin: 2px 0; }

/* ---- Buttons ---- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elev2);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, background .15s;
}
.btn:active { filter: brightness(1.2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #07120a; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 10px; font-size: 13px; border-radius: 8px; }
.btn-ghost { background: transparent; }
.btn-win { background: var(--win); border-color: var(--win); color: #07120a; }
.btn-lose { background: var(--lose); border-color: var(--lose); color: #fff; }
.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Login ---- */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.brand { text-align: center; margin-bottom: 6px; }
.brand h1 { margin: 8px 0 0; font-size: 26px; letter-spacing: .5px; }
.brand p { margin: 2px 0 0; }
.brand-mark {
  width: 58px; height: 58px; margin: 0 auto;
  display: grid; place-items: center;
  border-radius: 16px;
  font-size: 30px; font-weight: 800; color: #07120a;
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
}
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 16px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

/* ---- App shell ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: rgba(14,17,22,.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 800; font-size: 18px; }
#topbar-user { margin-left: auto; }
.topbar .btn { margin-left: 8px; }
#topbar-user + .btn { margin-left: 8px; }

.content {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px calc(96px + var(--safe-bottom));
}

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 4px 2px 14px;
}
.section-head h2 { margin: 0; font-size: 20px; }

/* ---- Tab bar ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.tab-btn {
  flex: 1; background: none; border: 0; color: var(--muted);
  padding: 10px 4px 12px; font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer;
}
.tab-btn .ico { font-size: 20px; }
.tab-btn.active { color: var(--accent); }

/* ---- Cards ---- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card.win { border-color: rgba(34,197,94,.5); }
.card.lose { border-color: rgba(239,68,68,.4); }
.card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card-date { font-size: 12px; color: var(--muted); }
.card-desc { font-weight: 700; margin: 2px 0 8px; word-break: break-word; }
.kv-row { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; margin-bottom: 4px; }
.kv-row .k { color: var(--muted); }
.kv-row .v { font-weight: 700; }

.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge.pendiente { background: rgba(245,158,11,.16); color: var(--warn); }
.badge.ganada, .badge.resuelta { background: rgba(34,197,94,.16); color: var(--win); }
.badge.perdida { background: rgba(239,68,68,.16); color: var(--lose); }

.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.card-actions .spacer { flex: 1; }

/* surebet lines */
.line {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 9px; background: var(--bg);
  border: 1px solid var(--border); margin-bottom: 6px; font-size: 14px;
}
.line.winner { border-color: var(--win); background: rgba(34,197,94,.10); }
.line .ln-name { font-weight: 700; }
.line .ln-num { color: var(--muted); }
.resolve-row { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.resolve-row .lbl { font-size: 12px; color: var(--muted); }

/* dynamic form lines */
.form-line {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px;
  margin-bottom: 10px; background: var(--bg);
}
.form-line-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-grid .full { grid-column: 1 / -1; }

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

/* dialog */
.dialog {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 16px 16px 0 0;
  padding: 0;
  width: 100%;
  max-width: 560px;
  margin: auto auto 0;
  max-height: 92dvh;
}
.dialog::backdrop { background: rgba(0,0,0,.55); }
.dialog-inner { padding: 18px 16px calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 12px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h3 { margin: 0; font-size: 18px; }
.fields { display: flex; flex-direction: column; gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.stat-box { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; text-align: center; }
.stat-box .lab { font-size: 11px; color: var(--muted); }
.stat-box .num { font-size: 16px; font-weight: 800; margin-top: 3px; }
.num.pos { color: var(--win); }
.num.neg { color: var(--lose); }
.stats-card h3 { margin: 0 0 10px; font-size: 16px; }
.pending-note { margin-top: 10px; font-size: 13px; color: var(--warn); }

@media (min-width: 560px) {
  .dialog { border-radius: 16px; margin: auto; }
}
@media (min-width: 640px) {
  .brand-mark { }
}
