:root {
  color-scheme: dark;

  --bg: #0D0806;
  --bg-2: #160E0A;
  --mud-1: #4A2614;
  --mud-2: #2A150B;
  --surface: rgba(255, 236, 220, 0.055);
  --surface-strong: rgba(255, 236, 220, 0.09);
  --surface-solid: #1C130E;
  --border: rgba(255, 220, 190, 0.13);
  --border-strong: rgba(255, 220, 190, 0.24);

  --text: #FFF4EA;
  --text-2: #E2CDBB;
  --muted: #B09886;

  --clay: #FF7A3D;
  --amber: #FFB547;
  --hot: #FF4D6D;
  --violet: #B57BFF;
  --on-brand: #1A0D06;
  --brand-gradient: linear-gradient(115deg, #FF7A3D 0%, #FFB547 45%, #FF4D6D 100%);

  --st-undefined: #FF5A4E;
  --st-pending: #FFC93C;
  --st-confirmed: #7CF29A;

  --danger: #FF8A80;
  --danger-soft: rgba(255, 90, 78, 0.14);

  --font-display: "Unbounded", "Plus Jakarta Sans", system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-sheet: 28px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 68px;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: 8px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.text-gradient {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Secciones ---------- */

.section {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 72px 20px 8px;
}

.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
}

.section-eyebrow::before {
  content: "";
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand-gradient);
}

.section-title {
  margin-top: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(30px, 9vw, 44px);
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.section-lead {
  margin-top: 12px;
  color: var(--text-2);
  font-size: 15px;
}

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.25;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 150ms var(--ease-out), background-color 200ms, border-color 200ms, opacity 200ms;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }

.btn-primary {
  position: relative;
  overflow: hidden;
  background: var(--brand-gradient);
  color: var(--on-brand);
  box-shadow: 0 10px 30px -10px rgba(255, 106, 61, 0.65);
}

.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: shine 3.8s var(--ease-out) infinite 1.2s;
}

.btn-secondary {
  background: var(--surface-strong);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost { background: transparent; color: var(--text-2); }

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger {
  background: #E5483C;
  color: #fff;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  transition: transform 150ms var(--ease-out);
}

.icon-btn:active { transform: scale(0.94); }

/* ---------- Chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  background: var(--surface-strong);
  color: var(--text-2);
}

.chip-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.chip.st-undefined { color: var(--st-undefined); background: rgba(255, 90, 78, 0.12); }
.chip.st-pending { color: var(--st-pending); background: rgba(255, 201, 60, 0.12); }
.chip.st-confirmed { color: var(--st-confirmed); background: rgba(124, 242, 154, 0.12); }
.chip.chip-hot { color: var(--hot); background: rgba(255, 77, 109, 0.14); }

/* ---------- Avatares ---------- */

.avatar {
  --size: 40px;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--avatar-bg);
  color: var(--on-brand);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: calc(var(--size) * 0.36);
  letter-spacing: -0.02em;
  box-shadow: 0 0 0 2px var(--bg);
}

.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { --size: 24px; margin-left: -7px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

.m-0 { --avatar-bg: linear-gradient(135deg, #FF7A3D, #FFC46B); }
.m-1 { --avatar-bg: linear-gradient(135deg, #FF4D6D, #FF9E8A); }
.m-2 { --avatar-bg: linear-gradient(135deg, #B57BFF, #F09BFF); }
.m-3 { --avatar-bg: linear-gradient(135deg, #4FD1FF, #9CF0FF); }
.m-4 { --avatar-bg: linear-gradient(135deg, #7CF29A, #D9FF8A); }
.m-5 { --avatar-bg: linear-gradient(135deg, #FFD23F, #FFF0A3); }

/* ---------- Tarjetas ---------- */

.card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 236, 220, 0.07), rgba(255, 236, 220, 0.03));
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

/* ---------- Campos ---------- */

.field { display: grid; gap: 6px; }

.field-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-size: 16px;
  transition: border-color 200ms;
}

.input:focus { outline: none; border-color: var(--amber); }
textarea.input { min-height: 90px; resize: vertical; }
select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23E2CDBB' viewBox='0 0 16 16'%3E%3Cpath d='M1.6 4.6a.75.75 0 0 1 1.06 0L8 9.94l5.34-5.34a.75.75 0 1 1 1.06 1.06l-5.87 5.87a.75.75 0 0 1-1.06 0L1.6 5.66a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.input::-webkit-calendar-picker-indicator { filter: invert(0.85); }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
}

.segmented button {
  min-height: 42px;
  padding: 0 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-2);
  font-weight: 700;
  font-size: 13px;
  transition: background-color 200ms, color 200ms;
}

.segmented button[aria-pressed="true"],
.segmented button[aria-selected="true"] {
  background: var(--text);
  color: var(--on-brand);
}

.switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-strong);
  transition: background-color 200ms;
}

.switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 250ms var(--ease-spring);
}

.switch[aria-checked="true"] { background: var(--clay); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* ---------- Hojas ---------- */

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(8, 4, 2, 0.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fade-in 250ms var(--ease-out);
}

.sheet-overlay.is-closing { animation: fade-out 220ms ease forwards; }
.sheet-overlay.is-closing .sheet { animation: sheet-down 220ms ease forwards; }

.sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: calc(100svh - var(--safe-top) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 20px calc(20px + var(--safe-bottom));
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  background: var(--surface-solid);
  box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, 0.8);
  animation: sheet-up 380ms var(--ease-out);
}

.sheet-handle {
  width: 40px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: var(--border-strong);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.sheet-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.sheet-body { display: grid; gap: 16px; }
.sheet-actions { display: grid; gap: 10px; margin-top: 22px; }

/* ---------- Avisos ---------- */

.toast-stack {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: 50%;
  z-index: 90;
  display: grid;
  gap: 8px;
  width: min(calc(100% - 32px), 420px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--amber);
  border-radius: 14px;
  background: rgba(28, 19, 14, 0.88);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.8);
  animation: toast-in 350ms var(--ease-spring);
}

.toast.is-error { border-left-color: var(--st-undefined); }
.toast.is-success { border-left-color: var(--st-confirmed); }
.toast.is-leaving { animation: fade-out 250ms ease forwards; }

/* ---------- Estados ---------- */

.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 32px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--text-2);
}

.empty i { font-size: 30px; color: var(--amber); }
.empty strong { color: var(--text); font-size: 16px; }

.skeleton {
  border-radius: var(--radius-lg);
  background: linear-gradient(100deg, var(--surface) 40%, var(--surface-strong) 50%, var(--surface) 60%);
  background-size: 200% 100%;
  animation: skeleton 1.4s linear infinite;
}

#confetti {
  position: fixed;
  inset: 0;
  z-index: 95;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- Animaciones ---------- */

@keyframes shine { 0%, 60% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px) scale(0.96); } }
@keyframes skeleton { to { background-position: -200% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-8px); } 40%, 60% { transform: translateX(8px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 currentColor; } 100% { box-shadow: 0 0 0 12px transparent; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-delay: 0s !important;
    transition-duration: 0.01ms !important;
  }
}
