:root {
  --primary: #0f766e;
  --primary-dark: #0d5f59;
  --accent: #0ea5e9;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; }

a { color: var(--primary); text-decoration: none; }

/* ---------- Layout base ---------- */

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.layout {
  display: flex;
  flex: 1;
  min-height: 100vh;
}

.sidebar {
  display: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
}

.topbar-brand .logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

.topbar-business {
  font-size: 12px;
  color: var(--text-muted);
}

.main-content {
  flex: 1;
  padding: 16px;
  padding-bottom: 90px; /* espacio para la barra inferior en móvil */
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Motor de búsqueda global ---------- */
/* Barra hermana de .topbar/.sidebar (ver renderShell() en app.js): vive
   fuera de ambos para que se vea igual en el layout móvil y de escritorio,
   sin tener que duplicar el marcado en dos lugares. */

.global-search-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}

.global-search-wrap {
  position: relative;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.global-search-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
  background: var(--bg);
}

.global-search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: var(--surface);
}

.global-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 65vh;
  overflow-y: auto;
  z-index: 30;
}

.global-search-group-title {
  padding: 10px 14px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.global-search-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.global-search-item:hover,
.global-search-item:focus {
  background: #f1f5f9;
}

.global-search-item .gs-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.global-search-empty {
  padding: 16px 14px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

@media (min-width: 860px) {
  .global-search-bar { padding: 10px 40px; }
}

/* ---------- Navegación inferior (móvil/tablet) ---------- */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 10;
}

.bottom-nav button {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: none;
  background: none;
  padding: 6px 2px;
  font-size: 11px;
  color: var(--text-muted);
  border-radius: 10px;
  cursor: pointer;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: var(--warning-bg);
  color: var(--warning);
}

.nav-badge.nav-badge-danger { background: var(--danger-bg); color: var(--danger); }

.bottom-nav .nav-badge {
  position: absolute;
  top: 2px;
  right: 14px;
}

.bottom-nav button.active {
  color: var(--primary);
  background: #ecfdf5;
}

.bottom-nav .icon {
  font-size: 18px;
  line-height: 1;
}

/* ---------- Escritorio: sidebar en vez de barra inferior ---------- */

@media (min-width: 860px) {
  .layout { flex-direction: row; }

  .sidebar {
    display: flex;
    flex-direction: column;
    width: 230px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 4px;
    padding: 0 8px;
  }

  .sidebar-business {
    font-size: 12px;
    color: var(--text-muted);
    padding: 0 8px;
    margin-bottom: 22px;
  }

  .sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
  }

  .sidebar button {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    border: none;
    background: none;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
  }

  .sidebar nav button .nav-badge {
    margin-left: auto;
  }

  .sidebar button.active {
    color: var(--primary);
    background: #ecfdf5;
    font-weight: 600;
  }

  .sidebar button:hover:not(.active) {
    background: #f1f5f9;
  }

  .topbar { display: none; }
  .bottom-nav { display: none; }
  .main-content { padding: 32px 40px; padding-bottom: 32px; max-width: 1200px; }
}

/* ---------- Componentes ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn:active:not(:disabled) { opacity: 0.85; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary { background: #ecfdf5; color: var(--primary); }

.btn-danger { background: var(--danger-bg); color: var(--danger); }

.btn-ghost { background: transparent; color: var(--text-muted); }

.btn-sm { padding: 7px 12px; font-size: 13px; }

.btn-block { width: 100%; }

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

.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

input, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: white;
  color: var(--text);
}

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

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

/* Secciones de formulario largo (hallazgo D3 de la evaluación de UX): agrupa
   visualmente los campos de "Nueva obligación" sin cambiar su estructura ni
   sus nombres. */
.form-section { margin-bottom: 18px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: none; }
.form-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-card .label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .value { font-size: 26px; font-weight: 700; }
.stat-card.warn { background: var(--warning-bg); border-color: #fde68a; }
.stat-card.warn .value { color: var(--warning); }
.stat-card.danger { background: var(--danger-bg); border-color: #fecaca; }
.stat-card.danger .value { color: var(--danger); }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; }
tr:last-child td { border-bottom: none; }

.table-scroll { overflow-x: auto; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-neutral { background: #f1f5f9; color: var(--text-muted); }

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0;
}

.modal {
  position: relative;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
}

/* Botón de cierre único y consistente para todos los modales (hallazgo D2
   de la evaluación de UX): antes cada modal cerraba distinto (algunos con
   un enlace "← Cerrar" arriba, otros con "Cerrar" hasta el final del
   formulario, ninguno con Escape). Este botón se inyecta automáticamente
   en cada modal desde app.js, así que no hay que repetirlo en cada uno. */
.modal-close-x {
  position: sticky;
  top: 0;
  float: right;
  margin: -20px -20px 8px 8px;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  border-radius: 0 18px 0 12px;
  cursor: pointer;
  z-index: 5;
}
.modal-close-x:hover { background: #f1f5f9; color: var(--text); }

@media (min-width: 860px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal { border-radius: var(--radius); }
  .modal-close-x { border-radius: var(--radius) 0 0 0; }
}

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 22px;
  font-weight: 700;
  font-size: 20px;
}

.auth-tabs {
  display: flex;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
}

.auth-tabs button {
  flex: 1;
  border: none;
  background: none;
  padding: 9px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
}

.auth-tabs button.active { background: white; color: var(--primary); box-shadow: var(--shadow); }

.error-text { color: var(--danger); font-size: 13px; margin: 8px 0 0; }

.toast {
  /* D6 (evaluación de UX): en pantallas angostas hay una barra superior
     fija (.topbar) con el logo y el nombre de la organización; antes este
     aviso flotaba a 16px del borde de la ventana sin importar esa barra, así
     que la tapaba mientras estaba visible (unos 3 segundos). En escritorio
     no hay .topbar (se usa el menú lateral), así que ahí no cambia nada. */
  position: fixed;
  top: calc(56px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 100;
  box-shadow: var(--shadow);
  max-width: 90vw;
}

.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

@media (min-width: 860px) {
  .toast { top: 16px; }
}

.install-banner {
  /* D6 (evaluación de UX): antes este aviso quedaba a una distancia fija
     (70px) del borde inferior, pero la barra de navegación inferior no
     tiene una altura fija — con etiquetas de dos líneas ("Tablero de
     control", "Tablas dinámicas") crece más de lo que esos 70px alcanzan a
     cubrir, y el aviso terminaba tapando la última tarjeta visible justo
     encima de la barra. Ahora la distancia se calcula en app.js a partir de
     la altura real de .bottom-nav (variable --bottom-nav-h) más un margen,
     así que siempre queda pegado justo arriba de la barra, la tape o no. */
  position: fixed;
  bottom: calc(var(--bottom-nav-h, 60px) + 10px);
  left: 12px;
  right: 12px;
  background: var(--text);
  color: white;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 40;
  font-size: 13px;
  box-shadow: var(--shadow);
}

.install-banner[hidden] { display: none; }

.install-banner-actions { display: flex; gap: 6px; flex-shrink: 0; }

@media (min-width: 860px) {
  .install-banner { bottom: 20px; left: auto; right: 20px; max-width: 360px; }
}

.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------- Componentes específicos de Servanda ---------- */

textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: white;
  color: var(--text);
  resize: vertical;
  min-height: 70px;
}
textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-primary { background: #ecfdf5; color: var(--primary); }

/* Aviso destacado dentro de un modal o vista (ej. modo simulado del
   conector de gestión documental): mismo lenguaje visual que las tarjetas
   de alerta (.stat-card.warn), pero pensado para un párrafo de texto. */
.alert { padding: 10px 14px; border-radius: 10px; font-size: 13px; line-height: 1.4; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fde68a; }

/* Riesgo */
.risk-alto { background: var(--danger-bg); color: var(--danger); }
.risk-medio { background: var(--warning-bg); color: var(--warning); }
.risk-bajo { background: var(--success-bg); color: var(--success); }

/* Estado de cumplimiento */
.status-Cumpliendo, .status-Cerrada, .status-Permanente { background: var(--success-bg); color: var(--success); }
.status-Cumplimiento-parcial, .status-A-solicitud { background: var(--warning-bg); color: var(--warning); }
.status-Incumplimiento-total { background: var(--danger-bg); color: var(--danger); }

/* Estado de hitos de entrega */
.status-Cumplido { background: var(--success-bg); color: var(--success); }
.status-En-curso { background: var(--warning-bg); color: var(--warning); }
.status-Pendiente { background: #f1f5f9; color: var(--text-muted); }
.status-Vencido, .status-Bloqueado { background: var(--danger-bg); color: var(--danger); }

/* Estado del contrato (Refinamiento Épica 1) */
.status-Borrador { background: #f1f5f9; color: var(--text-muted); }
.status-En-Ejecución { background: var(--success-bg); color: var(--success); }

/* Estado de aprobación de un hito por área (Aprobado/Pendiente ya cubiertos
   arriba; Rechazado reutiliza .status-Rechazado del registro de atrasos). */
.status-Aprobado { background: var(--success-bg); color: var(--success); }

/* Registro de atrasos: estados del caso (no confundir con estado_cumplimiento
   de una obligación, de donde vienen las reglas de arriba). */
.status-Registrado { background: #f1f5f9; color: var(--text-muted); }
.status-En-revisión, .status-En-disputa { background: var(--warning-bg); color: var(--warning); }
.status-Reconocido { background: var(--success-bg); color: var(--success); }
.status-Rechazado { background: var(--danger-bg); color: var(--danger); }

/* Barra de filtros */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar select, .filter-bar input[type=search] {
  width: auto;
  min-width: 130px;
  flex: 1;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
}
.chip {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Alternancia tarjetas/tabla (hallazgo D5 de la evaluación de UX): a la
   escala real de la matriz de obligaciones, la tabla compacta permite
   revisar muchas filas sin el scroll que exige una tarjeta por obligación. */
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; flex-shrink: 0; }
.view-toggle button {
  border: none; background: none; padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.view-toggle button.active { background: var(--primary); color: white; }

/* Barra de acciones del contrato (hallazgo D7 de la evaluación de UX): en
   escritorio se ve exactamente igual que antes (todos los botones en una
   fila y el botón "Más acciones" oculto). En móvil, solo "Nueva obligación"
   y "Más acciones" quedan siempre visibles; los demás botones viven dentro
   de un panel plegable para no empujar la lista de obligaciones fuera de
   la pantalla. */
.contract-actions-bar { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.contract-actions-toggle { display: none; }
.contract-actions-secondary { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 859px) {
  .contract-actions-toggle { display: inline-flex; }
  .contract-actions-secondary {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    margin-top: 4px;
  }
  .contract-actions-secondary.open { display: flex; }
  .contract-actions-secondary .btn { width: 100%; justify-content: flex-start; }
}

/* Tarjetas de obligación (vista tipo lista/tarjeta en móvil) */
.obligation-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.obligation-card:hover { border-top-color: var(--primary); border-right-color: var(--primary); border-bottom-color: var(--primary); }
/* Semaforización por riesgo: un vistazo rápido sin tener que leer la insignia */
.obligation-card.risk-semaforo-alto { border-left-color: var(--danger); }
.obligation-card.risk-semaforo-medio { border-left-color: var(--warning); }
.obligation-card.risk-semaforo-bajo { border-left-color: var(--success); }
.obligation-card .title { font-weight: 600; margin-bottom: 6px; }
.obligation-card .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--text-muted); }
.obligation-card .badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.obligation-numero {
  display: inline-block;
  color: var(--primary);
  font-weight: 700;
  margin-right: 8px;
}
.obligation-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.obligation-group-title {
  margin: 22px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--primary);
  color: var(--primary);
  font-size: 15px;
}

/* Vista de tabla compacta de obligaciones (una fila por obligación) */
.obligations-table th, .obligations-table td { white-space: nowrap; }
.obligations-table .obligation-table-asunto { white-space: normal; min-width: 220px; }
.obligations-table tbody tr.obligation-row { cursor: pointer; border-left: 4px solid var(--border); }
.obligations-table tbody tr.obligation-row:hover { background: #f8fafc; }
.obligations-table tr.risk-semaforo-alto { border-left-color: var(--danger); }
.obligations-table tr.risk-semaforo-medio { border-left-color: var(--warning); }
.obligations-table tr.risk-semaforo-bajo { border-left-color: var(--success); }
.obligations-table .obligation-table-actions { white-space: nowrap; }
.text-danger { color: var(--danger); font-weight: 600; }
.obligation-group-title:first-child { margin-top: 0; }

/* Tarjetas de contrato */
.contract-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.contract-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.contract-card:hover { border-color: var(--primary); }
.contract-card h3 { margin: 0 0 4px; font-size: 16px; }
.contract-card .meta { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.contract-card-body { display: flex; align-items: center; gap: 14px; }
.contract-donut { flex-shrink: 0; line-height: 0; }
.contract-card .stat-row { display: flex; gap: 14px; font-size: 12px; }
.contract-card .stat-row strong { display: block; font-size: 18px; color: var(--text); }

/* ---------- Gráficas: dona y barras ---------- */

.donut-chart-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut-svg { position: relative; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}
.donut-center strong { font-size: 20px; }
.donut-center span { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 180px; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.donut-legend-item strong { margin-left: auto; }
.donut-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.bar-chart { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { width: 130px; flex-shrink: 0; font-size: 13px; color: var(--text-muted); }
.bar-track { flex: 1; background: #f1f5f9; border-radius: 999px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-value { width: 34px; text-align: right; font-size: 13px; font-weight: 700; flex-shrink: 0; }

/* ---------- Calendario de vencimientos ---------- */

.cal-header { display: flex; align-items: center; gap: 12px; margin: 20px 0 14px; flex-wrap: wrap; }
.cal-header h2 { margin: 0; flex: 1; text-align: center; min-width: 140px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekday { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; padding-bottom: 4px; }
.cal-cell {
  min-height: 76px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  background: var(--surface);
}
.cal-cell-empty { border: none; background: transparent; }
.cal-cell-clickable { cursor: pointer; }
.cal-cell-clickable:hover { border-color: var(--primary); }
.cal-cell-today { border-color: var(--primary); border-width: 2px; }
.cal-day-num { font-size: 12px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 4px; }
.cal-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 15px; height: 15px; padding: 0 3px; border-radius: 999px;
  background: var(--text); color: white; font-size: 9px; font-weight: 700;
}
.cal-dots { display: flex; gap: 3px; flex-wrap: wrap; align-items: center; }
.cal-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.cal-more { font-size: 10px; color: var(--text-muted); }

@media (max-width: 600px) {
  .cal-cell { min-height: 52px; padding: 4px; }
  .cal-day-num { font-size: 11px; }
}

/* ---------- Impresión / exportar para presentaciones ---------- */

@media print {
  .sidebar, .bottom-nav, .topbar, .install-banner, .toast, .no-print,
  .btn, select, input[type="search"], .filter-bar, .chip-row, .tabs-underline {
    display: none !important;
  }
  body, #app, .main-content { background: white !important; padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
  .card { box-shadow: none !important; border: 1px solid #cbd5e1 !important; break-inside: avoid; }
  @page { size: landscape; margin: 12mm; }
}

/* Detalle de obligación: dos columnas en escritorio */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 960px) {
  .detail-grid { grid-template-columns: 1.4fr 1fr; align-items: start; }
}

.field-list { display: flex; flex-direction: column; gap: 10px; }
.field-list .field-row { display: flex; flex-direction: column; gap: 2px; }
.field-list .field-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); font-weight: 700; }
.field-list .field-value { font-size: 14px; }

/* Lista de evidencias */
.evidence-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}
.evidence-item .file-icon { font-size: 20px; }
.evidence-item .file-info { flex: 1; min-width: 0; }
.evidence-item .file-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evidence-item .file-meta { font-size: 11px; color: var(--text-muted); }

.upload-drop {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 12px;
}
.upload-drop:hover { border-color: var(--primary); color: var(--primary); }

/* Historial tipo timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: 12px;
  padding-bottom: 16px;
  position: relative;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 16px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 4px;
  flex-shrink: 0;
}
.timeline-content { font-size: 13px; }
.timeline-content .timeline-meta { color: var(--text-muted); font-size: 11px; margin-top: 2px; }

.alert-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.alert-list-item:last-child { border-bottom: none; }
.alert-list-item .title { font-size: 13px; font-weight: 600; }
.alert-list-item .subtitle { font-size: 12px; color: var(--text-muted); }

.tabs-underline { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs-underline button {
  border: none;
  background: none;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs-underline button.active { color: var(--primary); border-color: var(--primary); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 12px;
  background: none;
  border: none;
  padding: 0;
}
.back-link:hover { color: var(--primary); }
