:root {
  --bg: #ffffff;
  --surface: #fbf7f4;
  --line: #ede3e6;
  --line-strong: #d9c7cf;
  --ink: #1e1418;
  --ink-2: #3a2e33;
  --muted: #6e5c66;
  --gold: #d9b36c;
  --gold-ink: #8c6a2e;
  --pink: #e893b4;
  --pink-ink: #b4467a;
  --danger-bg: #fdecef;
  --danger-ink: #8a1f3d;
  --ok-ink: #2f6b4a;
  --radius: 16px;
  --font: 'DM Sans', system-ui, sans-serif;
  --display: 'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; -webkit-text-size-adjust: 100%; }
img { max-width: 100%; display: block; }
a { color: var(--gold-ink); }
a:hover { color: #6b4e1f; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Estructura de pantalla tipo app */
.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.page { flex: 1; padding: 20px 20px 28px; display: flex; flex-direction: column; gap: 18px; }
.topbar { display: flex; align-items: center; gap: 12px; }
.topbar h1 { font-family: var(--display); font-weight: 600; font-size: 22px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--pink-ink); }
.label { font-size: 13px; font-weight: 700; color: var(--pink-ink); }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* Encabezado con foto y firma */
.brand { display: flex; align-items: center; gap: 12px; }
.avatar { width: 72px; height: 72px; flex-shrink: 0; border-radius: 50%; padding: 3px; background: linear-gradient(180deg, #f3dca4, #b38943); box-shadow: 0 4px 0 #8a6a30, 0 8px 16px rgba(107, 78, 31, .25); }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.brand .logo { width: min(262px, 100%); height: auto; }

/* Botones 3D */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 20px; border-radius: var(--radius); font-weight: 700; font-size: 16px; text-decoration: none; border: 0; cursor: pointer; transition: transform .08s, box-shadow .08s; -webkit-tap-highlight-color: transparent; }
.btn.spread { justify-content: space-between; }
.btn.sm { min-height: 44px; font-size: 14px; padding: 0 14px; border-radius: 12px; }
.btn.round { width: 44px; min-height: 44px; height: 44px; padding: 0; border-radius: 12px; }
.btn:disabled { cursor: not-allowed; opacity: .55; }
.b3g { background: linear-gradient(180deg, #f3dca4 0%, #d9b36c 48%, #b38943 100%); color: #1a1208; box-shadow: inset 0 2px 0 rgba(255,255,255,.6), inset 0 -3px 0 rgba(0,0,0,.2), 0 6px 0 #8a6a30, 0 12px 20px rgba(107,78,31,.28); }
.b3g:active:not(:disabled) { transform: translateY(5px); box-shadow: inset 0 2px 0 rgba(255,255,255,.5), 0 1px 0 #8a6a30, 0 3px 8px rgba(107,78,31,.25); }
.b3g:hover { color: #1a1208; }
.b3p { background: linear-gradient(180deg, #f8cadb 0%, #e893b4 48%, #c45f8a 100%); color: #2a0c1a; box-shadow: inset 0 2px 0 rgba(255,255,255,.55), inset 0 -3px 0 rgba(0,0,0,.18), 0 6px 0 #9a4068, 0 12px 20px rgba(154,64,104,.25); }
.b3p:active:not(:disabled) { transform: translateY(5px); box-shadow: inset 0 2px 0 rgba(255,255,255,.5), 0 1px 0 #9a4068, 0 3px 8px rgba(154,64,104,.25); }
.b3p:hover { color: #2a0c1a; }
.b3ig { background: linear-gradient(135deg, #f9a13a 0%, #e1306c 45%, #9b2fbf 80%, #5b51d8 100%); color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.35); box-shadow: inset 0 2px 0 rgba(255,255,255,.45), inset 0 -3px 0 rgba(0,0,0,.2), 0 5px 0 #6a2287, 0 10px 18px rgba(106,34,135,.25); border-radius: 22px; min-height: 44px; font-size: 14px; padding: 0 16px 0 12px; }
.b3ig:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255,255,255,.4), 0 1px 0 #6a2287, 0 3px 8px rgba(106,34,135,.25); }
.b3ig:hover { color: #fff; }
.b3d { background: linear-gradient(180deg, #ffffff 0%, #f4eef0 100%); color: var(--ink); border: 1px solid #e3d6db; box-shadow: inset 0 1px 0 #fff, 0 4px 0 #d4c3ca, 0 8px 14px rgba(30,20,24,.10); }
.b3d:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 1px 0 #fff, 0 1px 0 #d4c3ca, 0 3px 6px rgba(30,20,24,.10); }
.b3d:hover { color: var(--ink); }
.b3x { background: #f4f0f2; color: #8a7f86; border: 1px solid #ede7ea; box-shadow: none; cursor: not-allowed; text-decoration: line-through; }
.btn-col { display: flex; flex-direction: column; gap: 16px; padding-bottom: 6px; }

/* Tarjetas */
.card { padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.card.gold { border-color: #e2c98f; background: #fffaf0; }
.card h2 { font-size: 17px; }
.alert { padding: 10px 12px; border-radius: 12px; background: var(--danger-bg); color: var(--danger-ink); font-size: 13px; line-height: 1.45; border: 1px solid #f3c6d2; }
.notice { padding: 12px 14px; border-radius: 12px; background: #fffaf0; border: 1px solid #e2c98f; font-size: 14px; line-height: 1.5; }

/* Publicidad */
.ad { display: block; border-radius: 18px; overflow: hidden; border: 1px solid #e3d6db; box-shadow: 0 6px 0 #e3d6db, 0 14px 26px rgba(30,20,24,.15); background: var(--surface); }
.ad img { width: 100%; height: auto; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.input { width: 100%; min-height: 46px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: #fff; font-size: 16px; }
textarea.input { padding: 10px 12px; min-height: 90px; resize: vertical; }
.input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 12px 8px; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 22px; font-weight: 700; font-size: 14px; }
.file-btn { position: relative; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Días */
.days { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scroll-snap-type: x mandatory; }
.day { flex: 0 0 66px; flex-direction: column; gap: 0; min-height: 0; padding: 10px 0; border-radius: 14px; text-align: center; scroll-snap-align: start; cursor: pointer; }
.day span { display: block; }
.day .n { font-size: 18px; font-weight: 700; }
.day .f { font-size: 11px; }
.slot { min-height: 46px; border-radius: 14px; font-size: 15px; font-weight: 700; }

/* Barra inferior fija */
.footbar { position: sticky; bottom: 0; padding: 14px 20px calc(18px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(6px); }
.nav { position: sticky; bottom: 0; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); border-top: 1px solid var(--line); background: #fff; font-size: 12px; text-align: center; padding-bottom: env(safe-area-inset-bottom); }
.nav a { padding: 14px 0 16px; text-decoration: none; color: var(--muted); }
.nav a.on { color: var(--gold-ink); font-weight: 700; }

/* Chat */
.chat { flex: 1; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 16px 20px; }
.bubble { max-width: 82%; padding: 10px 14px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.bubble.them { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; }
.bubble.me { align-self: flex-end; background: linear-gradient(180deg, #f8cadb, #e893b4); color: #2a0c1a; border-radius: 16px 16px 4px 16px; }
.bubble img { margin-top: 6px; border-radius: 10px; max-height: 260px; }
.bubble .t { display: block; font-size: 11px; opacity: .7; margin-top: 4px; }
.composer { display: flex; gap: 10px; align-items: center; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; position: sticky; bottom: 0; }
.composer .input { border-radius: 22px; }

/* Estados */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.st-pending { background: #fff3d6; color: #7a5a14; }
.st-approved, .st-open { background: #e3f3ea; color: var(--ok-ink); }
.st-rejected, .st-cancelled { background: var(--danger-bg); color: var(--danger-ink); }
.st-done, .st-closed { background: #efeaed; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: 90vw; padding: 12px 18px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 14px; z-index: 50; box-shadow: 0 10px 24px rgba(0,0,0,.25); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin .8s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn, .spinner { transition: none; animation-duration: 2s; } }
