:root {
  --nav-w: 16.5rem;
  --nav-w-collapsed: 4.35rem;
  --nav-font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --nav-font-size: 14px;
  --nav-item-size: 0.925rem;
  --nav-sub-size: 0.875rem;
  --nav-weight: 500;
  --nav-weight-active: 600;
}

/* Usado por el gate de menú (Maestro / OPERADOR) en todas las páginas del panel */
.nav-shell .hidden {
  display: none !important;
}

.app-shell,
#view-app.app-shell {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
}

body.nav-collapsed .app-shell,
body.nav-collapsed #view-app.app-shell {
  grid-template-columns: var(--nav-w-collapsed) minmax(0, 1fr);
}

.nav-shell {
  display: flex;
  flex-direction: column;
  background: #13262e;
  color: #d7e6ec;
  border-right: 0;
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow: hidden;
  /* Tipografía propia: no heredar la de cada página (Downloading, Prestador, etc.). */
  font-family: var(--nav-font);
  font-size: var(--nav-font-size);
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.nav-brand {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  height: 3.6rem;
  min-height: 3.6rem;
  max-height: 3.6rem;
  padding: 0 0.9rem;
  border-bottom: 1px solid #2c4650;
  color: white;
  flex: none;
}

.nav-mark {
  width: 1.85rem;
  height: 1.85rem;
  flex-shrink: 0;
  border-radius: 8px;
  background: #1f7a84;
}

.nav-brand-text {
  font-family: var(--nav-font);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.7rem 0.45rem;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: #d7e6ec;
  text-decoration: none;
  font-family: var(--nav-font);
  font-size: var(--nav-item-size);
  font-weight: var(--nav-weight);
  line-height: 1.3;
  letter-spacing: 0.01em;
  text-align: left;
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: #1d3944;
  color: white;
}

.nav-item.active {
  box-shadow: inset 3px 0 0 #1f7a84;
  font-weight: var(--nav-weight-active);
}

.nav-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.nav-icon svg {
  width: 1.2rem;
  height: 1.2rem;
  display: block;
}

.nav-label {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-group-toggle {
  position: relative;
}

.nav-chevron {
  margin-left: auto;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  opacity: 0.75;
  transition: transform 0.15s ease;
}

.nav-chevron svg {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
}

.nav-group.open > .nav-group-toggle .nav-chevron {
  transform: rotate(90deg);
}

.nav-group.child-active > .nav-group-toggle {
  color: white;
}

.nav-sublist {
  display: none;
  flex-direction: column;
  gap: 0.12rem;
  padding: 0.1rem 0 0.15rem 0.55rem;
  margin: 0 0 0.15rem;
  border-left: 2px solid #2c4650;
  margin-left: 1.05rem;
}

.nav-group.open > .nav-sublist {
  display: flex;
}

.nav-subitem {
  padding: 0.42rem 0.55rem;
  font-size: var(--nav-sub-size);
  font-weight: var(--nav-weight);
}

.nav-subitem .nav-icon {
  width: 1.05rem;
  height: 1.05rem;
}

.nav-subitem .nav-icon svg {
  width: 1rem;
  height: 1rem;
}

body.nav-collapsed .nav-chevron,
body.nav-collapsed .nav-sublist {
  display: none;
}

body.nav-collapsed .nav-group.open > .nav-sublist {
  display: none;
}

.nav-foot {
  border-top: 1px solid #2c4650;
  padding: 0.45rem;
}

body.nav-collapsed .nav-brand-text,
body.nav-collapsed .nav-label {
  display: none;
}

body.nav-collapsed .nav-collapse-btn .nav-icon {
  transform: rotate(180deg);
}

body.nav-collapsed .nav-brand {
  justify-content: center;
  height: 3.6rem;
  min-height: 3.6rem;
  max-height: 3.6rem;
  padding: 0 0.5rem;
}

.shell-body {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg, #e6eef1);
  color: var(--text, #1b2a32);
}

.shell-top {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 3.6rem;
  min-height: 3.6rem;
  max-height: 3.6rem;
  padding: 0 1rem;
  border-bottom: 0;
  background: var(--bg, #e6eef1);
  color: var(--text, #1b2a32);
  position: sticky;
  top: 0;
  z-index: 15;
  flex: none;
}

.shell-top-who {
  flex: 1;
  min-width: 0;
}

.shell-top-who strong {
  display: block;
}

.shell-scroll {
  flex: 1;
  padding: 1.15rem 1.25rem 2rem;
  overflow: auto;
}

.nav-toggle {
  flex-shrink: 0;
}

.dash-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.dash-head h2 {
  margin: 0 0 0.25rem;
}

.dash-head-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.dash-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--muted, #5d727c);
  cursor: pointer;
  user-select: none;
}

.dash-toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: #1f7a84;
}

.dash-section {
  margin-top: 1.1rem;
}

.dash-section:first-child {
  margin-top: 0.85rem;
}

.dash-section-title {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6a7f88;
}

.dash-section.is-hidden-section .dash-section-title {
  color: #9aa8af;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem;
}

.dash-tile.is-favorite {
  box-shadow: 0 10px 24px rgba(19, 38, 46, 0.08), 0 0 0 1px color-mix(in srgb, #e6b800 45%, transparent);
}

.dash-tile.is-hidden-tile {
  opacity: 0.72;
  filter: grayscale(0.15);
}

.dash-tile-tools {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: none;
}

.dash-tile-tool {
  width: 1.85rem;
  height: 1.85rem;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--dash-accent, #1f7a84) 10%, #fff);
  color: #5d727c;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}

.dash-tile-tool:hover {
  background: color-mix(in srgb, var(--dash-accent, #1f7a84) 18%, #fff);
  color: #13262e;
}

.dash-tile-tool.on {
  background: color-mix(in srgb, #e6b800 28%, #fff);
  color: #9a6b00;
}

.dash-tile-tool svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: currentColor;
}

.dash-tile {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--dash-accent, #1f7a84) 28%, #d3e0e6);
  border-radius: 16px;
  padding: 1rem 1rem 0.9rem;
  background:
    radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--dash-accent, #1f7a84) 18%, transparent), transparent 55%),
    linear-gradient(165deg, #ffffff 0%, #f4f8f9 100%);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.55rem;
  min-height: 9.5rem;
  box-shadow: 0 10px 24px rgba(19, 38, 46, 0.06);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.dash-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(19, 38, 46, 0.1);
}

.dash-tile-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.dash-tile-icon {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--dash-accent, #1f7a84) 16%, #fff);
  color: var(--dash-accent, #1f7a84);
  flex: none;
}

.dash-tile-icon svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: currentColor;
}

.dash-tile-action {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--dash-accent, #1f7a84) 12%, #fff);
  color: var(--dash-accent, #1f7a84);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}

.dash-tile-action:hover {
  background: var(--dash-accent, #1f7a84);
  color: #fff;
}

.dash-tile-action svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

.dash-tile-value {
  margin: 0;
  font-size: clamp(1.8rem, 2.4vw, 2.35rem);
  font-weight: 760;
  letter-spacing: -0.03em;
  line-height: 1;
  color: #13262e;
  font-variant-numeric: tabular-nums;
}

.dash-tile-label {
  margin: 0;
  color: #5d727c;
  font-size: 0.9rem;
  line-height: 1.35;
  max-width: 16rem;
}

.dash-tile-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

.dash-tile-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--dash-accent, #1f7a84) 12%, #fff);
  color: color-mix(in srgb, var(--dash-accent, #1f7a84) 80%, #13262e);
  font-size: 0.72rem;
  font-weight: 650;
}

.dash-tile.skeleton .dash-tile-value,
.dash-tile.skeleton .dash-tile-label {
  color: transparent;
  background: linear-gradient(90deg, #e8eef1, #f7fafb, #e8eef1);
  background-size: 200% 100%;
  animation: dash-shine 1.1s linear infinite;
  border-radius: 8px;
}

@keyframes dash-shine {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.dash-modal {
  width: min(720px, 94vw);
  max-height: min(80vh, 720px);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dash-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.dash-modal-head h2 {
  margin: 0 0 0.2rem;
}

.dash-modal-body {
  overflow: auto;
  min-height: 8rem;
}

.dash-espera {
  display: grid;
  place-items: center;
  min-height: 9rem;
  padding: 1.5rem;
  border: 1px solid #d3e0e6;
  border-radius: 12px;
  background: #f7fafb;
}

.dash-espera-giro {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  border: 3px solid #c9d9df;
  border-top-color: #1f7a84;
  border-radius: 50%;
  animation: dash-giro 0.75s linear infinite;
}

@keyframes dash-giro {
  to {
    transform: rotate(360deg);
  }
}

.dash-modal-body table {
  width: 100%;
  border-collapse: collapse;
}

.dash-modal-body th,
.dash-modal-body td {
  text-align: left;
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid #e2ebef;
  font-size: 0.9rem;
}

.dash-modal-body a {
  color: #1f7a84;
  text-decoration: none;
  font-weight: 650;
}

.dash-modal-body a:hover {
  text-decoration: underline;
}

.shell-body > .app {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.app-shell .topbar .brand {
  display: none;
}

.app-shell .topbar {
  position: static;
}

@media (max-width: 900px) {
  .app-shell,
  #view-app.app-shell,
  body.nav-collapsed .app-shell,
  body.nav-collapsed #view-app.app-shell {
    grid-template-columns: 1fr;
  }

  .nav-shell {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(18rem, 86vw);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  }

  body.nav-open .nav-shell,
  body.nav-collapsed.nav-open .nav-shell {
    transform: none;
  }

  body.nav-collapsed .nav-brand-text,
  body.nav-collapsed .nav-label {
    display: inline;
  }

  body.nav-collapsed .nav-item {
    justify-content: flex-start;
    padding: 0.55rem 0.65rem;
  }

  body.nav-collapsed .nav-chevron {
    display: grid;
  }

  body.nav-collapsed .nav-group.open > .nav-sublist {
    display: flex;
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 70;
  padding: 1rem;
}

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

.espera-modal {
  z-index: 80;
  background: rgba(19, 38, 46, 0.42);
}

.espera-modal .cargando-caja {
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  width: 18.5rem;
  min-width: 18.5rem;
  padding: 26px 28px 22px;
  background: #fff;
  color: #1b2a32;
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(19, 38, 46, 0.28);
  animation: cargando-entra 0.18s ease;
}

.espera-modal .cargando-giro {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: conic-gradient(from 90deg, rgba(31, 122, 132, 0.12), #1f7a84);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px));
  animation: cargando-giro 0.75s linear infinite;
}

.espera-modal .cargando-caja p {
  margin: 16px 0 0;
  text-align: center;
}

.espera-modal #procesandoTitle,
.espera-modal #ingresandoTitle,
.espera-modal #actualizandoTitle,
.espera-modal #cargandoTitle {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: #1b2a32;
}

.espera-modal .cargando-nota {
  margin: 6px 0 0;
  max-width: none;
  color: #5d727c;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0;
}

@keyframes cargando-entra {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes cargando-giro {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .espera-modal .cargando-caja,
  .espera-modal .cargando-giro {
    animation: none;
  }

  .espera-modal .cargando-giro {
    background: #1f7a84;
  }
}
