:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --line: #e2dfd7;
  --text: #1c1b19;
  --muted: #6b6860;
  --accent: #a92025;
  --accent-ink: #ffffff;

  --st-confirmado: #15803d;
  --st-aceptada: #2563eb;
  --st-provisional: #7c3aed;
  --st-disponibles: #0d9488;
  --st-esperando: #d97706;
  --st-abierto: #78716c;
  --st-cancelado: #b91c1c;
  --st-no: #b91c1c;

  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 16px rgb(0 0 0 / .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412; --surface: #1d1c1a; --surface-2: #262522; --line: #34322e;
    --text: #f2f0eb; --muted: #a29e95; --accent: #e0464b;
    --st-confirmado: #22c55e; --st-aceptada: #60a5fa; --st-provisional: #a78bfa;
    --st-disponibles: #2dd4bf; --st-esperando: #fbbf24; --st-abierto: #a8a29e; --st-cancelado: #f87171; --st-no: #f87171;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* ---------- Estructura ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
}
.topbar-inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 16px; }
.brand { font-weight: 800; letter-spacing: -.02em; font-size: 17px; display: flex; gap: 8px; align-items: center; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.brand-logo { width: 38px; height: 38px; border-radius: 9px; background: #fff; object-fit: contain; flex: none; box-shadow: 0 0 0 1px var(--line); }
.login-logo { width: 120px; height: 120px; border-radius: 22px; background: #fff; display: block; margin: 0 auto 4px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  text-decoration: none; padding: 8px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 14px;
}
.nav a.on { background: var(--text); color: var(--bg); }
main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 110px; }

@media (max-width: 760px) {
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; margin: 0; justify-content: space-around;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; padding: 6px 8px; border-radius: 10px; }
  .nav a.on { background: var(--surface-2); color: var(--text); }
  .nav .ico { font-size: 19px; line-height: 1; }
}
@media (min-width: 761px) { .nav .ico { display: none; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 10px; }

/* ---------- Botones y formularios ---------- */
button, .btn {
  font: inherit; font-weight: 650; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 10px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; gap: 6px; justify-content: center; min-height: 40px; user-select: none; touch-action: manipulation;
  transition: transform .12s ease-out, background-color .15s;
}
button:active, .btn:active { transform: scale(.97); }
button:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-dark { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--st-cancelado); }
.btn-wa { background: #25d366; border-color: #25d366; color: #0b2e17; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: 13px; border-radius: 8px; }
@media (hover: hover) { button:hover, .btn:hover { filter: brightness(.97); } }

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  font: inherit; font-size: 16px; width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
}
textarea { min-height: 70px; resize: vertical; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; color: var(--text); font-weight: 500; cursor: pointer; }

/* ---------- Estados ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.st-confirmado { --c: var(--st-confirmado); }
.st-aceptada { --c: var(--st-aceptada); }
.st-provisional { --c: var(--st-provisional); }
.st-disponibles { --c: var(--st-disponibles); }
.st-esperando { --c: var(--st-esperando); }
.st-abierto { --c: var(--st-abierto); }
.st-nadie { --c: var(--st-cancelado); }
.st-cancelado { --c: var(--st-cancelado); }
.st-si { --c: var(--st-confirmado); }
.st-no { --c: var(--st-no); }
.st-pendiente { --c: var(--st-esperando); }

/* ---------- Inicio ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(4, 1fr); }
@media (max-width: 960px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { border-top: 4px solid var(--c); padding: 14px; }
.kpi-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.kpi-num { font-size: 34px; font-weight: 800; letter-spacing: -.03em; color: var(--c); line-height: 1; }
.kpi-label { font-weight: 700; font-size: 14px; }
.kpi ul { list-style: none; margin: 10px 0 0; padding: 0; }
.kpi li a {
  display: flex; justify-content: space-between; gap: 8px; text-decoration: none; padding: 6px 0;
  border-top: 1px dashed var(--line); font-size: 13px;
}
.kpi li a span:last-child { color: var(--muted); text-align: right; }
.kpi .empty { font-size: 13px; color: var(--muted); margin-top: 10px; }
@media (max-width: 520px) {
  .kpi { padding: 12px; }
  .kpi-num { font-size: 28px; }
  .kpi ul { display: none; }
}

.alert {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); background: color-mix(in srgb, var(--c) 10%, var(--surface));
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px;
}

/* ---------- Calendario ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; padding: 4px 0; }
.cal-day {
  min-height: 92px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px;
  display: flex; flex-direction: column; gap: 4px; cursor: pointer; text-align: left; overflow: hidden;
}
.cal-day.out { opacity: .35; }
.cal-day.past { background: var(--surface-2); cursor: default; }
.cal-day.today .cal-num { background: var(--accent); color: var(--accent-ink); }
.cal-num { font-size: 12px; font-weight: 700; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-day .add { margin-top: auto; font-size: 12px; color: var(--muted); opacity: 0; }
@media (hover: hover) { .cal-day:not(.past):hover .add { opacity: 1; } }
.pill {
  display: block; font-size: 11.5px; font-weight: 650; padding: 3px 6px; border-radius: 6px; text-decoration: none;
  background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--c); border-left: 3px solid var(--c);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 640px) {
  .cal { gap: 2px; }
  .cal-day { min-height: 54px; padding: 3px; border-radius: 8px; align-items: center; }
  .pill { width: 9px; height: 9px; padding: 0; border: 0; border-radius: 50%; background: var(--c); font-size: 0; display: inline-block; }
  .pills { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
}
.legend { display: flex; gap: 10px 14px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Lista de huecos ---------- */
.slot-row {
  display: grid; grid-template-columns: 74px 1fr auto; gap: 12px; align-items: center; text-decoration: none;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.slot-row + .slot-row { margin-top: 8px; }
.datebox { text-align: center; border-radius: 10px; background: var(--surface-2); padding: 6px 4px; }
.datebox b { display: block; font-size: 22px; line-height: 1; }
.datebox span { font-size: 11px; text-transform: uppercase; font-weight: 700; color: var(--muted); }

/* ---------- Detalle de hueco ---------- */
.band-row { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface); }
.band-row + .band-row { margin-top: 8px; }
.band-row.best { border-color: var(--st-disponibles); box-shadow: 0 0 0 2px color-mix(in srgb, var(--st-disponibles) 25%, transparent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 3px 9px 3px 4px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.chip i {
  font-style: normal; width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800;
  background: var(--line); color: var(--muted);
}
.chip.a-si i { background: var(--st-confirmado); color: #fff; }
.chip.a-no i { background: var(--st-no); color: #fff; }
.chip.a-duda i { background: var(--st-esperando); color: #fff; }
.chip.stale { border-style: dashed; }
.chip .opt { color: var(--muted); font-size: 11px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.timeline li { padding: 6px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 120px 1fr; gap: 10px; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Diálogos ---------- */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(620px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / .3);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dlg-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dlg-body { padding: 16px 18px; }
.dlg-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--surface); }
@media (max-width: 640px) {
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 92dvh; }
  .dlg-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 100; box-shadow: 0 8px 24px rgb(0 0 0 / .25);
  max-width: calc(100vw - 32px); animation: pop .18s ease-out;
}
.toast.err { background: var(--st-cancelado); color: #fff; }

/* ---------- Login ---------- */
.login { max-width: 380px; margin: 12vh auto; }

/* ---------- Acceso de bandas y músicos ---------- */
.answer-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.answer-btns button { min-height: 50px; flex-direction: column; gap: 0; font-size: 14px; }
.answer-btns button .e { font-size: 18px; }
.answer-btns button.on.a-si { background: var(--st-confirmado); border-color: var(--st-confirmado); color: #fff; }
.answer-btns button.on.a-no { background: var(--st-no); border-color: var(--st-no); color: #fff; }
.answer-btns button.on.a-duda { background: var(--st-esperando); border-color: var(--st-esperando); color: #fff; }
.proposal { border: 2px solid var(--st-provisional); }
.proposal.accepted { border-color: var(--st-aceptada); }
.proposal.confirmed { border-color: var(--st-confirmado); }
.countdown { font-weight: 800; color: var(--st-provisional); }
.member-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.mini-btns { display: flex; gap: 4px; }
.mini-btns button { min-height: 32px; min-width: 38px; padding: 4px 8px; font-size: 13px; }
.mini-btns button.on.a-si { background: var(--st-confirmado); color: #fff; border-color: transparent; }
.mini-btns button.on.a-no { background: var(--st-no); color: #fff; border-color: transparent; }
.mini-btns button.on.a-duda { background: var(--st-esperando); color: #fff; border-color: transparent; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.cap { display: block; }
.cap::first-letter { text-transform: uppercase; }
.saved-note { margin-top: 8px; color: var(--st-confirmado); font-weight: 600; }
.answer-btns button:disabled, .mini-btns button:disabled { opacity: 1; }
.group-box { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.who-list { display: grid; gap: 10px; margin-top: 16px; }
.who-btn { justify-content: space-between; min-height: 58px; padding: 12px 16px; font-size: 17px; border-radius: 14px; background: var(--surface); }
.share-box { border-top: 4px solid #25d366; }
.share-box p { margin: 6px 0 12px; }

/* ---------- Siguiente paso ---------- */
.next-step { border: 2px solid var(--accent); }
.next-step.done { border-color: var(--st-confirmado); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; counter-reset: none; }
.steps li { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; color: var(--muted); text-align: center; position: relative; }
.steps li span { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 2px solid var(--line); font-size: 12px; font-weight: 800; }
.steps li.ok { color: var(--st-confirmado); }
.steps li.ok span { background: var(--st-confirmado); border-color: var(--st-confirmado); color: #fff; }
.steps li.now { color: var(--text); }
.steps li.now span { border-color: var(--accent); color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

/* ---------- Músico: enviar y confirmación ---------- */
.send-bar {
  position: sticky; bottom: 0; margin: 16px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}
.send-btn { width: 100%; min-height: 54px; font-size: 17px; border-radius: 14px; }
.thanks { text-align: center; padding: 28px 18px; }
.thanks-icon {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 12px; display: grid; place-items: center;
  background: var(--st-confirmado); color: #fff; font-size: 38px; font-weight: 800; animation: pop .25s ease-out;
}
.thanks-list { text-align: left; margin: 16px 0 8px; }
.join-box { margin-top: 18px; border-top: 4px solid var(--accent); }
