:root {
  --accent: #7a4d2d;
  --ink: #20242b;
  --muted: #6d7480;
  --paper: #fbf6ed;
  --line: #e4d8c7;
  --panel: #fffaf2;
  --nav: #263b52;
  --success: #1f7a55;
  --danger: #b93838;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--ink); background: #f4ede2; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
textarea { min-height: 96px; resize: vertical; }
[hidden] { display: none !important; }

.cover {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 10%, #fff8eb 0, #fff8eb 24%, transparent 25%), linear-gradient(135deg, #f5ead8 0%, #d7c2a3 52%, #25394e 100%);
}

.book-cover {
  width: min(1080px, 100%);
  min-height: min(680px, calc(100vh - 48px));
  display: grid;
  align-content: space-between;
  padding: clamp(24px, 5vw, 56px);
  color: #fff8eb;
  background: linear-gradient(135deg, rgba(61,38,22,.94), rgba(122,77,45,.92) 55%, rgba(32,49,68,.96)), url("/assets/img/logo.svg") right 8% bottom 10% / min(360px, 55vw) no-repeat;
  border: 1px solid rgba(255,255,255,.25);
  box-shadow: 0 30px 80px rgba(29, 24, 18, .32), inset 18px 0 0 rgba(255,255,255,.08);
  border-radius: 8px;
}

.brand-row { display: flex; gap: 12px; align-items: center; }
.brand-row span { display: block; color: rgba(255,255,255,.7); font-size: 13px; }
.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #caa56a, #7a4d2d 55%, #263b52);
  color: #fff8eb;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}

.cover-content { max-width: 680px; padding: 80px 0 48px; }
.eyebrow { color: #e8c67d; margin: 0 0 12px; font-weight: 800; text-transform: uppercase; font-size: 12px; }
.cover h1 { font-size: clamp(40px, 7vw, 76px); line-height: .98; margin: 0 0 22px; letter-spacing: 0; }
.cover p { font-size: 18px; line-height: 1.65; max-width: 620px; }
.install-note { color: rgba(255,250,242,.76); font-size: 14px !important; margin-top: 14px; }
.actions, .topbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.feature-strip { display: flex; gap: 12px; flex-wrap: wrap; color: rgba(255,255,255,.78); }
.feature-strip span { border: 1px solid rgba(255,255,255,.25); padding: 8px 12px; border-radius: 999px; }

.btn {
  border: 0;
  border-radius: 8px;
  padding: 12px 18px;
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn.primary { background: var(--accent); color: #fffaf2; }
.btn.ghost { background: rgba(255,255,255,.12); color: inherit; border: 1px solid rgba(127,95,60,.3); }
.text-link { display: inline-block; margin-top: 18px; color: var(--accent); font-weight: 700; }

.auth-page, .install-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #f5ead8, #ffffff 55%, #dfe7ec);
}
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card, .panel, .hero-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(45, 35, 24, .08);
}
.auth-card { width: min(440px, 100%); padding: 32px; }
.auth-card h1 { margin: 18px 0 8px; }
.auth-card p { color: var(--muted); line-height: 1.55; }

.stack-form, .grid-form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; color: #39424f; font-weight: 700; font-size: 13px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #d4c6b5;
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}
.grid-form { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.grid-form .wide { grid-column: 1 / -1; }

.alert { padding: 12px 14px; border-radius: 8px; margin: 0 0 16px; font-weight: 700; }
.alert.success { background: #e9f8f0; color: var(--success); }
.alert.danger { background: #fff0ee; color: var(--danger); }

.app-body { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: #f6efe6; }
.menu-toggle {
  display: block;
  position: fixed;
  z-index: 30;
  left: 14px;
  top: calc(12px + env(safe-area-inset-top));
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: #263b52;
  box-shadow: 0 10px 24px rgba(22, 20, 18, .22);
  cursor: pointer;
}
.menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  margin: 5px auto;
  background: #fffaf2;
  border-radius: 999px;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 18;
  background: rgba(15, 19, 24, .46);
}
.sidebar {
  position: fixed;
  z-index: 20;
  left: 0;
  top: 0;
  bottom: 0;
  width: min(320px, 86vw);
  height: 100vh;
  padding: 76px 22px 22px;
  color: #fffaf2;
  background: linear-gradient(180deg, #25394e, #32241b);
  transform: translateX(-105%);
  transition: transform .22s ease;
  box-shadow: 18px 0 38px rgba(22, 20, 18, .24);
}
body.menu-open .sidebar { transform: translateX(0); }
body.menu-open .sidebar-backdrop { display: block; }
.sidebar .brand-row {
  position: absolute;
  top: 18px;
  left: 74px;
  right: 14px;
}
.sidebar nav { display: grid; gap: 6px; margin-top: 28px; }
.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: rgba(255,250,242,.78);
  padding: 11px 12px;
  border-radius: 8px;
  font-weight: 700;
}
.nav-icon {
  display: none;
  width: 28px;
  height: 24px;
  place-items: center;
  border-radius: 7px;
  background: rgba(255,255,255,.12);
  font-size: 10px;
  font-weight: 900;
}
.sidebar a.active, .sidebar a:hover { background: rgba(255,255,255,.12); color: #fff; }
.workspace { padding: 26px; min-width: 0; }
.topbar { justify-content: space-between; margin-bottom: 22px; padding-left: 56px; }
.topbar h1 { margin: 0; font-size: clamp(26px, 4vw, 42px); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-grid article {
  background: #fffaf2;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.metric-grid span { color: var(--muted); font-weight: 700; }
.metric-grid strong { display: block; font-size: 34px; margin-top: 6px; }
.hero-panel, .panel { padding: 22px; margin-bottom: 18px; }
.hero-panel h2 { margin: 0 0 8px; font-size: clamp(26px, 4vw, 44px); }
.hero-panel p { color: var(--muted); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.list-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.list-item strong, .list-item span { display: block; }
.list-item span, .muted, small { color: var(--muted); }
.list-item p { margin: 8px 0 0; color: #3d4651; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
td small { display: block; margin-top: 4px; }
.badge { padding: 5px 9px; border-radius: 999px; background: #ece2d6; font-size: 12px; font-weight: 800; }
.badge.activo { background: #e9f8f0; color: var(--success); }
.badge.suspendido, .badge.vencido, .badge.pendiente { background: #fff0ee; color: var(--danger); }

.user-list { display: grid; gap: 18px; }
.user-row {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, minmax(120px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
fieldset { border: 1px solid var(--line); border-radius: 8px; grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 12px; }
.check { display: flex; grid-auto-flow: column; align-items: center; gap: 6px; }
.check input { width: auto; }
.reset-form { display: flex; gap: 10px; max-width: 520px; margin-left: 14px; }

.evidence-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.evidence-card {
  background: #fffaf2;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.evidence-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; margin: 10px 0; }

.plans-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #f8f2e8 0%, #ffffff 55%, #e2ebef 100%);
}
.plans-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px;
}
.plans-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 48px;
}
.plans-header .brand-row {
  text-decoration: none;
  color: var(--ink);
}
.plans-header .brand-row span { color: var(--muted); }
.plans-intro {
  max-width: 760px;
  margin-bottom: 24px;
}
.plans-intro h1 {
  margin: 0 0 16px;
  font-size: clamp(38px, 6vw, 68px);
  line-height: 1;
  letter-spacing: 0;
}
.plans-intro p {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
}
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}
.price-card {
  position: relative;
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 100%;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  box-shadow: 0 18px 42px rgba(45, 35, 24, .08);
}
.price-card.featured {
  background: linear-gradient(180deg, #fffaf2, #f1e2ca);
  border-color: #caa56a;
}
.price-card h2 { margin: 0; font-size: 28px; }
.price-card strong { font-size: 22px; color: var(--accent); }
.price-card p { color: var(--muted); line-height: 1.5; margin: 0; }
.price-card ul {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0 0 8px;
  list-style: none;
}
.price-card li {
  padding-left: 22px;
  position: relative;
  color: #39424f;
}
.price-card li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .55em;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.plan-badge {
  width: max-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: #263b52;
  color: #fffaf2;
  font-size: 12px;
  font-weight: 900;
}
.upgrade-card {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 20px;
  margin-bottom: 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #263b52, #7a4d2d);
  color: #fffaf2;
  box-shadow: 0 18px 42px rgba(45, 35, 24, .14);
}
.upgrade-card h2 { margin: 0 0 8px; font-size: 24px; }
.upgrade-card p { margin: 0; color: rgba(255,250,242,.82); line-height: 1.5; }
.upgrade-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.upgrade-card .btn.ghost { border-color: rgba(255,255,255,.32); }
.plan-chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 900;
  border: 1px solid var(--line);
}
.plan-chip.pro {
  background: #e9f8f0;
  color: var(--success);
  border-color: #b9e4cf;
}
.plan-chip.free {
  background: #fff0ee;
  color: var(--danger);
  border-color: #f1c4bf;
}
.plan-status {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 22px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}
.plan-status.paid {
  border-color: #b9e4cf;
  background: linear-gradient(135deg, #effaf4, #fffaf2);
}
.plan-status.free {
  border-color: #f1c4bf;
  background: linear-gradient(135deg, #fff4f1, #fffaf2);
}
.plan-status h2 { margin: 0 0 8px; font-size: 28px; }
.plan-status p { margin: 0; color: var(--muted); line-height: 1.5; }
.plan-limits {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
}
.plan-limits span {
  padding: 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  border: 1px solid var(--line);
  font-weight: 800;
  text-align: center;
}
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.module-grid article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}
.module-grid strong, .module-grid span { display: block; }
.module-grid span { margin-top: 6px; color: var(--muted); line-height: 1.45; }
.collection-list {
  display: grid;
  gap: 14px;
}
.collection-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  box-shadow: 0 12px 30px rgba(45, 35, 24, .06);
}
.collection-card h2 {
  margin: 8px 0 4px;
  font-size: 22px;
}
.collection-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}
.money-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.money-grid span {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}
.money-grid strong {
  color: var(--ink);
  font-size: 20px;
}
.collection-note {
  padding: 12px;
  border-radius: 8px;
  background: #f6efe6;
}
.collection-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.badge.abonado, .badge.reprogramado { background: #fff7df; color: #9b6b12; }
.badge.pagado { background: #e9f8f0; color: var(--success); }
.badge.no_estaba { background: #eef3f7; color: #425466; }
.stage-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  margin-bottom: 18px;
  border-radius: 8px;
  color: #fffaf2;
  background: linear-gradient(135deg, #1f2937, #7a4d2d);
  box-shadow: 0 18px 42px rgba(45, 35, 24, .14);
}
.stage-hero h2 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 44px);
}
.stage-hero p {
  margin: 0;
  color: rgba(255,250,242,.82);
  line-height: 1.5;
}
.stage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.stage-song, .stage-event {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.stage-song:last-child, .stage-event:last-child { border-bottom: 0; }
.stage-song strong, .stage-song span, .stage-event strong, .stage-event span {
  display: block;
}
.stage-song span, .stage-event span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 920px) {
  body { background: #fbf6ed; }
  .app-body { grid-template-columns: 1fr; }
  .sidebar {
    width: min(320px, 86vw);
    height: 100svh;
    padding: calc(72px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
    border-right: 1px solid rgba(255,255,255,.14);
  }
  .sidebar .brand-row {
    top: calc(14px + env(safe-area-inset-top));
    left: 74px;
    right: 14px;
  }
  .sidebar nav {
    margin: 0;
    display: grid;
    grid-auto-flow: row;
    grid-auto-columns: auto;
    overflow: visible;
    gap: 7px;
  }
  .sidebar a {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    padding: 12px;
    font-size: 14px;
    min-height: 46px;
  }
  .nav-icon { display: grid; }
  .workspace { padding: 16px; }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 4;
    margin: -16px -16px 16px;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px 68px;
    background: rgba(251, 246, 237, .94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
  }
  .topbar h1 { font-size: 24px; }
  .topbar-actions .btn { min-height: 38px; padding: 9px 12px; font-size: 13px; }
  .metric-grid, .split, .evidence-grid, .module-grid, .stage-grid { grid-template-columns: 1fr; }
  .pricing-grid { grid-template-columns: 1fr; }
  .grid-form, .user-row { grid-template-columns: 1fr; }
  .panel, .hero-panel { padding: 16px; }
  .metric-grid article { padding: 15px; }
  .cover { padding: 0; min-height: 100svh; }
  .book-cover {
    min-height: 100svh;
    width: 100%;
    border-radius: 0;
    padding: calc(22px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
    background-position: right -24px bottom 16px;
    background-size: 260px;
  }
  .cover-content { padding: 48px 0 30px; }
  .cover h1 { font-size: 42px; line-height: 1; }
  .cover p { font-size: 16px; line-height: 1.55; }
  .actions { display: grid; grid-template-columns: 1fr; }
  .btn { width: 100%; }
  .feature-strip { gap: 8px; }
  .feature-strip span { font-size: 12px; padding: 7px 10px; }
  .auth-shell { align-items: stretch; padding: 0; }
  .auth-card {
    width: 100%;
    min-height: 100svh;
    border-radius: 0;
    display: grid;
    align-content: center;
    padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  }
  .plans-shell {
    padding: calc(18px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  }
  .plans-header {
    align-items: flex-start;
    margin-bottom: 34px;
  }
  .plans-header .actions { justify-content: flex-end; }
  .plans-header .btn { width: auto; }
  .plans-intro h1 { font-size: 38px; }
  .plans-intro p { font-size: 16px; }
  .price-card { padding: 18px; }
  .upgrade-card {
    display: grid;
    padding: 16px;
  }
  .upgrade-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .plan-status { display: grid; padding: 16px; }
  .plan-limits { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .money-grid { grid-template-columns: 1fr; }
  .collection-actions .btn { width: 100%; }
  .stage-hero { display: grid; padding: 16px; }
}
