@import url('./fonts.css');

:root {
  font-family: 'DM Sans', sans-serif;
  color: #0f172a;
  background: #f1f5f9;
  font-synthesis: none;
  --motion-fast: 140ms;
  --motion-normal: 220ms;
  --motion-emphasis: 360ms;
}

/* Tareas */
.tareas-filter-grid { grid-template-columns: minmax(140px, .75fr) minmax(180px, 1fr) minmax(170px, .9fr) minmax(130px, .65fr); }
.tareas-list { display: grid; gap: 14px; }
.tarea-card { background: #fff; border: 1px solid var(--border, #dbe3ef); border-radius: 14px; padding: 18px 20px; box-shadow: 0 1px 2px rgba(15, 23, 42, .03); }
.tarea-card:focus-visible { outline: 3px solid rgba(79, 70, 229, .3); outline-offset: 3px; }
.tarea-card--new-step { border-color: #8175f5; animation: tarea-new-step-focus 3.5s cubic-bezier(.22,1,.36,1); }
.tarea-card-header, .tarea-card-footer { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.tarea-card h3 { margin: 0 0 8px; font-size: 17px; color: #0f172a; }
.tarea-badges, .tarea-card-actions, .tarea-state-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.tarea-meta { display: grid; grid-template-columns: repeat(3, minmax(130px, 1fr)); gap: 10px; margin-top: 16px; }
.tarea-meta-item { padding: 10px 12px; background: #f8fafc; border-radius: 9px; }
.tarea-meta-item small { display: block; margin-bottom: 3px; color: #71809a; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.tarea-meta-item strong { color: #334155; font-size: 13px; }
.tarea-description { margin: 14px 0 0; color: #53627a; line-height: 1.5; white-space: pre-wrap; }
.tarea-next-summary { margin-top: 14px; padding: 10px 12px; border: 1px solid #ddd6fe; border-radius: 9px; background: #f5f3ff; color: #5b43d6; font-size: 13px; }
.tarea-card-footer { align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid #edf1f7; }
.tarea-state-actions { margin-left: auto; }
.tarea-status--pendiente { background: #fff7dd; color: #9a6700; }
.tarea-status--en_progreso { background: #e9efff; color: #3156b7; }
.tarea-status--cumplida { background: #dcfce7; color: #167744; }
.tarea-status--cancelada { background: #f1f5f9; color: #64748b; }
.tarea-chain-badge, .tarea-origin { background: #f0edff; color: #5b43d6; }
.tarea-modal { width: min(620px, calc(100vw - 32px)); }
.modal-card.tarea-chain-editor-modal { display: flex; flex-direction: column; width: min(760px, calc(100vw - 40px)); max-height: calc(100vh - 40px); overflow: hidden; }
.tarea-chain-editor-modal form { display: flex; flex-direction: column; min-height: 0; }
.tarea-chain-editor-modal .modal-header, .tarea-chain-editor-modal .modal-footer { flex: 0 0 auto; }
.tarea-chain-editor-modal .modal-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.modal-help { margin: 0 0 18px; padding: 12px 14px; border-radius: 10px; background: #f5f3ff; color: #6d55de; line-height: 1.45; }
.tarea-current-step { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; padding: 13px 14px; border: 1px solid #ddd6fe; border-radius: 10px; background: #faf9ff; }
.tarea-current-step span { color: #71809a; font-size: 13px; }
.tarea-chain-editor-list { display: grid; gap: 12px; margin-bottom: 12px; }
.tarea-chain-editor-empty { margin: 0; padding: 14px; border: 1px dashed #cbd5e1; border-radius: 10px; color: #71809a; text-align: center; }
.tarea-chain-editor-step { padding: 14px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; }
.tarea-chain-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.tarea-chain-editor-actions { display: flex; gap: 6px; }
.tarea-chain-editor-step .form-group { margin-bottom: 10px; }
.tarea-chain-editor-step .form-group:last-child { margin-bottom: 0; }
.vencimiento-task-option { margin: 4px 0 18px; padding: 12px 14px; border: 1px solid #e5eaf1; border-radius: 10px; background: #f8fafc; }
.modal-footer-spacer { flex: 1; }
.tarea-chain-list { list-style: none; margin: 0; padding: 0; }
.tarea-chain-list li { position: relative; margin-left: 12px; padding: 0 0 22px 28px; border-left: 2px solid #ddd6fe; }
.tarea-chain-list li:last-child { padding-bottom: 0; border-left-color: transparent; }
.tarea-chain-list li::before { content: ''; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #5b43e8; box-shadow: 0 0 0 4px #ede9fe; }
.tarea-chain-list li.is-planned::before { background: #fff; border: 2px solid #8b7cf6; }
.tarea-chain-list strong, .tarea-chain-list span { display: block; }
.tarea-chain-list span { margin-top: 4px; color: #71809a; font-size: 13px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 220; max-width: min(420px, calc(100vw - 48px)); padding: 12px 16px; border-radius: 10px; box-shadow: 0 12px 28px rgba(15, 23, 42, .2); color: #fff; font-size: 14px; }
.toast-error { background: #b91c1c; }
.toast-success { background: #167744; }
@keyframes tarea-new-step-focus { 0%,35% { box-shadow: 0 0 0 4px rgba(79,70,229,.2), 0 12px 28px rgba(79,70,229,.18); background: #faf9ff; } 100% { box-shadow: 0 1px 2px rgba(15,23,42,.03); background: #fff; } }
@keyframes module-page-enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes modal-backdrop-enter { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-card-enter { from { opacity: 0; transform: translateY(7px) scale(.99); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (prefers-reduced-motion: no-preference) {
 html { scroll-behavior: smooth; }
 .module-page { animation: module-page-enter var(--motion-normal) ease-out; }
 .modal-overlay, .modal-backdrop { animation: modal-backdrop-enter var(--motion-fast) ease-out; }
 .modal-card, .modal-dialog { animation: modal-card-enter var(--motion-normal) cubic-bezier(.22,1,.36,1); }
 ::view-transition-old(root), ::view-transition-new(root) { animation-duration: var(--motion-normal); animation-timing-function: ease-out; }
}
@media (prefers-reduced-motion: reduce) {
 html { scroll-behavior: auto; }
 .tarea-card--new-step { animation: none; }
}
@media (max-width: 760px) {
 .tareas-filter-grid, .tarea-meta { grid-template-columns: 1fr; }
 .tarea-card-header, .tarea-card-footer { align-items: stretch; flex-direction: column; }
 .tarea-card-actions, .tarea-state-actions { justify-content: flex-end; }
 .tarea-state-actions { align-self: flex-end; margin-left: 0; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: #f1f5f9; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.boot-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #475569;
}
.boot-screen--contained { min-height: 240px; }
.boot-screen-text { color: #64748b; font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.font-mono { font-family: 'DM Mono', monospace; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e2e8f0;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.spinner-sm {
  width: 18px;
  height: 18px;
  border: 2px solid #e2e8f0;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 0, rgba(79, 70, 229, .09), transparent 34rem),
    #f1f5f9;
}

.login-card {
  width: min(500px, 100%);
  padding: 40px;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, .12);
}

.login-brand { text-align: center; margin-bottom: 30px; }
.lock-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: #eef2ff;
  color: #4f46e5;
  font-size: 22px;
}
.login-brand h1 { margin: 0; font-size: 28px; font-weight: 800; color: #0f172a; }
.login-brand p { margin: 8px 0 0; color: #64748b; font-size: 14px; }

label {
  display: block;
  margin: 0 0 8px;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.input {
  width: 100%;
  margin-bottom: 18px;
  padding: 11px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  outline: none;
  color: #0f172a;
  background: #fafbfc;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(129, 140, 248, .13); }
.input-mono { font-family: 'DM Mono', monospace; font-size: 13px; }
.input-textarea { resize: vertical; min-height: 80px; }

.select {
  width: 100%;
  margin-bottom: 18px;
  padding: 11px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  outline: none;
  color: #0f172a;
  background: #fafbfc;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.select:focus { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(129, 140, 248, .13); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color .15s, opacity .15s;
}
.btn-primary { color: #fff; background: #4f46e5; }
.btn-primary:hover { background: #4338ca; }
.btn-secondary { color: #334155; background: #e2e8f0; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }
.btn:disabled { cursor: not-allowed; opacity: .65; }
.btn.is-loading:disabled { cursor: progress; }
.login-submit { width: 100%; margin-top: 2px; }

/* Botones de acción compactos con icono (referencia Links / accesos) */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
  flex-shrink: 0;
}
.btn-icon:hover:not(:disabled) {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}
.btn-icon:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 1px;
}
.btn-icon:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.btn-icon-lg {
  width: 36px;
  height: 36px;
  border-radius: 9px;
}
.btn-icon-danger {
  color: #dc2626;
  border-color: #fee2e2;
}
.btn-icon-danger:hover:not(:disabled) {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fca5a5;
}
.btn-icon-danger:focus-visible {
  outline: 2px solid #dc2626;
}
.btn-icon-success {
  color: #16a34a;
  border-color: #dcfce7;
}
.btn-icon-success:hover:not(:disabled) {
  background: #f0fdf4;
  color: #15803d;
  border-color: #86efac;
}
.btn-icon-success:focus-visible {
  outline: 2px solid #16a34a;
}
.btn-icon-primary {
  color: #ffffff;
  background: #4f46e5;
  border-color: #4f46e5;
}
.btn-icon-primary:hover:not(:disabled) {
  color: #ffffff;
  background: #4338ca;
  border-color: #4338ca;
}

.form-error, .form-error-banner, .state-error-message {
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid #fecaca;
  border-radius: 10px;
  color: #dc2626;
  background: #fef2f2;
  font-size: 13px;
}
.form-error[hidden], .form-error-banner[hidden], .state-error-message[hidden] { display: none; }

.password-field { position: relative; width: 100%; margin-bottom: 18px; }
.password-field .input { display: block; width: 100%; margin-bottom: 0; padding-right: 50px; box-sizing: border-box; }
/* Edge agrega su propio ojo: estos campos ya tienen un control accesible. */
.password-field input::-ms-reveal { display: none; }
.password-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: #303030; cursor: pointer; }
.password-toggle:hover { background: #f1f5f9; }
.password-toggle:focus-visible { outline: 2px solid #4f46e5; outline-offset: 1px; }
.app-message { width: min(440px, calc(100vw - 40px)); box-sizing: border-box; border: 1px solid #dce4f0; border-radius: 18px; padding: 26px; color: #0f172a; background: white; box-shadow: 0 20px 60px #0f172a40; }
.app-message::backdrop { background: #0f172a99; }
.app-message h2 { margin: 0 0 16px; font-size: 20px; }
.app-message p { padding: 12px; border-radius: 10px; background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; overflow-wrap: anywhere; white-space: pre-line; }
.app-message-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.login-help {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 24px;
  padding: 16px;
  border-radius: 10px;
  color: #64748b;
  background: #f8fafc;
  font-size: 12px;
  line-height: 1.5;
}
.login-help strong { color: #334155; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  width: 230px;
  color: #fff;
  background: #0f172a;
}
.sidebar-brand { padding: 26px 22px 22px; border-bottom: 1px solid #1e293b; }
.sidebar-brand h1 { margin: 0; font-size: 20px; font-weight: 800; }
.sidebar-brand p { margin: 4px 0 0; color: #64748b; font-size: 11px; }
.sidebar-search { padding: 14px 12px 0; }
.sidebar-search .empresa-quick-search-field {
  height: 36px;
  border-color: #334155;
  color: #94a3b8;
  background: #172033;
  box-shadow: none;
}
.sidebar-search .empresa-quick-search-field:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, .22);
}
.sidebar-search .empresa-quick-search-field input { color: #f1f5f9; }
.sidebar-search .empresa-quick-search-field input::placeholder { color: #94a3b8; }
.sidebar-search .empresa-quick-search-results {
  left: 0;
  right: auto;
  width: 300px;
}
.sidebar-nav { flex: 1; padding: 12px; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 3px;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  text-align: left;
  color: #94a3b8;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  transition: background-color .15s, color .15s;
}
.nav-btn:hover { color: #f1f5f9; background: rgba(255, 255, 255, .05); }
.nav-btn.active { color: #fff; background: #1e293b; }
.sidebar-footer { padding: 14px 12px 18px; border-top: 1px solid #1e293b; }
.sidebar-user-row { display: flex; align-items: center; gap: 4px; }
.profile-trigger { min-width: 0; flex: 1; text-align: left; font: inherit; color: inherit; background: transparent; border: 1px solid transparent; border-radius: 10px; cursor: pointer; }
.profile-trigger:hover, .profile-trigger.active { background: #1e293b; }
.profile-trigger:focus-visible, .settings-trigger:focus-visible { outline: 2px solid #a5b4fc; outline-offset: 2px; }
.settings-trigger { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; border: 1px solid transparent; border-radius: 9px; color: #94a3b8; background: transparent; cursor: pointer; }
.settings-trigger:hover, .settings-trigger.active { color: #fff; background: #1e293b; }
.profile-card { max-width: 640px; padding: 28px; }
.profile-help { color: #64748b; font-size: 13px; line-height: 1.5; }
.profile-divider { border: 0; border-top: 1px solid #e2e8f0; margin: 24px 0; }
.signed-user { display: flex; align-items: center; gap: 10px; padding: 8px; }
.signed-user > span:last-child { display: flex; min-width: 0; flex-direction: column; }
.signed-user strong { overflow: hidden; color: #e2e8f0; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.signed-user small { margin-top: 2px; color: #64748b; font-size: 10px; }
.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 9px;
  color: #c7d2fe;
  background: #312e81;
  font-weight: 800;
}
.logout-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #7f1d1d;
  border-radius: 8px;
  color: #f87171;
  background: transparent;
  font-size: 11px;
  font-weight: 700;
}
.logout-btn:hover { background: rgba(127, 29, 29, .18); }

.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 720px); gap: 22px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid #e2e8f0; border-radius: 14px; background: #fff; }
.settings-nav button { padding: 11px 12px; border: 0; border-radius: 9px; text-align: left; color: #475569; background: transparent; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.settings-nav button:hover, .settings-nav button.active { color: #4338ca; background: #eef2ff; }
.settings-nav button:focus-visible { outline: 2px solid #6366f1; outline-offset: 1px; }
.settings-content .view-header { display: none; }
.settings-content .profile-card { max-width: none; }
.settings-card { padding: 26px; }
.settings-card h2 { margin: 0; font-size: 20px; }
.quota-metrics .settings-toggle { cursor: default; flex-wrap: wrap; gap: 6px 20px; }
.quota-metrics dt { font-weight: 600; font-size: 14px; }
.quota-metrics dd { margin: 0; color: #64748b; font-size: 13px; overflow-wrap: anywhere; }
.settings-intro { margin: 6px 0 22px; color: #64748b; font-size: 14px; }
.settings-group { margin: 0 0 22px; padding: 0; border: 0; }
.settings-group legend { width: 100%; margin-bottom: 8px; padding-bottom: 9px; border-bottom: 1px solid #e2e8f0; color: #0f172a; font-size: 14px; font-weight: 800; }
.settings-toggle { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 58px; margin-bottom: 0; padding: 9px 2px; border-bottom: 1px solid #f1f5f9; cursor: pointer; letter-spacing: normal; text-transform: none; }
.settings-toggle span { display: flex; flex-direction: column; gap: 3px; }
.settings-toggle strong { color: #1e293b; font-size: 14px; }
.settings-toggle small, .settings-note { color: #64748b; font-size: 12px; line-height: 1.45; }
.settings-toggle input { width: 19px; height: 19px; flex: 0 0 auto; accent-color: #4f46e5; }
.settings-note { margin: 0 0 6px; padding: 10px 12px; border-radius: 8px; background: #f8fafc; }
.quota-note { margin-top: 10px; }
.settings-card [data-ref="quota-form"] { margin-bottom: 16px; }
.settings-test-email { display:flex; align-items:center; justify-content:space-between; gap:16px; margin:10px 0 14px; padding:12px; border:1px solid #e2e8f0; border-radius:10px; background:#f8fafc; }
.settings-test-email > div { display:flex; flex-direction:column; gap:3px; }
.settings-test-email strong { color:#1e293b; font-size:14px; }
.settings-test-email small { color:#64748b; font-size:12px; line-height:1.45; }
.settings-email-history { margin:0 0 18px; padding:12px; border:1px solid #e2e8f0; border-radius:10px; background:#fff; }
.settings-email-history-header { display:flex; flex-direction:column; gap:3px; }
.settings-email-history-header strong { color:#1e293b; font-size:14px; }
.settings-email-history-header small,.settings-history-empty,.settings-history-error,.settings-email-history > p { color:#64748b; font-size:12px; line-height:1.45; }
.settings-history-error { margin-top:10px; color:#b91c1c; }
.settings-history-list { display:flex; flex-direction:column; gap:8px; margin:10px 0 0; padding:0; list-style:none; }
.settings-history-item { display:flex; flex-direction:column; gap:2px; padding:9px 10px; border-radius:8px; background:#f8fafc; }
.settings-history-item strong { color:#1e293b; font-size:13px; }
.settings-history-item span { color:#64748b; font-size:12px; }
@media (max-width: 560px) { .settings-test-email { align-items:stretch; flex-direction:column; } .settings-test-email .btn { width:100%; } }
.comentarios-modal-overlay { opacity:0; transition:opacity .24s ease; }
.comentarios-modal-overlay .comentarios-modal { opacity:.98; transform:translateY(8px); transition:opacity .2s ease,transform .24s ease; }
.comentarios-modal-overlay.is-open { opacity:1; }
.comentarios-modal-overlay.is-open .comentarios-modal { opacity:1; transform:translateY(0); }
.comentarios-modal-overlay.is-closing { pointer-events:none; }
.comentarios-modal { display:flex; flex-direction:column; width:min(640px,calc(100vw - 32px)); max-height:calc(100vh - 32px); overflow:hidden; }
.cert-card-actions { display:flex; align-items:center; gap:8px; }
.comentarios-modal .modal-header small { display:block; margin-top:3px; color:#64748b; font-size:12px; font-weight:500; }
.comentarios-modal-body { display:flex; flex-direction:column; min-height:260px; overflow-y:auto; scrollbar-gutter:stable; }
.comentarios-loading,.comentarios-empty { padding:28px 12px; color:#64748b; text-align:center; }
.comentarios-older { align-self:center; margin-bottom:12px; }
.comentarios-list { display:flex; flex-direction:column; gap:16px; margin:0; padding:0; list-style:none; }
.comentario-thread { min-width:0; }
.comentario-item { display:flex; align-items:flex-start; gap:10px; min-width:0; }
.comentario-avatar { display:inline-flex; flex:0 0 32px; align-items:center; justify-content:center; width:32px; height:32px; border-radius:50%; background:#ede9fe; color:#5b21b6; font-size:11px; font-weight:800; letter-spacing:.02em; }
.comentario-bubble { position:relative; flex:1 1 auto; min-width:0; padding:10px 12px 9px; border-radius:12px 12px 12px 5px; background:#f5f7fb; }
.comentario-bubble::before { position:absolute; top:11px; left:-6px; width:0; height:0; border-top:6px solid transparent; border-right:7px solid #f5f7fb; border-bottom:6px solid transparent; content:""; }
.comentario-head { display:flex; align-items:baseline; justify-content:space-between; gap:8px 12px; margin-bottom:4px; }
.comentario-head strong { min-width:0; color:#1e293b; font-size:13px; overflow-wrap:anywhere; }
.comentario-head time { color:#64748b; font-size:11px; white-space:nowrap; }
.comentario-content { margin:0; color:#334155; font-size:14px; line-height:1.5; overflow-wrap:anywhere; white-space:pre-wrap; }
.comentario-quote { display:flex; flex-direction:column; gap:2px; margin:0 0 8px; padding:8px 10px; border-left:3px solid #8b5cf6; border-radius:0 7px 7px 0; background:#f3f0ff; color:#475569; overflow-wrap:anywhere; }
.comentario-quote strong { color:#5b21b6; font-size:12px; }
.comentario-quote span { display:-webkit-box; overflow:hidden; font-size:12px; line-height:1.4; -webkit-box-orient:vertical; -webkit-line-clamp:3; }
.comentario-reply-action { min-height:30px; margin:3px 0 -5px -7px; padding:5px 7px; border:0; border-radius:6px; background:transparent; color:#4f46e5; cursor:pointer; font:inherit; font-size:12px; font-weight:700; transition:background-color .16s ease,color .16s ease; }
.comentario-reply-action:hover { background:#ede9fe; color:#3730a3; }
.comentario-reply-action:focus-visible { border-radius:3px; outline:2px solid #6366f1; outline-offset:2px; }
.comentario-thread-actions { display:flex; min-height:30px; margin:2px 0 -4px 42px; }
.comentario-thread-actions:empty { display:none; }
.comentario-thread-toggle { display:inline-flex; align-items:center; gap:5px; min-height:30px; padding:4px 7px; border:0; border-radius:6px; background:transparent; color:#4f46e5; cursor:pointer; font:inherit; font-size:12px; font-weight:700; transition:background-color .16s ease,color .16s ease; }
.comentario-thread-toggle:hover { background:#f3f0ff; color:#3730a3; }
.comentario-thread-toggle:focus-visible { border-radius:3px; outline:2px solid #6366f1; outline-offset:2px; }
.comentario-thread-chevron { display:inline-block; font-size:16px; line-height:1; transform:rotate(0); transform-origin:center; transition:transform .18s ease; }
.comentario-thread-toggle[aria-expanded="true"] .comentario-thread-chevron { transform:rotate(180deg); }
.comentario-responses-shell { display:grid; grid-template-rows:0fr; opacity:0; visibility:hidden; pointer-events:none; transition:grid-template-rows .22s ease,opacity .16s ease,visibility 0s linear .22s; }
.comentario-responses-shell.is-expanded { grid-template-rows:1fr; opacity:1; visibility:visible; pointer-events:auto; transition-delay:0s; }
.comentario-responses { display:flex; flex-direction:column; gap:9px; min-height:0; margin:5px 0 0 32px; padding:3px 0 2px 11px; overflow:hidden; border-left:1px solid #ddd6fe; }
.comentario-response-item .comentario-avatar { flex-basis:30px; width:30px; height:30px; background:#f1f5f9; color:#475569; }
.comentario-response-item .comentario-bubble { background:#f8fafc; }
.comentario-response-item .comentario-bubble::before { border-right-color:#f8fafc; }
.comentario-responses-more { align-self:flex-start; }
.comentario-responses-status { margin:0; color:#64748b; font-size:12px; }
.comentario-compact-reference { display:flex; min-width:0; gap:5px; margin:0 0 6px; padding:5px 7px; border-radius:6px; background:#f1f5f9; color:#64748b; font-size:11px; line-height:1.35; overflow-wrap:anywhere; }
.comentario-compact-reference strong { flex:0 0 auto; color:#475569; }
.comentario-compact-reference span { display:block; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.comentarios-form { margin-top:16px; padding-top:16px; border-top:1px solid #e2e8f0; }
.comentarios-reply-form { margin:10px 0 0 42px; padding:12px; border:1px solid #ddd6fe; border-radius:12px; background:#fafaff; transition:border-color .16s ease,background-color .16s ease; }
.comentarios-reply-form:focus-within { border-color:#a78bfa; background:#fff; }
.comentarios-reply-form[hidden] { display:none; }
.comentarios-reply-selection { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:12px; padding:9px 10px; border-radius:8px; background:#f3f0ff; }
.comentarios-reply-selection[hidden] { display:none; }
.comentarios-reply-selection > div { min-width:0; }
.comentarios-reply-selection strong { display:block; color:#5b21b6; font-size:12px; }
.comentarios-reply-selection p { display:-webkit-box; margin:3px 0 0; overflow:hidden; color:#64748b; font-size:12px; line-height:1.4; overflow-wrap:anywhere; -webkit-box-orient:vertical; -webkit-line-clamp:3; }
.comentarios-reply-selection .btn { flex:0 0 auto; }
.comentarios-form label { display:block; margin-bottom:6px; color:#334155; font-size:13px; font-weight:700; }
.comentarios-form-actions { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:8px; }
.comentarios-form-actions small { color:#64748b; font-size:11px; }
@keyframes comentarioAppear { from { opacity:0; transform:translateY(5px); } to { opacity:1; transform:translateY(0); } }
.comentario-item--new { animation:comentarioAppear .2s ease-out both; }
@media (max-width:560px) { .comentarios-modal { width:calc(100vw - 20px); max-height:calc(100vh - 20px); } .comentarios-modal .modal-header,.comentarios-modal .modal-body { padding-left:16px; padding-right:16px; } .comentario-item { gap:8px; } .comentario-avatar { flex-basis:28px; width:28px; height:28px; font-size:10px; } .comentario-head { flex-wrap:wrap; gap:2px 8px; } .comentario-thread-actions { margin-left:34px; } .comentario-responses { margin-left:14px; padding-left:8px; } .comentarios-reply-form { margin-left:14px; } .comentario-compact-reference { flex-direction:column; gap:1px; } .comentario-compact-reference span { white-space:normal; } .comentarios-reply-selection { align-items:stretch; flex-direction:column; } .comentarios-reply-selection .btn { align-self:flex-start; } .comentarios-form-actions { align-items:stretch; flex-direction:column; } .comentarios-form-actions .btn { width:100%; } }
@media (prefers-reduced-motion:reduce) { .comentarios-modal-overlay,.comentarios-modal-overlay .comentarios-modal,.comentario-responses-shell,.comentario-thread-chevron,.comentario-reply-action,.comentario-thread-toggle,.comentarios-reply-form { transition:none; } .comentario-item--new { animation:none; } }

@media (max-width: 760px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; }
  .settings-nav button { flex: 0 0 auto; white-space: nowrap; }
  .settings-card { padding: 20px; }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

.mobile-header { display: none; }
.hamburger-btn {
  display: none;
  background: none;
  border: 0;
  color: #fff;
  font-size: 20px;
  padding: 2px 8px;
  margin-right: 8px;
  cursor: pointer;
}
.main-content { min-height: 100vh; margin-left: 230px; padding: 32px; }
.main-content > * {
  width: 100%;
  max-width: 1360px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}
.page-header,
.view-header,
.module-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 26px; }
.view-header-content { flex: 1; width: 100%; min-width: 0; }
.heading-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.page-header h1,
.page-header h2,
.view-header .view-title,
.module-header h1,
.module-header h2 {
  margin: 0;
  color: #0f172a;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
}
.page-header p,
.view-header .view-subtitle,
.module-header p {
  margin: 6px 0 0;
  color: #94a3b8;
  font-size: 14px;
}
.environment-badge {
  padding: 7px 11px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  color: #4f46e5;
  background: #eef2ff;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 500;
}

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card, .card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
}
.stat-card { display: flex; flex-direction: column; }
.stat-card span { color: #94a3b8; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.stat-card strong { margin-top: 10px; color: #0f172a; font-size: 30px; }
.stat-card small { margin-top: 4px; color: #94a3b8; font-size: 11px; }

.inicio-upcoming h3 { margin: 7px 0 18px; color: #0f172a; font-size: 20px; }
.inicio-upcoming-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.inicio-upcoming-grid h4 { margin: 0 0 10px; color: #0f172a; font-size: 14px; }
.inicio-upcoming-grid ul { margin: 0; padding: 0; list-style: none; }
.inicio-upcoming-grid li { display: grid; gap: 3px; padding: 10px 0; border-top: 1px solid #f1f5f9; }
.inicio-upcoming-grid li strong { overflow-wrap: anywhere; font-size: 13px; }
.inicio-upcoming-grid li small { color: #64748b; font-size: 11px; }
.inicio-activity-list { margin: 0; padding: 0; list-style: none; }
.inicio-activity-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid #f1f5f9; }
.inicio-activity-content { display: grid; min-width: 0; gap: 6px; overflow-wrap: anywhere; }
.inicio-activity-label { color: #0f172a; font-size: 14px; }
.inicio-activity-detail { color: #64748b; font-size: 13px; line-height: 1.5; }
.inicio-activity-date { color: #64748b; font-size: 11px; }
.inicio-activity-row > .btn { justify-self: end; white-space: nowrap; }
@media (max-width: 600px) {
  .inicio-activity-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .inicio-activity-row > .btn { justify-self: start; }
}

.foundation-card { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; padding: 26px; }
.card-accent { position: absolute; inset: 0 0 auto; height: 3px; background: #4f46e5; }
.section-label { color: #4f46e5; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.foundation-card h3 { margin: 7px 0 8px; font-size: 20px; }
.foundation-card p { max-width: 580px; margin: 0; color: #64748b; font-size: 13px; line-height: 1.6; }
.service-list { display: grid; gap: 9px; }
.service-list > div {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  padding: 12px;
  border: 1px solid #f1f5f9;
  border-radius: 10px;
}
.service-list strong { font-size: 13px; }
.service-list small { grid-column: 2; margin-top: 2px; color: #64748b; font-size: 10px; }
.service-dot { width: 10px; height: 10px; margin-top: 3px; border-radius: 50%; background: #d97706; }
.service-dot--ready { background: #059669; }
.service-dot--error { background: #dc2626; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 24px;
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  background: #fff;
}
.empty-state-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin-bottom: 18px;
  border-radius: 16px;
  background: #eef2ff;
  font-size: 26px;
}
.empty-state h3 {
  margin: 0 0 8px;
  color: #0f172a;
  font-size: 18px;
  font-weight: 700;
}
.empty-state p {
  max-width: 460px;
  margin: 0 0 20px;
  color: #64748b;
  font-size: 14px;
  line-height: 1.6;
}

/* ==========================================================================
   Componente común de filtros y búsquedas (tarjeta, grilla, campos, pie y checkbox)
   ========================================================================== */
.header-before-filters { margin-bottom: 26px; }

.filter-card,
.empresa-filters {
  background: #fff;
  border: 1px solid #dce4ef;
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 18px;
}

.filter-grid,
.empresa-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.filter-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.filter-label,
.empresa-filter-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  text-transform: none;
  letter-spacing: normal;
  margin-bottom: 0;
}

.filter-label .input,
.filter-label .select,
.empresa-filter-label .input,
.empresa-filter-label .select {
  width: 100%;
  min-width: 0;
  margin-bottom: 0;
}

.filter-checkbox-cell {
  display: flex;
  align-items: center;
  min-height: 44px;
  align-self: end;
}

.filter-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
  user-select: none;
  margin-bottom: 0;
}

.filter-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #4f46e5;
  cursor: pointer;
  margin: 0;
}

.filter-footer,
.empresa-filter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.filter-count,
.empresa-filter-count {
  color: #64748b;
  font-size: 13px;
}

@media (max-width: 640px) {
  .filter-grid,
  .empresa-filter-grid {
    grid-template-columns: 1fr;
  }
  .filter-card,
  .empresa-filters {
    padding: 14px;
  }
  .filter-footer,
  .empresa-filter-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Table styles */
.table-container {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
}
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}
.table th {
  padding: 14px 18px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.table td {
  padding: 14px 18px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }
.table-row-clickable {
  cursor: pointer;
  transition: background-color .15s;
}
.table-row-clickable:hover { background-color: #f8fafc; }
.table-rut { font-family: 'DM Mono', monospace; font-size: 12px; color: #475569; }
.table-arrow { text-align: right; color: #cbd5e1; font-weight: bold; }

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-active {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}
.badge-inactive {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}
.badge-neutral { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }
.badge-vencido, .badge-danger { background: #fef2f2; color: #b91c1c; border: 1px solid #fca5a5; }
.badge-por-vencer, .badge-warning { background: #fffbeb; color: #b45309; border: 1px solid #fcd34d; }
.badge-vigente, .badge-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge-tramite-sin-gestion { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }
.badge-tramite-en-tramite { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-tramite-presentado { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge-tramite-suspendido { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }

/* Stat card alert variants */
.stat-card--danger strong { color: #b91c1c; }
.stat-card--warning strong { color: #b45309; }
.stat-card--success strong { color: #047857; }

/* Tabs */
.tabs-container {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid #e2e8f0;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.tab-btn {
  flex-shrink: 0;
  white-space: nowrap;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  color: #64748b;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: #0f172a; }
.tab-btn.active { color: #4f46e5; border-bottom-color: #4f46e5; }
.tab-panel[hidden] { display: none; }

/* Certificados Layout and Cards */
.certificados-tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.section-title { margin: 0; font-size: 18px; font-weight: 800; color: #0f172a; }
.section-subtitle { margin: 4px 0 0; color: #64748b; font-size: 13px; }
.table-date { font-family: 'DM Mono', monospace; font-size: 12px; font-weight: 600; }

.certificados-vertical-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.certificados-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 18px;
}

.cert-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px 20px;
  border-left: 5px solid #cbd5e1;
  box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.05);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.cert-card.card-vencido { border-left-color: #ef4444; }
.cert-card.card-por-vencer { border-left-color: #f59e0b; }
.cert-card.card-vigente { border-left-color: #10b981; }

.cert-card--clickable {
  cursor: pointer;
}
.cert-card--clickable:hover,
.cert-card--clickable:focus {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.cert-card--full {
  width: 100%;
}

.cert-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.cert-card-empresa {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.cert-card-title-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cert-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.cert-card-tipo {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
}

.cert-card-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.cert-card-body {
  margin-bottom: 4px;
}

.cert-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.cert-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

.cert-due-text {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.cert-date-text {
  font-size: 12px;
  color: #64748b;
}

@media (max-width: 768px) {
  .certificados-grid {
    grid-template-columns: 1fr;
  }
}

/* Contactos Layout and Cards */
.contactos-tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.contactos-vertical-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.contacto-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.05);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.contacto-card--full {
  width: 100%;
}

.contacto-card--inactive {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.contacto-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.contacto-card-title-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.contacto-card-nombre {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.contacto-card--inactive .contacto-card-nombre {
  color: #475569;
}

.contacto-card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.contacto-card-body {
  margin-top: 4px;
}

.contacto-card-details {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 20px;
  row-gap: 8px;
}

.contacto-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.contacto-field[hidden] {
  display: none;
}

.contacto-field-label {
  color: #64748b;
  font-weight: 600;
}

.contacto-field-value {
  color: #1e293b;
}

.contacto-link {
  color: #4f46e5;
  text-decoration: none;
  font-size: 13px;
}

.contacto-link:hover {
  text-decoration: underline;
}

/* Modal styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .6);
  backdrop-filter: blur(3px);
}
.modal-card {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 25px -5px rgba(15, 23, 42, .2);
  border: 1px solid #e2e8f0;
  overflow: hidden;
}
.association-selector { display:flex; flex-direction:column; max-height:calc(100vh - 40px); }
.association-selector .modal-body { min-height:0; overflow-y:auto; }
.association-selector .modal-body > label { display:block; margin-bottom:8px; font-weight:700; }
.association-selector .modal-body > input { width:100%; }
.association-selector-options { display:grid; gap:4px; margin-top:14px; }
.association-selector-option { display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:8px; cursor:pointer; }
.association-selector-option:hover { background:#f1f5f9; }
.association-selector-option input { flex:none; accent-color:#4f46e5; }
.association-selector-option span { overflow-wrap:anywhere; }
.association-selector-empty { color:#64748b; }
@media (max-width:560px) { .association-selector { max-height:calc(100vh - 20px); } }

/* Modal amplio usado por Calendarios y sus asociaciones. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .6);
  backdrop-filter: blur(3px);
}

.modal-dialog {
  display: flex;
  flex-direction: column;
  width: min(680px, 100%);
  max-height: calc(100vh - 40px);
  overflow: hidden;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  box-shadow: 0 20px 25px -5px rgba(15, 23, 42, .2);
}

.modal-dialog form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.modal-dialog .modal-body {
  overflow-y: auto;
}

.modal-title {
  margin: 0;
  color: #0f172a;
  font-size: 18px;
  font-weight: 800;
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
}

.modal-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.modal-close:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 1px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #e2e8f0;
}
.modal-header h3 { margin: 0; font-size: 18px; font-weight: 800; color: #0f172a; }
.modal-close-btn {
  background: none;
  border: 0;
  font-size: 20px;
  color: #94a3b8;
  padding: 4px 8px;
  line-height: 1;
}
.modal-close-btn:hover { color: #0f172a; }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

/* Detail view */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  color: #4f46e5;
  background: none;
  border: 0;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.back-link:hover { text-decoration: underline; }

.detail-card {
  width: 100%;
  box-sizing: border-box;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 30px;
}
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid #e2e8f0;
}
.detail-header h3 { margin: 0; font-size: 20px; font-weight: 800; color: #0f172a; }
.detail-meta {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed #e2e8f0;
  font-size: 11px;
  color: #94a3b8;
}

.alert-success {
  margin-bottom: 18px;
  padding: 12px 16px;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  color: #065f46;
  background: #ecfdf5;
  font-size: 13px;
  font-weight: 600;
}

.empresa-save-status {
  margin-bottom: 18px;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  text-transform: none;
  margin-bottom: 18px;
}
.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #4f46e5;
  cursor: pointer;
}

/* ==========================================================================
   Módulo Calendarios: Catálogo compacto, Detalle, Matriz de Vencimientos y Pestaña Empresa
   ========================================================================== */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.font-bold { font-weight: 700; }
.font-medium { font-weight: 600; }

/* Barra de búsqueda y filtros del catálogo */
.calendarios-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 14px 18px;
}

.toolbar-search {
  flex: 1;
  min-width: 240px;
}

.toolbar-search .input {
  margin-bottom: 0;
}

.toolbar-filter {
  min-width: 180px;
}

.toolbar-filter .input-select {
  margin-bottom: 0;
}

/* Tablas de Calendarios y Empresa */
.table-calendarios,
.table-empresa-calendarios {
  width: 100%;
}

.cal-nombre-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cal-nombre-text,
.empresa-cal-nombre-text {
  font-weight: 700;
  color: #0f172a;
}

.cal-row-badges,
.table-status-badges {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.table-actions-header {
  text-align: right;
}

.col-cal-acciones,
.col-emp-cal-acciones {
  text-align: right;
  white-space: nowrap;
}

.calendario-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge-organismo {
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 700;
}

.badge-tipo {
  background: #f1f5f9;
  color: #334155;
  font-weight: 600;
}

.badge-criterio {
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
}

.badge-categoria {
  background: #f3e8ff;
  color: #7e22ce;
  border: 1px solid #d8b4fe;
  font-size: 10px;
}

.badge-periodicidad {
  background: #ede9fe;
  color: #5b21b6;
  font-weight: 600;
}

.badge-origen {
  font-weight: 600;
}

.badge-manual {
  background: #f1f5f9;
  color: #475569;
}

.badge-auto {
  background: #e0f2fe;
  color: #0369a1;
}

/* Detalle de Calendario Maestro */
.detail-top-nav {
  margin-bottom: 18px;
}

.calendario-detail-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.calendario-detail-title-row .btn-editar-maestro {
  flex: 0 0 auto;
  margin-left: auto;
}

.calendario-detail-info {
  margin-bottom: 24px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 20px;
}

.calendario-field {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  color: #475569;
  font-size: 13px;
}

.ediciones-section {
  margin-top: 28px;
}

.ediciones-section > .section-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.ediciones-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.edicion-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px;
}

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

.edicion-card-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.edicion-anio {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.edicion-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.edicion-card-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #475569;
}

.edicion-field {
  display: flex;
  gap: 6px;
}

.edicion-matriz-preview-wrap {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
}

.matriz-preview-title {
  margin: 0 0 10px 0;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.matriz-empty-notice {
  color: #64748b;
  font-style: italic;
  font-size: 13px;
  padding: 10px 0;
  margin: 0;
}

/* Matrices de Vencimientos (Mensual 12 columnas y Personalizada) */
.table-matrix-container {
  overflow-x: auto;
  margin-top: 8px;
  margin-bottom: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
}

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

.table-matrix th {
  padding: 10px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #475569;
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  text-align: center;
  white-space: nowrap;
}

.table-matrix th.th-aplica {
  text-align: left;
  min-width: 140px;
  padding-left: 14px;
}

.table-matrix th.th-anio {
  min-width: 60px;
}

.table-matrix td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}

.table-matrix td.col-aplica-a {
  text-align: left;
  padding-left: 14px;
  white-space: nowrap;
}

.table-matrix tr:last-child td {
  border-bottom: 0;
}

.matrix-cell {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
}

.matrix-cell--has-date {
  font-weight: 700;
  color: #0f172a;
  background: #fafbfc;
  cursor: help;
  transition: background-color .15s, color .15s;
}

.matrix-cell--has-date:hover {
  background: #eef2ff;
  color: #4338ca;
}

.matrix-cell--empty {
  color: #cbd5e1;
  font-weight: 400;
}

/* Tabla personalizada */
.table-matrix-personalizada th,
.table-matrix-personalizada td {
  text-align: left;
  padding: 10px 14px;
}

.table-matrix-personalizada td.col-pers-obs {
  color: #64748b;
  font-size: 12px;
}

/* Editor de Matriz de Vencimientos */
.view-matriz-editor {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.matriz-editor-meta-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 20px;
}

.matriz-editor-body {
  margin-top: 8px;
}

.table-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.table-matrix-editor td {
  padding: 6px 4px;
}

.table-matrix-editor .input {
  margin-bottom: 0;
}

.matrix-input-cell {
  min-width: 90px;
}

.matrix-date-input {
  width: 100%;
  min-width: 85px;
  padding: 5px 4px;
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
}

.matrix-date-input:focus {
  border-color: #6366f1;
}

.matrix-day-input {
  width: 100%;
  min-width: 44px;
  max-width: 60px;
  text-align: center;
  padding: 6px 4px;
  font-size: 13px;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  margin: 0 auto;
}

.matrix-day-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.matrix-day-input::-webkit-outer-spin-button,
.matrix-day-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.matrix-day-input[type=number] {
  -moz-appearance: textfield;
}

.col-accion {
  width: 44px;
  text-align: center;
}

/* Tabla especializada para MES_BALANCE (AIN) */
.table-balance-container {
  max-width: 640px;
}

.table-matrix-balance th,
.table-matrix-balance td {
  padding: 10px 14px;
}

.table-matrix-balance .col-bal-mes {
  width: 35%;
  font-weight: 700;
  color: #0f172a;
}

.table-matrix-balance .col-bal-cierre,
.table-matrix-balance .col-bal-limite {
  width: 32.5%;
}

.table-matrix-editor-balance td {
  padding: 8px 10px;
}

.table-matrix-editor-balance .input-balance-cierre,
.table-matrix-editor-balance .input-balance-limite {
  width: 100%;
}

/* Pestaña Calendarios en Empresa */
.view-empresa-calendarios-tab {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Fechas oficiales aplicables modal */
.modal-dialog--lg {
  max-width: 780px;
  width: 95%;
}

.fechas-top-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.fechas-disclaimer {
  color: #64748b;
  font-size: 12px;
}

.field-display-static {
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-weight: 600;
  color: #0f172a;
}

/* ==========================================================================
   Módulo Equipo del estudio
   ========================================================================== */
.view-equipo-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* El gap del contenedor completa los 26 px compartidos del encabezado. */
.view-equipo-container > .view-header {
  margin-bottom: 6px;
}

.equipo-toolbar {
  padding: 16px 20px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.equipo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.equipo-card {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.equipo-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.equipo-card-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.equipo-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}

.equipo-header-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.equipo-nombre {
  font-size: 16px;
  color: #0f172a;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.equipo-cargo {
  font-size: 13px;
  color: #64748b;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.equipo-badges-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.badge-acceso-si {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-acceso-no {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.badge-departamento-asignado {
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

.modal-dialog--compact {
  width: min(520px, calc(100vw - 32px));
}

.equipo-contact-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
  flex: 1;
}

.equipo-contact-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #475569;
}

.equipo-contact-item .contact-icon {
  font-size: 14px;
  opacity: 0.7;
}

.equipo-email-link,
.equipo-telefono-link {
  color: #4f46e5;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.equipo-email-link:hover,
.equipo-telefono-link:hover {
  text-decoration: underline;
}

.equipo-card-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

/* ==========================================================================
   Módulo Accesos e Invitaciones
   ========================================================================== */
.view-accesos-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.view-accesos-container > .view-header {
  margin-bottom: 6px;
}

.accesos-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.stat-card--active {
  border-left: 4px solid #10b981;
}

.stat-card--pending {
  border-left: 4px solid #3b82f6;
}

.stat-card--inactive {
  border-left: 4px solid #94a3b8;
}

.stat-card .stat-label {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #0f172a;
}

.accesos-toolbar {
  padding: 16px 20px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.accesos-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.acceso-card {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.acceso-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.acceso-card-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.acceso-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

.acceso-header-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.acceso-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.acceso-nombre {
  font-size: 16px;
  color: #0f172a;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acceso-email {
  font-size: 13px;
  color: #64748b;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acceso-badges-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.badge-system {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #ddd6fe;
  font-size: 11px;
}

.badge-pending {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.badge-role-admin {
  background: #fdf2f8;
  color: #9d174d;
  border: 1px solid #fbcfe8;
}

.badge-role-usuario {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.acceso-info-details {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 12px;
}

.acceso-card-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
}

.access-manage-menu { position: relative; margin-left: auto; }
.access-manage-menu > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 170px; list-style: none; cursor: pointer; }
.access-manage-menu > summary::-webkit-details-marker { display: none; }
.access-manage-menu[open] > summary { border-color: #6366f1; color: #4338ca; }
.access-manage-dropdown { position: fixed; z-index: 1000; box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain; padding: 8px; border: 1px solid #dbe3ef; border-radius: 12px; background: #fff; box-shadow: 0 16px 36px rgba(15,23,42,.18); }
.access-manage-dropdown[data-placement="down"] { transform-origin: top right; }
.access-manage-dropdown[data-placement="up"] { transform-origin: bottom right; }
.access-menu-group { padding: 11px 10px; }
.access-menu-group + .access-menu-group { border-top: 1px solid #eef2f7; }
.access-menu-group > strong { display: block; margin-bottom: 8px; color: #475569; font-size: 12px; letter-spacing: .02em; text-transform: uppercase; }
.access-menu-group .acceso-actions { flex-direction: column; align-items: stretch; }
.access-menu-group .btn { width: 100%; justify-content: flex-start; text-align: left; }
.access-danger-zone { margin-top: 4px; border-top-color: #fecaca !important; background: #fff7f7; border-radius: 8px; }
.access-danger-zone > strong { color: #b91c1c; }
.equipo-notes-textarea { width: 100%; min-height: 120px; line-height: 1.5; }
.equipo-notes-counter { display: block; margin-top: 6px; text-align: right; color: #64748b; }

@media (max-width: 700px) {
  .access-manage-menu,.access-manage-menu > summary { width: 100%; }
}

.acceso-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Vista pública de aceptación de invitaciones */
.public-invite-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.public-invite-card {
  max-width: 480px;
  width: 100%;
}

.public-invite-subtitle {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 16px 0;
  text-align: center;
}

.invite-recipient-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
}

.password-requirements-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12px;
  color: #475569;
  margin-bottom: 20px;
}

.password-requirements-box ul {
  margin: 6px 0 0 18px;
  padding: 0;
}

.password-requirements-box li {
  margin-bottom: 2px;
}

.password-requirements-box li.is-met::marker {
  content: "✓  ";
  color: #15803d;
  font-weight: 700;
}

.copy-notice {
  font-size: 13px;
  font-weight: 600;
  margin-top: 8px;
}

.btn-danger {
  background: #dc2626;
  color: #ffffff;
  border: 1px solid #b91c1c;
}
.btn-danger:hover {
  background: #b91c1c;
}
.btn-danger:focus-visible {
  outline: 2px solid #ef4444;
  outline-offset: 2px;
}

.btn-outline-danger {
  background: transparent;
  color: #dc2626;
  border: 1px solid #fca5a5;
}
.btn-outline-danger:hover {
  background: #fef2f2;
  border-color: #ef4444;
  color: #b91c1c;
}
.btn-outline-danger:focus-visible {
  outline: 2px solid #ef4444;
  outline-offset: 2px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.confirm-modal-description {
  font-size: 14px;
  line-height: 1.5;
  color: #334155;
  margin: 0;
}

/* Centro de Notificaciones Internas */
.shell-topbar {
  margin-left: 230px;
  padding: 16px 32px 0 32px;
  display: flex;
  justify-content: flex-end;
  position: relative;
  z-index: 40;
}
.shell-topbar-inner {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 14px;
}
.empresa-quick-search { position: relative; width: 100%; }
.empresa-quick-search-toggle { display: none; }
.empresa-quick-search-panel { position: relative; width: 100%; }
.empresa-quick-search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  color: #64748b;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
}
.empresa-quick-search-field:focus-within {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, .13);
}
.empresa-quick-search-field input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: #0f172a;
  background: transparent;
  font-size: 13px;
}
.empresa-quick-search-field input::placeholder { color: #94a3b8; }
.empresa-quick-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 70;
  max-height: 320px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 16px 32px rgba(15, 23, 42, .16);
}
.empresa-quick-search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 7px;
  color: #0f172a;
  background: transparent;
  text-align: left;
}
.empresa-quick-search-result:hover,
.empresa-quick-search-result.is-active { background: #eef2ff; }
.empresa-quick-search-result strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.empresa-quick-search-result small { flex: 0 0 auto; color: #64748b; font-family: 'DM Mono', monospace; font-size: 11px; }
.empresa-quick-search-message { margin: 0; padding: 10px; color: #64748b; font-size: 12px; }
.notificaciones-bell-container {
  position: relative;
  display: inline-flex;
}
.notificaciones-bell-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
  position: relative;
}
.notificaciones-bell-btn:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}
.notificaciones-bell-btn:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}
.notificaciones-bell-btn--mobile {
  background: #1e293b;
  border: 1px solid #334155;
  color: #f1f5f9;
}
.notificaciones-bell-btn--mobile:hover {
  background: #334155;
  color: #ffffff;
}
.notificaciones-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #4f46e5;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.notificaciones-bell-btn--mobile .notificaciones-badge {
  border-color: #0f172a;
}
.notificaciones-badge[hidden] {
  display: none !important;
}

/* Panel Desplegable */
.notificaciones-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: 480px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 20px 25px -5px rgba(15, 23, 42, .12), 0 8px 10px -6px rgba(15, 23, 42, .06);
  display: flex;
  flex-direction: column;
  z-index: 150;
  overflow: hidden;
}
.notificaciones-panel[hidden] {
  display: none !important;
}
.notificaciones-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  background: #ffffff;
}
.notificaciones-panel-title-area {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.notificaciones-panel-title-area strong {
  font-size: 15px;
  color: #0f172a;
  font-weight: 700;
  line-height: 1.2;
}
.notificaciones-panel-subtitle {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  line-height: 1.2;
}
.notificaciones-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.notificaciones-panel-actions [hidden] {
  display: none !important;
}
.notificaciones-panel-actions .btn:disabled {
  cursor: default;
}
.btn-icon-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #94a3b8;
  border-radius: 6px;
  cursor: pointer;
}
.btn-icon-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.btn-icon-close:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 1px;
}
.notificaciones-panel-body {
  overflow-y: auto;
  max-height: 360px;
  flex: 1;
}
.notificaciones-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 16px;
  color: #64748b;
  font-size: 13px;
}
.notificaciones-error {
  padding: 24px 16px;
  text-align: center;
  color: #b91c1c;
  font-size: 13px;
}
.notificaciones-empty {
  padding: 40px 16px;
  text-align: center;
  color: #64748b;
}
.notificaciones-empty-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: .5;
}
.notificaciones-empty p {
  margin: 0;
  font-size: 13px;
}
.notificaciones-list {
  display: flex;
  flex-direction: column;
}
.notificacion-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #f8fafc;
  background: #ffffff;
  transition: background-color .15s;
  position: relative;
}
.notificacion-item:hover {
  background: #f8fafc;
}
.notificacion-item.notificacion-unread {
  background: #f5f7ff;
  border-left: 3px solid #4f46e5;
}
.notificacion-item.notificacion-unread:hover {
  background: #eef2ff;
}
.notificacion-item-main {
  flex: 1;
  cursor: pointer;
  outline: none;
}
.notificacion-item-main:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
  border-radius: 4px;
}
.notificacion-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.notificacion-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 6px;
  border-radius: 4px;
}
.notificacion-tag--empresa {
  background: #eef2ff;
  color: #4f46e5;
}
.notificacion-tag--vencimiento {
  background: #fff7ed;
  color: #c2410c;
}
.notificacion-tag--certificado {
  background: #ecfdf5;
  color: #047857;
}
.notificacion-date {
  font-size: 11px;
  color: #94a3b8;
}
.notificacion-message {
  margin: 0;
  font-size: 13px;
  color: #1e293b;
  line-height: 1.4;
}
.notificacion-item-actions {
  display: flex;
  align-items: center;
}
.notificacion-btn-read {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  transition: all .15s;
}
.notificacion-btn-read:hover {
  background: #eef2ff;
  color: #4f46e5;
  border-color: #c7d2fe;
}
.notificacion-btn-read:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 1px;
}
.notificaciones-panel-footer {
  padding: 10px 16px;
  border-top: 1px solid #f1f5f9;
  background: #fafbfc;
  text-align: center;
}
.btn-ver-historial {
  background: transparent;
  border: none;
  color: #4f46e5;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.btn-ver-historial:hover {
  background: #eef2ff;
}

/* Modal de Historial de 90 Días */
.notificaciones-historial-body {
  padding: 16px 24px;
}
.notificaciones-historial-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}
.notificaciones-historial-count {
  font-size: 13px;
  color: #64748b;
  font-weight: 600;
}
.notificaciones-list-historial {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  max-height: 440px;
  overflow-y: auto;
}
.notificaciones-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}
.pagination-info {
  font-size: 13px;
  color: #64748b;
  font-weight: 600;
}
.notificaciones-pagination .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Resaltado temporal al navegar desde una notificación */
@keyframes notificacionTargetPulse {
  0% {
    background-color: rgba(99, 102, 241, 0.22);
    outline: 2px solid #6366f1;
    outline-offset: -1px;
  }
  70% {
    background-color: rgba(99, 102, 241, 0.10);
    outline: 2px solid rgba(99, 102, 241, 0.7);
    outline-offset: -1px;
  }
  100% {
    background-color: transparent;
    outline: 2px solid transparent;
    outline-offset: -1px;
  }
}

.notification-target-highlight {
  animation: notificacionTargetPulse 2.5s ease-out forwards;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  .notification-target-highlight {
    animation: none;
    background-color: rgba(99, 102, 241, 0.16);
    outline: 2px solid #6366f1;
    outline-offset: -1px;
  }
}

@media (max-width: 760px) {
  .equipo-grid,
  .accesos-grid,
  .accesos-stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell-topbar {
    display: block;
    position: static;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
  }
  .shell-topbar .notificaciones-bell-btn {
    display: none;
  }
  .sidebar-search { display: none; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 100;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    color: #fff;
    background: #0f172a;
  }
  .mobile-header-brand {
    display: flex;
    align-items: center;
  }
  .mobile-header-actions { display: flex; align-items: center; gap: 6px; }
  .mobile-header-actions .empresa-quick-search { width: auto; }
  .mobile-header-actions .empresa-quick-search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid #334155;
    border-radius: 10px;
    color: #e2e8f0;
    background: #1e293b;
  }
  .mobile-header-actions .empresa-quick-search-panel {
    display: none;
    position: fixed;
    top: 58px;
    left: 12px;
    right: 12px;
    z-index: 75;
    width: auto;
  }
  .mobile-header-actions .empresa-quick-search.is-open .empresa-quick-search-panel { display: block; }
  .notificaciones-panel {
    position: fixed;
    top: 56px;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 72px);
  }
  .hamburger-btn { display: block; }
  .main-content { margin-left: 0; padding: 22px 16px; }
  .page-header,
  .view-header,
  .module-header { flex-direction: column; }
  .stats-grid, .foundation-card, .inicio-upcoming-grid { grid-template-columns: 1fr; }
  .login-card { padding: 30px 24px; }
  .empty-state { padding: 44px 18px; }
  .detail-card { padding: 20px 16px; }
}

