:root {
  --bg: #f6f3f0;
  --card: #ffffff;
  --text: #2b2522;
  --muted: #7a706a;
  --line: #e6dfda;
  --accent: #c2255c;
  --danger: #c92a2a;
  --ok: #2b8a3e;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1817;
    --card: #262220;
    --text: #f1ece8;
    --muted: #a99e97;
    --line: #3a3431;
    --accent: #f06595;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
html {
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%; /* iOS no agranda la letra al girar */
  touch-action: manipulation; /* sin zoom por doble toque (teclado del PIN) */
}
body {
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }

header.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
header.top h1 { font-size: 22px; }
header.top .who { font-size: 14px; color: var(--muted); }

main { padding: 0 16px 16px; max-width: 720px; margin: 0 auto; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}

.now { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.now .card { margin: 0; }
.now .label { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.now .big { font-size: 24px; font-weight: 700; margin-top: 2px; }

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }

/* calendario */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 10px; }
.month-nav h2 { font-size: 20px; text-transform: capitalize; }
.icon-btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  width: 44px; height: 44px; font-size: 20px;
}
/* minmax(0, 1fr): columnas iguales aunque un nombre sea largo (si no, el domingo se sale de la pantalla) */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal, nav.tabs, .keypad, .people { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.cal .dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.day {
  min-height: 64px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  padding: 3px 2px; display: flex; flex-direction: column; gap: 3px; text-align: left;
  position: relative; min-width: 0;
}
.day.out { opacity: .35; }
.day.today { outline: 3px solid var(--accent); outline-offset: -1px; }
.day.past { opacity: .6; }
.day .n { font-size: 14px; font-weight: 600; padding-left: 2px; }
.chip {
  display: block; border-radius: 6px; color: #fff; font-size: 12px; font-weight: 600;
  padding: 2px 2px; letter-spacing: -.01em; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip.none { background: transparent; color: var(--danger); border: 1px dashed var(--danger); }
.day .q {
  position: absolute; top: 3px; right: 4px; font-size: 11px; font-weight: 700; color: #e67700;
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; margin: 12px 0; color: var(--muted); }

/* listas */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: left; width: 100%;
}
.row .bar { width: 6px; align-self: stretch; border-radius: 3px; }
.row .grow { flex: 1; min-width: 0; }
.row .sub { font-size: 15px; color: var(--muted); }
.section-title { font-size: 15px; color: var(--muted); margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }

.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 12px; line-height: 20px; text-align: center;
}
.status { font-size: 13px; font-weight: 600; }
.status.pending { color: #e67700; }
.status.approved { color: var(--ok); }
.status.rejected, .status.cancelled { color: var(--muted); }

/* botones */
.btn {
  display: block; width: 100%; border: 0; border-radius: 12px; padding: 14px;
  background: var(--accent); color: #fff; font-weight: 600; margin-top: 10px;
}
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.small { width: auto; display: inline-block; padding: 8px 16px; margin: 0; min-height: 44px; }
.btn:disabled { opacity: .5; }
.actions { display: flex; gap: 8px; margin-top: 10px; }
.actions .btn { margin: 0; }

.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.person {
  border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 8px;
  font-weight: 600; text-align: center;
}
.person.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }

label.field { display: block; margin-top: 12px; font-size: 15px; color: var(--muted); }
label.field input, label.field textarea, label.field select {
  display: block; width: 100%; margin-top: 4px; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); font-size: 17px; /* >= 16px: iOS no hace zoom */
}
/* iOS: el campo de fecha vacío se encoge y centra el texto; se le da alto fijo y alineación normal */
label.field input[type=date] { -webkit-appearance: none; appearance: none; min-height: 50px; text-align: left; }
label.field input[type=date]::-webkit-date-and-time-value { text-align: left; }
label.field select { -webkit-appearance: none; appearance: none; min-height: 50px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }

/* pestañas */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  border: 0; background: none; padding: 8px 2px 10px; font-size: 13px; color: var(--muted); min-height: 56px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative;
}
nav.tabs button .ic { font-size: 22px; line-height: 1; }
nav.tabs button.on { color: var(--accent); font-weight: 600; }
nav.tabs .badge { position: absolute; top: 4px; left: 55%; }

/* login */
.login { max-width: 420px; margin: 0 auto; padding: calc(40px + env(safe-area-inset-top)) 16px 16px; text-align: center; }
.login h1 { font-size: 26px; margin-bottom: 6px; }
.login p { color: var(--muted); margin-top: 0; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots span.on { background: var(--text); border-color: var(--text); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 300px; margin: 0 auto; }
.keypad button {
  height: 64px; border-radius: 16px; border: 1px solid var(--line); background: var(--card);
  font-size: 26px; font-weight: 500;
}
.keypad button.ghost { border: 0; background: none; font-size: 16px; color: var(--muted); }

/* hoja inferior */
dialog#sheet {
  border: 0; padding: 0; width: 100%; max-width: 560px; margin: auto auto 0;
  border-radius: 20px 20px 0 0; background: var(--card); color: var(--text);
  max-height: 90vh; max-height: 90dvh;
  /* --vvh / --kb los pone app.js cuando sale el teclado del celular, para que no tape la hoja */
  max-height: min(90dvh, calc(var(--vvh, 100dvh) - 12px));
  margin-bottom: var(--kb, 0px);
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
/* navegadores sin <dialog> (iOS < 15.4) */
dialog#sheet.fallback[open] { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
dialog#sheet::backdrop { background: rgba(0, 0, 0, .45); }
#sheet-body { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
#sheet-body h3 { font-size: 20px; outline: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 8px; }
.tabs-inline { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.tabs-inline button {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 8px 14px; font-size: 16px; min-height: 44px;
}
.tabs-inline button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.hint { font-size: 15px; color: var(--muted); margin-top: 6px; }
.warn { background: #fff4e6; color: #a34f00; border-radius: 10px; padding: 10px; font-size: 15px; margin-top: 10px; }
@media (prefers-color-scheme: dark) { .warn { background: #3b2a14; color: #ffc078; } }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #2b2522; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; }
.offline { background: var(--danger); color: #fff; text-align: center; font-size: 15px; padding: calc(6px + env(safe-area-inset-top)) 8px 6px; }
#banner:not(:empty) + header.top { padding-top: 12px; }
