/* =========================================================
   DISHECO SERVICE — Panel Operativo v2
   Rojo #E30613 · Fondo blanco/gris claro · IBM Plex Sans
   Estética: informe técnico industrial, no startup oscuro
   ========================================================= */

/* ── GOOGLE FONTS ────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&display=swap');

/* ── RESET & TOKENS ─────────────────────────────── */
:root {
  --red:      #E30613;
  --red-dark: #b8040f;
  --red-light:#fde8e9;
  --red-mid:  #f0a0a4;
  --white:    #ffffff;
  --bg:       #F8F9FA;
  --bg-card:  #ffffff;
  --border:   #DEE2E6;
  --border-dk:#ced4da;
  --txt-hi:   #212529;
  --txt-md:   #495057;
  --txt-lo:   #6C757D;
  --txt-dim:  #adb5bd;
  --black:    #0d0d0d;
  --green:    #28a745;

  --s-pendiente-bg:  #fff3cd; --s-pendiente-tx:  #856404;
  --s-ack-bg:        #d1ecf1; --s-ack-tx:        #0c5460;
  --s-draft-bg:      #e8daef; --s-draft-tx:      #4a235a;
  --s-entregado-bg:  #d4edda; --s-entregado-tx:  #155724;
  --s-followup-bg:   #fde8d8; --s-followup-tx:   #7c3800;
  --s-escalado-bg:   #f8d7da; --s-escalado-tx:   #721c24;

  --font:      'IBM Plex Sans', 'Inter', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', Consolas, monospace;
  --radius:    6px;
  --t:         160ms ease;
  --header-h:  60px;
  --bnav-h:    58px;
  --shadow:    0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  color: var(--txt-hi);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dk); border-radius: 2px; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.hidden { display: none !important; }

/* ── ESCALADO BANNER ────────────────────────────── */
.escalado-banner { background: var(--s-escalado-bg); border-bottom: 2px solid var(--red); }
.escalado-banner:not(.hidden) { display: block; animation: slideDown 280ms ease; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.banner-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--s-escalado-tx);
}

.banner-inner > svg { flex-shrink: 0; }

#banner-text {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
}

.banner-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--s-escalado-tx);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 3px;
  transition: background var(--t);
}

.banner-close:hover { background: rgba(185,28,28,.1); }

/* ── HEADER ─────────────────────────────────────── */
/* Header oscuro — igual que disheco.com (logo blanco sobre fondo dark navy) */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #1a1d23;
  border-bottom: 3px solid var(--red);
  box-shadow: 0 2px 12px rgba(0,0,0,.22);
  height: var(--header-h);
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
}

/* Banda roja izquierda — igual que el lateral del PDF de informe */
.header-accent { width: 0; flex-shrink: 0; display: none; }

.header-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
}

.header-logo {
  display: flex;
  align-items: baseline;
  gap: 0;
  line-height: 1;
  user-select: none;
}

/* Logo sobre fondo dark: "D" en rojo, "isheco" en blanco — identidad web disheco.com */
.logo-d      { font-size: 22px; font-weight: 700; color: var(--red); letter-spacing: -.02em; }
.logo-isheco { font-size: 22px; font-weight: 700; color: #ffffff; letter-spacing: -.02em; }
.logo-service {
  font-size: 10px;
  font-weight: 300;
  color: rgba(255,255,255,.45);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-left: 10px;
  align-self: center;
}

.header-live { display: flex; align-items: center; gap: 6px; }

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,.3);
  flex-shrink: 0;
  transition: background var(--t);
}

.live-dot.active  { background: var(--green); box-shadow: 0 0 0 2px rgba(40,167,69,.25); animation: pulse-dot 2s infinite; }
.live-dot.error   { background: var(--red); animation: blink 1.2s infinite; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1;  box-shadow: 0 0 0 0   rgba(40,167,69,.4); }
  50%       { opacity: .6; box-shadow: 0 0 0 4px rgba(40,167,69,0); }
}

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

#live-text {
  font-size: 11px;
  color: rgba(255,255,255,.5);
  font-family: var(--font-mono);
}

/* ── MAIN WRAP ───────────────────────────────────── */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--bnav-h); /* space for mobile bottom nav */
}

@media (min-width: 768px) { .main-wrap { padding-bottom: 0; } }

/* ── CHIPS ROW ───────────────────────────────────── */
.chips-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.chips-row::-webkit-scrollbar { display: none; }

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  box-shadow: var(--shadow);
}

.chip-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .7;
}
.chip-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chip--total     { background: var(--bg-card); border: 1px solid var(--border); color: var(--txt-md); }
.chip--pendiente { background: var(--s-pendiente-bg); color: var(--s-pendiente-tx); border: 1px solid #fde68a; }
.chip--entregado { background: var(--s-entregado-bg); color: var(--s-entregado-tx); border: 1px solid #a3cfb8; }
.chip--escalado  { background: var(--s-escalado-bg);  color: var(--s-escalado-tx);  border: 1px solid var(--red-mid); }
.chip--ack       { background: var(--s-ack-bg);       color: var(--s-ack-tx);       border: 1px solid #9ec8d3; }

/* Pulse dot — visible only when there are escalados */
.chip-pulse {
  position: absolute;
  top: 5px; right: 5px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--red);
  display: none;
}

/* JS adds class 'has-escalados' to the escalado chip wrapper */
.chip--escalado.has-escalados .chip-pulse {
  display: block;
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0   rgba(227,6,19,.5); }
  50%       { box-shadow: 0 0 0 5px rgba(227,6,19,0); }
}

/* ── TABS NAV ────────────────────────────────────── */
.tabs-nav {
  display: flex;
  align-items: stretch;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
  position: relative;
}

.tabs-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  flex-shrink: 0;
  padding: 12px 16px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--txt-lo);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--t), border-color var(--t);
  white-space: nowrap;
}

.tab-btn:hover { color: var(--txt-hi); }
.tab-btn.active { color: var(--red); border-bottom-color: var(--red); }

.tab-indicator {
  position: absolute;
  bottom: 0;
  height: 2px;
  background: var(--red);
  transition: left 220ms ease, width 220ms ease;
  pointer-events: none;
}

/* ── TAB PANELS ──────────────────────────────────── */
.tab-panel { display: none; flex-direction: column; flex: 1; overflow-y: auto; }
.tab-panel.active { display: flex; animation: fadeUp 180ms ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── SECTION HEADER ─────────────────────────────── */
/* Estilo cabecera de sección en informe PDF Disheco:
   MAYÚSCULAS + underline rojo fino, sin decoración lateral */
.section-header { padding: 14px 16px 8px; }

.section-header h2 {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--txt-hi);
  padding-bottom: 5px;
  border-bottom: 2px solid var(--red);
}

/* ── SKELETON ────────────────────────────────────── */
.skeleton-wrap {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-row {
  height: 42px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--border) 0%, var(--bg) 40%, var(--border) 80%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── OFFLINE NOTICE ──────────────────────────────── */
.offline-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin: 0 16px 10px;
  font-size: 11px;
  color: var(--txt-lo);
}

/* ── TABLE ───────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 8px 16px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 540px;
  font-size: 12px;
}

/* Cabecera de tabla estilo informe PDF: fondo rojo suave, texto rojo */
.data-table thead {
  background: #f2e8e8;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table thead th {
  padding: 8px 12px;
  text-align: left;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--red);
  white-space: nowrap;
  border-right: 1px solid var(--red-mid);
  border-bottom: 2px solid var(--red-mid);
}

.data-table thead th:last-child { border-right: none; }

/* Row transitions + animations */
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--t), transform var(--t);
}

.data-table tbody tr:last-child { border-bottom: none; }

/* Hover: slide right + tint rojo suave (informe style) */
.data-table tbody tr:hover { background: #fdf5f5; transform: translateX(3px); }

/* New row: fade+slide in on first load */
.data-table tbody tr.row-new {
  animation: rowFadeIn .3s ease both;
}

/* Updated row: brief yellow flash */
.data-table tbody tr.row-flash {
  animation: rowFlash .8s ease forwards;
}

@keyframes rowFadeIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes rowFlash {
  0%   { background-color: rgba(255,193,7,.35); }
  100% { background-color: transparent; }
}

.data-table tbody td {
  padding: 10px 12px;
  color: var(--txt-md);
  vertical-align: middle;
}

.td-sender strong { display: block; font-weight: 600; color: var(--txt-hi); }
.td-sender small  { font-size: 10px; color: var(--txt-dim); }

.td-subject {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-date, .td-age {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--txt-lo);
  white-space: nowrap;
}

.td-replies {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--txt-lo);
  text-align: center;
}

.table-empty {
  padding: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--txt-dim);
}

/* ── STATUS BADGE ────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-pendiente   { background: var(--s-pendiente-bg); color: var(--s-pendiente-tx); }
.badge-ack_enviado { background: var(--s-ack-bg);       color: var(--s-ack-tx); }
.badge-draft_listo { background: var(--s-draft-bg);     color: var(--s-draft-tx); }
.badge-entregado   { background: var(--s-entregado-bg); color: var(--s-entregado-tx); }
.badge-followup    { background: var(--s-followup-bg);  color: var(--s-followup-tx); }
.badge-escalado    { background: var(--s-escalado-bg);  color: var(--s-escalado-tx); }

/* ── FLUJOS GRID ─────────────────────────────────── */
.flujos-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 8px 16px 16px;
}

@media (min-width: 600px) { .flujos-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .flujos-grid { grid-template-columns: repeat(3, 1fr); } }

.flujo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--t), box-shadow var(--t);
}

.flujo-card:hover { border-color: var(--border-dk); box-shadow: 0 2px 8px rgba(0,0,0,.06); }

.flujo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.flujo-name { font-size: 13px; font-weight: 700; color: var(--txt-hi); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-on  { background: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,.22); }
.dot-off { background: var(--txt-dim); }

.flujo-desc { font-size: 11px; color: var(--txt-lo); line-height: 1.5; }

.flujo-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--txt-dim);
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

/* ── METRICS ─────────────────────────────────────── */
.metrics-wrap {
  padding: 8px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.metrics-kpi-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (min-width: 600px) { .metrics-kpi-row { grid-template-columns: repeat(4, 1fr); } }

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--txt-dim);
  text-transform: uppercase;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--txt-hi);
  line-height: 1.1;
}

/* All KPI values are accented red in Disheco informe style */
.kpi-value { color: var(--red); }
.kpi-value.accent { color: var(--red); }

.chart-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.chart-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--txt-lo);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.chart-title::before {
  content: '';
  width: 3px; height: 12px;
  background: var(--red);
  border-radius: 1px;
  flex-shrink: 0;
}

.bar-chart svg { width: 100%; max-width: 480px; overflow: visible; display: block; }

/* ── LOGIN MODAL ─────────────────────────────────── */
.login-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(15,15,15,.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 180ms ease;
}

.login-modal.slide-up {
  animation: slideUp 260ms ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-16px); }
}

.login-card {
  background: var(--bg-card);
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  display: flex;
  overflow: hidden;
  width: 100%;
  max-width: 400px;
  position: relative;
}

.login-card-accent {
  width: 6px;
  background: var(--red);
  flex-shrink: 0;
}

.login-card-body {
  flex: 1;
  padding: 32px 28px;
}

.login-logo {
  display: flex;
  align-items: baseline;
  gap: 0;
  margin-bottom: 20px;
}

.login-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--txt-hi);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 12px;
  color: var(--txt-lo);
  margin-bottom: 24px;
}

.login-form { display: flex; flex-direction: column; gap: 14px; }

.login-field { display: flex; flex-direction: column; gap: 5px; }

.login-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--txt-lo);
  text-transform: uppercase;
}

.login-input {
  width: 100%;
  border: 1px solid var(--border-dk);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--txt-hi);
  background: var(--bg);
  transition: border-color var(--t), box-shadow var(--t);
}

.login-input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(227,6,19,.12);
}

.login-error {
  font-size: 12px;
  color: #842029;
  background: #f8d7da;
  border: 1px solid #f5c2c7;
  border-radius: var(--radius);
  padding: 8px 12px;
  animation: fadeIn 180ms ease;
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 12px 20px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background var(--t), transform 80ms;
  margin-top: 4px;
}

.login-btn:hover  { background: var(--red-dark); }
.login-btn:active { transform: scale(.98); }
.login-btn:disabled { opacity: .6; cursor: not-allowed; }

.login-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── HEADER RIGHT CLUSTER ────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── QUOTA BADGE ─────────────────────────────────── */
.quota-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  position: relative;
  cursor: default;
  border: 1px solid transparent;
  transition: box-shadow var(--t);
  flex-shrink: 0;
}

.quota-badge:hover .quota-tooltip { opacity: 1; pointer-events: auto; transform: translateY(0); }

.quota-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* colour variants — semitransparent para que funcionen sobre header dark */
.quota-green { background: rgba(40,167,69,.18); color: #6ee09a; border: 1px solid rgba(40,167,69,.3); }
.quota-green .quota-dot  { background: #6ee09a; }
.quota-yellow { background: rgba(255,193,7,.15); color: #ffd760; border: 1px solid rgba(255,193,7,.3); }
.quota-yellow .quota-dot { background: #ffd760; }
.quota-red  { background: rgba(227,6,19,.18); color: #ff8a8a; border: 1px solid rgba(227,6,19,.3); }
.quota-red .quota-dot   { background: #ff8a8a; }

.quota-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--txt-hi);
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 5px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity var(--t), transform var(--t);
  z-index: 300;
}

.quota-tooltip::before {
  content: '';
  position: absolute;
  bottom: 100%;
  right: 12px;
  border: 5px solid transparent;
  border-bottom-color: var(--txt-hi);
}

/* ── AUTH CONTROLS ───────────────────────────────── */
.auth-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-user {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  font-family: var(--font-mono);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) { .auth-user { display: none; } }

.btn-logout {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius);
  padding: 5px 10px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.65);
  cursor: pointer;
  transition: border-color var(--t), color var(--t), background var(--t);
}

.btn-logout:hover { border-color: var(--red); color: #fff; background: rgba(227,6,19,.18); }

/* ── TOAST NOTIFICATIONS ─────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 70px;
  right: 16px;
  z-index: 800;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

@media (min-width: 768px) { .toast-container { bottom: 20px; } }

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  max-width: 320px;
  pointer-events: auto;
  animation: toastIn 200ms ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

.toast.toast-out { animation: toastOut 200ms ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

.toast-red    { background: #F8D7DA; color: #842029; border: 1px solid #f5c2c7; }
.toast-yellow { background: #FFF3CD; color: #664D03; border: 1px solid #ffe69c; }
.toast-green  { background: #D1E7DD; color: #0F5132; border: 1px solid #a3cfb4; }

/* ── AI SUBTABS ──────────────────────────────────── */
.ai-subtabs {
  display: flex;
  gap: 2px;
  padding: 8px 16px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.ai-subtab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--txt-lo);
  cursor: pointer;
  transition: color var(--t), border-color var(--t);
  white-space: nowrap;
  margin-bottom: -1px;
}

.ai-subtab:hover  { color: var(--txt-hi); }
.ai-subtab.active { color: var(--red); border-bottom-color: var(--red); }

/* ── AI PANELS ───────────────────────────────────── */
.ai-panel { display: none; flex-direction: column; flex: 1; overflow-y: auto; }
.ai-panel.active { display: flex; animation: fadeUp 180ms ease; }

/* ── CHAT ────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 240px;
  max-height: calc(100dvh - 340px);
}

.chat-welcome { display: flex; justify-content: flex-start; }

.chat-bubble {
  display: flex;
  max-width: 80%;
}

.chat-bubble--user { justify-content: flex-end; align-self: flex-end; }
.chat-bubble--pepe { justify-content: flex-start; align-self: flex-start; }
.chat-bubble--system { align-self: center; max-width: 95%; }

.bubble-content {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

/* User: gris claro, derecha */
.chat-bubble--user .bubble-content {
  background: #e9ecef;
  color: var(--txt-hi);
  border-bottom-right-radius: 3px;
}

/* Pepe: blanco con borde rojo izquierdo */
.chat-bubble--pepe .bubble-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  color: var(--txt-hi);
  border-bottom-left-radius: 3px;
}

/* System errors */
.chat-bubble--system .bubble-content {
  background: #f8d7da;
  border: 1px solid #f5c2c7;
  color: #842029;
  border-radius: 6px;
  font-size: 12px;
  text-align: center;
}

/* Typing indicator */
.typing-dots { display: flex; gap: 4px; align-items: center; padding: 10px 14px; }

.typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border-dk);
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* Mini markdown inside bubbles */
.bubble-content strong { font-weight: 700; }
.bubble-content code {
  font-family: var(--font-mono);
  font-size: .9em;
  background: rgba(0,0,0,.07);
  padding: 1px 5px;
  border-radius: 3px;
}
.bubble-content a { color: var(--red); text-decoration: underline; }

/* Chat form */
.chat-form {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  background: var(--bg-card);
  flex-shrink: 0;
}

.chat-input-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  border: 1px solid var(--border-dk);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--txt-hi);
  background: var(--bg);
  resize: none;
  max-height: 120px;
  line-height: 1.45;
  transition: border-color var(--t), box-shadow var(--t);
}

.chat-input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(227,6,19,.1);
}

.chat-send-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t), transform 80ms;
}

.chat-send-btn:hover  { background: var(--red-dark); }
.chat-send-btn:active { transform: scale(.94); }
.chat-send-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── DRAFT CARDS ─────────────────────────────────── */
.draft-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 16px;
}

@media (min-width: 600px) { .draft-grid { grid-template-columns: repeat(3, 1fr); } }

.draft-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--t), box-shadow var(--t);
}

.draft-card:hover { border-color: var(--red-mid); box-shadow: 0 2px 10px rgba(0,0,0,.06); }

.draft-card-icon { color: var(--red); }

.draft-card-body { flex: 1; }

.draft-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--txt-hi);
  margin-bottom: 4px;
}

.draft-card-desc {
  font-size: 12px;
  color: var(--txt-lo);
  line-height: 1.5;
}

.draft-card-btn {
  align-self: flex-start;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 7px 14px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background var(--t), transform 80ms;
}

.draft-card-btn:hover  { background: var(--red-dark); }
.draft-card-btn:active { transform: scale(.97); }
.draft-card-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Draft context prompt */
.draft-context-wrap {
  margin: 0 16px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fadeUp 160ms ease;
}

.draft-context-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--txt-lo);
  text-transform: uppercase;
}

.draft-context-input {
  width: 100%;
  border: 1px solid var(--border-dk);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--txt-hi);
  background: var(--bg);
  resize: vertical;
  transition: border-color var(--t);
}

.draft-context-input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(227,6,19,.1);
}

.draft-context-actions { display: flex; gap: 8px; justify-content: flex-end; }

.btn-primary {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--t);
}

.btn-primary:hover { background: var(--red-dark); }

.btn-secondary {
  background: none;
  color: var(--txt-md);
  border: 1px solid var(--border-dk);
  border-radius: var(--radius);
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--t), color var(--t);
}

.btn-secondary:hover { border-color: var(--txt-md); color: var(--txt-hi); }

/* Draft result */
.draft-result-wrap {
  margin: 12px 16px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  animation: fadeUp 160ms ease;
}

.draft-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #f2e8e8;
}

.draft-result-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--red);
  text-transform: uppercase;
}

.btn-copy {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--red-mid);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  color: var(--red);
  cursor: pointer;
  transition: background var(--t);
}

.btn-copy:hover { background: var(--red-light); }

.draft-result-text {
  padding: 16px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--txt-hi);
  white-space: pre-wrap;
  max-height: 360px;
  overflow-y: auto;
}

/* ── SEMANTIC SEARCH ─────────────────────────────── */
.search-form { padding: 16px; }

.search-input-wrap {
  display: flex;
  gap: 8px;
}

.search-input {
  flex: 1;
  border: 1px solid var(--border-dk);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--txt-hi);
  background: var(--bg);
  transition: border-color var(--t), box-shadow var(--t);
}

.search-input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(227,6,19,.1);
}

.search-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t);
}

.search-btn:hover { background: var(--red-dark); }
.search-btn:disabled { opacity: .5; cursor: not-allowed; }

.search-results {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--t);
  animation: fadeUp 160ms ease;
}

.search-result-card:hover { border-color: var(--border-dk); }

.search-result-path {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--red);
  word-break: break-all;
  text-decoration: none;
}

.search-result-path:hover { text-decoration: underline; }

.search-result-snippet {
  font-size: 12px;
  color: var(--txt-md);
  line-height: 1.55;
}

.search-result-score-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-result-score-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--txt-dim);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

.search-score-bar {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  max-width: 120px;
}

.search-score-fill {
  height: 100%;
  background: var(--red);
  border-radius: 3px;
}

.search-score-val {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--txt-lo);
}

.search-empty {
  font-size: 13px;
  color: var(--txt-dim);
  text-align: center;
  padding: 32px;
}

/* ── EQUIPO — "TÚ" badge ─────────────────────────── */
.equipo-me-row { border: 1.5px solid var(--red-mid) !important; background: #fff8f8; }

.badge-tu {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  background: var(--red);
  color: #fff;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── FOOTER ──────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 12px 16px;
  font-size: 11px;
  color: var(--txt-dim);
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.site-footer a { color: var(--red); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ── MOBILE BOTTOM NAV ───────────────────────────── */
#mobile-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bnav-h);
  background: var(--black);
  border-top: 1px solid #1f1f1f;
  display: flex;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (min-width: 768px) { #mobile-nav { display: none; } }

.mnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: #666;
  font-family: var(--font);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0 2px;
  position: relative;
  transition: color var(--t);
}

.mnav-item:hover { color: #aaa; }
.mnav-item.active { color: var(--white); }

.mnav-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 14px; right: 14px;
  height: 2px;
  background: var(--red);
  border-radius: 0 0 2px 2px;
}

.mnav-icon {
  width: 22px; height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mnav-icon svg {
  width: 18px; height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── ROW ANIMATIONS (table email rows) ──────────── */
@keyframes rowFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes rowFlash {
  0%   { background: #fff8e1; }
  100% { background: transparent; }
}

tr.row-new   { animation: rowFadeIn 260ms ease forwards; }
tr.row-flash { animation: rowFlash 900ms ease forwards; }

/* ── ANIM-IN for flujo cards ─────────────────────── */
.anim-in { animation: rowFadeIn 220ms ease forwards; }

/* ── FILES BROWSER ───────────────────────────────── */
.files-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 8px 16px 4px;
  font-size: 12px;
  color: var(--txt-lo);
}

.files-breadcrumb .bc-root {
  font-weight: 700;
  color: var(--txt-hi);
  cursor: pointer;
}

.files-breadcrumb .bc-sep { color: var(--txt-dim); }

.files-breadcrumb .bc-item {
  color: var(--red);
  cursor: pointer;
  text-decoration: none;
}

.files-breadcrumb .bc-item:hover { text-decoration: underline; }
.files-breadcrumb .bc-item.current { color: var(--txt-hi); font-weight: 600; pointer-events: none; }

.files-list {
  display: flex;
  flex-direction: column;
  margin: 8px 16px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
}

.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--t);
  text-decoration: none;
  color: inherit;
}

.file-row:last-child { border-bottom: none; }
.file-row:hover { background: #fafafa; }

.file-row-icon {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.file-icon-dir  { background: #fff3cd; color: #b45309; }
.file-icon-pdf  { background: #fee2e2; color: var(--red); }
.file-icon-docx { background: #dbeafe; color: #1d4ed8; }
.file-icon-xlsx { background: #dcfce7; color: #15803d; }
.file-icon-img  { background: #f3e8ff; color: #7c3aed; }
.file-icon-other{ background: var(--bg); color: var(--txt-lo); }

.file-row-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--txt-hi);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--txt-dim);
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.file-row-dl {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: none;
  border: 1px solid var(--border);
  color: var(--txt-lo);
  cursor: pointer;
  transition: border-color var(--t), color var(--t);
  text-decoration: none;
  flex-shrink: 0;
}

.file-row-dl:hover { border-color: var(--red); color: var(--red); }

.file-row-dl svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── CHAT TYPING INDICATOR ───────────────────────── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--txt-dim);
  animation: typingBounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── CONTEXT INPUT (directrices a Pepe) ─────────── */
.chat-context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-top: 1px dashed var(--border);
  background: #fffbf0;
}

.context-bar-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  color: #b45309;
  text-transform: uppercase;
  white-space: nowrap;
}

.context-bar-input {
  flex: 1;
  border: 1px solid #f0d080;
  border-radius: 4px;
  padding: 5px 10px;
  font-family: var(--font);
  font-size: 12px;
  background: var(--white);
  color: var(--txt-hi);
}

.context-bar-input:focus { outline: none; border-color: #b45309; }

.context-toggle-btn {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--txt-lo);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t), border-color var(--t);
}

.context-toggle-btn:hover { color: var(--txt-hi); border-color: var(--border-dk); }

/* ── CHANGE PASSWORD BUTTON (header) ─────────────── */
.btn-change-password {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--txt-lo);
  cursor: pointer;
  transition: color var(--t), border-color var(--t), background var(--t);
  white-space: nowrap;
}
.btn-change-password:hover {
  color: var(--txt-hi);
  border-color: var(--border-dk);
  background: var(--bg-2);
}
@media (max-width: 600px) {
  .btn-change-password-label { display: none; }
}

/* ── SKIP BUTTON (change-pwd modal) ─────────────── */
.btn-chpwd-skip {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  background: none;
  border: none;
  font-size: 12px;
  color: var(--txt-lo);
  cursor: pointer;
  text-align: center;
  letter-spacing: .04em;
  transition: color var(--t);
}
.btn-chpwd-skip:hover { color: var(--txt-hi); }

/* ── REDUCED MOTION ──────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
