/* Atención Proactiva v15.4.6 · tablero con accesos clínicos directos y navegación simplificada. */
:root {
  --v154-green-950: #04483b;
  --v154-green-900: #075947;
  --v154-green-800: #08705a;
  --v154-green-700: #0a8168;
  --v154-green-100: #dff3ed;
  --v154-green-50: #f1faf7;
  --v154-amber: #b87800;
  --v154-red: #c92b24;
  --v154-soft-shadow: 0 8px 26px rgba(20, 52, 45, .075);
  --v154-card-shadow: 0 2px 10px rgba(20, 52, 45, .05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  letter-spacing: -.005em;
}

.app-header {
  min-height: 86px;
  padding: 1rem clamp(1rem, 3.2vw, 2.25rem);
  background: linear-gradient(118deg, var(--v154-green-950), var(--v154-green-800));
  box-shadow: 0 5px 22px rgba(3, 62, 49, .15);
}
.brand-home {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0;
}
.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 15px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.52);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
  font-size: 1.28rem;
  position: relative;
  overflow: hidden;
}
.brand-mark-main {
  display: block;
  transform: translateY(-.03rem);
}
.brand-signature {
  position: absolute;
  right: .34rem;
  bottom: .24rem;
  font-size: .34rem;
  font-weight: 720;
  line-height: 1;
  letter-spacing: .105em;
  opacity: .38;
  user-select: none;
  transition: opacity .16s ease;
}
.brand-home:hover .brand-signature,
.brand-home:focus-visible .brand-signature { opacity: .68; }
.brand-copy { display: grid; gap: .08rem; min-width: 0; }
.brand-title { font-weight: 850; font-size: clamp(1.35rem, 2.2vw, 2rem); line-height: 1.08; }
.brand-subtitle { font-size: .92rem; opacity: .94; }
.brand-meta { display: inline-flex; align-items: center; gap: .38rem; font-size: .75rem; opacity: .84; margin-top: .12rem; }
.header-status-dot { width: .48rem; height: .48rem; border-radius: 50%; background: #7ce2b8; box-shadow: 0 0 0 3px rgba(124,226,184,.13); }
.header-actions { align-items: center; }
.header-icon-btn, .header-backup-btn {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  min-height: 42px;
  border-radius: 12px;
  padding: .65rem .9rem;
}
.header-backup-btn { background: var(--v154-amber); border-color: #d29a2d; }
.ui-icon { font-size: 1.05rem; line-height: 1; }

.app-nav {
  display: block;
  padding: 0;
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(21, 49, 43, .055);
  overflow: visible;
}
.nav-groups {
  width: min(1440px, calc(100% - 2rem));
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .2rem;
  align-items: stretch;
}
.nav-group {
  appearance: none;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 0;
  padding: .8rem .72rem .7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .62rem;
  min-width: 0;
  font: inherit;
  text-align: left;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}
.nav-group:hover { background: var(--panel-2); }
.nav-group.active, .nav-group-direct.active {
  background: color-mix(in srgb, var(--primary) 7%, transparent);
  border-bottom-color: var(--primary);
  color: var(--primary);
}
.nav-group-icon {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  font-size: 1.28rem;
  flex: 0 0 auto;
  color: currentColor;
}
.nav-group > span:last-child { min-width: 0; display: grid; line-height: 1.2; }
.nav-group strong { font-size: .91rem; }
.nav-group small { color: var(--muted); font-size: .72rem; font-weight: 500; margin-top: .1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-panels {
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background: var(--panel);
}
.app-nav[data-active-group="inicio"] .nav-panels,
.app-nav[data-active-group="reportes"] .nav-panels { display: none; }
.nav-panel {
  width: min(1440px, calc(100% - 2rem));
  margin: 0 auto;
  padding: .58rem 0;
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}
.nav-panel[hidden] { display: none !important; }
.nav-panel .nav-btn {
  padding: .55rem .82rem;
  border-radius: 10px;
  background: transparent;
  font-size: .86rem;
  border-color: transparent;
}
.nav-panel .nav-btn:hover { background: var(--panel-2); border-color: var(--border); }
.nav-panel .nav-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.nav-insert-anchor { display: none; }

.app-shell { width: min(1440px, calc(100% - 2rem)); margin-top: 1.15rem; }
.panel, .card { box-shadow: var(--v154-soft-shadow); }
.panel { border-radius: 18px; }
.card { border-radius: 14px; box-shadow: var(--v154-card-shadow); }
.btn { border-radius: 11px; padding: .68rem .95rem; }
.actions .btn { min-height: 41px; }
.btn-primary { box-shadow: 0 7px 16px rgba(8,112,90,.14); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea { border-radius: 10px; }
.table-wrap { border-radius: 14px; }
th { background: color-mix(in srgb, var(--panel-2) 88%, var(--panel)); }
tbody tr:hover td { background: color-mix(in srgb, var(--primary) 3%, var(--panel)); }

.v154-icon { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; }
.v154-dashboard { display: grid; grid-template-columns: minmax(0, 2.15fr) minmax(300px, .88fr); gap: 1rem; align-items: start; }
.v154-dashboard-main { min-width: 0; display: grid; gap: 1rem; }
.v154-dashboard-side { min-width: 0; display: grid; gap: 1rem; position: sticky; top: 8.2rem; }
.v154-hero-card {
  min-height: 350px;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, .85fr);
  background: linear-gradient(140deg, var(--v154-green-50), #edf6f3 68%, #e3f2ec);
  border: 1px solid #cfe3dd;
  border-radius: 20px;
  box-shadow: var(--v154-soft-shadow);
}
.v154-hero-copy { padding: clamp(1.35rem, 3vw, 2rem); position: relative; z-index: 2; align-self: center; }
.v154-kicker { color: var(--primary); font-size: .72rem; font-weight: 850; text-transform: uppercase; letter-spacing: .095em; }
.v154-hero-copy h2 { margin: .48rem 0 .72rem; color: #064d3f; font-size: clamp(2rem, 4.3vw, 3.15rem); line-height: 1.05; letter-spacing: -.045em; }
.v154-hero-copy > p { max-width: 640px; margin: 0; color: #4c625c; font-size: 1.02rem; }
.v154-hero-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-top: 1.25rem; max-width: 920px; }
.v154-primary-action, .v154-secondary-action { min-height: 82px; display: flex; align-items: center; justify-content: flex-start; gap: .85rem; text-align: left; padding: .9rem 1rem; }
.v154-primary-action .v154-icon, .v154-secondary-action .v154-icon { width: 1.75rem; height: 1.75rem; }
.v154-primary-action span, .v154-secondary-action span { display: grid; }
.v154-primary-action strong, .v154-secondary-action strong { font-size: 1rem; }
.v154-primary-action small, .v154-secondary-action small { font-weight: 500; opacity: .83; margin-top: .15rem; }
.v154-secondary-action { background: rgba(255,255,255,.85); border-color: #73aa9c; color: var(--v154-green-900); box-shadow: 0 5px 14px rgba(20, 78, 64, .06); }
.v154-text-action, .v154-link-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .42rem;
}
.v154-text-action { margin-top: .9rem; padding: .35rem 0; }
.v154-text-action .v154-icon:last-child, .v154-link-button .v154-icon { width: 1rem; height: 1rem; }
.v154-hero-art { min-width: 0; display: flex; align-items: end; justify-content: end; }
.v154-hero-art img { display: block; width: 100%; height: 100%; min-height: 320px; object-fit: cover; object-position: center bottom; }
.v154-trust-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.v154-trust-card {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: .8rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 14px;
  padding: .85rem 1rem;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--v154-card-shadow);
}
.v154-trust-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.v154-trust-card > .v154-icon { width: 2.15rem; height: 2.15rem; padding: .45rem; border-radius: 50%; background: var(--v154-green-100); color: var(--primary); }
.v154-trust-card span { display: grid; }
.v154-trust-card strong { color: var(--primary); }
.v154-trust-card small { color: var(--muted); margin-top: .13rem; }
.v154-summary-panel, .v154-activity-panel { margin: 0; }
.v154-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.v154-section-heading h2 { margin: .15rem 0 0; }
.v154-link-button { padding: .4rem 0; white-space: nowrap; }
.v154-stats-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .65rem; }
.stat {
  min-height: 110px;
  padding: .82rem;
  display: flex;
  align-items: flex-start;
  gap: .68rem;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: none;
  text-align: left;
}
.stat-action { cursor: pointer; color: var(--text); }
.stat-action:hover { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 10%, transparent); transform: translateY(-1px); }
.stat-action.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, var(--panel)); }
.stat-icon { width: 2.45rem; height: 2.45rem; border-radius: 12px; background: var(--v154-green-100); color: var(--primary); display: grid; place-items: center; flex: 0 0 auto; }
.stat-icon .v154-icon { width: 1.35rem; height: 1.35rem; }
.stat-copy { min-width: 0; display: grid; }
.stat .num { font-size: 1.55rem; line-height: 1; }
.stat .label { margin-top: .28rem; color: var(--text); font-weight: 750; font-size: .79rem; line-height: 1.18; }
.stat small { color: var(--primary); font-size: .7rem; font-weight: 750; margin-top: .25rem; }
.stat-danger .stat-icon { background: #fde7e5; color: var(--v154-red); }
.stat-danger .num { color: var(--v154-red); }
.stat-warning .stat-icon, .stat-attention .stat-icon { background: #fff0d2; color: var(--v154-amber); }
.stat-warning .num, .stat-attention .num { color: var(--v154-amber); }
.stat-success .stat-icon { background: #e0f5e8; color: var(--success); }
.v154-more-metrics { margin-top: .85rem; border-top: 1px solid var(--border); padding-top: .55rem; }
.v154-more-metrics summary { width: fit-content; font-size: .86rem; }
.v154-secondary-metrics { margin-top: .75rem; }
.activity-list { display: grid; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.activity-row {
  appearance: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  min-height: 58px;
  padding: .7rem .85rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: .75rem;
  align-items: center;
  text-align: left;
  cursor: pointer;
}
.activity-row:last-child { border-bottom: 0; }
.activity-row:hover { background: var(--panel-2); }
.activity-main { min-width: 0; display: grid; }
.activity-title { font-weight: 690; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-time { color: var(--muted); font-size: .76rem; }
.activity-chip { border-radius: 999px; padding: .24rem .55rem; font-size: .7rem; font-weight: 800; }
.activity-success { background: #e2f5e9; color: #116b38; }
.activity-warning { background: #fff0d2; color: #845500; }
.activity-danger { background: #fde7e5; color: #a7241f; }
.activity-neutral { background: var(--panel-2); color: var(--muted); }
.activity-arrow { width: 1rem; height: 1rem; color: var(--muted); }

.v154-side-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 17px;
  padding: 1rem;
  box-shadow: var(--v154-card-shadow);
}
.v154-side-heading { min-height: 30px; display: flex; align-items: center; gap: .55rem; margin-bottom: .65rem; }
.v154-side-heading > .v154-icon { color: var(--primary); }
.v154-side-heading h3 { margin: 0; font-size: 1rem; flex: 1; }
.v154-side-heading button { appearance: none; border: 0; background: transparent; color: var(--primary); cursor: pointer; font-weight: 800; font-size: .75rem; }
.v154-status { border-radius: 999px; padding: .25rem .55rem; font-size: .68rem; font-weight: 850; white-space: nowrap; }
.v154-status-success { background: #dff5e7; color: #126d39; }
.v154-status-warning { background: #fff0ce; color: #805000; }
.v154-status-danger { background: #fde4e2; color: #a6241e; }
.v154-side-row {
  appearance: none;
  width: 100%;
  min-height: 54px;
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr) 1rem;
  align-items: center;
  gap: .5rem;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.v154-side-row:hover { color: var(--primary); }
.v154-side-row strong { font-size: 1.35rem; }
.v154-side-row span { font-size: .84rem; font-weight: 650; }
.v154-side-row .v154-icon { width: 1rem; height: 1rem; color: var(--muted); }
.tone-warning { color: var(--v154-amber); }
.tone-danger { color: var(--v154-red); }
.v154-side-footnote { margin: .55rem 0 0; padding-top: .55rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .75rem; }
.v154-side-main-value { margin: .15rem 0 .18rem; font-weight: 800; }
.v154-side-muted { margin: .18rem 0; color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.v154-card-action { width: 100%; margin-top: .75rem; display: flex; align-items: center; justify-content: center; gap: .5rem; background: transparent; color: var(--primary); }
.dashboard-detail { margin-top: 1rem; }

[data-theme="dark"] .v154-hero-card { background: linear-gradient(140deg, #172b27, #1a312c 68%, #18352e); border-color: #365148; }
[data-theme="dark"] .v154-hero-copy h2 { color: #d8fff3; }
[data-theme="dark"] .v154-hero-copy > p { color: #bdd0ca; }
[data-theme="dark"] .v154-secondary-action { background: rgba(23,32,30,.82); color: var(--text); border-color: #4f7168; }
[data-theme="dark"] .v154-hero-art img { opacity: .78; }
[data-theme="dark"] .stat-danger .stat-icon { background: rgba(201,43,36,.18); }
[data-theme="dark"] .stat-warning .stat-icon, [data-theme="dark"] .stat-attention .stat-icon { background: rgba(184,120,0,.19); }
[data-theme="dark"] .stat-success .stat-icon { background: rgba(20,122,62,.2); }
[data-theme="dark"] .activity-success, [data-theme="dark"] .v154-status-success { background: rgba(20,122,62,.22); color: #a7e8bd; }
[data-theme="dark"] .activity-warning, [data-theme="dark"] .v154-status-warning { background: rgba(184,120,0,.22); color: #ffd788; }
[data-theme="dark"] .activity-danger, [data-theme="dark"] .v154-status-danger { background: rgba(201,43,36,.22); color: #ffaaa4; }

@media (max-width: 1180px) {
  .nav-groups { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .v154-dashboard { grid-template-columns: minmax(0, 1.65fr) minmax(285px, .85fr); }
  .v154-stats-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .v154-hero-card { grid-template-columns: minmax(0,1.2fr) minmax(220px,.8fr); }
}
@media (max-width: 900px) {
  .app-header { flex-direction: row; align-items: center; }
  .brand-subtitle { display: none; }
  .v154-dashboard { grid-template-columns: 1fr; }
  .v154-dashboard-side { position: static; grid-template-columns: repeat(2, minmax(0,1fr)); }
  .v154-hero-card { grid-template-columns: 1fr; min-height: 0; }
  .v154-hero-art { display: none; }
}
@media (max-width: 720px) {
  .app-header { align-items: flex-start; }
  .brand-mark { width: 46px; height: 46px; }
  .brand-signature { right: .27rem; bottom: .19rem; font-size: .30rem; }
  .brand-meta { flex-wrap: wrap; }
  .header-actions { margin-left: auto; }
  .header-icon-btn span:last-child, .header-backup-btn span:last-child { display: none; }
  .header-icon-btn, .header-backup-btn { min-width: 42px; justify-content: center; padding: .55rem; }
  .nav-groups { width: 100%; grid-template-columns: repeat(5, minmax(0,1fr)); overflow: hidden; padding: 0 .25rem; }
  .nav-group { min-width: 0; padding: .68rem .12rem .55rem; flex-direction: column; text-align: center; gap: .2rem; }
  .nav-group strong { font-size: .68rem; letter-spacing: -.01em; white-space: nowrap; }
  .nav-group-icon { width: 1.5rem; height: 1.5rem; font-size: 1rem; }
  .nav-group small { display: none; }
  .nav-panel { width: 100%; flex-wrap: nowrap; overflow-x: auto; padding: .5rem; }
  .nav-panel .nav-btn { white-space: nowrap; flex: 0 0 auto; }
  .app-shell { width: min(100% - .75rem, 1440px); margin-top: .7rem; }
  .v154-hero-copy { padding: 1.15rem; }
  .v154-hero-copy h2 { font-size: clamp(1.75rem, 9vw, 2.4rem); }
  .v154-hero-actions { grid-template-columns: 1fr; }
  .v154-primary-action, .v154-secondary-action { min-height: 70px; }
  .v154-trust-grid, .v154-dashboard-side { grid-template-columns: 1fr; }
  .v154-section-heading { align-items: flex-start; flex-direction: column; }
  .v154-stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stat { min-height: 104px; padding: .7rem; gap: .5rem; }
  .stat-icon { width: 2.1rem; height: 2.1rem; }
  .activity-row { grid-template-columns: minmax(0,1fr) auto; }
  .activity-arrow { display: none; }
}
@media (max-width: 420px) {
  .brand-title { font-size: 1.15rem; }
  .brand-meta { font-size: .66rem; }
  .v154-stats-grid { grid-template-columns: 1fr 1fr; }
  .stat { flex-direction: column; }
}
@media print {
  .v154-dashboard, .v154-trust-grid, .v154-side-card, .nav-groups, .nav-panels { display: none !important; }
}

.header-icon-btn[hidden] { display: none !important; }

/* v15.4.7 · contención de accesos clínicos y enlace al modo visita rápida. */
.v154-primary-action, .v154-secondary-action { min-width: 0; }
.v154-primary-action > span, .v154-secondary-action > span { min-width: 0; width: 100%; }
.v154-primary-action strong, .v154-secondary-action strong { display: block; max-width: 100%; line-height: 1.08; overflow-wrap: anywhere; word-break: normal; hyphens: auto; }
.v154-micro-action { padding-inline: .72rem; gap: .5rem; }
.v154-micro-action .v154-icon { width: 1.42rem; height: 1.42rem; }
.v154-micro-action strong { font-size: clamp(.84rem, 1.02vw, .96rem); letter-spacing: -.025em; }
.cedula-quick-mode-btn { margin-left: auto; white-space: nowrap; }
@media (max-width: 720px) {
  .v154-micro-action { padding-inline: 1rem; gap: .85rem; }
  .v154-micro-action .v154-icon { width: 1.75rem; height: 1.75rem; }
  .v154-micro-action strong { font-size: 1rem; overflow-wrap: normal; }
  .cedula-quick-mode-btn { width: 100%; margin-left: 0; }
}

/* Interfaz unificada local v15.5.4: únicamente visibilidad y navegación; sin cambios de datos. */
.ap-ui-unified-tabs{display:flex;flex-wrap:wrap;gap:10px;margin:14px 0 20px;padding:12px;background:var(--surface-subtle,#eef5f3);border:1px solid rgba(25,100,87,.18);border-radius:14px}
.ap-ui-unified-tabs .btn{min-height:42px;white-space:normal;text-align:center}
.ap-ui-advanced{margin-top:18px;border-top:1px solid rgba(25,100,87,.18);padding-top:15px}
.ap-ui-advanced summary{cursor:pointer;font-weight:650;margin-bottom:12px}
.ap-ui-advanced .actions{margin-top:10px}
.ap-ui-backup-actions{display:flex;gap:12px;flex-wrap:wrap;margin:18px 0}
.ap-ui-backup-actions .btn{flex:1 1 210px;white-space:normal;text-align:center;min-height:50px}
.ap-admin-settings-heading{padding:18px 21px;background:var(--surface-subtle,#eef5f3);border-radius:12px}
.ap-admin-settings-heading h2{margin:0 0 8px}
.ap-admin-settings-heading p{margin:0}
.ap-security-module[data-ui-screen="recovery"] [data-ui-feature="pin"]{display:none!important}
.ap-security-module[data-ui-screen="access"] [data-ui-feature="backup"]{display:none!important}
/* Ocultar por atributo HTML incluso si un estilo anterior configura .nav-btn como display:flex. */
.app-nav [hidden], .app-nav #legacyPartialToolsNav[hidden]{display:none!important}
@media(max-width:700px){.ap-ui-unified-tabs{display:grid;grid-template-columns:1fr}.ap-ui-backup-actions{display:grid;grid-template-columns:1fr}}
