:root {
  color-scheme: dark;
  --bg: #020617;
  --ink-950: #020617;
  --ink-900: #07111f;
  --ink-850: #0b1424;
  --ink-800: #111c2f;
  --ink-700: #1a2942;
  --line: rgba(255, 255, 255, 0.1);
  --slate-700: #334155;
  --text: #f8fbff;
  --muted: #8ca5ca;
  --muted-2: #94a3b8;
  --mint: #35e0b6;
  --skyline: #60a5fa;
  --danger: #ff5578;
  --violet: #8b5cf6;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  background:
    radial-gradient(circle at top left, rgba(53, 224, 182, 0.08), transparent 26rem),
    linear-gradient(180deg, #020617 0%, #06111e 48%, #020617 100%);
  color: var(--text);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #07111f; }
::-webkit-scrollbar-thumb { background: #263757; border-radius: 999px; }

.page { min-height: 100vh; padding: 16px 12px; }
.container { max-width: 80rem; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }

@media (min-width: 640px) { .page { padding: 16px 20px; } }
@media (min-width: 1024px) { .page { padding: 16px 32px; } }

/* Header */
.header {
  display: flex; flex-direction: column; gap: 12px;
  border-bottom: 1px solid var(--line); padding-bottom: 16px;
}
@media (min-width: 640px) {
  .header { flex-direction: row; align-items: center; justify-content: space-between; }
}
.header-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-logo {
  display: flex; align-items: center; justify-content: center;
  height: 44px; width: 44px; flex-shrink: 0; overflow: hidden;
  border-radius: 999px; border: 1px solid var(--slate-700); background: var(--ink-800);
  color: var(--skyline);
}
.header-logo img { width: 100%; height: 100%; object-fit: cover; border-radius: 999px; display: block; }
.header-title { margin: 0; font-size: 20px; font-weight: 900; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 640px) { .header-title { font-size: 24px; } }
.header-sub { margin: 4px 0 0; font-size: 14px; color: var(--muted-2); }
.header-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Botoes */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 6px; border: 1px solid var(--slate-700); background: var(--ink-800);
  padding: 8px 12px; font-size: 14px; font-weight: 600; color: #fff;
  transition: border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--skyline); color: var(--skyline); }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn-icon { height: 36px; width: 36px; padding: 0; }
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 6px;
  background: linear-gradient(90deg, var(--skyline), var(--violet));
  padding: 8px 16px; font-size: 14px; font-weight: 700; color: #fff;
  box-shadow: 0 10px 15px rgba(23, 37, 84, 0.3);
  transition: filter 0.15s;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { cursor: not-allowed; opacity: 0.5; }
.btn-danger-text { color: var(--danger); }

/* Painel */
.panel {
  border-radius: 8px; border: 1px solid var(--line); background: var(--ink-850);
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.16), 0 16px 45px rgba(2, 6, 23, 0.35);
}

/* Campos */
.field {
  width: 100%; border-radius: 6px; border: 1px solid var(--slate-700);
  background: var(--ink-800); padding: 8px 12px; font-size: 14px; color: #fff;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.field::placeholder { color: #64748b; }
.field:focus { border-color: var(--skyline); box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2); }
textarea.field { min-height: 112px; resize: vertical; }
.field-label { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--muted-2); }
input[type="date"].field, input[type="datetime-local"].field { color-scheme: dark; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px; padding: 4px 8px; font-size: 12px; font-weight: 700;
  border: 1px solid transparent;
}
.badge-time { border-color: #475569; background: var(--ink-950); color: #fff; }
.badge-type { background: rgba(59, 130, 246, 0.15); color: #bfdbfe; }
.badge-book { background: #ef4444; color: #fff; }
.badge-free { background: rgba(245, 158, 11, 0.15); color: #fde68a; }
.badge-live { background: rgba(16, 185, 129, 0.15); color: #a7f3d0; }
.badge-tag { background: var(--slate-700); color: #e2e8f0; }
.badge-dark { border-color: var(--slate-700); background: var(--ink-800); color: #fff; }

.status-pending { background: rgba(51, 65, 85, 0.8); color: #e2e8f0; border-color: rgba(100, 116, 139, 0.3); }
.status-won { background: rgba(16, 185, 129, 0.12); color: var(--mint); border-color: rgba(52, 211, 153, 0.3); }
.status-lost { background: rgba(244, 63, 94, 0.12); color: var(--danger); border-color: rgba(251, 113, 133, 0.3); }
.status-void { background: rgba(14, 165, 233, 0.12); color: #bae6fd; border-color: rgba(56, 189, 248, 0.3); }
.status-refunded { background: rgba(6, 182, 212, 0.12); color: #a5f3fc; border-color: rgba(34, 211, 238, 0.3); }
.status-cashout { background: rgba(20, 184, 166, 0.12); color: #99f6e4; border-color: rgba(45, 212, 191, 0.3); }

/* Cards de estatisticas */
.stats-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1280px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .stats-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
}
.stat-card { display: flex; min-height: 96px; align-items: center; justify-content: space-between; padding: 16px 20px; }
.stat-label { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--muted-2); }
.stat-value { margin: 4px 0 0; font-size: 24px; font-weight: 900; }
.stat-icon { color: #64748b; flex-shrink: 0; }

.text-mint { color: var(--mint); }
.text-danger { color: var(--danger); }
.text-sky { color: var(--skyline); }
.text-amber { color: #fcd34d; }
.text-white { color: #fff; }

/* Grafico */
.chart-panel { height: 320px; width: 100%; padding: 12px; position: relative; }
@media (min-width: 640px) { .chart-panel { height: 360px; } }
.chart-panel svg { display: block; width: 100%; height: 100%; }
.chart-tooltip {
  position: absolute; pointer-events: none; display: none; z-index: 5;
  background: #07111f; border: 1px solid #263757; border-radius: 8px;
  color: var(--text); padding: 8px 10px; font-size: 12px; white-space: nowrap;
}
.chart-tooltip .tt-label { color: var(--muted); }
.chart-tooltip .tt-value { font-weight: 700; color: var(--mint); }

/* Lista de apostas */
.list-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 12px 16px; }
.list-head-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 900; }
.list-body { display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.day-label { margin: 0; padding: 8px; font-size: 14px; font-weight: 900; text-transform: capitalize; color: #cbd5e1; }
.day-bets { display: flex; flex-direction: column; gap: 8px; }
.empty-box {
  border-radius: 8px; border: 1px solid var(--line); background: var(--ink-900);
  padding: 32px 16px; text-align: center; font-size: 14px; color: var(--muted-2);
}

.bet-card {
  display: grid; width: 100%; grid-template-columns: 1fr; gap: 12px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--ink-850);
  padding: 16px; text-align: left; color: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.bet-card:hover { border-color: rgba(96, 165, 250, 0.6); background: var(--ink-800); }
@media (min-width: 768px) { .bet-card { grid-template-columns: 1fr auto auto; } }
.bet-main { min-width: 0; }
.bet-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.bet-selection { margin: 0; font-size: 14px; font-weight: 900; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bet-meta { margin: 4px 0 0; font-size: 12px; color: var(--muted-2); }
.bet-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; text-align: right; }
@media (min-width: 640px) { .bet-metrics { min-width: 360px; } }
.metric-value { margin: 0; font-size: 14px; font-weight: 900; }
.metric-label { margin: 2px 0 0; font-size: 11px; color: var(--muted-2); }
.bet-end { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@media (min-width: 768px) { .bet-end { justify-content: flex-end; } }
.chev { color: #64748b; transition: transform 0.15s, color 0.15s; }
.bet-card:hover .chev { transform: translateX(4px); color: var(--skyline); }

/* Drawers */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(4px);
  display: none;
}
.overlay.open { display: block; }

.drawer {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 40;
  width: 100%; max-width: 390px;
  border-left: 1px solid var(--line); background: var(--ink-950);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  transform: translateX(100%); transition: transform 0.2s;
  display: flex; flex-direction: column;
}
.drawer.left { left: 0; right: auto; border-left: 0; border-right: 1px solid var(--line); transform: translateX(-100%); }
.drawer.wide { max-width: 580px; z-index: 50; }
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; height: 56px; flex-shrink: 0; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); padding: 0 20px;
}
.drawer-title { margin: 0; font-size: 14px; font-weight: 900; display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }

/* Grid de formularios / filtros */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }
.form-grid .span-2 { grid-column: 1 / -1; }
.label-row { display: flex; align-items: center; justify-content: space-between; }
.add-link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--skyline); font-size: 12px; font-weight: 700;
}
.add-link:hover { text-decoration: underline; }
.type-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.check-row {
  display: flex; align-items: center; gap: 8px;
  border-radius: 6px; border: 1px solid var(--line); background: var(--ink-800);
  padding: 8px 12px; font-size: 14px; color: #e2e8f0;
}

.toggle-group { margin-top: 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--ink-800); padding: 8px; }
.toggle-label { margin-bottom: 8px; font-size: 12px; font-weight: 600; color: #cbd5e1; }
.toggle-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.toggle-btn {
  border-radius: 6px; border: 1px solid var(--slate-700); background: var(--ink-900);
  padding: 8px 12px; font-size: 14px; font-weight: 700; color: #e2e8f0;
}
.toggle-btn.active { border-color: #a78bfa; background: rgba(139, 92, 246, 0.2); color: #ddd6fe; }

.drawer-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 16px; }
.form-footer {
  position: sticky; bottom: 0; margin-top: 20px; padding: 12px 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; background: var(--ink-950);
}

/* Estatisticas (drawer) */
.stats-drawer-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stats-row { border-radius: 6px; border: 1px solid var(--line); background: var(--ink-800); padding: 12px; }
.stats-row p { margin: 0; }
.stats-row .k { font-size: 12px; color: var(--muted-2); }
.stats-row .v { margin-top: 4px; font-size: 14px; font-weight: 900; color: #fff; }
.stats-row .v.neg { color: var(--danger); }

/* Tabelas (admin) */
.table-wrap { overflow-x: auto; }
table.data { min-width: 980px; width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
table.data.logs { min-width: 720px; }
table.data thead { background: var(--ink-900); }
table.data th { padding: 12px 16px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted-2); }
table.data td { padding: 12px 16px; color: #e2e8f0; vertical-align: top; border-top: 1px solid var(--line); background: var(--ink-850); }
table.data td p { margin: 0; }
table.data .cell-sub { margin-top: 4px; font-size: 12px; color: var(--muted-2); }
.logs-scroll { max-height: 460px; overflow: auto; }
.log-json { margin-top: 8px; max-width: 360px; overflow: auto; border-radius: 6px; background: var(--ink-950); padding: 12px; font-size: 12px; color: #cbd5e1; }
details summary { cursor: pointer; color: var(--skyline); }

/* Login */
.login-wrap { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 28rem; display: flex; flex-direction: column; gap: 16px; padding: 20px; }
.login-title { margin: 0; font-size: 20px; font-weight: 900; }
.login-sub { margin: 4px 0 0; font-size: 14px; color: var(--muted-2); }
.input-icon { position: relative; }
.input-icon .field { padding-left: 40px; }
.input-icon svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #64748b; }
.input-icon-right { position: relative; }
.input-icon-right .field { padding-right: 36px; }
.input-icon-right svg { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }
.error-box {
  border-radius: 6px; border: 1px solid rgba(244, 63, 94, 0.3); background: rgba(244, 63, 94, 0.1);
  padding: 8px 12px; font-size: 14px; font-weight: 600; color: var(--danger);
}

.icon { width: 16px; height: 16px; flex-shrink: 0; }
.icon-sm { width: 12px; height: 12px; }
.icon-lg { width: 20px; height: 20px; }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }
.actions-cell { display: flex; gap: 8px; }
