:root {
  --bg: #fff8f3;
  --surface: #ffffff;
  --surface-2: #fbeee6;
  --text: #2b2024;
  --muted: #7a6a70;
  --line: #eedfd7;
  --primary: #e0566f;
  --primary-ink: #ffffff;
  --ok: #2f9e6b;
  --ok-bg: #e3f5ec;
  --wait: #b7791f;
  --wait-bg: #fdf1d8;
  --no: #c2414b;
  --no-bg: #fbe4e6;
  --busy: #8c8389;
  --busy-bg: #efeaec;
  --shadow: 0 8px 30px rgba(80, 30, 40, .12);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1517;
    --surface: #261e21;
    --surface-2: #322729;
    --text: #f5ecee;
    --muted: #b3a3a9;
    --line: #3d3033;
    --primary: #f07a90;
    --primary-ink: #1b1517;
    --ok: #5cc995;
    --ok-bg: #1f3a2d;
    --wait: #e8b55a;
    --wait-bg: #3b2f17;
    --no: #f07a82;
    --no-bg: #432327;
    --busy: #a69ba0;
    --busy-bg: #332b2e;
    --shadow: 0 8px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1517; --surface: #261e21; --surface-2: #322729; --text: #f5ecee; --muted: #b3a3a9;
  --line: #3d3033; --primary: #f07a90; --primary-ink: #1b1517; --ok: #5cc995; --ok-bg: #1f3a2d;
  --wait: #e8b55a; --wait-bg: #3b2f17; --no: #f07a82; --no-bg: #432327; --busy: #a69ba0; --busy-bg: #332b2e;
  --shadow: 0 8px 30px rgba(0, 0, 0, .45); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }

.wrap { max-width: 480px; margin: 0 auto; padding: 16px 16px 120px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 0 16px;
}
.top h1 { font-size: 26px; }
.top .sub { color: var(--muted); font-size: 15px; }
.link-btn {
  background: none; border: 0; color: var(--muted); padding: 10px; font-size: 15px;
  text-decoration: underline; text-underline-offset: 3px;
}

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 0 22px; border-radius: 999px; border: 0;
  background: var(--primary); color: var(--primary-ink); font-weight: 650; font-size: 18px;
  width: 100%; transition: transform .08s;
}
.btn:active { transform: scale(.97); }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.small { min-height: 44px; font-size: 16px; width: auto; padding: 0 18px; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.no { background: var(--no-bg); color: var(--no); }
.btn:disabled { opacity: .5; }

.card {
  background: var(--surface); border-radius: var(--radius); padding: 16px;
  box-shadow: 0 1px 0 var(--line), 0 2px 12px rgba(80, 30, 40, .05);
}
.stack > * + * { margin-top: 12px; }
.section-title { font-size: 15px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 28px 4px 10px; }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; }
.hero { text-align: center; margin-bottom: 28px; }
.hero .car { font-size: 64px; line-height: 1; }
.hero h1 { font-size: 30px; margin-top: 10px; }
.hero p { color: var(--muted); margin: 6px 0 0; }
.names { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.names button {
  min-height: 88px; border-radius: var(--radius); border: 2px solid var(--line);
  background: var(--surface); font-size: 20px; font-weight: 650;
}
.names button:active { border-color: var(--primary); }
.names button:only-child { grid-column: 1 / -1; }

.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 18px 0 26px; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--primary); }
.pin-dots span.on { background: var(--primary); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-10px) } 75% { transform: translateX(10px) } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 320px; margin: 0 auto; }
.keypad button {
  aspect-ratio: 1.25; border-radius: 22px; border: 0; background: var(--surface);
  font-size: 28px; font-weight: 600; box-shadow: 0 1px 0 var(--line);
}
.keypad button:active { background: var(--surface-2); }
.keypad .ghost { background: none; box-shadow: none; font-size: 17px; color: var(--muted); }
.error { color: var(--no); text-align: center; min-height: 1.5em; margin-top: 12px; font-weight: 550; }

/* ---------- Tira de días ---------- */
.days {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -16px; padding: 4px 16px 10px; scrollbar-width: none;
}
.days::-webkit-scrollbar { display: none; }
.day {
  flex: 0 0 62px; scroll-snap-align: start; border: 2px solid transparent;
  background: var(--surface); border-radius: 16px; padding: 8px 0 10px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.day .dw { font-size: 13px; color: var(--muted); text-transform: capitalize; }
.day .dn { font-size: 22px; font-weight: 700; }
.day .dots { display: flex; gap: 3px; height: 8px; }
.day .dots i { width: 7px; height: 7px; border-radius: 50%; }
.day.sel { border-color: var(--primary); }
.day.blocked { background: var(--busy-bg); }
.day.blocked .dn { color: var(--busy); text-decoration: line-through; }
.month-label { font-size: 15px; color: var(--muted); margin: 0 4px 8px; text-transform: capitalize; }

.dot-ok { background: var(--ok); }
.dot-wait { background: var(--wait); }
.dot-busy { background: var(--busy); }

/* ---------- Viajes ---------- */
.trip { display: flex; gap: 14px; align-items: flex-start; }
.trip .time { font-size: 20px; font-weight: 700; min-width: 58px; }
.trip .body { flex: 1; min-width: 0; }
.trip .route { font-weight: 600; overflow-wrap: anywhere; }
.trip .route small { display: block; color: var(--muted); font-weight: 400; font-size: 15px; }
.trip .meta { color: var(--muted); font-size: 15px; margin-top: 4px; overflow-wrap: anywhere; }
.trip .reply { margin-top: 8px; background: var(--surface-2); border-radius: 12px; padding: 8px 12px; font-size: 15px; }
.trip .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.trip.busy { opacity: .8; }
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 650;
}
.chip.aceptado { background: var(--ok-bg); color: var(--ok); }
.chip.pendiente { background: var(--wait-bg); color: var(--wait); }
.chip.rechazado { background: var(--no-bg); color: var(--no); }
.chip.cancelado, .chip.ocupado { background: var(--busy-bg); color: var(--busy); }
.maps { color: var(--primary); font-weight: 600; text-decoration: none; font-size: 15px; }

/* ---------- Botón fijo + hoja inferior ---------- */
.fab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.fab-bar .btn { max-width: 448px; margin: 0 auto; box-shadow: var(--shadow); }

.sheet-bg {
  position: fixed; inset: 0; background: rgba(20, 10, 14, .45); opacity: 0; pointer-events: none;
  transition: opacity .2s; z-index: 10;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .25s ease-out; max-width: 560px; margin: 0 auto;
}
.sheet::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
body.sheet-open .sheet-bg { opacity: 1; pointer-events: auto; }
body.sheet-open .sheet { transform: none; }
body.sheet-open { overflow: hidden; }
.sheet h2 { font-size: 22px; margin-bottom: 16px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; min-height: 52px; padding: 12px 14px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--bg); font-size: 17px;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--primary); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.warn { background: var(--wait-bg); color: var(--wait); border-radius: 12px; padding: 10px 12px; font-size: 15px; margin-bottom: 14px; }

.toast {
  position: fixed; left: 50%; top: calc(16px + env(safe-area-inset-top)); transform: translate(-50%, -150%);
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 600;
  transition: transform .25s; z-index: 20; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); }

/* ---------- Admin (PC) ---------- */
.admin .wrap { max-width: 1200px; padding-bottom: 40px; }
.admin-grid { display: grid; gap: 24px; }
@media (min-width: 900px) {
  .admin-grid { grid-template-columns: 420px 1fr; align-items: start; }
}
.respuesta { width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); font-size: 16px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-head h2 { text-transform: capitalize; font-size: 22px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .wd { text-align: center; font-size: 13px; color: var(--muted); font-weight: 600; padding-bottom: 4px; }
.cal .cell {
  min-height: 96px; background: var(--surface); border-radius: 12px; padding: 6px; border: 2px solid transparent;
  text-align: left; display: flex; flex-direction: column; gap: 3px; font-size: 13px; overflow: hidden;
}
.cal .cell.other { opacity: .35; }
.cal .cell.today { border-color: var(--primary); }
.cal .cell.blocked { background: var(--busy-bg); }
.cal .cell .n { font-weight: 700; font-size: 15px; }
.cal .ev { border-radius: 6px; padding: 1px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.aceptado { background: var(--ok-bg); color: var(--ok); }
.cal .ev.pendiente { background: var(--wait-bg); color: var(--wait); }
.cal .ev.blk { background: none; color: var(--busy); font-style: italic; }
@media (max-width: 600px) { .cal .cell { min-height: 60px; } .cal .ev { font-size: 0; height: 6px; padding: 0; } }
table.hist { width: 100%; border-collapse: collapse; font-size: 15px; }
table.hist th, table.hist td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.hist th { color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.admin-login { max-width: 380px; margin: 0 auto; }
