/* Agenda — estilo único para panel y PWA. Mobile-first, tema oscuro. */
:root {
  --bg: #0b1120;
  --bg2: #111a2e;
  --card: #152038;
  --card2: #1b2843;
  --line: #26365a;
  --text: #e6ecf7;
  --muted: #93a3c0;
  --brand: #3b82f6;
  --brand2: #2563eb;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
a { color: #8bb8ff; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }

/* Barra superior */
.top {
  position: sticky; top: 0; z-index: 10; background: rgba(11,17,32,.95);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 10px; min-height: 54px; }
.logo { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo .dot { width: 26px; height: 26px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; font-size: .8rem; color: #fff; }
.top .biz { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); background: var(--bg); }
.tabs::-webkit-scrollbar { display: none; }
.tabs .wrap { display: flex; gap: 4px; }
.tabs a {
  padding: 10px 12px; color: var(--muted); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; font-weight: 500;
}
.tabs a.on { color: var(--text); border-color: var(--brand); }

main { padding: 16px 0 80px; }
section { margin-bottom: 18px; }

/* Tarjetas y listas */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat b { display: block; font-size: 1.5rem; }
.stat span { color: var(--muted); font-size: .82rem; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px;
}
.item.click { cursor: pointer; }
.item.click:hover { background: var(--card2); }
.item .when { min-width: 54px; font-weight: 700; font-variant-numeric: tabular-nums; }
.item .main { flex: 1; min-width: 0; }
.item .main .t { font-weight: 600; overflow-wrap: anywhere; }
.item .main .s { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.item .side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.dayhead { margin: 14px 0 6px; color: var(--muted); font-size: .85rem; text-transform: capitalize; font-weight: 600; }
.empty { color: var(--muted); padding: 14px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; background: var(--card2); color: var(--muted); border: 1px solid var(--line); }
.pill.pendiente { color: #fcd34d; border-color: #6b5513; background: #2a230d; }
.pill.confirmada { color: #86efac; border-color: #1f5f37; background: #0e2a1a; }
.pill.cancelada { color: #fca5a5; border-color: #6b2020; background: #2a1010; }
.pill.asistio { color: #93c5fd; border-color: #1e3a8a; background: #0f1d3d; }
.pill.no_asistio { color: #d4d4d8; border-color: #3f3f46; background: #1f1f23; }

/* Formularios */
label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; max-width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font: inherit; font-size: 16px; /* 16px evita zoom en iOS */
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type="checkbox"] { width: auto; }
.check { display: inline-flex; align-items: center; gap: 6px; margin: 4px 12px 4px 0; color: var(--text); font-size: .95rem; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 12px; }
@media (min-width: 560px) { .grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.hint { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.err { color: #fca5a5; font-size: .9rem; min-height: 1.2em; margin-top: 8px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; min-height: 42px;
}
button:hover, .btn:hover { border-color: #3a4f7d; }
button.primary, .btn.primary { background: var(--brand2); border-color: var(--brand2); color: #fff; }
button.ok { background: #15803d; border-color: #15803d; color: #fff; }
button.danger { background: transparent; color: #fca5a5; border-color: #6b2020; }
button.sm, .btn.sm { padding: 6px 10px; min-height: 34px; font-size: .85rem; }
button:disabled { opacity: .55; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btns > * { flex: 1 1 auto; }
select.status { width: auto; padding: 4px 8px; font-size: .85rem; min-height: 32px; }

/* Diálogos */
dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 18px;
}
dialog::backdrop { background: rgba(0,0,0,.6); }
.qr { background: #fff; border-radius: 12px; padding: 10px; width: 240px; max-width: 100%; margin: 10px auto; display: block; }
.qr img { width: 100%; height: auto; display: block; image-rendering: pixelated; }
.linkbox { font-family: ui-monospace, monospace; font-size: .8rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; overflow-wrap: anywhere; }

/* Login */
.center { min-height: 80vh; display: grid; place-items: center; padding: 16px; }
.auth { width: 100%; max-width: 400px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  background: #0f172a; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; max-width: calc(100vw - 32px);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.banner { background: #13254a; border: 1px solid #23417a; border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.cap { text-transform: capitalize; }
.list li.row { padding: 6px 0; border-top: 1px solid var(--line); }

/* Ajustes tras revisar capturas */
h1, h2, h3, .t { overflow-wrap: anywhere; }
.grow { flex: 1 1 200px; }
main .row.between { margin-bottom: 10px; }
.cap { display: inline-block; text-transform: none; }
.cap::first-letter { text-transform: uppercase; }
@media (max-width: 560px) {
  .item.appt { flex-wrap: wrap; }
  .item.appt .main { flex: 1 1 0; }
  .item.appt .side {
    flex: 1 1 100%; flex-direction: row; align-items: center; justify-content: flex-end;
    border-top: 1px solid var(--line); padding-top: 8px;
  }
  .item.appt .side .pill { margin-right: auto; }
}
.when .cap { display: block; }
.dayhead { text-transform: none; }
.dayhead::first-letter { text-transform: uppercase; }
.toolbar { margin-bottom: 12px; }
.auth .logo { margin-bottom: 12px; }

/* ---------- Etapa 2: chat, insignias, acciones peligrosas ---------- */
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--bad); color: #fff; font-size: .72rem; font-weight: 700; line-height: 1;
}
.tabs a .badge { margin-left: 6px; }
.chat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.msgs { height: min(58dvh, 520px); overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 2px; background: var(--bg2); overscroll-behavior: contain; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 14px; margin: 3px 0; overflow-wrap: anywhere; }
.msg .body { white-space: pre-wrap; }
.msg .meta { font-size: .7rem; opacity: .75; text-align: right; margin-top: 2px; }
.msg.mine { align-self: flex-end; background: var(--brand2); color: #fff; border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; background: var(--card2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.daysep { text-align: center; margin: 10px 0 4px; font-size: .75rem; color: var(--muted); }
.daysep span { background: var(--card); border: 1px solid var(--line); padding: 2px 10px; border-radius: 999px; }
.center-text { text-align: center; margin: auto; }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 140px; resize: none; flex: 1; }
.composer button { flex: 0 0 auto; }
.chat-foot { padding: 0 10px; margin: 0 !important; }
.chat-foot .err { margin: 0 0 6px; }
.conv .preview { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .t { color: #fff; }
.conv.unread .preview { color: var(--text); font-weight: 600; }
.danger-zone { border-color: #4a1d1d; }
.btn.has-badge, button.has-badge { position: relative; }
.chat-page main { padding-bottom: 16px; }
.chat-page .msgs { height: calc(100dvh - 54px - 32px - 110px); min-height: 260px; }
a.stat { text-decoration: none; color: inherit; }
a.stat:hover { border-color: #3a4f7d; }
.conv-head { margin: 0 !important; flex-wrap: nowrap; }
.conv-head .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .side .badge { align-self: flex-end; }
@media (max-width: 430px) {
  .tabs .wrap { padding: 0 6px; gap: 0; }
  .tabs a { padding: 10px 8px; font-size: .9rem; }
}
.conv-head .t { flex: 1 1 auto; min-width: 0; }
.conv-head > span { white-space: nowrap; flex: 0 0 auto; }
.chat-foot .err { min-height: 0; }
.chat-foot .err:empty, .chat-foot .hint:empty { display: none; }
.mailbody { white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.5 system-ui, sans-serif; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 55dvh; overflow: auto; }
.link-like { color: #8bb8ff !important; }
#email-action h1 { margin-top: 10px; }
.fu-under { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--line); font-size: .9rem; }
.bigcode { font: 700 1.9rem/1.2 ui-monospace, Consolas, monospace; letter-spacing: .12em; text-align: center; padding: 14px 8px; margin: 10px 0; background: var(--bg2); border: 1px dashed #3a4f7d; border-radius: 12px; user-select: all; }
.codeinput { font: 700 1.4rem ui-monospace, Consolas, monospace; letter-spacing: .12em; text-transform: uppercase; text-align: center; }
.ok-text { color: #86efac; }
#push-card .err:empty, #link-card .err:empty { display: none; }
