/* =========================================================
   SSMC · Sistema de Gestión Operativa
   Hoja de estilos global
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* Paleta */
  --bg: #EEF1ED;
  --surface: #FFFFFF;
  --surface-2: #F5F7F4;
  --ink: #1C2B28;
  --ink-soft: #5B6B68;
  --ink-faint: #93A19D;
  --border: #DCE3DD;
  --border-strong: #C3CEC7;

  --primary: #1B4F9B;
  --primary-dark: #1a3f7a;
  --primary-soft: #E8EEF8;

  --accent: #D0312D;
  --accent-soft: #FAEAEA;

  --danger: #C1574A;
  --danger-soft: #FBE8E4;

  --info: #4A7FA5;
  --info-soft: #E6EFF5;

  --success: #5C8A5C;
  --success-soft: #E7F0E5;

  --warning: #D6A03C;
  --warning-soft: #FBF1DD;

  /* Color propio para Tareas en el calendario semanal (antes usaba un gris
     neutro que se confundía con el fondo y con Visitas) */
  --task: #6D5BA6;
  --task-soft: #EFEAF7;

  /* Tipografía */
  --font-display: 'Fraunces', serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  /* Layout */
  --sidebar-w: 248px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(28, 43, 40, 0.04), 0 4px 16px rgba(28, 43, 40, 0.05);
  --transition: 180ms ease;
}

[data-theme="oscuro"] {
  --bg: #131D1B;
  --surface: #1B2A27;
  --surface-2: #20302C;
  --ink: #E8EFEB;
  --ink-soft: #9FB0AB;
  --ink-faint: #6B7C77;
  --border: #2E3F3B;
  --border-strong: #3C4F4A;

  --primary: #4A7FCC;
  --primary-dark: #3A6AB5;
  --primary-soft: #1E2D45;

  --accent: #E05550;
  --accent-soft: #3D1F1F;

  --danger: #E0827A;
  --danger-soft: #332220;

  --info: #7FAAD0;
  --info-soft: #1F2B33;

  --success: #8AB888;
  --success-soft: #1F2D1F;

  --warning: #E5BE74;
  --warning-soft: #332B19;

  --task: #9D8BD6;
  --task-soft: #2A2440;


  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

a { color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------
   Pulso (elemento de firma) — divisor tipo trazado clínico
   --------------------------------------------------------- */

.pulse-divider {
  display: block;
  width: 100%;
  height: 28px;
  margin: 4px 0 20px;
}

.pulse-divider svg {
  width: 100%;
  height: 100%;
  display: block;
}

.pulse-divider path {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pulse-divider.accent path {
  stroke: var(--accent);
  stroke-width: 2;
}

/* ---------------------------------------------------------
   Layout general
   --------------------------------------------------------- */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .mark {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand .mark svg { width: 22px; height: 22px; }

.sidebar-brand .text { line-height: 1.25; }
.sidebar-brand .text .title { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.sidebar-brand .text .subtitle { font-size: 11px; color: var(--ink-soft); letter-spacing: 0.04em; text-transform: uppercase; }

.nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  padding: 16px 10px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-link:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

[data-theme="oscuro"] .nav-link.active { color: var(--primary); }

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.depto-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.depto-pill .dot { width: 7px; height: 7px; border-radius: 50%; }

.solo-lectura-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-dark, #8a5a00);
  background: var(--accent-soft, #FBF0DC);
  border: 1px solid var(--accent, #D6A03C);
}
.solo-lectura-pill svg { width: 14px; height: 14px; flex-shrink: 0; }

/* =========================================================
   Modo solo lectura (jefatura superior / Subdirección Médica)
   ---------------------------------------------------------
   Oculta los controles de creación, edición, eliminación,
   aprobación/rechazo y el botón de acción rápida (FAB) del
   Dashboard. El arrastre de tarjetas en los tableros Kanban
   se desactiva por JavaScript (ver kanban-tareas.js y
   kanban-reuniones.js, variable window.SSMC_SOLO_LECTURA).
   ========================================================= */
.solo-lectura #newTaskBtn,
.solo-lectura #newMeetingBtn,
.solo-lectura #newVisitaBtn,
.solo-lectura #newContBtn,
.solo-lectura #newAusBtn,
.solo-lectura #newReqBtn,
.solo-lectura #mEditar,
.solo-lectura #mEliminar,
.solo-lectura #mGuardar,
.solo-lectura #mAprobar,
.solo-lectura #mRechazar,
.solo-lectura .fab-root {
  display: none !important;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.user-card .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}

.user-card .meta { line-height: 1.3; overflow: hidden; }
.user-card .meta .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .meta .role { font-size: 11px; color: var(--ink-soft); }

.theme-toggle {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 100px;
  padding: 5px 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-soft);
  width: 100%;
  justify-content: center;
}

.theme-toggle svg { width: 14px; height: 14px; }

.logout-btn {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 100px;
  padding: 5px 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-soft);
  width: 100%;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  margin-top: 6px;
}
.logout-btn:hover {
  background: #FBE8E4;
  color: #C1574A;
  border-color: #C1574A44;
}
.logout-btn svg { width: 14px; height: 14px; }

/* Main */

.main {
  padding: 28px 36px 60px;
  max-width: 1280px;
  width: 100%;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 6px;
}

.page-header .eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 6px;
}

.page-header h1 {
  font-size: 28px;
}

.page-header p.lead {
  color: var(--ink-soft);
  margin-top: 6px;
  max-width: 640px;
  font-size: 14px;
}

.header-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ---------------------------------------------------------
   Botones
   --------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.92); }

.btn-sm { padding: 6px 11px; font-size: 12px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------------------------------------------------
   Tarjetas / KPIs
   --------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.card-pad { padding: 20px 22px; }

.section-title {
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-display);
  margin-bottom: 4px;
}

.section-sub {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 18px 0 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.kpi-card .kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.kpi-card .kpi-value {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
}

.kpi-card .kpi-value sup {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-left: 4px;
}

.kpi-card .kpi-foot {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}

.kpi-card.tone-accent { border-color: var(--accent); }
.kpi-card.tone-accent .kpi-value { color: var(--accent); }
.kpi-card.tone-danger .kpi-value { color: var(--danger); }
.kpi-card.tone-info .kpi-value { color: var(--info); }
.kpi-card.tone-success .kpi-value { color: var(--success); }

/* Grids de gráficos */

.charts-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.charts-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.chart-card { padding: 18px 20px; display: flex; flex-direction: column; }
.chart-card .chart-canvas-wrap { position: relative; height: 240px; width: 100%; margin-top: 8px; }
.chart-card canvas { max-height: 240px; }

/* ---------------------------------------------------------
   Dashboard rediseñado — 3 columnas (Hoy / Planificación / Mi estado)
   --------------------------------------------------------- */

.dash-3col {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 16px;
  align-items: start;
}
.dash-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Listas críticas (contingencias, agenda, próximas a vencer) */
.crit-card { padding: 16px 18px; }
.crit-card .crit-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.crit-card .crit-title { font-size: 13px; font-weight: 700; color: var(--ink); }
.crit-card .crit-count {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 100px; background: var(--surface-2); color: var(--ink-soft);
}
.crit-card.is-empty .crit-count { background: var(--success-soft); color: var(--success); }
.crit-list { display: flex; flex-direction: column; gap: 6px; }
.crit-item {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 8px 10px; border-radius: 8px; background: var(--surface-2);
  border-left: 3px solid var(--border-strong); font-size: 12px; line-height: 1.4;
}
.crit-item.danger  { border-left-color: var(--danger);  background: var(--danger-soft); }
.crit-item.warning { border-left-color: var(--warning); background: var(--warning-soft); }
.crit-item.info    { border-left-color: var(--info);    background: var(--info-soft); }
.crit-item .crit-time { font-family: var(--font-mono); font-weight: 700; font-size: 11px; flex-shrink: 0; white-space: nowrap; }
.crit-item .crit-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crit-item .crit-sub { display: block; font-size: 10.5px; color: var(--ink-faint); margin-top: 1px; }
.crit-empty { font-size: 12px; color: var(--ink-faint); text-align: center; padding: 14px 0; }
.crit-more { font-size: 11.5px; color: var(--primary); text-align: center; padding-top: 4px; cursor: pointer; font-weight: 600; }
.crit-more:hover { text-decoration: underline; }

/* Tendido de KPIs secundarios (más discretos que los críticos) */
.kpi-grid-secondary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px;
}
.kpi-grid-secondary .kpi-card { padding: 12px 14px; }
.kpi-grid-secondary .kpi-label { font-size: 10.5px; }
.kpi-grid-secondary .kpi-value { font-size: 20px; }

/* Panel "Ver más" colapsable (usado en móvil para la columna central) */
.dash-collapse-toggle {
  display: none;
  width: 100%; text-align: center; padding: 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  font-size: 12.5px; font-weight: 700; color: var(--primary); cursor: pointer; margin-bottom: 12px;
}
.dash-collapse-toggle .chev { display: inline-block; transition: transform .2s ease; margin-left: 4px; }
.dash-collapse-toggle.is-open .chev { transform: rotate(180deg); }

/* ---------------------------------------------------------
   FAB de acción rápida (solo visible en móvil)
   --------------------------------------------------------- */
.fab-root { display: none; }
.fab-btn {
  position: fixed; right: 18px; bottom: 22px; z-index: 60;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  box-shadow: 0 8px 20px rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform .2s ease;
}
.fab-btn svg { width: 24px; height: 24px; }
.fab-btn.is-open { transform: rotate(45deg); }
.fab-menu {
  position: fixed; right: 18px; bottom: 88px; z-index: 60;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  opacity: 0; pointer-events: none; transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
}
.fab-menu.is-open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.fab-menu-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 100px;
  padding: 8px 14px 8px 8px; box-shadow: 0 4px 14px rgba(0,0,0,.15);
  font-size: 12.5px; font-weight: 600; color: var(--ink); cursor: pointer; white-space: nowrap;
}
.fab-menu-item .ico {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.fab-menu-item.contingencia .ico { background: var(--danger); }
.fab-menu-item.tarea .ico       { background: var(--primary); }
.fab-menu-item.visita .ico      { background: var(--accent); }
.fab-backdrop {
  position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.15);
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.fab-backdrop.is-open { opacity: 1; pointer-events: auto; }

/* ---------------------------------------------------------
   Filtros
   --------------------------------------------------------- */

.filters-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 18px 0;
}

.filters-bar label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  display: block;
  margin-bottom: 4px;
}

.field-inline { display: flex; flex-direction: column; }

select, input, textarea {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

select:focus, input:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

/* ---------------------------------------------------------
   Tags / badges de estado
   --------------------------------------------------------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 100px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tag-pendiente { background: var(--info-soft); color: var(--info); }
.tag-en-proceso { background: var(--warning-soft); color: var(--warning); }
.tag-en-revision { background: var(--accent-soft); color: var(--accent); }
.tag-completada, .tag-realizada, .tag-aprobada, .tag-cerrada { background: var(--success-soft); color: var(--success); }
.tag-programada { background: var(--info-soft); color: var(--info); }
.tag-confirmada { background: var(--success-soft); color: var(--success); }
.tag-suspendida, .tag-rechazada { background: var(--danger-soft); color: var(--danger); }
.tag-abierta { background: var(--danger-soft); color: var(--danger); }
.tag-en-seguimiento { background: var(--warning-soft); color: var(--warning); }

.tag-prioridad-alta { background: var(--danger-soft); color: var(--danger); }
.tag-prioridad-media { background: var(--warning-soft); color: var(--warning); }
.tag-prioridad-baja { background: var(--success-soft); color: var(--success); }

.tag-impacto-alto, .tag-alto { background: var(--danger-soft); color: var(--danger); }
.tag-impacto-medio, .tag-medio { background: var(--warning-soft); color: var(--warning); }
.tag-impacto-bajo, .tag-bajo { background: var(--success-soft); color: var(--success); }

/* ---------------------------------------------------------
   Tablero Kanban
   --------------------------------------------------------- */

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  align-items: start;
}

.kanban-column {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kanban-column.drag-over { border-color: var(--primary); background: var(--primary-soft); }

.kanban-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 6px;
  border-bottom: 2px solid var(--border-strong);
  margin-bottom: 2px;
}

.kanban-column-head h3 {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}

.kanban-count {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 1px 8px;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 13px;
  cursor: grab;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}

.kanban-card:hover { box-shadow: var(--shadow-card); border-color: var(--border-strong); }
.kanban-card.dragging { opacity: 0.4; }

.kanban-card .kc-title {
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 6px;
  line-height: 1.35;
}

.kanban-card .kc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.kanban-card .kc-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--ink-soft);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 6px;
}

.kanban-card .kc-foot .kc-resp {
  display: flex; align-items: center; gap: 6px;
  overflow: hidden;
}

.kc-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 10px;
  flex-shrink: 0;
}

.kc-due-warning { color: var(--danger); font-weight: 600; }

.empty-column {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 18px 10px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-faint);
}

/* ---------------------------------------------------------
   Tablas
   --------------------------------------------------------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  background: var(--surface-2);
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

.table-actions { display: flex; gap: 6px; }

.muted { color: var(--ink-soft); }
.mono { font-family: var(--font-mono); }

.text-right { text-align: right; }

/* ---------------------------------------------------------
   Modal / formularios
   --------------------------------------------------------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 30, 28, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  border: 1px solid var(--border);
}

.modal.modal-xl {
  max-width: 1160px;
}

@media (max-width: 900px) {
  .modal.modal-xl { max-width: 96vw; }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--surface);
}

.modal-head h2 { font-size: 18px; }
.modal-head .close-btn {
  background: none; border: none; cursor: pointer;
  color: var(--ink-soft); width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
}
.modal-head .close-btn:hover { background: var(--surface-2); color: var(--ink); }

.modal-body { padding: 18px 22px 22px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid .full { grid-column: 1 / -1; }

.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}
.form-field .req { color: var(--danger); }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.helper-text { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }

/* Caja de automatización */
.auto-note {
  display: flex; gap: 10px;
  background: var(--info-soft);
  border: 1px solid var(--info);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--ink);
  margin-top: 12px;
}
.auto-note svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--info); margin-top: 1px; }

/* Comentarios / historial */
.detail-section { margin-top: 18px; }
.detail-section h4 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-soft); margin-bottom: 8px; font-family: var(--font-body); font-weight: 600;
}

.comment {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  margin-bottom: 8px;
  font-size: 13px;
}
.comment .comment-meta { font-size: 11px; color: var(--ink-soft); margin-bottom: 3px; }

.history-item {
  display: flex; gap: 10px; align-items: baseline;
  font-size: 12.5px; color: var(--ink-soft);
  padding: 5px 0;
}
.history-item .hi-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex-shrink: 0;
  margin-top: 5px;
}
.history-item .hi-date { font-family: var(--font-mono); font-size: 11px; flex-shrink: 0; }

.attachment-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 4px 10px;
  font-size: 12px;
  margin: 2px 4px 2px 0;
}
.attachment-chip svg { width: 13px; height: 13px; color: var(--ink-soft); }

/* ---------------------------------------------------------
   Landing
   --------------------------------------------------------- */

.landing {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background:
    radial-gradient(circle at 12% 18%, var(--primary-soft) 0%, transparent 45%),
    radial-gradient(circle at 88% 82%, var(--accent-soft) 0%, transparent 45%),
    var(--bg);
}

.landing-shell {
  width: 100%;
  max-width: 980px;
}

.landing-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 30px;
}

.landing-brand { display: flex; align-items: center; gap: 12px; }
.landing-brand .mark {
  width: 46px; height: 46px; border-radius: var(--radius-md);
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.landing-brand .mark svg { width: 26px; height: 26px; }
.landing-brand .text .title { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.landing-brand .text .subtitle { font-size: 12px; color: var(--ink-soft); letter-spacing: 0.05em; text-transform: uppercase; }

.landing-hero {
  margin-bottom: 28px;
}

.landing-hero .eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 10px;
}

.landing-hero h1 {
  font-size: 38px;
  line-height: 1.15;
  max-width: 680px;
  margin-bottom: 12px;
}

.landing-hero p {
  color: var(--ink-soft);
  max-width: 560px;
  font-size: 15px;
}

.dept-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.dept-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-card);
}

.dept-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.dept-card .dept-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
}
.dept-card .dept-icon svg { width: 22px; height: 22px; }

.dept-card .dept-sigla {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

.dept-card h3 { font-size: 17px; }
.dept-card p { font-size: 12.5px; color: var(--ink-soft); margin: 0; }

.landing-footer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-card);
  flex-wrap: wrap;
}

.landing-footer-card .role-select { display: flex; align-items: center; gap: 10px; }
.landing-footer-card .role-select label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }

.landing-note { font-size: 12px; color: var(--ink-faint); margin-top: 14px; text-align: center; }

/* ---------------------------------------------------------
   Toast
   --------------------------------------------------------- */

.toast-wrap {
  position: fixed;
  bottom: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  min-width: 260px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toast-in 220ms ease;
}

.toast svg { width: 16px; height: 16px; color: var(--primary); flex-shrink: 0; margin-top: 1px; }

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

/* ---------------------------------------------------------
   Misceláneo
   --------------------------------------------------------- */

.progress-track {
  height: 8px;
  background: var(--surface-2);
  border-radius: 100px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 100px;
}

.depto-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.depto-row:last-child { border-bottom: none; }
.depto-row .name { display: flex; align-items: center; gap: 8px; }
.depto-row .name .dot { width: 8px; height: 8px; border-radius: 50%; }
.depto-row .pct { font-family: var(--font-mono); font-weight: 600; }

.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin-bottom: 6px; }
.legend-row .dot { width: 9px; height: 9px; border-radius: 50%; }

/* ---------------------------------------------------------
   Responsivo
   --------------------------------------------------------- */

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .charts-grid-3 { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: repeat(2, 1fr); }
  .dept-grid { grid-template-columns: 1fr; }
  .dash-3col { grid-template-columns: 1fr; }
  .kpi-grid-secondary { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .sidebar-brand { border-bottom: none; margin-bottom: 0; padding-bottom: 4px; }
  .nav-section-label { display: none; }
  .sidebar-footer { width: 100%; }
  .main { padding: 20px 16px 40px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kanban-board { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .landing-top { flex-direction: column; align-items: flex-start; gap: 14px; }
  .landing-hero h1 { font-size: 28px; }

  /* Dashboard: orden de prioridad — semáforo propio y críticos primero,
     planificación (gráficos, calendario) colapsada bajo "Ver más". */
  .dash-3col { display: flex; flex-direction: column; gap: 12px; }
  .dash-col { gap: 12px; }
  .dash-col-mistate  { order: 1; }
  .dash-col-hoy      { order: 2; }
  .dash-col-plan      { order: 3; }
  .kpi-grid-secondary { grid-template-columns: repeat(3, 1fr); }
  .dash-collapse-toggle { display: block; }
  .dash-col-plan.is-collapsed > *:not(.dash-collapse-toggle) { display: none; }

  /* FAB visible solo en móvil */
  .fab-root { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* =========================================================
   Coresponsables — tarjetas Kanban y modales
   ========================================================= */

/* Grupo de avatares apilados en la tarjeta */
.kc-avatars {
  display: flex;
  align-items: center;
  gap: 0;
}
.kc-avatars .kc-avatar {
  margin-right: -6px;
  border: 2px solid var(--surface);
  font-size: 10px;
  width: 26px;
  height: 26px;
}
.kc-avatars .kc-avatar:first-child { z-index: 3; }
.kc-avatars .kc-avatar:nth-child(2) { z-index: 2; }
.kc-avatars .kc-avatar:nth-child(3) { z-index: 1; }
.kc-avatar-main {
  background: var(--brand);
  color: #fff;
}
.kc-avatar-more {
  background: var(--ink-soft);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}
.kc-avatar-sm {
  width: 22px;
  height: 22px;
  font-size: 9px;
  flex-shrink: 0;
}
.kc-resp-label {
  margin-left: 10px;
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

/* Chips de coresponsables en el modal detalle (vista) */
.coresponsables-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.corsp-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px 3px 4px;
  font-size: 12px;
  color: var(--ink);
}

/* Multiselect de coresponsables (formulario crear/editar) */
.multiselect-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 42px;
}
.corsp-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 6px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
.corsp-option input[type="checkbox"] {
  display: none;
}
.corsp-option:hover {
  border-color: var(--brand);
  background: var(--brand-light, #e8f0fe);
}
.corsp-option--checked {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.corsp-option--checked .kc-avatar {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

/* =========================================================
   Recurrencia — panel y badge
   ========================================================= */

/* Badge en la tarjeta */
.recurrencia-badge {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 6px;
  color: var(--brand);
  opacity: 0.85;
}
.recurrencia-badge svg {
  width: 13px;
  height: 13px;
}

/* Toggle "Tarea/Reunión recurrente" */
.recurrencia-toggle-wrap {
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
}
.recurrencia-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink);
  user-select: none;
}
.recurrencia-toggle-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--brand);
  cursor: pointer;
}
.recurrencia-icon-inline {
  display: inline-flex;
  color: var(--brand);
}
.recurrencia-icon-inline svg {
  width: 15px;
  height: 15px;
}

/* Panel expandible de opciones */
.recurrencia-panel {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  animation: fadeSlideDown 0.18s ease;
}
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Nota de preview dentro del panel */
.recurrencia-preview-note {
  margin-top: 10px;
  background: color-mix(in srgb, var(--brand) 8%, transparent);
  border-color: color-mix(in srgb, var(--brand) 30%, transparent);
  color: var(--ink);
}
.recurrencia-preview-note svg {
  color: var(--brand);
  flex-shrink: 0;
}

/* =========================================================
   Segmented control (selector semana / mes)
   ========================================================= */
.segmented-control {
  display: inline-flex;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  padding: 5px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-btn:hover:not(.active) {
  background: var(--surface);
  color: var(--ink);
}
.seg-btn.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* =========================================================
   KanbanPager — botón "Cargar N más"
   ========================================================= */
.kp-load-more {
  width: 100%;
  margin-top: 8px;
  padding: 9px 12px;
  background: var(--surface-raised);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  color: var(--ink);
}
.kp-load-more:hover {
  background: var(--surface);
  border-color: var(--brand);
  border-style: solid;
}
.kp-load-more-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand);
  gap: 8px;
}
.kp-load-more-rest {
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-faint);
  white-space: nowrap;
}
