/* Panel del equipo — piel "Glovo adulto" (backoffice sobrio).
   Tarjetas blancas con borde de 1px, sin sombras; KPIs en Manrope 700,
   titulares en Cormorant; un único acento ciruela y tonos apagados en las gráficas.
   Móvil primero: tarjetas apiladas y barra de pestañas abajo.
   ≥768: KPIs en fila y gráficas a dos columnas. ≥1100: tabla real.
   ≥1200: barra lateral. Cifras siempre en .num (Manrope lining/tabular). */

body { --toast-bottom: 96px; }
body.ready { background: var(--bg); }

/* ---------- Cargando (antes de saber si hay sesión) ---------- */
.boot {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink-2);
  font-size: var(--fs-min);
  font-weight: 500;
}
.boot .spin { border-color: var(--line-2); border-top-color: var(--plum); }

/* ---------- Esqueleto ---------- */
.side { display: none; }
.ev-in {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) var(--pad) calc(112px + env(safe-area-inset-bottom));
  display: grid;
  gap: 16px;
  min-width: 0;
}
.ev-in > * { min-width: 0; }

/* Cabecera: marca + salir, y debajo el titular */
.ev-head { display: grid; gap: 4px; scroll-margin-top: 16px; }
.ev-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ev-top .wordmark b { font-size: 24px; }
.ev-head h1 { font-size: clamp(32px, 9vw, 40px); color: var(--ink); line-height: 1.05; }
.ev-head .hi { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: var(--fs-min); color: var(--ink-2); line-height: 1.35; }
.ev-head .hi .chip { padding: 4px 10px; }
.chip.live { background: var(--st-booked-bg); color: var(--st-booked-fg); font-weight: 600; }

/* Selector de periodo: chips como el mockup (seleccionado en tinta) */
.period { display: grid; gap: 8px; }
.period-k { display: flex; align-items: center; gap: 8px; font-size: var(--fs-min); font-weight: 600; color: var(--ink-2); }
.period-k .ico { width: 18px; height: 18px; color: var(--plum); }
.seg {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.seg button {
  min-height: var(--tap);
  min-width: 0;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-chip);
  background: var(--card);
  font-size: var(--fs-min);
  font-weight: 500;
  line-height: 1.15;
  color: var(--ink);
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), transform var(--dur-press) var(--ease-out);
}
.seg button:active { transform: scale(.97); }
.seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
@media (hover: hover) {
  .seg button:not([aria-pressed="true"]):hover { border-color: var(--line-2); }
}

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 14px 14px 16px;
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
}
.kpi .k { display: flex; align-items: center; gap: 8px; font-size: var(--fs-min); font-weight: 500; color: var(--ink-2); line-height: 1.3; }
.kpi .k .ico { width: 18px; height: 18px; color: var(--plum); }
.kpi .v {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: clamp(30px, 8.4vw, 38px);
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  line-height: 1.1;
}
.kpi .u { font-size: var(--fs-min); font-weight: 600; color: var(--ink-2); margin-left: 3px; letter-spacing: 0; }
.kpi .d { font-size: var(--fs-min); font-weight: 400; color: var(--ink-2); line-height: 1.4; }
.kpi .d.up { color: var(--st-booked-fg); }
.kpi.alert { border-color: var(--pink-200); }
.kpi.alert .v { color: var(--alert); }
.kpi.alert .k .ico { color: var(--alert); }

.delta {
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-min);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.3;
  padding: 2px 8px;
  border-radius: var(--r-xs);
  background: var(--st-booked-bg);
  color: var(--st-booked-fg);
  white-space: nowrap;
}
.delta.down { background: var(--st-new-bg); color: var(--st-new-fg); }
.delta.same { background: var(--fill); color: var(--ink-2); }

/* ---------- Tarjetas de panel ---------- */
.grid2 { display: grid; gap: 16px; min-width: 0; }
.panel { padding: 18px; min-width: 0; scroll-margin-top: 16px; }
.panel h2 { display: flex; align-items: center; gap: 10px; font-size: 26px; color: var(--ink); line-height: 1.1; }
.panel h2 > .ico { width: 22px; height: 22px; color: var(--plum); transform: translateY(1px); }
.panel .cs { font-size: var(--fs-min); color: var(--ink-2); font-weight: 400; margin-top: 4px; line-height: 1.4; }
.ph { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.ph .btn-sm { margin-left: auto; }
.chart-empty { display: flex; align-items: center; gap: 10px; padding: 18px 2px 4px; font-weight: 500; color: var(--ink-2); }
.chart-empty .ico { width: 20px; height: 20px; color: var(--ink-2); }

/* Barras por semana: gris de línea = avisos; ciruela = acabaron en cita */
.wchart {
  display: grid;
  grid-template-columns: repeat(var(--n, 8), minmax(0, 1fr));
  gap: 6px;
  align-items: end;
  height: 210px;
  margin-top: 16px;
  padding-top: 6px;
}
.wb { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; justify-items: center; gap: 6px; min-width: 0; }
.wb .v { font-size: var(--fs-min); font-weight: 600; color: var(--ink-2); align-self: end; line-height: 1.2; }
.wb .bar {
  position: relative;
  width: 100%;
  max-width: 40px;
  align-self: end;
  height: calc(var(--h) * 100%);
  min-height: 4px;
  overflow: hidden;
  border-radius: 6px 6px 2px 2px;
  background: var(--line-2);
}
.wb .bar .bk {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--b) * 100%);
  background: var(--plum);
}
.wb.cur .bar { background: #C4B8BE; }
.wb.cur .v { color: var(--ink); font-weight: 700; }
.wb .lb { font-size: var(--fs-min); color: var(--ink-2); font-weight: 500; white-space: nowrap; min-height: 24px; line-height: 1.4; }
.wb.cur .lb { color: var(--ink); font-weight: 700; }
@media (max-width: 599px) {
  .wb:nth-last-child(even) .lb { visibility: hidden; }
}
.legend { display: flex; gap: 6px 18px; flex-wrap: wrap; margin-top: 12px; font-size: var(--fs-min); font-weight: 500; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend .sw-total { background: var(--line-2); }
.legend .sw-booked { background: var(--plum); }

/* Barras horizontales */
.hbars { display: grid; gap: 14px; margin-top: 16px; }
.hb { display: grid; gap: 8px; min-width: 0; }
.hb .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 500; font-size: var(--fs-min); line-height: 1.3; }
.hb .lbl-h { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink); }
.hb .lbl-h > .ico { width: 20px; height: 20px; color: var(--plum); }
/* Miniatura de categoría (tono apagado + icono en blanco) */
.hb-mini { width: 32px; height: 32px; border-radius: var(--r-xs); display: grid; place-items: center; flex: none; }
.hb-mini .ico { width: 20px; height: 20px; stroke-width: 1.5; }
.hb .n { color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.hb .track { height: 8px; border-radius: 4px; background: var(--fill); overflow: hidden; }
.hb .track i { display: block; height: 100%; width: calc(var(--w) * 100%); border-radius: 4px; background: var(--c, var(--plum)); }

/* ---------- Avisos: buscador, chips de estado, filtros y tabla ---------- */
.tools { display: grid; gap: 12px; margin-top: 16px; }
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 4px 0 14px;
  background: var(--fill);
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  min-width: 0;
  transition: border-color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
.search:focus-within { background: var(--card); border-color: var(--plum-500); box-shadow: var(--ring); }
.search > .ico { width: 20px; height: 20px; color: var(--ink-2); }
.search input { flex: 1; min-width: 0; min-height: 48px; border: 0; outline: 0; background: none; font-size: var(--fs-body); font-weight: 500; }
.search input::placeholder { color: var(--placeholder); font-weight: 400; opacity: 1; }

/* Chips de estado: fila deslizable, seleccionado en tinta (como el mockup) */
.fchips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -18px;
  padding: 0 18px 2px;
  scroll-padding: 0 18px;
}
.fchips::-webkit-scrollbar { display: none; }
.fchips button {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-chip);
  background: var(--card);
  font-size: var(--fs-min);
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), transform var(--dur-press) var(--ease-out);
}
.fchips button:active { transform: scale(.97); }
.fchips button .n { color: var(--ink-2); font-weight: 600; }
.fchips button .sdot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--c, var(--line-2)); }
.fchips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.fchips button[aria-pressed="true"] .n { color: rgba(255, 255, 255, .78); }
.fchips button[aria-pressed="true"] .sdot { box-shadow: 0 0 0 1.5px #fff; }
.fchips button[aria-pressed="true"]:focus-visible { outline-color: var(--plum); }
@media (hover: hover) {
  .fchips button:not([aria-pressed="true"]):hover { border-color: var(--line-2); }
}

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 10px; }
.filters label { min-width: 0; }
.sel {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 52px;
  border-radius: var(--r-btn);
  border: 1px solid var(--line);
  /* Flecha: SVG embebido con color fijo (#6E6470 = --ink-2); no puede heredar currentColor */
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236E6470' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center;
  padding: 0 40px 0 14px;
  font-size: var(--fs-min);
  font-weight: 500;
  color: var(--ink);
  text-overflow: ellipsis;
  outline: none;
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}
@media (hover: hover) {
  .sel:hover { border-color: var(--line-2); }
}
.sel:focus-visible { border-color: var(--plum-500); box-shadow: var(--ring); outline: 2px solid var(--plum); outline-offset: 2px; }
.sel.on { border-color: var(--plum-500); background-color: var(--plum-soft); }
.res-line { display: flex; justify-content: space-between; align-items: center; gap: 4px 10px; flex-wrap: wrap; font-size: var(--fs-min); font-weight: 500; color: var(--ink-2); min-height: var(--tap); }

.tbl { width: 100%; border-collapse: collapse; margin-top: 4px; }
.tbl th { text-align: left; font-size: var(--fs-min); color: var(--ink-2); font-weight: 600; padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 14px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: var(--fs-min); font-weight: 400; min-width: 0; }
.c-name { display: flex; align-items: center; gap: 12px; }
.av { width: 44px; height: 44px; border-radius: var(--r-chip); display: grid; place-items: center; font-weight: 700; font-size: var(--fs-min); flex: none; }
.who { display: grid; min-width: 0; }
.nm { font-weight: 600; font-size: var(--fs-body); color: var(--ink); line-height: 1.25; }
.tel { display: block; color: var(--ink-2); font-weight: 400; }
.svcs { list-style: none; display: grid; gap: 2px; font-weight: 600; color: var(--ink); line-height: 1.35; }
.svcs li { display: flex; gap: 6px; }
.svcs li + li::before { content: "+"; color: var(--ink-2); font-weight: 500; }
.c-svc .when { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--ink-2); font-weight: 400; }
.c-svc .when .ico { width: 18px; height: 18px; color: var(--plum); }
.c-svc .msg {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  margin-top: 6px;
  color: var(--ink-2);
  font-style: italic;
}
.org { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; color: var(--ink); }
.org .ico { width: 20px; height: 20px; color: var(--plum); }
.c-rec { color: var(--ink-2); }
.c-act { white-space: nowrap; }
.c-act .icon-btn { display: inline-grid; vertical-align: middle; }
.c-act .icon-btn + .icon-btn { margin-left: 8px; }
/* WhatsApp por fila: botón neutro con borde; el verde solo en el icono */
.row-wa { background: var(--wa); border-color: var(--wa); color: var(--wa-ink); }
.row-wa .ico { color: currentColor; }
@media (hover: hover) {
  .row-wa:hover { background: var(--wa-hover); border-color: var(--wa-hover); }
  .c-act .icon-btn-soft:hover { background: var(--fill-2); }
}

/* Estado por fila: desplegable con el tono (apagado) del estado */
.stsel {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  max-width: 100%;
  min-height: var(--tap);
  border-radius: var(--r-chip);
  border: 0;
  padding: 0 36px 0 14px;
  font-size: var(--fs-min);
  font-weight: 600;
  text-overflow: ellipsis;
  cursor: pointer;
  /* Flecha: color fijo (#4A4250), única excepción a currentColor */
  background: var(--fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234A4250' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}
.stsel:disabled { opacity: .6; cursor: progress; }
.stsel.nuevo { background-color: var(--st-new-bg); color: var(--st-new-fg); }
.stsel.avisado { background-color: var(--st-notified-bg); color: var(--st-notified-fg); }
.stsel.contactado { background-color: var(--st-done-bg); color: var(--st-done-fg); }
.stsel.cita { background-color: var(--st-booked-bg); color: var(--st-booked-fg); }
.stsel.perdido { background-color: var(--st-lost-bg); color: var(--st-lost-fg); }
.stsel option { background: #fff; color: var(--ink); }

.empty-t { padding: 28px 16px; text-align: center; color: var(--ink-2); font-weight: 500; }
.empty-t .ico-tile { margin: 0 auto 10px; }
.more-row { display: flex; justify-content: center; margin-top: 14px; }
.more-row .btn { min-width: min(320px, 100%); }

/* Móvil y tableta: cada aviso es una tarjeta */
@media (max-width: 1099px) {
  .tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .tbl, .tbl tbody { display: block; }
  .tbl tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name act" "svc svc" "org rec" "st st";
    gap: 12px;
    padding: 14px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    margin-top: 10px;
  }
  .tbl td { display: block; padding: 0; border: 0; }
  .tbl td.c-name { grid-area: name; display: flex; }
  .tbl td.c-act { grid-area: act; align-self: start; justify-self: end; }
  .tbl td.c-svc { grid-area: svc; padding-top: 12px; border-top: 1px solid var(--line); }
  .tbl td.c-org { grid-area: org; align-self: center; }
  .tbl td.c-rec { grid-area: rec; align-self: center; text-align: right; color: var(--ink-2); }
  .tbl td.c-st { grid-area: st; }
  .tbl tr.empty-row { display: block; }
  .tbl td.empty-t { padding: 24px 12px; }
}
/* En pantallas estrechas el avatar (decorativo) cede su sitio al nombre y al celular */
@media (max-width: 419px) {
  .tbl td.c-name .av { display: none; }
}
@media (max-width: 359px) {
  .tbl tr { grid-template-areas: "name name" "act act" "svc svc" "org org" "rec rec" "st st"; }
  .tbl td.c-rec { text-align: left; }
  .tbl td.c-act { justify-self: start; }
}

/* ---------- Conexiones (lista agrupada) ---------- */
.integ { display: grid; margin-top: 12px; }
.ig { display: flex; align-items: center; gap: 10px 14px; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; min-width: 0; }
.ig:last-child { border-bottom: 0; }
.ig .b { width: 48px; height: 48px; border-radius: var(--r-btn); display: grid; place-items: center; flex: none; background: var(--fill); color: var(--plum); }
.ig .b .ico { width: 24px; height: 24px; }
.ig .b.b-green { background: var(--fill); color: var(--green); }
.ig .b .gcal { width: 40px; height: 40px; }
.ig .tx { flex: 1; min-width: 150px; }
.ig strong { display: block; font-weight: 600; line-height: 1.3; }
.ig .s { display: block; font-size: var(--fs-min); color: var(--ink-2); font-weight: 400; line-height: 1.4; overflow-wrap: anywhere; }
.ig .chip { white-space: normal; }
.reset { margin-top: 14px; }

/* Interruptor (role="switch"): encendido en ciruela, el único acento */
.switch {
  position: relative;
  width: 60px;
  height: var(--tap);
  min-width: 60px;
  flex: none;
  padding: 0;
  margin-left: auto;
  border: 0;
  border-radius: var(--r-btn);
  background: none;
  cursor: pointer;
}
.switch::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 10px;
  height: 28px;
  border-radius: 14px;
  background: var(--line-2);
  transition: background-color var(--dur-1) var(--ease-out);
}
.switch::after {
  content: "";
  position: absolute;
  top: 12px;
  left: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(31, 23, 32, .25);
  transition: transform var(--dur-1) var(--ease-out);
}
.switch[aria-checked="true"]::before { background: var(--plum); }
.switch[aria-checked="true"]::after { transform: translateX(24px); }
.switch:disabled { opacity: .6; cursor: progress; }

/* ---------- QR ---------- */
.qr-box { width: min(220px, 72%); margin: 16px auto 10px; background: #fff; border-radius: var(--r-card); padding: 12px; border: 1px solid var(--line); }
.qr-url { font-weight: 500; color: var(--ink-2); text-align: center; overflow-wrap: anywhere; font-size: var(--fs-min); }
.qr-acts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 10px; margin: 14px 0 12px; }
.hint { font-size: var(--fs-min); font-weight: 400; color: var(--ink-2); line-height: 1.5; }
.hint b { color: var(--ink); font-weight: 600; }

/* ---------- Barra de pestañas (móvil) ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-dock);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  padding: 6px 6px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96);
  -webkit-backdrop-filter: saturate(1.2) blur(12px);
  backdrop-filter: saturate(1.2) blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 58px;
  padding: 4px 2px;
  border: 0;
  border-radius: var(--r-btn);
  background: none;
  font-size: var(--fs-min);
  font-weight: 500;
  line-height: 1.15;
  color: var(--ink-2);
  transition: color var(--dur-1) var(--ease-out), transform var(--dur-press) var(--ease-out);
}
.tab:active { transform: scale(.96); }
.tab-ico { display: grid; place-items: center; width: 52px; height: 30px; border-radius: var(--r-chip); transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out); }
.tab[aria-current="true"] { color: var(--ink); font-weight: 600; }
.tab[aria-current="true"] .tab-ico { background: var(--plum-soft); color: var(--plum); }
@media (max-width: 359px) {
  .tabbar { padding-inline: 2px; gap: 0; }
  .tab { letter-spacing: -.01em; }
}

/* Las barras y filas de una tarjeta que aún no se ve esperan a que aparezca */
@media (prefers-reduced-motion: no-preference) {
  .reveal:not(.is-in) :is(.anim-grow-x, .anim-grow-y, .row-in) { animation-play-state: paused; }
}

/* ---------- Ficha de un aviso (<dialog class="sheet">) ---------- */
html:has(dialog.sheet[open]) { overflow: hidden; }
dialog.sheet {
  margin: auto 0 0;
  width: 100%;
  max-width: 100%;
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--bg);
  color: var(--ink);
  box-shadow: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}
dialog.sheet::backdrop { background: rgba(31, 23, 32, .4); }
.dlg { display: grid; padding-bottom: env(safe-area-inset-bottom); }
.dlg-grab { display: flex; justify-content: center; align-items: center; height: 24px; }
.dlg-grab::before { content: ""; width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 4px 16px 12px 20px; }
.dlg-head .av { width: 52px; height: 52px; background: var(--plum-soft); color: var(--plum); font-size: 18px; }
.dlg-head h2 { font-size: 30px; color: var(--ink); line-height: 1.05; }
.dlg-head p { color: var(--ink-2); font-weight: 400; font-size: var(--fs-min); }
.dlg-body { display: grid; gap: 16px; padding: 4px 20px 18px; }
.dlg-body .chip { white-space: normal; background: var(--card); border: 1px solid var(--line); }
.dlg-body .chip .ico { color: var(--plum); }
.dlg-facts { list-style: none; display: grid; gap: 10px; }
.dlg-facts li { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-min); font-weight: 400; color: var(--ink-2); line-height: 1.45; }
.dlg-facts .ico { width: 20px; height: 20px; color: var(--plum); margin-top: 1px; }
.dlg-facts b { color: var(--ink); font-weight: 600; }
.dlg-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r-btn);
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 400;
  font-style: italic;
  font-size: var(--fs-min);
  line-height: 1.5;
}
.dlg-msg .ico { color: var(--plum); margin-top: 1px; }
.dlg-body .fields { gap: 14px; }
.dlg-body .input { background-color: var(--card); border-color: var(--line); }
.dlg-body .input:focus { border-color: var(--plum-500); }
.dlg-foot {
  display: grid;
  gap: 10px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.dlg-more { display: grid; gap: 8px; }
.dlg-more .gcal { width: 30px; height: 30px; font-size: var(--fs-min); }
.dlg-more .gcal::before { border-top-width: 4px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-radius: 6px; }
.dlg-more .ico { color: var(--plum); }
.dlg-close { justify-self: center; }

/* ---------- Tableta ---------- */
@media (min-width: 768px) {
  body { --toast-bottom: 104px; }
  .ev-in { padding: calc(24px + env(safe-area-inset-top)) var(--pad) calc(120px + env(safe-area-inset-bottom)); gap: 20px; }
  .period { grid-template-columns: auto minmax(0, 440px); align-items: center; gap: 14px; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .wchart { gap: 8px; }
  .grid2 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; }
  .panel { padding: 22px; }
  .panel h2 { font-size: 28px; }
  .fchips { margin: 0; padding: 0; flex-wrap: wrap; overflow: visible; }
  .dlg-more { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dlg-more #gcal-marcela { grid-column: 1 / -1; }
  dialog.sheet {
    margin: auto;
    width: min(600px, calc(100% - 48px));
    max-height: min(88vh, 860px);
    border-radius: var(--r-sheet);
    border: 1px solid var(--line);
    box-shadow: var(--sh-modal);
  }
  .dlg-grab { display: none; }
  .dlg-head { padding-top: 20px; }
  .dlg-foot { padding-bottom: 16px; }
}

/* ---------- Escritorio: tabla de verdad ---------- */
@media (min-width: 1100px) {
  .tbl { table-layout: fixed; }
  .tbl th:nth-child(1) { width: 22%; }
  .tbl th:nth-child(2) { width: 27%; }
  .tbl th:nth-child(3) { width: 12%; }
  .tbl th:nth-child(4) { width: 14%; }
  .tbl th:nth-child(5) { width: 15%; }
  .tbl th:nth-child(6) { width: 116px; }
  .tbl tbody tr { transition: background-color var(--dur-1) var(--ease-out); }
  .tbl tbody tr:not(.empty-row):hover { background: var(--bg); }
  .tbl td.c-name { display: table-cell; }
  .tbl td.c-name .av, .tbl td.c-name .who { display: inline-grid; vertical-align: middle; }
  .tbl td.c-name .av { margin-right: 12px; }
  .tbl td.c-name .who { max-width: calc(100% - 58px); }
  .c-org .org { white-space: normal; }
}

@media (min-width: 1200px) {
  body { --toast-bottom: 24px; }
  body.ready #app { display: grid; grid-template-columns: 260px minmax(0, 1fr); align-items: start; min-height: 100vh; }
  .tabbar, .head-exit, .ev-top { display: none; }
  .ev-in { padding: 36px 32px 60px; width: 100%; }
  .side {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    padding: 28px 16px 20px;
    background: var(--card);
    border-right: 1px solid var(--line);
  }
  .side .brand { display: grid; gap: 10px; padding: 0 10px 22px; }
  .side .brand .wordmark b { font-size: 26px; }
  .side .brand small { font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
  .nav { display: grid; gap: 4px; }
  .nav button {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--tap);
    padding: 0 12px;
    border: 0;
    border-radius: var(--r-btn);
    background: none;
    font-weight: 500;
    font-size: var(--fs-min);
    color: var(--ink-2);
    text-align: left;
    transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), transform var(--dur-press) var(--ease-out);
  }
  .nav button .ico { width: 20px; height: 20px; }
  .nav button:not([aria-current="true"]):hover { background: var(--bg); color: var(--ink); }
  .nav button:active { transform: scale(.98); }
  .nav button[aria-current="true"] { background: var(--plum-soft); color: var(--plum); font-weight: 600; }
  .side .team { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 4px 0; border-top: 1px solid var(--line); }
  .side .team .av { background: var(--plum-soft); color: var(--plum); }
  .side .team .grow b, .side .team .grow span { display: block; line-height: 1.3; }
  .side .team .grow b { font-weight: 600; }
  .side .team .grow span { color: var(--ink-2); font-weight: 400; font-size: var(--fs-min); }
  .period { grid-template-columns: auto minmax(0, 460px); justify-content: end; margin-top: -8px; }
}

/* ---------- Oferta de passkey tras el enlace de alta ---------- */
.pk-offer {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: var(--z-toast);
  max-width: 460px;
  margin: 0 auto;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card, 14px);
  box-shadow: var(--sh-float);
  animation: pk-in var(--dur-2) var(--ease-out) both;
}
.pk-offer h2 { display: flex; align-items: center; gap: 10px; font-size: 28px; line-height: 1.1; }
.pk-offer p { margin-top: 8px; color: var(--ink-2); }
.pk-actions { display: grid; gap: 10px; margin-top: 16px; }
@keyframes pk-in { from { opacity: 0; transform: translateY(16px); } }
@media (prefers-reduced-motion: reduce) { .pk-offer { animation: none; } }
