/*
 * Hoja principal de estilo de INVERGEST.
 * Define login, shell autenticado, tablas, formularios y paneles de seguridad.
 */

:root {
  --app-bg: #edf8fa;
  --app-surface: #f7fcfd;
  --app-card: #ffffff;
  --app-border: rgba(1, 162, 177, 0.16);
  --app-ink: #01A2B1;
  --app-muted: #5f7b80;
  --app-primary: #01A2B1;
  --app-primary-strong: #007985;
  --app-accent: #f2b84b;
  --app-success: #2f9e73;
  --app-danger: #c94b4b;
  --app-shadow: 0 18px 45px rgba(1, 162, 177, 0.12);
  --app-radius: 22px;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--app-ink);
  background:
    radial-gradient(circle at top left, rgba(195, 166, 107, 0.18), transparent 32%),
    linear-gradient(180deg, #f7f5ef 0%, var(--app-bg) 48%, #e7ece4 100%);
  font-family: "Instrument Sans", sans-serif;
}

a {
  color: inherit;
}

.mono {
  font-family: "IBM Plex Mono", monospace;
}

.app-shell {
  min-height: 100vh;
}

.flash-stack {
  max-width: 1080px;
  margin: 0 auto 1rem;
}

.login-hero,
.app-navbar,
.top-filter-card,
.sidebar-card,
.panel,
.settings-card,
.auth-card {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-card);
  box-shadow: var(--app-shadow);
}

.login-hero {
  background:
    linear-gradient(
      140deg,
      rgba(1, 162, 177, 0.96) 0%,
      rgba(0, 121, 133, 0.92) 54%,
      rgba(111, 231, 240, 0.85) 100%
    );
}

.hero-panel {
  display: flex;
  align-items: stretch;
  min-height: 100%;
  color: #f4f1ea;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  padding: 2.5rem;
}

.hero-kicker,
.navbar-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero-kicker {
  color: rgba(255, 255, 255, 0.8);
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.04;
}

.hero-copy p {
  margin: 0;
  max-width: 32rem;
  color: rgba(255, 255, 255, 0.82);
  font-size: 1.05rem;
}

.hero-list {
  margin: 0;
  padding-left: 1.15rem;
  color: rgba(255, 255, 255, 0.88);
}

.hero-list li + li {
  margin-top: 0.5rem;
}

.form-panel {
  background: rgba(248, 247, 242, 0.96);
}

.auth-card {
  margin: 1.5rem;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
}

.form-control,
.form-select,
.input-group-text {
  border-color: rgba(39, 76, 63, 0.12);
  border-radius: 14px;
  background: #fbfbf8;
  color: var(--app-ink);
}

.input-group > .form-control,
.input-group > .form-select,
.input-group > .btn {
  min-height: 48px;
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(39, 76, 63, 0.34);
  box-shadow: 0 0 0 0.2rem rgba(39, 76, 63, 0.14);
}

.btn {
  border-radius: 14px;
  font-weight: 600;
}

.btn-primary {
  border-color: var(--app-primary);
  background: var(--app-primary);
}

.btn-primary:hover,
.btn-primary:focus {
  border-color: var(--app-primary-strong);
  background: var(--app-primary-strong);
}

.btn-outline-dark {
  border-color: rgba(32, 49, 38, 0.22);
  color: var(--app-primary-strong);
}

.front-shell {
  max-width: 1560px;
  margin: 0 auto;
}

.app-navbar .card-body {
  padding-top: 1.4rem;
  padding-bottom: 1.4rem;
}

.navbar-kicker {
  color: var(--app-accent);
}

.session-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: #f2f2ed;
  color: var(--app-primary-strong);
  font-size: 0.92rem;
  font-weight: 600;
}

.sidebar-card {
  position: sticky;
  top: 1.5rem;
}

.module-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(39, 76, 63, 0.08);
  border-radius: 16px;
  background: #fcfcf9;
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.module-link:hover,
.module-link:focus {
  transform: translateX(3px);
  border-color: rgba(39, 76, 63, 0.24);
  box-shadow: 0 12px 24px rgba(28, 42, 32, 0.08);
}

.module-link.active {
  border-color: rgba(39, 76, 63, 0.25);
  background: linear-gradient(135deg, rgba(39, 76, 63, 0.1), rgba(195, 166, 107, 0.12));
  color: var(--app-primary-strong);
}

.panel-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.filter-form--top {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  align-items: start;
  column-gap: clamp(1.5rem, 3vw, 3rem);
  row-gap: 1rem;
}

.filter-fields {
  display: grid;
  grid-column: 2;
  grid-row: 2;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  justify-self: end;
  gap: 0.85rem;
  width: min(100%, 960px);
  min-width: 0;
}

.filter-fields .filter-field {
  min-width: 0;
}

.filter-field {
  flex: 1 1 180px;
  min-width: 160px;
}

.filter-field--search {
  grid-column: 1 / -1;
  grid-row: 1;
  width: 100%;
  min-width: 0;
}

.filter-field--range {
  flex-basis: 230px;
}

.filter-field--dir {
  flex: 0 1 160px;
}

.filter-range {
  display: flex;
  gap: 0.45rem;
}

.filter-range .form-control,
.filter-range .form-select {
  flex: 1 1 0;
  min-width: 0;
}

.filter-actions {
  display: flex;
  grid-column: 1;
  grid-row: 2;
  flex-direction: column;
  gap: 0.55rem;
  padding-right: 1.25rem;
  border-right: 1px solid var(--app-border);
  width: 100%;
}

.filter-actions .btn {
  width: 100%;
}

.panel {
  overflow: hidden;
}

.panel .card-body,
.settings-card {
  padding: 1.5rem;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 280px;
  padding: 2rem;
  text-align: center;
  color: var(--app-muted);
  background:
    radial-gradient(circle at top, rgba(195, 166, 107, 0.12), transparent 40%),
    linear-gradient(180deg, rgba(248, 247, 242, 0.65), rgba(248, 247, 242, 0.3));
  border: 1px dashed rgba(39, 76, 63, 0.16);
  border-radius: 18px;
}

.empty-state.compact {
  min-height: 0;
  padding: 1.5rem;
}

.empty-state i {
  font-size: 2rem;
}

.result-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: #f1eee4;
  color: var(--app-primary-strong);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.app-table {
  margin: 0;
}

.app-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbfbf7;
  color: var(--app-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom-color: rgba(39, 76, 63, 0.12);
}

.app-table td,
.app-table th {
  padding-top: 0.95rem;
  padding-bottom: 0.95rem;
  border-color: rgba(39, 76, 63, 0.08);
}

.table-responsive {
  border: 1px solid rgba(39, 76, 63, 0.08);
  border-radius: 18px;
}

.comments-panel,
.security-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.comment-item,
.security-row,
.permission-tile,
.info-panel {
  border: 1px solid rgba(39, 76, 63, 0.1);
  border-radius: 16px;
  background: #fcfcfa;
}

.comment-item,
.security-row {
  padding: 1rem 1.1rem;
}

.comment-item__meta,
.security-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.comment-item__meta {
  margin-bottom: 0.65rem;
  color: var(--app-muted);
  font-size: 0.9rem;
}

.settings-card {
  height: 100%;
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.9rem;
}

.permission-tile {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem;
  cursor: pointer;
}

.permission-tile input {
  margin-top: 0.2rem;
}

.permission-tile__body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.permission-tile__body small {
  color: var(--app-muted);
}

.filter-form .btn,
.settings-card .btn {
  min-height: 44px;
}

.info-panel {
  padding: 1rem;
}

.filter-form .form-label,
.settings-card .form-label {
  font-weight: 600;
}

.badge.text-bg-light {
  color: var(--app-primary-strong) !important;
  background: #f4f1e7 !important;
}

.standalone-toolbar {
  padding: 0.75rem 0;
}

.contents-fieldset {
  display: contents;
}

.multi-check-select {
  position: relative;
  border: 1px solid var(--bs-border-color);
  border-radius: 8px;
  background: #fff;
}

.multi-check-select summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  list-style: none;
}

.multi-check-select summary::-webkit-details-marker {
  display: none;
}

.multi-check-select .js-multi-check-summary {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.multi-check-select[open] summary {
  border-bottom: 1px solid var(--app-border);
}

.multi-check-select[open] summary i {
  transform: rotate(180deg);
}

.multi-check-select__options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem 1rem;
  max-height: 240px;
  overflow-y: auto;
  padding: 0.85rem;
}

.multi-check-select__options .form-check {
  min-width: 0;
  margin: 0;
}

.client-access-list {
  border-top: 1px solid var(--app-border);
}

.client-access-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.35fr) minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--app-border);
}

.client-access-row__user {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.client-access-row__permissions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 1rem;
}

.client-access-row__permissions .form-check {
  margin: 0;
}

.status-history {
  display: flex;
  flex-direction: column;
}

.status-history__item {
  display: grid;
  grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--app-border);
}

@media (max-width: 1199.98px) {
  .sidebar-card {
    position: static;
  }
}

@media (max-width: 991.98px) {
  .hero-copy,
  .auth-card {
    padding: 1.5rem;
    margin: 0;
  }

  .panel .card-body,
  .settings-card,
  .sidebar-card .card-body {
    padding: 1.2rem;
  }

  .table-responsive {
    border-radius: 14px;
  }
}

@media (max-width: 767.98px) {
  .comment-item__meta,
  .security-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .session-chip,
  .result-pill {
    width: 100%;
    justify-content: center;
  }

  .filter-form--top {
    grid-template-columns: minmax(0, 1fr);
  }

  .filter-fields,
  .filter-actions {
    grid-column: 1;
  }

  .filter-fields {
    grid-row: 3;
    grid-template-columns: minmax(0, 1fr);
    justify-self: stretch;
    width: 100%;
  }

  .filter-field,
  .filter-actions,
  .filter-actions .btn {
    width: 100%;
  }

  .filter-actions {
    grid-row: 2;
    padding-right: 0;
    border-right: 0;
  }

  .filter-range {
    flex-direction: column;
  }

  .multi-check-select__options,
  .client-access-row__permissions {
    grid-template-columns: minmax(0, 1fr);
  }

  .client-access-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .status-history__item {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Estados de prospección para Clientes y Demanda. */
.table-sort-link {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.table-sort-link:hover,
.table-sort-link:focus {
  color: var(--app-primary-strong);
}

.estado-filter-panel {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid rgba(39, 76, 63, 0.1);
  border-radius: 18px;
  background: #fcfcfa;
}

.estado-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.estado-filter,
.estado-badge,
.code-state,
.prospect-row {
  --estado-color: #fd7e14;
  --estado-soft: rgba(253, 126, 20, 0.18);
  --estado-hover: rgba(253, 126, 20, 0.24);
  --estado-border: rgba(253, 126, 20, 0.55);
  --estado-ink: #7a3a00;
  --estado-text: #2b1a00;
}

.estado-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 38px;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--estado-border);
  border-radius: 999px;
  background: var(--estado-soft);
  color: var(--estado-ink);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
  transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.estado-filter span {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 999px;
  background: var(--estado-color);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.65);
}

.estado-filter.active,
.estado-filter:hover,
.estado-filter:focus {
  transform: translateY(-1px);
  background: var(--estado-color);
  color: var(--estado-text);
  box-shadow: 0 10px 18px var(--estado-soft);
}

.estado-filter.active {
  outline: 2px solid var(--estado-border);
  outline-offset: 2px;
}

.estado-filter-clear {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0.5rem 0.8rem;
  border: 1px solid rgba(39, 76, 63, 0.16);
  border-radius: 999px;
  background: #fff;
  color: var(--app-primary-strong);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.estado-filter-clear:hover,
.estado-filter-clear:focus {
  background: #f1eee4;
}

.estado-badge,
.code-state {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.estado-badge {
  padding: 0.38rem 0.75rem;
  border: 1px solid var(--estado-border);
  background: var(--estado-color);
  color: var(--estado-text);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.14);
}

.code-state {
  padding: 0.28rem 0.58rem;
  border: 1px solid var(--estado-border);
  background: var(--estado-color);
  color: var(--estado-text);
  box-shadow: 0 8px 18px var(--estado-soft);
}

.estado-descartado,
.estado-desartado {
  --estado-color: #dc3545;
  --estado-soft: rgba(220, 53, 69, 0.17);
  --estado-hover: rgba(220, 53, 69, 0.25);
  --estado-border: rgba(220, 53, 69, 0.62);
  --estado-ink: #8f1723;
  --estado-text: #fff;
}

.estado-standby,
.estado-preparado {
  --estado-color: #ffc107;
  --estado-soft: rgba(255, 193, 7, 0.22);
  --estado-hover: rgba(255, 193, 7, 0.32);
  --estado-border: rgba(255, 193, 7, 0.7);
  --estado-ink: #7a5b00;
  --estado-text: #2b2200;
}

.estado-activo {
  --estado-color: #198754;
  --estado-soft: rgba(25, 135, 84, 0.17);
  --estado-hover: rgba(25, 135, 84, 0.25);
  --estado-border: rgba(25, 135, 84, 0.62);
  --estado-ink: #0f5f3a;
  --estado-text: #fff;
}

.estado-cierre {
  --estado-color: #0d6efd;
  --estado-soft: rgba(13, 110, 253, 0.17);
  --estado-hover: rgba(13, 110, 253, 0.25);
  --estado-border: rgba(13, 110, 253, 0.62);
  --estado-ink: #084298;
  --estado-text: #fff;
}

.estado-pendiente {
  --estado-color: #fd7e14;
  --estado-soft: rgba(253, 126, 20, 0.2);
  --estado-hover: rgba(253, 126, 20, 0.3);
  --estado-border: rgba(253, 126, 20, 0.66);
  --estado-ink: #8a4300;
  --estado-text: #2b1a00;
}

.app-table tbody tr.prospect-row > * {
  transition: background-color 0.16s ease, box-shadow 0.16s ease;
}

.app-table tbody tr.prospect-row:hover > * {
  background-color: var(--estado-hover) !important;
}

/* Supervisión administrativa de usuarios. */
.supervision-banner {
  position: sticky;
  top: 0.75rem;
  z-index: 1030;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(133, 100, 4, 0.35);
  border-left: 5px solid #b58105;
  border-radius: 8px;
  background: #fff8df;
  box-shadow: 0 12px 28px rgba(48, 39, 15, 0.16);
  color: #342a0b;
}

.supervision-banner__icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: #342a0b;
  color: #fff;
  font-size: 1.1rem;
}

.supervision-banner__content {
  min-width: 0;
}

.supervision-mode form[method="post"]:not(.supervision-exit-form) {
  pointer-events: none;
  opacity: 0.62;
}

.supervision-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.supervision-stat-grid > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem;
  border: 1px solid rgba(39, 76, 63, 0.14);
  border-radius: 8px;
  background: #f8faf9;
}

.supervision-stat-grid strong {
  color: var(--app-primary-strong);
  font-size: 1.45rem;
  line-height: 1;
}

.supervision-stat-grid span {
  color: #68736e;
  font-size: 0.78rem;
  font-weight: 700;
}

.supervision-permissions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.supervision-permissions span {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(39, 76, 63, 0.12);
  border-radius: 6px;
  background: #fff;
  font-size: 0.84rem;
}

.supervision-permissions i {
  flex: 0 0 auto;
  color: #198754;
}

.supervision-launcher {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.supervision-table-scroll {
  max-height: 360px;
  overflow: auto;
}

.supervision-table-scroll--large {
  max-height: 540px;
}

.supervision-history-list {
  display: flex;
  max-height: 360px;
  flex-direction: column;
  gap: 0.75rem;
  overflow: auto;
}

.supervision-history-list article {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(39, 76, 63, 0.12);
}

.supervision-history-list article:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

@media (max-width: 991.98px) {
  .supervision-banner {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .supervision-exit-form {
    grid-column: 1 / -1;
  }

  .supervision-exit-form .btn {
    width: 100%;
  }

  .supervision-stat-grid,
  .supervision-permissions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .supervision-banner {
    grid-template-columns: minmax(0, 1fr);
  }

  .supervision-banner__icon {
    display: none;
  }

  .supervision-stat-grid,
  .supervision-permissions {
    grid-template-columns: minmax(0, 1fr);
  }
}
