:root {
  --bg: #F4F6FA;
  --card: #FFFFFF;
  --ink: #16233F;
  --muted: #6B7690;
  --line: #E3E7EF;
  --pink: #FF4F87;
  --mint: #0EA394;
  --mint-soft: #DDF6F2;
  --pink-soft: #FFE3EC;
  --amber: #C77700;
  --amber-soft: #FFF1DA;
  --radius: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: Poppins, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding: env(safe-area-inset-top) 0 calc(84px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
header {
  background: var(--ink);
  color: #fff;
  padding: 16px 16px 18px;
  border-radius: 0 0 24px 24px;
}
header .top { display: flex; align-items: center; gap: 12px; }
header .logo { width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0; }
header .titles { flex: 1; min-width: 0; }
header h1 { font-size: 20px; margin: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cloud { font-size: 12px; margin-top: 2px; opacity: .85; }
.cloud.ok { color: #7FE8DC; }
.cloud.err { color: #FFB3C9; }
.back {
  background: rgba(255,255,255,.12); border: 0; color: #fff; flex-shrink: 0;
  width: 44px; height: 44px; border-radius: 12px; font-size: 22px; cursor: pointer;
}
main { padding: 16px; max-width: 560px; margin: 0 auto; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(22,35,63,.06); }
.pnav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.pnav button {
  background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 12px;
  width: 48px; height: 48px; font-size: 26px; cursor: pointer; flex-shrink: 0;
}
.pnav .label { text-align: center; flex: 1; min-width: 0; }
.pnav .label b { display: block; font-size: 26px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.pnav .label span { font-size: 14px; opacity: .75; }
.today-link { background: rgba(255,255,255,.12); border: 0; color: #fff; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; padding: 5px 12px; border-radius: 999px; display: block; margin: 6px auto 0; }

/* tarjetas de personas */
.person {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit; border: 0; cursor: pointer;
  background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(22,35,63,.06); border-left: 6px solid var(--mint);
}
.person.owes { border-left-color: var(--amber); }
.person .ph { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--ink); color: #fff; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 600; font-size: 18px;
}
.person .pn { flex: 1; min-width: 0; }
.person .pn b { display: block; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .pn span { font-size: 12px; color: var(--muted); }
.person .chev { color: var(--muted); font-size: 22px; }
.person .pstats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.person .pstats div { background: var(--bg); border-radius: 12px; padding: 8px 10px; }
.person .pstats small { display: block; font-size: 11px; color: var(--muted); }
.person .pstats b { font-size: 16px; }
.person .pstats .due b { color: var(--amber); }
.person .pstats .ok b { color: var(--mint); }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: #fff; border-radius: 14px; padding: 4px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(22,35,63,.06); }
.seg button { border: 0; background: none; font: inherit; font-size: 14px; color: var(--muted); padding: 10px 0; border-radius: 10px; cursor: pointer; }
.seg button.active { background: var(--ink); color: #fff; font-weight: 600; }
.seg.two { grid-template-columns: 1fr 1fr; }
.month-total { font-size: 30px; font-weight: 700; margin: 2px 0 12px; }
.mstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin-bottom: 4px; }
.mstats div { background: var(--bg); border-radius: 12px; padding: 8px 4px; }
.mstats b { display: block; font-size: 16px; }
.mstats span { font-size: 11px; color: var(--muted); }
.mstats .paid b { color: var(--mint); }
.mstats .due b { color: var(--amber); }
.month-card .hist-item:first-of-type { margin-top: 8px; border-top: 1px solid var(--line); }
.pane { display: none; }
.pane.active { display: block; }

.days { display: grid; gap: 8px; }
.day {
  display: flex; align-items: center; gap: 12px;
  border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px;
  background: #fff; transition: background .15s, border-color .15s;
}
.day.yes { background: var(--mint-soft); border-color: var(--mint); }
.day.no { background: var(--pink-soft); border-color: var(--pink); }
.day.today .dname::after { content: "Hoy"; font-size: 10px; background: var(--ink); color: #fff; border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }
.day .date { flex: 1; min-width: 0; }
.dname { font-weight: 600; font-size: 15px; text-transform: capitalize; }
.dnum { font-size: 12px; color: var(--muted); }
.toggle { display: flex; gap: 6px; }
.toggle button {
  border: 1.5px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 10px; height: 40px; min-width: 44px; padding: 0 10px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.toggle button.on.y { background: var(--mint); border-color: var(--mint); color: #fff; }
.toggle button.on.n { background: var(--pink); border-color: var(--pink); color: #fff; }
.rides { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.rides button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 16px; color: var(--ink); cursor: pointer; padding: 0; }
.rides b { color: var(--ink); min-width: 14px; text-align: center; }
.rides-row { display: none; padding: 2px 4px 0; justify-content: flex-end; }
.day-wrap.yes .rides-row { display: flex; }

.summary { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; text-align: center; }
.summary div { background: var(--bg); border-radius: 12px; padding: 10px 4px; }
.summary b { display: block; font-size: 20px; }
.summary span { font-size: 11px; color: var(--muted); }
.total { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 4px; }
.total .amt { font-size: 32px; font-weight: 700; }
.total .calc { font-size: 13px; color: var(--muted); }

label.f { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
input, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff;
}
input:focus, select:focus { outline: none; border-color: var(--mint); }
.row2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }

.status-btn {
  width: 100%; margin-top: 14px; border: 0; border-radius: 14px; padding: 14px;
  font: inherit; font-weight: 600; font-size: 16px; cursor: pointer;
}
.status-btn.pending { background: var(--amber-soft); color: var(--amber); }
.status-btn.paid { background: var(--mint); color: #fff; }
.paid-note { font-size: 12px; color: var(--muted); text-align: center; margin-top: 6px; }

.pill { font: inherit; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; border: 0; }
.pill.paid { background: var(--mint-soft); color: var(--mint); }
.pill.pending { background: var(--amber-soft); color: var(--amber); }
button.pill { padding: 6px 12px; font-size: 12px; cursor: pointer; }

h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; }
.hist-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.hist-item:last-child { border-bottom: 0; }
.hist-item .w { flex: 1; min-width: 0; }
.hist-item .w b { font-size: 14px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-item .w span { font-size: 12px; color: var(--muted); }
.hist-item .m { font-weight: 700; }
.week-head { display: flex; justify-content: space-between; align-items: baseline; }
.week-head small { color: var(--muted); font-size: 12px; }
.owed { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--amber-soft); color: var(--amber); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; font-weight: 600; }
.owed.zero { background: var(--mint-soft); color: var(--mint); }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 20px 0; }

.btn { border: 0; border-radius: 12px; padding: 12px 14px; font: inherit; font-weight: 600; cursor: pointer; width: 100%; margin-top: 10px; font-size: 15px; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.ghost { background: var(--bg); color: var(--ink); }
.btn.add { background: #fff; color: var(--ink); border: 2px dashed var(--line); padding: 14px; margin-top: 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
details.archived { margin-top: 18px; }
details.archived summary { color: var(--muted); font-size: 13px; cursor: pointer; padding: 6px 0; }
.arch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.arch-row button { width: auto; margin: 0; padding: 8px 12px; font-size: 13px; }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line);
  display: flex; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 5;
}
nav.tabs button {
  flex: 1; background: none; border: 0; font: inherit; font-size: 11px; color: var(--muted);
  padding: 6px 0; border-radius: 12px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
nav.tabs button .i { font-size: 20px; line-height: 1; }
nav.tabs button.active { color: var(--ink); font-weight: 600; background: var(--bg); }
.view { display: none; }
.view.active { display: block; }
.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; transition: .2s; pointer-events: none; z-index: 10;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- AlDía ---------- */
.seg.three { grid-template-columns: repeat(3, 1fr); }
.view:not(.active) { display: none; }
.hero { text-align: center; padding: 8px 8px 16px; }
.hero h2 { font-size: 22px; line-height: 1.3; margin: 6px 0 8px; }
.hero p { color: var(--muted); margin: 0; font-size: 14px; }
.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; display: block; margin: 14px auto 0; padding: 6px; }
.msg { margin-top: 12px; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.45; background: var(--mint-soft); color: var(--mint); }
.msg.err { background: var(--pink-soft); color: #C2185B; }
.center { text-align: center; }
.big-emoji { font-size: 44px; }
a.btn { display: block; text-align: center; text-decoration: none; box-sizing: border-box; }
.btn.wa { background: #25D366; color: #fff; }
.btn:disabled { opacity: .6; }
.foot { text-align: center; color: var(--muted); font-size: 12px; }

.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tpl {
  border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 12px 4px; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 600; color: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.tpl .e { font-size: 28px; }
.tpl.active { border-color: var(--pink); background: #FFF5F8; }
.tpl-chip { display: inline-block; background: var(--bg); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; }

.client-ico {
  width: 44px; height: 44px; border-radius: 14px; background: var(--bg); flex-shrink: 0;
  display: grid; place-items: center; font-size: 24px;
}
.dnote { font-size: 12px; color: var(--ink); background: #fff8; border-radius: 6px; margin-top: 2px; }
.note-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; height: 28px; padding: 0 8px; font-size: 13px; cursor: pointer; }
.rides-row { gap: 8px; align-items: center; }

.item-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item-row .w { flex: 1; min-width: 0; }
.item-row .w b { display: block; font-size: 14px; font-weight: 600; }
.item-row .w span { font-size: 12px; color: var(--muted); }
.item-row .x { border: 0; background: var(--bg); width: 32px; height: 32px; border-radius: 10px; cursor: pointer; color: var(--muted); font-size: 14px; }
.inline-form { margin-top: 6px; }
.row2.eq { grid-template-columns: 1fr 1fr; }
input[type=date] { min-height: 46px; }

.month-total { font-size: 30px; font-weight: 700; margin: 2px 0 12px; }
.mstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin-bottom: 4px; }
.mstats div { background: var(--bg); border-radius: 12px; padding: 8px 4px; }
.mstats b { display: block; font-size: 16px; }
.mstats span { font-size: 11px; color: var(--muted); }
.mstats .paid b { color: var(--mint); }
.mstats .due b { color: var(--amber); }
.month-card .hist-item:first-of-type { margin-top: 8px; border-top: 1px solid var(--line); }
.pnav .label b { font-size: 24px; }

.ad-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ad-row .w { flex: 1; min-width: 0; }
.ad-row .w b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.ad-row .w span { font-size: 12px; color: var(--muted); }
#adSearch { margin-bottom: 6px; }

/* Quién está conectado / modo administradora */
.who { font-size: 12px; opacity: .8; margin-top: 2px; display: flex; gap: 6px; align-items: center; min-width: 0; }
.who #who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role { background: var(--pink); color: #fff; font-weight: 600; border-radius: 999px; padding: 1px 8px; font-size: 11px; white-space: nowrap; flex-shrink: 0; }
header { transition: background .2s; }
header.admin-mode { background: linear-gradient(135deg, #16233F 0%, #4A1E3F 100%); }
.admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.admin-stats div { background: var(--card); border-radius: 14px; padding: 12px 6px; text-align: center; box-shadow: 0 1px 3px rgba(22,35,63,.06); }
.admin-stats b { display: block; font-size: 24px; }
.admin-stats span { font-size: 11px; color: var(--muted); }
.admin-note { margin: 0 4px 12px; }
