/* ============================================================
   Tour Manager — design system
   Tema CLARO estilo Flexo. Accent único: azul Flexo #2563eb.
   (El estilo del PDF es aparte, vive en pdf.js — no depende de esto.)
   ============================================================ */

:root {
  /* ---- Superficies ---- */
  --bg: #ffffff;            /* fondo de página */
  --surface: #ffffff;       /* tarjetas blancas / inputs */
  --surface-2: #f7f9fc;     /* zonas suaves: cabeceras, nav, celdas */
  --panel-soft: #eff6ff;    /* resalte azulado tenue */

  /* ---- Líneas ---- */
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* ---- Texto ---- */
  --text: #0f172a;          /* primario (slate-900) */
  --muted: #475569;         /* secundario */
  --text-dim: #64748b;      /* terciario / descripciones */
  --placeholder: #94a3b8;

  /* ---- Acento (identidad Flexo) ---- */
  --accent: #2563eb;
  --accent-hover: #1e40af;
  --secondary: #cbd5e1;     /* neutro para anillos/barras suaves */

  /* ---- Estados (terna Flexo border / bg-tenue / text) ---- */
  --ok: #16a34a;      --ok-bg: #ecfdf5;      --ok-text: #065f46;
  --warning: #f59e0b; --warning-bg: #fef3c7; --warning-text: #92400e;
  --danger: #dc2626;  --danger-bg: #fee2e2;  --danger-text: #991b1b;
  --info: #3b82f6;    --info-bg: #dbeafe;    --info-text: #1e40af;
  --violet: #8b5cf6;  --violet-bg: #ede9fe;  --violet-text: #5b21b6;

  /* ---- Tipografía (sistema, sin web-fonts en la UI) ---- */
  --font-display: Arial, sans-serif;
  --font-body: Arial, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', 'Menlo', monospace;

  /* ---- Forma ---- */
  --radius: 10px;       /* controles: botones, inputs, filas */
  --radius-card: 12px;  /* tarjetas de menú */
  --radius-lg: 18px;    /* tarjetas/secciones grandes */
  --radius-pill: 999px;
  --bar: 3px;           /* barra izquierda de acento */

  /* ---- Sombras ---- */
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
  --shadow: 0 4px 16px rgba(15,23,42,.06);
  --shadow-lg: 0 8px 24px rgba(15,23,42,.08);

  --header-h: 52px;
  --nav-h: 56px;
  --maxw: 920px;

  color-scheme: light; /* pickers nativos (date/time) en claro */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Títulos: tight (letter-spacing negativo), caja normal, peso alto */
h1, h2, h3, .display { font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; margin: 0; color: var(--text); }
a { color: inherit; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

::selection { background: var(--accent); color: #fff; }

/* Micro-etiquetas: MAYÚSCULAS anchas (+.08em) */
.label {
  font-family: var(--font-display); text-transform: uppercase; letter-spacing: .08em;
  font-size: 11px; font-weight: 700; color: var(--text-dim);
}

/* ---- Header ---- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 18px; height: 18px; border-radius: 4px; background: var(--accent); box-shadow: inset 0 0 0 2px rgba(255,255,255,.7); transform: rotate(-8deg); }
.brand-text { font-family: var(--font-display); font-weight: 800; letter-spacing: -.02em; font-size: 18px; color: var(--text); }
.brand-text em { color: var(--accent); font-style: normal; }
.app-header .btn { margin-left: auto; }

/* ---- Menú dev ---- */
.dev-menu {
  position: absolute; right: 12px; top: calc(var(--header-h) - 4px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; min-width: 220px; padding: 6px; z-index: 40;
  box-shadow: var(--shadow-lg);
}
/* Respeta el atributo hidden (el display:flex de arriba lo anularía si no). Cerrado = oculto; toggle abre/cierra en desktop y móvil. */
.dev-menu[hidden] { display: none; }
.dev-item { text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--text); }
.dev-item:hover, .dev-item:focus-visible { background: var(--surface-2); }
.dev-danger { color: var(--danger); }

/* ---- Nav ---- */
.app-nav {
  position: sticky; top: var(--header-h); z-index: 20;
  display: flex; gap: 2px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
}
.app-nav a {
  flex: 1; text-align: center; text-decoration: none; color: var(--text-dim);
  font-family: var(--font-display); font-weight: 700; letter-spacing: 0; font-size: 13px;
  padding: 12px 6px; border-bottom: var(--bar) solid transparent;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.app-nav a .nav-ico { font-size: 12px; opacity: .9; }
.app-nav a:hover { color: var(--text); }
.app-nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- Vista ---- */
.app-view { max-width: var(--maxw); margin: 0 auto; padding: 16px 14px 40px; outline: none; }
.app-view:focus { outline: none; }

/* ---- Botones ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  font-family: var(--font-display); letter-spacing: 0; font-size: 14px; font-weight: 700;
  padding: 9px 14px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: #fff; border-style: dashed; border-color: var(--border-strong); color: var(--muted); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* ---- Secciones / tarjetas ---- */
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); margin: 14px 0; overflow: hidden; box-shadow: var(--shadow-sm); }
.section > header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.section > header h2 { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.section > .body { padding: 16px; }
.section-bar { width: var(--bar); align-self: stretch; background: var(--accent); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }

/* ---- Campos ---- */
select, input[type=text], input[type=date], input[type=time], input[type=tel], input[type=number], textarea {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 9px 11px; width: 100%;
  color-scheme: light;
  transition: border-color .12s ease, box-shadow .12s ease;
}
select { width: auto; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
::placeholder { color: var(--placeholder); opacity: 1; }

/* ---- Calendario ---- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.cal-dow { background: var(--surface-2); color: var(--text-dim); font-family: var(--font-display); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; font-size: 11px; text-align: center; padding: 8px 0; }
.cal-cell { background: var(--surface); min-height: 76px; padding: 6px 6px 8px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; border: 0; text-align: left; }
.cal-cell.is-other { background: var(--surface-2); opacity: .7; }
.cal-cell.is-today .cal-num { background: var(--accent); color: #fff; }
.cal-cell.is-selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-num { align-self: flex-start; font-family: var(--font-mono); font-size: 12px; min-width: 22px; text-align: center; padding: 1px 4px; border-radius: 2px; color: var(--text-dim); }
.cal-cell.is-today .cal-num { color: #fff; }
.cal-bars { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.cal-ev { font-size: 11px; line-height: 1.2; padding: 2px 5px; border-radius: 3px; border-left: var(--bar) solid var(--ev,#888); background: var(--surface-2); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-more { font-size: 10px; color: var(--text-dim); }

/* Agenda (lista) */
.agenda { display: flex; flex-direction: column; gap: 8px; }
.agenda-item { display: flex; gap: 12px; align-items: stretch; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 0; cursor: pointer; overflow: hidden; text-align: left; box-shadow: var(--shadow-sm); transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.agenda-item:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.agenda-item .stripe { width: var(--bar); background: var(--ev,#888); }
.agenda-item .when { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); padding: 12px 0 12px 12px; min-width: 64px; }
.agenda-item .meta { padding: 11px 14px 11px 0; }
.agenda-item .meta .t { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; }
.agenda-item .meta .s { color: var(--text-dim); font-size: 13px; }

/* Chips / colores de grupo */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.chip .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c,#888); }

/* Panel del día */
.day-panel { margin-top: 14px; }
.day-panel .ev-row { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-left: var(--bar) solid var(--ev,#888); border-radius: var(--radius); background: var(--surface); margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow-sm); }

/* ---- Estado vacío ---- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-dim); }
.empty .ico { font-size: 40px; opacity: .5; }
.empty h2 { color: var(--text); margin: 14px 0 6px; }
.empty p { margin: 0 0 18px; }

/* ---- Placeholder módulos no construidos ---- */
.soon { text-align: center; padding: 40px 20px; color: var(--text-dim); }
.soon .tag { display: inline-block; font-family: var(--font-display); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; font-size: 12px; color: var(--accent); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 10px; }

/* ---- Grupos (Módulo 2) ---- */
.glist { display: flex; flex-direction: column; gap: 8px; }
.grow { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 12px; box-shadow: var(--shadow-sm); }
.gdot { width: 14px; height: 14px; border-radius: 4px; background: var(--c,#888); flex: 0 0 auto; box-shadow: inset 0 0 0 1px rgba(15,23,42,.12); }
.gmeta { flex: 1; min-width: 0; }
.gname { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; }
.gsub { color: var(--text-dim); font-size: 12px; }
.gactions { display: flex; gap: 6px; }

.gform { display: flex; flex-direction: column; gap: 14px; }
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld > .label { margin-bottom: 2px; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 8px; background: var(--c); border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

.contacts { display: flex; flex-direction: column; gap: 8px; }
.crow { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; }
.crow input { width: 100%; }
@media (max-width: 560px) { .crow { grid-template-columns: 1fr 1fr; } }

.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.preview { width: 100%; border-collapse: collapse; font-size: 13px; }
table.preview th, table.preview td { white-space: nowrap; }

/* ---- Evento (Módulo 3) ---- */
.eform { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.dates { display: flex; flex-direction: column; gap: 6px; }
.drow { display: flex; align-items: center; gap: 8px; }
.drow input[type=date] { width: auto; }
.maplinks { display: flex; gap: 8px; margin-top: 6px; align-items: center; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12px; background: var(--panel-soft); border-left: var(--bar) solid var(--info); padding: 8px 10px; border-radius: var(--radius); margin: 0; }

/* ---- Roster + Presencias (Módulo 4) ---- */
.prow { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.prow:last-child { border-bottom: 0; }
.ptype { font-family: var(--font-display); text-transform: uppercase; font-weight: 700; font-size: 10px; letter-spacing: .08em; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border); flex: 0 0 auto; }
.ptype.band { color: var(--muted); }
.ptype.crew { color: var(--accent); border-color: var(--accent); }
.pmeta { flex: 1; min-width: 0; }
.pname { font-weight: 700; }
.psub { color: var(--text-dim); font-size: 12px; }

.attlist { display: flex; flex-direction: column; gap: 6px; }
.attrow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-left: var(--bar) solid transparent; border-radius: var(--radius); cursor: pointer; background: var(--surface); }
.attrow.on { border-left-color: var(--ok); background: var(--ok-bg); }
.attrow input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--ok); flex: 0 0 auto; }
.attrow .pname { flex: 0 1 auto; }
.attrow .psub { flex: 1; }

/* ---- Timeline / Horarios (Módulo 5) ---- */
.tl-day { margin-bottom: 16px; }
.tl-day h3 { font-family: var(--font-display); text-transform: uppercase; font-weight: 700; font-size: 12px; letter-spacing: .08em; color: var(--text-dim); border-bottom: 1px solid var(--border); padding-bottom: 6px; margin: 6px 0 8px; }
.tl-row { border: 1px solid var(--border); border-left: var(--bar) solid var(--border-strong); border-radius: var(--radius); padding: 10px; margin: 6px 0; background: var(--surface); box-shadow: var(--shadow-sm); }
/* Tipos de fila — ternas Flexo border-left / fondo tenue / texto */
.tl-row.is-show   { border-left-color: var(--danger);  background: var(--danger-bg); }
.tl-row.is-show .tl-desc { color: var(--danger-text); font-weight: 700; }
.tl-row.is-salida { border-left-color: var(--warning); background: var(--warning-bg); }
.tl-row.is-salida .tl-desc { color: var(--warning-text); }
.tl-row.is-hotel  { border-left-color: var(--info);    background: var(--info-bg); }
.tl-row.is-hotel .tl-desc { color: var(--info-text); }
.tl-row.is-prueba { border-left-color: var(--ok);      background: var(--ok-bg); }
.tl-row.is-prueba .tl-desc { color: var(--ok-text); }
.tl-row.is-comida { border-left-color: var(--violet);  background: var(--violet-bg); }
.tl-row.is-comida .tl-desc { color: var(--violet-text); }
.tl-row.is-vuelo  { border-left-color: #06b6d4; background: #cffafe; }
.tl-row.is-vuelo .tl-desc { color: #155e75; }
.tl-row.is-tren   { border-left-color: #6366f1; background: #e0e7ff; }
.tl-row.is-tren .tl-desc { color: #3730a3; }
.tl-transport { margin-top: 8px; padding: 8px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.tl-tlabel { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.tl-tgrid { display: grid; grid-template-columns: 1fr 1fr 1fr 120px 1fr; gap: 6px; align-items: center; }
.tl-tgrid input { width: 100%; }
.tl-tll { display: flex; align-items: center; gap: 6px; }
.tl-tll .label { white-space: nowrap; }
@media (max-width: 560px) { .tl-tgrid { grid-template-columns: 1fr 1fr; } }
.tl-head { display: grid; grid-template-columns: 92px 1fr 96px auto; gap: 6px; align-items: center; }
.tl-time { font-family: var(--font-mono); }
.tl-hl { font-size: 12px; }
.tl-assign { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.achip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 4px 2px 8px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface-2); }
.achip.per { border-color: var(--border-strong); }
.achip.veh { border-color: var(--warning); }
.achip-x { background: none; border: 0; color: var(--text-dim); cursor: pointer; padding: 0 2px; font-size: 13px; }
.tl-addper { font-size: 12px; }
.tl-veh { width: 130px; }
@media (max-width: 560px) { .tl-head { grid-template-columns: 76px 1fr; } }
.tl-addper, .tl-addveh { font-size: 12px; }

/* Vehículos */
.veh-row { display: grid; grid-template-columns: 1fr 150px 1fr auto; gap: 6px; align-items: center; margin: 6px 0; }
.veh-row input, .veh-row select { width: 100%; }
@media (max-width: 560px) { .veh-row { grid-template-columns: 1fr 1fr; } }
table.preview th { text-align: left; font-family: var(--font-display); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; font-size: 11px; color: var(--text-dim); border-bottom: 1px solid var(--border); padding: 8px; }
table.preview td { padding: 8px; border-bottom: 1px solid var(--border); color: var(--text); }

/* ---- Toast ---- */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border); border-left: var(--bar) solid var(--accent); color: var(--text); padding: 10px 16px; border-radius: var(--radius); z-index: 50; box-shadow: var(--shadow-lg); max-width: 90vw; }

/* ---- Accesibilidad ---- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ============================================================
   Layout con sidebar fija (desktop-first) + home-dashboard
   ============================================================ */
.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); align-items: start; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 6px 8px 14px; }
.sidebar-brand .brand-text { font-size: 18px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  text-decoration: none; color: var(--muted);
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  border-left: var(--bar) solid transparent;
}
.sidebar-nav a .nav-ico { font-size: 14px; width: 18px; text-align: center; opacity: .9; }
/* Icono "ayuda": ? rojo en círculo (estilo Flexo), siempre rojo aunque la voz esté activa */
.sidebar-nav a .help-ico { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 17px; height: 17px; border: 1.5px solid var(--danger); border-radius: 999px; color: var(--danger); font-size: 11px; font-weight: 800; line-height: 1; opacity: 1; }
.sidebar-nav a:hover { background: var(--surface); color: var(--text); }
.sidebar-nav a.active { color: var(--accent); background: var(--panel-soft); border-left-color: var(--accent); }
.sidebar-cta {
  margin-top: 10px; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 12px; border-radius: var(--radius);
  background: var(--accent); color: #fff !important; font-weight: 700; text-decoration: none;
  transition: background .12s ease;
}
.sidebar-cta:hover { background: var(--accent-hover); }
.sidebar-spacer { flex: 1; }
.sidebar-foot { position: relative; display: flex; flex-direction: column; gap: 2px; padding-top: 10px; border-top: 1px solid var(--border); }
.sidebar-foot .foot-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; padding: 10px 12px; border-radius: var(--radius);
  color: var(--muted); font-weight: 700; font-size: 14px; cursor: pointer;
}
.sidebar-foot .foot-btn:hover { background: var(--surface); color: var(--text); }
/* Popover de copia de seguridad, anclado al pie de la sidebar (abre hacia arriba). */
.sidebar-foot .dev-menu { left: 8px; right: 8px; top: auto; bottom: calc(100% + 6px); min-width: 0; }

/* ---- Home / dashboard ---- */
.home-shell { display: flex; flex-direction: column; gap: 2.5rem; padding-top: 8px; }
.home-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 16px 12px 4px; }
.home-hero h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 .25rem; }
.home-hero-sub { margin: 0; color: var(--text-dim); font-size: 1rem; }
.home-section { display: flex; flex-direction: column; gap: 1rem; }
.home-section-title { margin: 0; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }
.home-grid { display: grid; gap: 1rem; }
.home-grid-1 { grid-template-columns: 1fr; }
.home-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.home-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.home-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.home-card {
  display: flex; flex-direction: column; gap: .5rem;
  padding: 1.5rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-card);
  text-decoration: none; color: var(--text); cursor: pointer; text-align: left;
  font-family: inherit; box-shadow: var(--shadow-sm); width: 100%;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.home-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.home-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.home-card-icon { font-size: 2rem; line-height: 1; }
.home-card-title { font-size: 1.05rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.home-card-desc { font-size: .875rem; color: var(--text-dim); line-height: 1.5; }
.home-card-accent { background: var(--accent); border-color: var(--accent); }
.home-card-accent .home-card-icon, .home-card-accent .home-card-title { color: #fff; }
.home-card-accent .home-card-desc { color: rgba(255,255,255,.85); }
.home-card-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ---- Branding "powered by Flexo" (logo plata/oro sobre claro, como la dashboard de Flexo) ---- */
.powered-by { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text-dim); font-size: 11px; font-weight: 600; letter-spacing: .02em; padding: 8px 12px; opacity: .95; transition: opacity .12s ease; }
.powered-by:hover { opacity: 1; }
.powered-by img { display: block; width: 150px; height: auto; }   /* sidebar (~260px): 150 es el máximo que entra */

/* Home: el logo es el protagonista — centrado, generoso, sobre blanco */
.home-powered { display: flex; justify-content: center; padding: 18px 0 6px; margin-top: .5rem; border-top: 1px solid var(--border); }
.powered-by-lg { flex-direction: column; gap: 6px; }
.powered-by-lg img { width: 350px; height: auto; }

/* ---- Logo del grupo (form Grupos) ---- */
.logo-field { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.logo-preview { max-width: 200px; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; background: var(--surface-2); }
.logo-preview img { max-width: 100%; max-height: 120px; display: block; margin: 0 auto; }

/* ---- Licencia: gate de activación + banner ---- */
body.booting .app-shell { visibility: hidden; }
.license-gate { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 20px; overflow-y: auto; }
.license-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 28px 24px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.license-logo { display: flex; justify-content: center; margin-bottom: 2px; }
.license-logo img { width: 180px; height: auto; }
.license-card h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -.02em; }
.license-sub { margin: 0; color: var(--text-dim); font-size: 14px; }
.license-input { width: 100%; font-family: var(--font-mono); font-size: 13px; resize: vertical; }
.license-err { margin: 0; padding: 10px 12px; background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger); border-radius: var(--radius); font-size: 13px; font-weight: 600; text-align: left; }
.license-err[hidden] { display: none; }
.license-card .btn-primary { justify-content: center; }
.license-contact { margin: 6px 0 0; color: var(--text-dim); font-size: 13px; }
.license-contact a { color: var(--accent); }
.license-banner { background: var(--warning-bg); color: var(--warning-text); border-bottom: 1px solid var(--warning); padding: 8px 14px; font-size: 13px; font-weight: 600; text-align: center; }

/* ---- Selector de destinatarios (enviar hoja por email) ---- */
.email-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; margin: 4px 0; }
.email-row.is-off { opacity: .5; }
.email-row .psub { margin-left: auto; }

/* ============================================================
   Guía rápida (página estática)
   ============================================================ */
.guia-shell { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; padding-top: 6px; }
.guia-hero { padding: 6px 2px 2px; }
.guia-hero h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 .4rem; }
.guia-intro { margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.55; }
.guia-steps { display: flex; flex-direction: column; gap: 12px; }
.guia-step .card-head h2 { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.guia-num { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 26px; height: 26px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 800; }
.guia-text { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.guia-text a { color: var(--accent); text-decoration: none; font-weight: 600; }
.guia-text a:hover { text-decoration: underline; }
.guia-list { margin: 8px 0 0; padding-left: 20px; color: var(--muted); font-size: 15px; line-height: 1.6; display: flex; flex-direction: column; gap: 6px; }
.guia-list strong { color: var(--text); }
.guia-warning { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border: 1px solid var(--warning); border-left: var(--bar) solid var(--warning); background: var(--warning-bg); border-radius: var(--radius-card); }
.guia-warning-ico { font-size: 20px; line-height: 1.4; }
.guia-warning p { margin: 0; color: var(--warning-text); font-size: 15px; line-height: 1.55; }
.guia-foot { display: flex; justify-content: center; padding: 10px 0 4px; }
.guia-foot .powered-by img { width: 200px; height: auto; }

/* ---- Modal (confirmación + sub-altas de formulario) ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-width: 460px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 22px; }
.modal h2 { font-size: 19px; margin: 0 0 8px; }
.modal p { margin: 0 0 18px; color: var(--muted); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.modal-header h2 { margin: 0; }
.modal-close { background: none; border: 0; font-size: 20px; line-height: 1; color: var(--text-dim); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-form { display: flex; flex-direction: column; gap: 12px; margin: 6px 0 4px; }
.modal-error { margin: 0; padding: 10px 12px; background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger); border-radius: var(--radius); font-size: 13px; font-weight: 600; }
.modal-error[hidden] { display: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* ============================================================
   Form-evento: patrón híbrido card + índice lateral (tipo Flexo)
   ============================================================ */
.event-form-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 6px; }
.event-sections { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Índice lateral sticky con estado relleno/vacío y scroll-spy */
.event-index { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 2px; padding: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-card); }
.event-index .idx-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--text-dim); padding: 6px 8px 4px; }
.event-index button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-family: inherit; font-weight: 600; font-size: 14px; cursor: pointer; border-left: var(--bar) solid transparent; }
.event-index button:hover { background: var(--surface); color: var(--text); }
.event-index button.active { background: var(--panel-soft); color: var(--accent); border-left-color: var(--accent); }
.event-index .idx-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.event-index .idx-state { margin-left: auto; font-size: 13px; font-weight: 700; }
.event-index button.filled .idx-state { color: var(--ok); }
.event-index button.empty .idx-state { color: var(--border-strong); }

/* Cards del formulario */
.ev-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-sm); overflow: hidden; scroll-margin-top: 12px; }
.ev-card .card-head { padding: 14px 16px 0; }
.ev-card .card-head h2 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.ev-card .card-body { padding: 14px 16px 16px; }

/* Progressive disclosure "Más opciones" */
.advanced-wrap { margin-top: 2px; }
.advanced-toggle { background: none; border: 0; color: var(--accent); font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer; padding: 6px 0; display: inline-flex; align-items: center; gap: 6px; }
.advanced-toggle::before { content: '▸'; display: inline-block; transition: transform .12s ease; }
.advanced-toggle.open::before { transform: rotate(90deg); }
.advanced-section { margin-top: 10px; padding: 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); display: flex; flex-direction: column; gap: 14px; }
.advanced-section[hidden] { display: none; }

/* Save-bar + feedback + estado de error de campo */
.save-bar { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.save-feedback { margin-top: 10px; font-size: 14px; font-weight: 600; }
.save-feedback[hidden] { display: none; }
.save-feedback.error { color: var(--danger-text); background: var(--danger-bg); border: 1px solid var(--danger); padding: 10px 12px; border-radius: var(--radius); }
.save-feedback.ok { color: var(--ok-text); background: var(--ok-bg); border: 1px solid var(--ok); padding: 10px 12px; border-radius: var(--radius); }
.field-alert { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(220,38,38,.15); }

/* Índice apilado en pantallas estrechas (chips horizontales, sin romper) */
@media (max-width: 900px) {
  .event-form-layout { grid-template-columns: 1fr; }
  .event-index { position: static; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .event-index .idx-title { width: 100%; }
  .event-index button { width: auto; border-left: 0; border-bottom: var(--bar) solid transparent; }
  .event-index button.active { border-left: 0; border-bottom-color: var(--accent); }
}

/* ---- Navegación móvil: top-bar + drawer off-canvas (≤768px). Desktop intacto. ---- */
.mobile-topbar { display: none; }   /* oculta en desktop */
.nav-overlay { display: none; }     /* oculto en desktop */

@media (max-width: 900px) {
  /* solo las tarjetas de la home pasan a 2 columnas en tablet; la sidebar NO cambia aquí */
  .home-grid-3, .home-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  /* top-bar compacta con hamburguesa */
  .mobile-topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30;
    height: 52px; padding: 0 12px; background: var(--bg); border-bottom: 1px solid var(--border); }
  body.booting .mobile-topbar { display: none; }
  .nav-toggle { background: none; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
    font-size: 20px; line-height: 1; width: 40px; height: 40px; display: inline-flex; align-items: center;
    justify-content: center; cursor: pointer; }
  .mobile-brand { text-decoration: none; color: var(--text); font-family: var(--font-display); font-weight: 800;
    font-size: 17px; letter-spacing: -.02em; }
  .mobile-brand em { color: var(--accent); font-style: normal; }

  /* contenido a todo el ancho; la sidebar se convierte en drawer off-canvas */
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 280px; max-width: 84vw;
    z-index: 60; transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }

  /* overlay detrás del drawer */
  .nav-overlay { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(15,23,42,.45);
    opacity: 0; visibility: hidden; transition: opacity .2s ease; }
  body.nav-open .nav-overlay { opacity: 1; visibility: visible; }

  /* logo powered-by más pequeño dentro del drawer */
  .powered-by img { width: 120px; }

  /* popup "Copia de seguridad": en móvil NO flota (evita cubrir "Nuevo evento").
     Bloque en flujo bajo su propio botón; empuja el logo y el drawer scrollea si hace falta. */
  .sidebar-foot .dev-menu {
    position: static; left: auto; right: auto; top: auto; bottom: auto;
    width: 100%; min-width: 0; margin-top: 6px; box-shadow: none;
  }
}

/* ---- Responsive (mobile-first, uso principal desde el teléfono) ---- */
@media (max-width: 640px) {
  .home-grid-2, .home-grid-3, .home-grid-4 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .cal-cell { min-height: 62px; }
  .cal-ev { font-size: 10px; }
  .app-view { padding: 12px 10px 40px; }
}
