:root {
  --ink: #241b38;
  --muted: #6c6385;
  --line: #e7e2f3;
  --surface: #ffffff;
  --page: #f5f2fb;
  --brand: #7b2cbf;
  --brand-2: #f72585;
  --danger: #d62839;
  --ok: #1b9e6b;
  --radius: 16px;
  --display: "Fredoka", "Nunito", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
  min-height: 100vh;
}
h1, h2 { font-family: var(--display); font-weight: 600; margin: 0 0 14px; }
h2 { font-size: 20px; }
.muted { color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: 700 15px "Nunito", sans-serif;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .1s, background .2s, box-shadow .2s;
}
.btn:hover { background: #faf8ff; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 16px rgba(123, 44, 191, .28);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.icon { width: 38px; min-height: 38px; padding: 0; }
.danger-text { color: var(--danger); }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Campos ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-weight: 700; font-size: 14px; }
.field > span { color: var(--ink); }
input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font: 600 15px "Nunito", sans-serif;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(123, 44, 191, .12); }
input[type="range"] { width: 100%; accent-color: var(--brand); }
input[type="color"] {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 12px;
  box-shadow: 0 0 0 1.5px var(--line);
  cursor: pointer;
  background: none;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 10px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* Interruptor */
.switch { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; font-weight: 700; cursor: pointer; }
.switch input { display: none; }
.switch .slider {
  flex: none;
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 99px;
  background: #d9d3e8;
  transition: background .2s;
}
.switch .slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
  transition: transform .2s;
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::after { transform: translateX(20px); }

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: linear-gradient(135deg, #3a0ca3, #f72585);
}
.login-card {
  width: min(400px, 100%);
  padding: 34px 28px 24px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(0,0,0,.3);
  text-align: center;
  animation: up .5s cubic-bezier(.2,1.2,.4,1);
}
.login-card .field { text-align: left; }
@keyframes up { from { opacity: 0; transform: translateY(24px) scale(.97); } }
.login-icon { font-size: 54px; animation: spin 6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-card h1 { font-size: 26px; margin: 8px 0 4px; }
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 46px; }
.pass-toggle {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 38px;
  height: 36px;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 18px;
  opacity: .6;
}
.error { color: var(--danger); font-weight: 700; min-height: 20px; margin: 0 0 10px; font-size: 14px; }
.shake { animation: shake .4s; }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
.back-link { display: inline-block; margin-top: 16px; color: var(--muted); font-weight: 700; text-decoration: none; }

/* ---------- Panel ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px max(16px, 3vw);
  background: linear-gradient(135deg, #3a0ca3, #7b2cbf 55%, #f72585);
  color: #fff;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-brand > div { min-width: 0; }
.topbar-brand strong { display: block; font-family: var(--display); font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-brand small { opacity: .85; }
.topbar-logo {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 24px;
  overflow: hidden;
}
.topbar-logo img { width: 90%; height: 90%; object-fit: contain; }
.topbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.4); }
.topbar .btn.ghost:hover { background: rgba(255,255,255,.12); }
.topbar-actions { display: flex; gap: 8px; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 12px max(16px, 3vw) 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  flex: none;
  padding: 10px 16px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font: 800 15px "Nunito", sans-serif;
  cursor: pointer;
}
.tab:hover { background: #ebe5f7; }
.tab.active { background: #fff; color: var(--brand); box-shadow: 0 2px 10px rgba(36, 27, 56, .08); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  padding: 16px max(16px, 3vw) 110px;
  align-items: start;
}
.content { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 2px 14px rgba(36, 27, 56, .06);
  border: 1px solid #efeaf8;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }

/* Logo */
.logo-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.logo-preview {
  width: 110px;
  height: 110px;
  border-radius: 24px;
  border: 2px dashed var(--line);
  display: grid;
  place-items: center;
  font-size: 48px;
  overflow: hidden;
  background: repeating-conic-gradient(#f4f1fa 0 25%, #fff 0 50%) 0 0 / 16px 16px;
}
.logo-preview img { width: 90%; height: 90%; object-fit: contain; }
.logo-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; font-weight: 600; }

/* Premios (pensado para lectura fácil) */
.help-box {
  margin: 0 0 18px;
  padding: 16px 18px;
  border-radius: 14px;
  background: #fff8e6;
  border: 1px solid #ffe2a3;
  font-size: 16px;
  line-height: 1.55;
}
.help-box p { margin: 0 0 6px; }
.help-box ul { margin: 0; padding-left: 20px; }
.help-box li { margin: 4px 0; }

.prize-list { display: flex; flex-direction: column; gap: 14px; }
.prize-card {
  border-radius: 16px;
  background: #fff;
  border: 2px solid #ece6f8;
  border-left: 10px solid var(--c, #ccc);
  padding: 16px 18px;
  animation: rowIn .25s ease;
}
@keyframes rowIn { from { opacity: 0; transform: translateY(-6px); } }
.prize-card.soldout { background: #f7f5fa; }
.prize-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.prize-num {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f1ebfb;
  color: var(--brand);
  font-weight: 800;
}
.prize-top input[type="text"] { font-size: 18px; font-weight: 800; min-height: 50px; }
.prize-top .color-pick { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 800; color: var(--muted); }
.prize-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 620px; }
.prize-fields .f-type { grid-column: 1 / -1; order: -1; }
.prize-fields .field { margin: 0; font-size: 15px; }
.prize-fields select { font-size: 17px; min-height: 52px; font-weight: 700; }
.pct-wrap { position: relative; }
.pct-wrap input { font-size: 20px; font-weight: 800; min-height: 50px; padding-right: 40px; }
.pct-wrap::after { content: "%"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 20px; font-weight: 800; color: var(--muted); }
.stock-input { font-size: 18px !important; min-height: 50px !important; font-weight: 800 !important; }
.stock-input::placeholder { color: #9a92ad; font-weight: 700; font-size: 16px; }
.prize-note { margin: 10px 0 0; font-weight: 700; font-size: 15px; }
.prize-note.warn { color: #b15c00; }
.prize-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px dashed #e7e2f3; }
.prize-actions .btn { min-height: 40px; font-size: 14px; }

.total-bar {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 17px;
  font-weight: 800;
}
.total-bar.ok { background: #e3f8ee; color: #136b49; }
.total-bar.bad { background: #fff1e0; color: #8a4a00; }
.add-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 16px; }
.add-row .muted { margin: 0; }
.btn.big { min-height: 52px; font-size: 17px; padding: 0 24px; }

/* Colores */
.colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.color-field { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px; background: #faf8fe; border: 1px solid #eee8f8; }
.color-field b { display: block; font-size: 15px; }
.color-field small { color: var(--muted); font-weight: 600; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.preset {
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  box-shadow: 0 2px 10px rgba(36,27,56,.08);
  font: 800 14px "Nunito", sans-serif;
  color: var(--ink);
  transition: transform .15s;
}
.preset:hover { transform: translateY(-2px); }
.preset .sw { height: 56px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.preset .sw i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; }
.preset span { display: block; padding: 8px; }

/* Música */
.music-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pill { padding: 8px 14px; border-radius: 99px; background: #f1ebfb; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Historial */
.hist-filter { margin: 4px 0 14px; font-weight: 700; }
.hist-filter select { width: auto; margin-left: 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { padding: 14px; border-radius: 14px; background: #faf8fe; border: 1px solid #eee8f8; }
.stat b { display: block; font-family: var(--display); font-size: 28px; font-weight: 600; }
.stat span { color: var(--muted); font-weight: 700; font-size: 13px; }
.stat.hl { background: linear-gradient(135deg, #7b2cbf, #f72585); color: #fff; border: 0; }
.stat.hl span { color: rgba(255,255,255,.85); }
.stat .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.table-wrap { max-height: 460px; overflow: auto; border-radius: 12px; border: 1px solid var(--line); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { position: sticky; top: 0; background: #f6f3fc; text-align: left; padding: 10px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.table td { padding: 10px 12px; border-top: 1px solid #f0ecf7; font-weight: 600; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 800; }
.tag.win { background: #e3f8ee; color: var(--ok); }
.tag.lose { background: #f1eef6; color: var(--muted); }

/* Vista previa */
.preview { position: sticky; top: 140px; }
.preview-stage {
  border-radius: 14px;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--bg1, #3a0ca3), var(--bg2, #f72585));
  color: var(--text, #fff);
}
.preview-wheel-wrap { position: relative; width: 230px; height: 230px; }
#previewWheel { width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.preview-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--rim, #ffc300);
  display: grid;
  place-items: center;
  color: var(--button, #ff006e);
  font-size: 22px;
  overflow: hidden;
}
.preview-hub img { width: 80%; height: 80%; object-fit: contain; }
.preview-pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-top: 26px solid var(--rim, #ffc300);
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.4));
}
.preview-name { font-family: var(--display); font-size: 20px; text-align: center; }
.preview-btn {
  padding: 8px 26px;
  border-radius: 99px;
  font-family: var(--display);
  font-weight: 700;
  color: #fff;
  background: var(--button, #ff006e);
  box-shadow: 0 4px 0 rgba(0,0,0,.25);
}

/* Barra de guardado */
.savebar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 6;
  width: min(720px, calc(100% - 32px));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 10px 10px 20px;
  border-radius: 18px;
  background: #241b38;
  color: #fff;
  box-shadow: 0 14px 40px rgba(36, 27, 56, .35);
  font-weight: 700;
}
.savebar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.3); }
.savebar.dirty { background: linear-gradient(135deg, #3a0ca3, #7b2cbf); }
.savebar.dirty #saveStatus::before { content: "● "; color: #ffd166; }

/* Aviso */
.toast {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translate(-50%, -160%);
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border-radius: 14px;
  background: #241b38;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  visibility: hidden;
  transition: transform .35s cubic-bezier(.2,1.2,.4,1), visibility 0s .35s;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; transition-delay: 0s; }
.toast.err { background: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .preview { position: static; order: -1; }
  .preview-stage { flex-direction: row; justify-content: center; flex-wrap: wrap; }
  .preview-wheel-wrap { width: 170px; height: 170px; }
}
@media (max-width: 820px) {
  .prize-num { display: none; }
  .prize-actions { justify-content: stretch; }
  .prize-actions .btn { flex: 1; }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .topbar { padding: 10px 12px; }
  .topbar-brand { gap: 8px; }
  .topbar-brand strong { font-size: 15px; }
  .topbar-brand small { display: none; }
  .topbar-logo { width: 36px; height: 36px; font-size: 20px; }
  .topbar-actions { flex: none; gap: 6px; }
  .topbar .btn { padding: 0 10px; font-size: 13px; min-height: 36px; }
  .card { padding: 18px 16px; }
  .savebar { padding: 8px 8px 8px 14px; flex-wrap: nowrap; font-size: 13px; bottom: 10px; }
  .savebar .btn { padding: 0 10px; font-size: 13px; min-height: 38px; }
}
.savebar .row-gap { flex-wrap: nowrap; }
.savebar #saveStatus { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

