* {
  box-sizing: border-box;
}

:root {
  --background: #f5f7fa;
  --panel: #ffffff;
  --border: #dfe4ea;
  --text: #17202a;
  --muted: #667085;
  --primary: #175cd3;
  --primary-hover: #134aa8;
  --success: #067647;
  --success-bg: #ecfdf3;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --warning: #b54708;
  --warning-bg: #fffaeb;
}

body {
  margin: 0;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--background);
  color: var(--text);
}

.topbar {
  height: 64px;
  background: #111827;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar strong {
  font-size: 18px;
  margin-right: 14px;
}

.topbar span {
  opacity: 0.8;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.container {
  width: min(1800px, 97%);
  margin: 28px auto 60px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 24px;
}

.panel-header,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.preview-title {
  margin-bottom: 18px;
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
}

h1 {
  font-size: 24px;
  margin-bottom: 6px;
}

h2 {
  font-size: 19px;
  margin-bottom: 5px;
}

p {
  margin: 5px 0;
}

label {
  font-weight: 600;
}

textarea,
input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 11px 12px;
  font: inherit;
  color: var(--text);
  background: white;
}

textarea {
  margin-top: 8px;
  resize: vertical;
  font-family: Consolas, monospace;
}

textarea:focus,
input:focus {
  outline: 2px solid rgba(23, 92, 211, 0.14);
  border-color: var(--primary);
}

.actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
}

.btn {
  border: 0;
  border-radius: 7px;
  padding: 10px 17px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary {
  background: var(--primary);
  color: white;
}

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

.btn-success {
  background: var(--success);
  color: white;
}

.btn-secondary {
  background: #334155;
  color: white;
}

.btn-light {
  background: #374151;
  color: white;
}

.muted,
.help-text,
.empty-value {
  color: var(--muted);
}

.help-text {
  font-size: 13px;
  margin-top: 7px;
}

.empty-value {
  font-size: 12px;
  font-style: italic;
}

.hidden {
  display: none !important;
}

.status-box {
  white-space: pre-line;
  padding: 15px 18px;
  border-radius: 8px;
  margin-bottom: 24px;
  border: 1px solid;
}

.status-info {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.status-success {
  background: var(--success-bg);
  border-color: #abefc6;
  color: #05603a;
}

.status-warning {
  background: var(--warning-bg);
  border-color: #fedf89;
  color: #93370d;
}

.status-error {
  background: var(--danger-bg);
  border-color: #fecdca;
  color: var(--danger);
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

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

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

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: #475467;
  background: #f8fafc;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.preview-table {
  min-width: 1950px;
  table-layout: fixed;
}

.preview-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
}

.preview-table th:nth-child(1),
.preview-table td:nth-child(1) {
  width: 100px;
}

.preview-table th:nth-child(2),
.preview-table td:nth-child(2) {
  width: 100px;
}

.preview-table th:nth-child(3),
.preview-table td:nth-child(3) {
  width: 85px;
}

.preview-table th:nth-child(4),
.preview-table td:nth-child(4) {
  width: 130px;
}

.preview-table th:nth-child(5),
.preview-table td:nth-child(5) {
  width: 135px;
}

.preview-table th:nth-child(6),
.preview-table td:nth-child(6) {
  width: 75px;
}

.preview-table th:nth-child(7),
.preview-table td:nth-child(7) {
  width: 150px;
}

.preview-table th:nth-child(8),
.preview-table td:nth-child(8) {
  width: 230px;
}

.preview-table th:nth-child(9),
.preview-table td:nth-child(9) {
  width: 240px;
}

.preview-table th:nth-child(10),
.preview-table td:nth-child(10) {
  width: 180px;
}

.preview-table th:nth-child(11),
.preview-table td:nth-child(11) {
  width: 260px;
}

.preview-table th:nth-child(12),
.preview-table td:nth-child(12) {
  width: 220px;
}

.preview-row {
  background: white;
  transition: background-color 0.15s ease;
}

.preview-row:hover td {
  background: #fbfcfe;
}

.preview-row-changed td {
  background: #fffdf5;
}

.preview-row-changed:hover td {
  background: #fffaeb;
}

.preview-row-invalid td {
  background: #fffafa;
}

.sticky-anexo {
  position: sticky;
  left: 0;
  z-index: 2;
  background: white;
  box-shadow: 1px 0 0 var(--border);
}

.preview-table thead .sticky-anexo,
.preview-table thead th:first-child {
  z-index: 5;
  background: #f8fafc;
}

.preview-row-changed .sticky-anexo {
  background: #fffdf5;
}

.preview-row-invalid .sticky-anexo {
  background: #fffafa;
}

.anexo-cell {
  font-size: 16px;
  letter-spacing: 0.4px;
}

.mono-cell,
.imei-cell,
.history-status {
  font-family: Consolas, monospace;
}

.remark-cell {
  max-width: 220px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: Consolas, monospace;
  font-size: 11px;
  color: #475467;
}

.groups-cell {
  padding-top: 9px;
}

.group-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 86px;
  overflow-y: auto;
  padding-right: 2px;
}

.group-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 999px;
  padding: 4px 7px;
  background: #f9fafb;
  color: #344054;
  font-size: 11px;
  line-height: 1.2;
}

.group-chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.group-chip small {
  color: #667085;
  font-size: 9px;
}

.group-chip-preserved {
  border-style: dashed;
  background: #f8fafc;
}

.selector-cell {
  vertical-align: middle;
}

.group-selector-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid #b8c5d6;
  border-radius: 7px;
  padding: 9px 10px;
  background: white;
  color: #344054;
  font-weight: 600;
  cursor: pointer;
}

.group-selector-button:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #f8fbff;
}

.selector-count {
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #eef4ff;
  color: #1849a9;
  font-size: 11px;
}

.changes-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.change-chip {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 600;
}

.change-add {
  color: #05603a;
  background: #ecfdf3;
  border: 1px solid #abefc6;
}

.change-remove {
  color: #b42318;
  background: #fef3f2;
  border: 1px solid #fecdca;
}

.change-none {
  color: var(--muted);
  font-size: 12px;
}

.inline-error {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--danger);
}

.group-popover {
  position: fixed;
  z-index: 2000;
  width: 360px;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow:
    0 12px 30px rgba(16, 24, 40, 0.16),
    0 2px 8px rgba(16, 24, 40, 0.08);
  overflow: hidden;
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
}

.popover-header strong,
.popover-header small {
  display: block;
}

.popover-header small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.popover-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #667085;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.popover-close:hover {
  background: #f2f4f7;
  color: #101828;
}

.popover-search-wrap {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.popover-search {
  padding: 9px 10px;
  font-size: 13px;
}

.popover-groups {
  flex: 1;
  overflow-y: auto;
  min-height: 120px;
  max-height: 275px;
}

.popover-group-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 12px;
  border-bottom: 1px solid #eef2f6;
  cursor: pointer;
  font-weight: 400;
}

.popover-group-option:last-child {
  border-bottom: 0;
}

.popover-group-option:hover {
  background: #f8fafc;
}

.popover-group-option input {
  width: auto;
  margin: 3px 0 0;
}

.popover-group-option span {
  min-width: 0;
}

.popover-group-option strong,
.popover-group-option small {
  display: block;
}

.popover-group-option strong {
  font-size: 13px;
}

.popover-group-option small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.popover-empty {
  padding: 24px 14px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.popover-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
}

.message-error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #fecdca;
  padding: 12px;
  border-radius: 7px;
}

.history-table {
  min-width: 950px;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111827;
}

.login-card {
  width: min(420px, 92%);
  background: white;
  border-radius: 12px;
  padding: 36px;
}

.login-logo {
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111827;
  color: white;
  font-size: 12px;
  font-weight: 800;
  border-radius: 10px;
  margin-bottom: 24px;
}

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 25px;
}

.login-form .btn {
  margin-top: 10px;
}

.alert {
  padding: 10px 12px;
  margin-top: 18px;
  border-radius: 7px;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecdca;
}

@media (max-width: 900px) {
  .topbar {
    padding: 0 14px;
  }

  .topbar > div:first-child span {
    display: none;
  }

  .container {
    width: 96%;
    margin-top: 16px;
  }

  .panel {
    padding: 16px;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview-title .btn {
    width: 100%;
  }
}

/* ==============================
   Cambio masivo por company
   ============================== */

.bulk-title {
  margin-bottom: 18px;
}

.bulk-company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
  gap: 16px;
}

.bulk-company-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
  overflow: hidden;
}

.bulk-company-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  background: white;
  border-bottom: 1px solid var(--border);
}

.bulk-company-name {
  font-size: 17px;
  font-weight: 700;
  color: #101828;
}

.bulk-company-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.badge-company {
  background: #eef4ff;
  color: #1849a9;
  border: 1px solid #c7d7fe;
}

.bulk-company-controls {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(180px, 0.9fr) minmax(260px, 1.4fr) minmax(170px, 0.8fr);
  gap: 14px;
  padding: 16px 18px;
}

.bulk-field {
  min-width: 0;
}

.bulk-field > label {
  display: block;
  margin-bottom: 7px;
  color: #344054;
  font-size: 12px;
}

.bulk-field > small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.bulk-mode-select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 8px 10px;
  background: white;
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.bulk-selected-field .group-chip-list {
  max-height: 92px;
}

.bulk-action-field .btn {
  width: 100%;
  min-height: 40px;
}

@media (max-width: 1350px) {
  .bulk-company-controls {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .bulk-company-grid {
    grid-template-columns: 1fr;
  }

  .bulk-company-controls {
    grid-template-columns: 1fr;
  }

  .bulk-company-header {
    flex-direction: column;
  }
}

.bulk-panel {
  padding: 0;
  overflow: visible;
}

.bulk-details {
  width: 100%;
}

.bulk-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 24px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.bulk-summary::-webkit-details-marker {
  display: none;
}

.bulk-summary::before {
  content: "▸";
  flex: 0 0 auto;
  font-size: 16px;
  transition: transform 0.15s ease;
}

.bulk-details[open] > .bulk-summary::before {
  transform: rotate(90deg);
}

.bulk-summary > div {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex: 1;
}

.bulk-summary > div > strong {
  font-size: 18px;
}

.bulk-summary-count {
  flex: 0 0 auto;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.bulk-details-content {
  border-top: 1px solid var(--border);
  padding: 20px 24px 24px;
}

.bulk-intro {
  margin: 0 0 16px;
}



/* ============================================================
   LAYOUT PRINCIPAL + SIDEBAR
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
}

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky;
  top: 64px;
  align-self: start;
  height: calc(100vh - 64px);
  overflow-y: auto;
}

.sidebar-title {
  padding: 0 10px 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-category {
  border-bottom: 1px solid #edf0f3;
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.nav-category summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 800;
  color: #344054;
  user-select: none;
}

.nav-category summary::-webkit-details-marker {
  display: none;
}

.nav-category summary:hover {
  background: #f8fafc;
}

.nav-chevron {
  transition: transform 0.18s ease;
  color: #98a2b3;
  font-size: 20px;
  line-height: 1;
}

.nav-category[open] .nav-chevron {
  transform: rotate(90deg);
}

.nav-submenu {
  display: grid;
  gap: 4px;
  padding: 4px 0 3px 8px;
}

.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: #475467;
  text-align: left;
  padding: 10px 11px 10px 13px;
  border-radius: 7px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
}

.nav-item:hover {
  background: #f2f4f7;
  color: #101828;
}

.nav-item.active {
  background: #eff6ff;
  color: var(--primary);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--primary);
}

.main-content {
  min-width: 0;
  padding: 28px 24px 60px;
}

.main-content > .app-view {
  width: min(1800px, 100%);
  margin: 0 auto;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.page-heading h1 {
  margin-bottom: 5px;
}

.page-eyebrow {
  display: inline-block;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.topbar-brand {
  display: flex;
  align-items: center;
}


/* ============================================================
   GESTIÓN DE GRUPOS
   ============================================================ */

.management-heading {
  margin-bottom: 20px;
}

.management-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 18px;
}

.form-field {
  display: grid;
  gap: 7px;
}

.form-field label {
  font-size: 13px;
}

select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 11px 12px;
  font: inherit;
  color: var(--text);
  background: #ffffff;
}

select:focus {
  outline: 2px solid rgba(23, 92, 211, 0.14);
  border-color: var(--primary);
}

select:disabled {
  background: #f8fafc;
  color: #98a2b3;
  cursor: not-allowed;
}

.management-context {
  margin-top: 22px;
}

.empty-state {
  min-height: 190px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 24px;
  color: #667085;
}

.empty-state strong {
  color: #344054;
  font-size: 15px;
}

.compact-empty-state {
  min-height: 105px;
}

.future-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(250px, 1fr));
  gap: 16px;
}

.future-action-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 18px;
  display: grid;
  gap: 6px;
  background: #ffffff;
}

.future-action-card strong {
  color: #101828;
}

.future-action-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}


/* La vista anterior usaba .container directamente.
   Dentro del nuevo layout se conserva por compatibilidad,
   pero no necesitamos su margen exterior. */
.app-view .container {
  width: 100%;
  margin: 0;
}


@media (max-width: 1000px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .management-filters {
    grid-template-columns: 1fr;
  }

  .future-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .main-content {
    padding: 18px 12px 45px;
  }

  .topbar-brand span {
    display: none;
  }
}


/* ============================================================
   GESTIÓN DE GRUPOS INRICO - V6
   ============================================================ */

.management-result {
  min-height: 88px;
  border-radius: 9px;
  border: 1px solid var(--border);
  padding: 17px 18px;
  display: grid;
  align-content: center;
  gap: 5px;
  background: #f8fafc;
}

.management-result strong {
  color: #344054;
}

.management-result span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.management-result-success {
  background: var(--success-bg);
  border-color: #abefc6;
}

.management-result-success strong {
  color: var(--success);
}

.management-result-error {
  background: var(--danger-bg);
  border-color: #fecdca;
}

.management-result-error strong {
  color: var(--danger);
}

.management-result-warning {
  background: var(--warning-bg);
  border-color: #fedf89;
}

.management-result-warning strong {
  color: var(--warning);
}

.management-result-loading {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.management-result-loading strong {
  color: var(--primary);
}

.group-management-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 20px;
  margin-top: 22px;
}

.create-group-card,
.company-groups-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 18px;
  min-width: 0;
}

.create-group-card {
  display: grid;
  align-content: start;
  gap: 15px;
}

.create-group-card h3,
.company-groups-card h3 {
  margin: 0;
}

.create-group-card .btn {
  margin-top: 3px;
}

.group-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 14px;
}

.group-list-header > div {
  display: grid;
  gap: 3px;
}

.management-group-search {
  width: min(300px, 45%);
}

.management-group-table-wrapper {
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.management-group-table {
  min-width: 720px;
}

.management-group-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.management-group-table td:nth-child(3) {
  max-width: 330px;
  white-space: normal;
  word-break: break-word;
}

.btn-danger {
  background: #b42318;
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #912018;
}

.btn-small {
  padding: 7px 10px;
  font-size: 12px;
}

.table-empty {
  text-align: center;
  padding: 28px 10px;
  color: var(--muted);
}

@media (max-width: 1050px) {
  .group-management-layout {
    grid-template-columns: 1fr;
  }

  .management-group-search {
    width: 100%;
  }

  .group-list-header {
    align-items: stretch;
    flex-direction: column;
  }
}


/* ============================================================
   GESTIÓN DE GRUPOS INRICO - V7
   Creación arriba en formato horizontal y listado debajo.
   ============================================================ */

.group-management-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  margin-top: 22px;
}

.group-management-stack .create-group-card,
.group-management-stack .company-groups-card {
  width: 100%;
}

.group-management-stack .create-group-card {
  display: block;
}

.create-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.create-group-title > div {
  display: grid;
  gap: 4px;
}

.create-group-title span {
  font-size: 12px;
}

.create-group-form-row {
  display: grid;
  grid-template-columns:
    minmax(260px, 1.15fr)
    minmax(320px, 1.6fr)
    auto;
  gap: 16px;
  align-items: end;
}

.create-group-form-row .form-field {
  min-width: 0;
}

.create-group-action {
  display: flex;
  align-items: end;
}

.create-group-action .btn {
  min-height: 42px;
  white-space: nowrap;
  margin: 0;
}

.group-management-stack .company-groups-card {
  margin-top: 0;
}

@media (max-width: 980px) {
  .create-group-form-row {
    grid-template-columns:
      minmax(220px, 1fr)
      minmax(260px, 1.25fr);
  }

  .create-group-action {
    grid-column: 1 / -1;
  }

  .create-group-action .btn {
    width: 100%;
  }
}

@media (max-width: 680px) {
  .create-group-form-row {
    grid-template-columns: 1fr;
  }

  .create-group-action {
    grid-column: auto;
  }
}


/* ============================================================
   GESTIÓN DE GRUPOS INRICO - V8
   Filtros compactos y estado de company sin cajas grandes.
   ============================================================ */

.management-filters-two {
  grid-template-columns:
    minmax(220px, 0.75fr)
    minmax(360px, 1.4fr);
  max-width: 980px;
}

.company-status-line {
  margin-top: 13px;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.company-status-success {
  color: #067647;
  background: #ecfdf3;
  border: 1px solid #abefc6;
}

.company-status-error {
  color: #b42318;
  background: #fef3f2;
  border: 1px solid #fecdca;
}

.company-status-loading {
  color: #175cd3;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.company-status-neutral {
  color: #475467;
  background: #f8fafc;
  border: 1px solid #e4e7ec;
}

@media (max-width: 800px) {
  .management-filters-two {
    grid-template-columns: 1fr;
    max-width: none;
  }
}


/* ============================================================
   GESTIÓN DE GRUPOS INRICO - V9
   Búsqueda de cliente por código o nombre
   ============================================================ */

.management-filters-client-search {
  grid-template-columns:
    minmax(190px, 0.55fr)
    minmax(250px, 0.8fr)
    minmax(390px, 1.45fr);
  max-width: 1250px;
}

#inricoClientSearch:disabled {
  background: #f8fafc;
  color: #98a2b3;
  cursor: not-allowed;
}

@media (max-width: 1000px) {
  .management-filters-client-search {
    grid-template-columns:
      minmax(190px, 0.7fr)
      minmax(260px, 1fr);
  }

  .management-filters-client-search .form-field:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .management-filters-client-search {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .management-filters-client-search .form-field:last-child {
    grid-column: auto;
  }
}


/* ============================================================
   GESTIÓN DE GRUPOS INRICO - V10
   Cliente: búsqueda y selección fusionadas en un combobox.
   ============================================================ */

.management-filters-client-search {
  grid-template-columns:
    minmax(190px, 0.55fr)
    minmax(520px, 1.7fr);
  max-width: 1050px;
}

.client-combobox-field {
  min-width: 0;
}

.client-combobox {
  position: relative;
}

.client-combobox input {
  padding-right: 45px;
}

.client-combobox-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 42px;
  height: calc(100% - 2px);
  border: 0;
  border-left: 1px solid #e4e7ec;
  border-radius: 0 6px 6px 0;
  background: #ffffff;
  color: #475467;
  cursor: pointer;
  font-size: 16px;
}

.client-combobox-toggle:hover:not(:disabled) {
  background: #f8fafc;
}

.client-combobox-toggle:disabled {
  background: #f8fafc;
  color: #c5cbd3;
  cursor: not-allowed;
}

.client-combobox-options {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 340px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow:
    0 12px 28px rgba(16, 24, 40, 0.14);
}

.client-combobox-option {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #f2f4f7;
  background: #ffffff;
  padding: 10px 12px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--text);
}

.client-combobox-option:last-child {
  border-bottom: 0;
}

.client-combobox-option:hover,
.client-combobox-option:focus {
  background: #f2f4f7;
  outline: none;
}

.client-combobox-option strong {
  flex: 0 0 auto;
  font-weight: 700;
}

.client-combobox-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-combobox-empty {
  padding: 14px 12px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 800px) {
  .management-filters-client-search {
    grid-template-columns: 1fr;
    max-width: none;
  }
}


/* ============================================================
   INRICO - CAMBIO DE CONTRASEÑA
   ============================================================ */

.password-table-wrapper {
  max-height: 520px;
}

.password-table {
  min-width: 920px;
}

.password-table th:nth-child(1) {
  min-width: 90px;
}

.password-table th:nth-child(2) {
  min-width: 90px;
}

.password-table th:nth-child(3) {
  min-width: 180px;
}

.password-table th:nth-child(4) {
  min-width: 150px;
}

.password-table th:nth-child(5) {
  min-width: 180px;
}

.password-table th:nth-child(6) {
  min-width: 280px;
}

.password-value-wrap {
  display: flex;
  align-items: center;
}

.password-value {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  background: #f8fafc;
  color: #101828;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.password-status-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.password-status-cell small {
  color: var(--muted);
  line-height: 1.35;
}

.password-result-text {
  min-height: 180px;
  resize: vertical;
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    monospace;
  line-height: 1.55;
}


/* ============================================================
   CAMBIO DE CONTRASEÑA - V13
   ============================================================ */

.password-table {
  min-width: 1080px;
}

.password-table th:nth-child(5) {
  min-width: 190px;
}

.password-table th:nth-child(6) {
  min-width: 180px;
}

.password-table th:nth-child(7) {
  min-width: 280px;
}


/* ============================================================
   GESTIÓN DE GRUPOS - V14
   ============================================================ */

.management-group-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  white-space: nowrap;
}

.management-group-table th:last-child,
.management-group-table td:last-child {
  min-width: 215px;
}

/* ============================================================
   REALPTT - V15
   ============================================================ */

.app-view[data-page="realptt-group-management"] .management-group-table {
  min-width: 980px;
}

.app-view[data-page="realptt-password-change"] .password-table {
  min-width: 1180px;
}

.app-view[data-page="realptt-assignment"] .preview-table {
  min-width: 1600px;
}


/* ============================================================
   INRICO - QR DE ACCESO (PRUEBA)
   ============================================================ */
.password-qr-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 28px;
  align-items: start;
}

.password-qr-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 380px;
  padding: 18px;
  border: 1px solid var(--border-color, #d8dee9);
  border-radius: 12px;
  background: #fff;
}

.password-qr-image {
  display: block;
  width: 100%;
  max-width: 360px;
  height: auto;
}

.password-qr-details {
  min-width: 0;
}

.password-qr-details p {
  margin: 0 0 12px;
}

.password-qr-warning {
  margin-top: 20px;
}

.password-qr-debug {
  margin-top: 18px;
}

.password-qr-debug code {
  display: block;
  margin-top: 10px;
  padding: 12px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  border-radius: 8px;
  background: #f5f7fb;
}

.password-qr-button {
  white-space: nowrap;
}

@media (max-width: 900px) {
  .password-qr-layout {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   INRICO - GENERACIÓN DE QR V19
   ============================================================ */

.qr-experimental-note {
  margin-top: 14px;
}

.qr-results-grid {
  display: grid;
  gap: 18px;
}

.qr-result-card {
  display: grid;
  grid-template-columns: minmax(190px, 250px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.qr-result-success {
  border-color: #abefc6;
}

.qr-result-failed {
  border-color: #fecdca;
  background: #fffafa;
}

.qr-result-error-icon {
  min-height: 190px;
  display: grid;
  place-items: center;
  border: 1px dashed #fda29b;
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 56px;
  font-weight: 800;
}

.qr-result-title-row > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.qr-result-title-row strong {
  color: #101828;
  font-size: 17px;
}

.qr-result-message {
  margin-top: 12px !important;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.qr-dispatcher-info {
  color: #344054;
}

/* Respuesta cruda de INRICO visible para captura/soporte. */
.qr-api-error-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #fda29b;
  border-radius: 10px;
  background: #fff4f2;
}

.qr-api-error-title {
  margin-bottom: 10px;
  color: #b42318;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.qr-api-error-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  margin-bottom: 8px;
  color: #344054;
  font-size: 13px;
}

.qr-api-error-meta code {
  overflow-wrap: anywhere;
}

.qr-api-error-note {
  margin-bottom: 10px;
  color: #475467;
  font-size: 13px;
}

.qr-api-error-response {
  max-height: 360px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid #fecdca;
  border-radius: 8px;
  background: #fff;
  color: #7a271a;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .qr-result-card {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   INRICO - HISTORIAL GPS V21
   ============================================================ */

.gps-query-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.2fr) minmax(260px, 0.8fr);
  gap: 24px;
  align-items: start;
}

.gps-date-fields {
  display: grid;
  gap: 14px;
}

.gps-date-fields > div {
  display: grid;
  gap: 7px;
}

.gps-date-fields input[type="date"] {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.gps-actions {
  margin-top: 18px;
}

.gps-summary-table {
  min-width: 1050px;
}

.gps-results-table {
  min-width: 1300px;
}

.gps-results-wrap {
  max-height: 620px;
  overflow: auto;
}

.gps-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.gps-status-badge.status-success {
  background: var(--success-bg);
  color: var(--success);
}

.gps-status-badge.status-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.gps-map-link {
  font-weight: 700;
  text-decoration: none;
}

.gps-map-link:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .gps-query-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   INRICO - AJUSTES GPS V22
   ============================================================ */

.app-view[data-page="inrico-gps-history"] .table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.app-view[data-page="inrico-gps-history"] .gps-summary-table {
  width: 100%;
  min-width: 820px;
  table-layout: fixed;
}

.app-view[data-page="inrico-gps-history"] .gps-summary-table th:nth-child(1),
.app-view[data-page="inrico-gps-history"] .gps-summary-table td:nth-child(1) { width: 10%; }
.app-view[data-page="inrico-gps-history"] .gps-summary-table th:nth-child(2),
.app-view[data-page="inrico-gps-history"] .gps-summary-table td:nth-child(2) { width: 12%; }
.app-view[data-page="inrico-gps-history"] .gps-summary-table th:nth-child(3),
.app-view[data-page="inrico-gps-history"] .gps-summary-table td:nth-child(3) { width: 20%; }
.app-view[data-page="inrico-gps-history"] .gps-summary-table th:nth-child(4),
.app-view[data-page="inrico-gps-history"] .gps-summary-table td:nth-child(4) { width: 16%; }
.app-view[data-page="inrico-gps-history"] .gps-summary-table th:nth-child(5),
.app-view[data-page="inrico-gps-history"] .gps-summary-table td:nth-child(5) { width: 10%; }
.app-view[data-page="inrico-gps-history"] .gps-summary-table th:nth-child(6),
.app-view[data-page="inrico-gps-history"] .gps-summary-table td:nth-child(6) { width: 12%; }
.app-view[data-page="inrico-gps-history"] .gps-summary-table th:nth-child(7),
.app-view[data-page="inrico-gps-history"] .gps-summary-table td:nth-child(7) { width: 20%; }

.app-view[data-page="inrico-gps-history"] .gps-summary-table td:last-child {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.app-view[data-page="inrico-gps-history"] .gps-results-table {
  min-width: 980px;
}

/* ============================================================
   INRICO - TRÁFICO V22
   ============================================================ */

.traffic-main-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.7fr) minmax(180px, 0.7fr);
  gap: 16px;
  align-items: end;
}

.traffic-scope-fields {
  display: grid;
  grid-template-columns: minmax(180px, 0.55fr) minmax(320px, 1.45fr);
  gap: 16px;
  margin-top: 18px;
}

.traffic-company-field,
.traffic-annex-field {
  grid-column: 1 / -1;
}

.traffic-client-field input,
.traffic-company-field input,
.traffic-main-grid input[type="date"] {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.traffic-annex-field textarea {
  width: 100%;
}

.traffic-actions {
  margin-top: 18px;
}

.traffic-context-box {
  display: grid;
  gap: 5px;
  margin-top: 18px;
  padding: 13px 15px;
  border: 1px solid #c7d7fe;
  border-radius: 9px;
  background: #f5f8ff;
}

.traffic-context-box > strong {
  color: #101828;
}

.traffic-context-box > span {
  color: var(--muted);
  font-size: 13px;
}

.traffic-context-warnings {
  display: grid;
  gap: 4px;
  margin-top: 6px;
  color: var(--warning);
  font-size: 12px;
}

.traffic-group-field {
  margin-top: 18px;
  max-width: 720px;
}

.traffic-group-field select {
  width: 100%;
}

.traffic-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.traffic-kpi-card {
  display: grid;
  gap: 6px;
  padding: 18px;
}

.traffic-kpi-card span {
  color: var(--muted);
  font-size: 13px;
}

.traffic-kpi-card strong {
  color: #101828;
  font-size: 28px;
  line-height: 1;
}

.traffic-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.traffic-summary-table {
  width: 100%;
  min-width: 760px;
}

.traffic-detail-table {
  width: 100%;
  min-width: 980px;
}

.traffic-detail-wrap {
  max-height: 620px;
  overflow: auto;
  margin-top: 14px;
}

.traffic-details > summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  cursor: pointer;
  list-style: none;
}

.traffic-details > summary::-webkit-details-marker {
  display: none;
}

@media (max-width: 900px) {
  .traffic-main-grid,
  .traffic-scope-fields,
  .traffic-kpi-grid {
    grid-template-columns: 1fr;
  }

  .traffic-company-field,
  .traffic-annex-field {
    grid-column: auto;
  }
}

/* ============================================================
   INRICO - TRÁFICO V26
   ============================================================ */

.nav-subcategory {
  margin: 2px 0 2px 6px;
}

.nav-subcategory > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  padding: 8px 10px 8px 13px;
  border-radius: 7px;
  color: #475467;
  font-size: 13px;
  font-weight: 700;
  user-select: none;
}

.nav-subcategory > summary::-webkit-details-marker {
  display: none;
}

.nav-subcategory > summary:hover {
  background: #f8fafc;
  color: #101828;
}

.nav-subcategory[open] > summary .nav-chevron {
  transform: rotate(90deg);
}

.nav-submenu-nested {
  padding-left: 10px;
}

.nav-submenu-nested .nav-item {
  font-size: 12.5px;
  padding-left: 16px;
}

.traffic-filter-grid {
  grid-template-columns: minmax(170px, 0.55fr) minmax(320px, 1.45fr) minmax(170px, 0.6fr) minmax(170px, 0.6fr);
  align-items: end;
}

.traffic-filter-grid .client-combobox-field {
  min-width: 0;
}

.traffic-filter-grid input[type="date"],
.traffic-filter-grid select,
.traffic-annex-grid input[type="date"] {
  width: 100%;
}

.traffic-annex-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.7fr) minmax(180px, 0.65fr) minmax(180px, 0.65fr);
  gap: 16px;
  align-items: end;
}

.traffic-annex-grid .traffic-annex-field {
  grid-column: auto;
  grid-row: span 2;
}

.traffic-results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

@media (max-width: 1150px) {
  .traffic-filter-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 900px) {
  .traffic-filter-grid,
  .traffic-annex-grid {
    grid-template-columns: 1fr;
  }

  .traffic-annex-grid .traffic-annex-field {
    grid-row: auto;
  }

  .traffic-results-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}


/* ============================================================
   TRÁFICO v28
   - Por grupo: País / Cliente / Grupo perfectamente alineados.
   - Fechas en segunda fila con ancho compacto.
   - Tablas con anchos propios para evitar superposición.
   ============================================================ */

.traffic-group-top-grid {
  display: grid;
  grid-template-columns:
    minmax(170px, 0.65fr)
    minmax(360px, 1.55fr)
    minmax(280px, 1fr);
  gap: 16px;
  align-items: end;
}

.traffic-group-top-grid .form-field {
  min-width: 0;
  align-self: end;
}

.traffic-group-top-grid select,
.traffic-group-top-grid .client-combobox,
.traffic-group-top-grid .client-combobox input {
  width: 100%;
}

.traffic-group-date-grid {
  display: grid;
  grid-template-columns: 220px 220px;
  gap: 18px;
  margin-top: 18px;
  align-items: end;
}

.traffic-group-date-grid input[type="date"] {
  width: 220px;
  max-width: 100%;
}

.traffic-summary-table,
.traffic-detail-table {
  table-layout: fixed;
}

.traffic-summary-table th:nth-child(1),
.traffic-summary-table td:nth-child(1) { width: 120px; }
.traffic-summary-table th:nth-child(2),
.traffic-summary-table td:nth-child(2) { width: 120px; }
.traffic-summary-table th:nth-child(3),
.traffic-summary-table td:nth-child(3) { width: 140px; }
.traffic-summary-table th:nth-child(4),
.traffic-summary-table td:nth-child(4) {
  width: 300px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.traffic-summary-table th:nth-child(5),
.traffic-summary-table td:nth-child(5) {
  width: 130px;
  text-align: center;
  white-space: nowrap;
}

.traffic-detail-table th:nth-child(1),
.traffic-detail-table td:nth-child(1) { width: 120px; }
.traffic-detail-table th:nth-child(2),
.traffic-detail-table td:nth-child(2) { width: 120px; }
.traffic-detail-table th:nth-child(3),
.traffic-detail-table td:nth-child(3) {
  width: 260px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.traffic-detail-table th:nth-child(4),
.traffic-detail-table td:nth-child(4) { width: 120px; }
.traffic-detail-table th:nth-child(5),
.traffic-detail-table td:nth-child(5) { width: 140px; }
.traffic-detail-table th:nth-child(6),
.traffic-detail-table td:nth-child(6) {
  width: 300px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.traffic-detail-table th:nth-child(7),
.traffic-detail-table td:nth-child(7) {
  width: 130px;
  text-align: center;
  white-space: nowrap;
}

@media (max-width: 1150px) {
  .traffic-group-top-grid {
    grid-template-columns: 1fr 1fr;
  }

  .traffic-group-top-grid > .form-field:nth-child(3) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .traffic-group-top-grid,
  .traffic-group-date-grid {
    grid-template-columns: 1fr;
  }

  .traffic-group-date-grid input[type="date"] {
    width: 100%;
  }

  .traffic-group-top-grid > .form-field:nth-child(3) {
    grid-column: auto;
  }
}

/* ============================================================
   REALPTT - HISTORIAL GPS V31
   Reutiliza el layout GPS de INRICO y ajusta tablas a la vista.
   ============================================================ */

.app-view[data-page="realptt-gps-history"] .table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.app-view[data-page="realptt-gps-history"] .gps-summary-table {
  width: 100%;
  min-width: 860px;
  table-layout: fixed;
}

.app-view[data-page="realptt-gps-history"] .gps-summary-table th:nth-child(1),
.app-view[data-page="realptt-gps-history"] .gps-summary-table td:nth-child(1) { width: 10%; }
.app-view[data-page="realptt-gps-history"] .gps-summary-table th:nth-child(2),
.app-view[data-page="realptt-gps-history"] .gps-summary-table td:nth-child(2) { width: 14%; }
.app-view[data-page="realptt-gps-history"] .gps-summary-table th:nth-child(3),
.app-view[data-page="realptt-gps-history"] .gps-summary-table td:nth-child(3) { width: 18%; }
.app-view[data-page="realptt-gps-history"] .gps-summary-table th:nth-child(4),
.app-view[data-page="realptt-gps-history"] .gps-summary-table td:nth-child(4) { width: 16%; }
.app-view[data-page="realptt-gps-history"] .gps-summary-table th:nth-child(5),
.app-view[data-page="realptt-gps-history"] .gps-summary-table td:nth-child(5) { width: 10%; }
.app-view[data-page="realptt-gps-history"] .gps-summary-table th:nth-child(6),
.app-view[data-page="realptt-gps-history"] .gps-summary-table td:nth-child(6) { width: 12%; }
.app-view[data-page="realptt-gps-history"] .gps-summary-table th:nth-child(7),
.app-view[data-page="realptt-gps-history"] .gps-summary-table td:nth-child(7) { width: 20%; }

.app-view[data-page="realptt-gps-history"] .gps-summary-table td:last-child {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.app-view[data-page="realptt-gps-history"] .gps-results-table {
  min-width: 1020px;
}

/* ============================================================
   INRICO - RECICLADOR / RENOVACIÓN
   ============================================================ */
.recycler-panel-header {
  align-items: flex-start;
}

.recycler-counter {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 11px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.recycler-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.recycler-kpi {
  min-width: 0;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.recycler-kpi span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.recycler-kpi strong {
  display: block;
  font-size: 23px;
  line-height: 1.1;
}

.recycler-table-wrapper {
  max-width: 100%;
  overflow-x: auto;
}

.recycler-preview-table,
.recycler-renewal-table,
.recycler-process-table {
  min-width: 1450px;
}

.recycler-renewal-table {
  min-width: 1900px;
}

.recycler-preview-table th,
.recycler-preview-table td,
.recycler-renewal-table th,
.recycler-renewal-table td,
.recycler-process-table th,
.recycler-process-table td {
  vertical-align: top;
}

.recycler-client-cell {
  min-width: 190px;
  max-width: 280px;
  white-space: normal;
}

.recycler-description-cell,
.recycler-message-cell {
  min-width: 220px;
  max-width: 360px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.recycler-inline-select {
  min-width: 125px;
  width: auto;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 8px 9px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

.recycler-inline-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.recycler-account-cell {
  min-width: 170px;
}

.recycler-account-cell strong,
.recycler-account-cell small,
.recycler-block-small {
  display: block;
}

.recycler-account-cell small,
.recycler-block-small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.recycler-mini-warning {
  margin-top: 5px;
  color: var(--warning);
  font-size: 11px;
  font-weight: 700;
}

.recycler-package {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.recycler-service {
  display: inline-flex;
  margin-bottom: 4px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f2f4f7;
  color: #667085;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.recycler-service.is-active {
  background: var(--success-bg);
  color: var(--success);
}

.recycler-status {
  display: inline-flex;
  align-items: center;
  max-width: 240px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: anywhere;
}

.recycler-status-success {
  background: var(--success-bg);
  color: var(--success);
}

.recycler-status-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.recycler-status-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.recycler-status-neutral {
  background: #f2f4f7;
  color: #475467;
}

.recycler-renewal-form {
  display: flex;
  align-items: end;
  gap: 16px;
}

.recycler-days-field {
  width: 220px;
}

.recycler-days-field input {
  max-width: 120px;
}

@media (max-width: 760px) {
  .recycler-panel-header {
    flex-direction: column;
  }

  .recycler-counter {
    align-self: flex-start;
  }

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

/* ============================================================
   INRICO - RECICLADOR UI V32.2
   Aísla las tablas del .preview-table general del portal para
   conservar el layout amplio del reciclador original.
   ============================================================ */
.app-view[data-page="inrico-recycler-reuse"] #recyclerPreviewPanel,
.app-view[data-page="inrico-recycler-renewal"] #renewalPreviewPanel {
  padding: 16px 18px;
  border-radius: 14px;
}

.app-view[data-page="inrico-recycler-reuse"] #recyclerPreviewPanel > .panel-header,
.app-view[data-page="inrico-recycler-renewal"] #renewalPreviewPanel > .panel-header {
  margin-bottom: 14px;
}

.app-view[data-page="inrico-recycler-reuse"] #recyclerPreviewPanel .panel-header h2,
.app-view[data-page="inrico-recycler-renewal"] #renewalPreviewPanel .panel-header h2 {
  margin-bottom: 4px;
}

.recycler-table-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
}

.recycler-preview-table,
.recycler-renewal-table,
.recycler-process-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  table-layout: auto;
  font-size: 13px;
}

.recycler-preview-table {
  min-width: 1550px;
}

.recycler-renewal-table {
  min-width: 2100px;
}

.recycler-process-table {
  min-width: 1300px;
}

.recycler-preview-table th,
.recycler-preview-table td,
.recycler-renewal-table th,
.recycler-renewal-table td,
.recycler-process-table th,
.recycler-process-table td {
  width: auto;
  padding: 12px;
  vertical-align: middle;
  border-bottom: 1px solid #f3f4f6;
}

.recycler-preview-table th,
.recycler-renewal-table th,
.recycler-process-table th {
  text-align: left;
  background: #f9fafb;
  color: #374151;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.recycler-preview-table tbody tr:hover td,
.recycler-renewal-table tbody tr:hover td,
.recycler-process-table tbody tr:hover td {
  background: #fafafa;
}

/* Columnas del reciclador: mantener lectura horizontal y evitar
   que Descripción/Cliente se partan como en la tabla general. */
.recycler-preview-table th:nth-child(1),
.recycler-preview-table td:nth-child(1) { min-width: 90px; }
.recycler-preview-table th:nth-child(2),
.recycler-preview-table td:nth-child(2) { min-width: 120px; }
.recycler-preview-table th:nth-child(3),
.recycler-preview-table td:nth-child(3) { min-width: 120px; }
.recycler-preview-table th:nth-child(4),
.recycler-preview-table td:nth-child(4) { min-width: 220px; }
.recycler-preview-table th:nth-child(5),
.recycler-preview-table td:nth-child(5) { min-width: 70px; }
.recycler-preview-table th:nth-child(6),
.recycler-preview-table td:nth-child(6) { min-width: 320px; }
.recycler-preview-table th:nth-child(7),
.recycler-preview-table td:nth-child(7) { min-width: 115px; }
.recycler-preview-table th:nth-child(8),
.recycler-preview-table td:nth-child(8) { min-width: 170px; }
.recycler-preview-table th:nth-child(9),
.recycler-preview-table td:nth-child(9) { min-width: 160px; }
.recycler-preview-table th:nth-child(10),
.recycler-preview-table td:nth-child(10) { min-width: 160px; }
.recycler-preview-table th:nth-child(11),
.recycler-preview-table td:nth-child(11) { min-width: 190px; }
.recycler-preview-table th:nth-child(12),
.recycler-preview-table td:nth-child(12) { min-width: 190px; }

.recycler-client-cell {
  min-width: 220px;
  max-width: 260px;
  font-weight: 700;
  line-height: 1.35;
  white-space: normal;
}

.recycler-description-cell {
  min-width: 320px;
  max-width: 380px;
  color: #374151;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}

.recycler-package {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #f3f4f6;
  color: #111827;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
}

.recycler-inline-select {
  width: 150px;
  min-width: 150px;
  height: 38px;
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #ffffff;
  color: #111827;
  font: inherit;
  font-weight: 800;
}

.recycler-account-cell {
  min-width: 170px;
  line-height: 1.45;
  text-align: center;
}

.recycler-account-cell strong {
  color: #111827;
}

.recycler-account-cell small {
  margin-top: 4px;
}

.recycler-mini-warning {
  display: inline-block;
  margin-top: 7px;
  padding: 5px 7px;
  border-radius: 8px;
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  font-weight: 800;
}

.recycler-service {
  display: inline-block;
  margin-bottom: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.recycler-service.is-active {
  background: #dcfce7;
  color: #166534;
}

.recycler-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  max-width: 210px;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ============================================================
   REALPTT - GRUPO POR DEFECTO
   ============================================================ */

.real-assignment-table {
  min-width: 2400px;
}

.real-assignment-table th:nth-child(11),
.real-assignment-table td:nth-child(11) {
  width: 190px;
}

.real-assignment-table th:nth-child(12),
.real-assignment-table td:nth-child(12) {
  width: 260px;
}

.real-assignment-table th:nth-child(13),
.real-assignment-table td:nth-child(13) {
  width: 300px;
}

.default-group-cell {
  vertical-align: middle;
}

.default-group-current {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.default-group-current strong {
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.default-group-current small,
.default-group-help {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.real-default-group-select {
  width: 100%;
  min-width: 210px;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 8px 10px;
  background: white;
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.real-default-group-select:focus {
  outline: 2px solid rgba(79, 70, 229, 0.15);
  border-color: #818cf8;
}

.change-default {
  color: #3730a3;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
}

/* ============================================================
   INRICO - Sincronización de cuentas
   ============================================================ */
.sync-preview-table,
.sync-process-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.sync-preview-table th,
.sync-preview-table td,
.sync-process-table th,
.sync-process-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  vertical-align: middle;
  text-align: left;
}

.sync-preview-table th,
.sync-process-table th {
  white-space: nowrap;
  font-weight: 700;
}

.sync-preview-table th:nth-child(1),
.sync-preview-table td:nth-child(1) { min-width: 90px; }
.sync-preview-table th:nth-child(2),
.sync-preview-table td:nth-child(2) { min-width: 165px; }
.sync-preview-table th:nth-child(3),
.sync-preview-table td:nth-child(3) { min-width: 190px; }
.sync-preview-table th:nth-child(4),
.sync-preview-table td:nth-child(4) { min-width: 190px; }
.sync-preview-table th:nth-child(5),
.sync-preview-table td:nth-child(5) { min-width: 190px; }
.sync-preview-table th:nth-child(6),
.sync-preview-table td:nth-child(6) { min-width: 220px; }
.sync-preview-table th:nth-child(7),
.sync-preview-table td:nth-child(7) { min-width: 160px; }
.sync-preview-table th:nth-child(8),
.sync-preview-table td:nth-child(8) { min-width: 160px; }
.sync-preview-table th:nth-child(9),
.sync-preview-table td:nth-child(9) { min-width: 220px; }
.sync-preview-table th:nth-child(10),
.sync-preview-table td:nth-child(10) { min-width: 220px; }
.sync-preview-table th:nth-child(11),
.sync-preview-table td:nth-child(11) { min-width: 210px; }
.sync-preview-table th:nth-child(12),
.sync-preview-table td:nth-child(12) { min-width: 360px; }
.sync-preview-table th:nth-child(13),
.sync-preview-table td:nth-child(13) { min-width: 210px; }
.sync-preview-table th:nth-child(14),
.sync-preview-table td:nth-child(14) { min-width: 220px; }
.sync-preview-table th:nth-child(15),
.sync-preview-table td:nth-child(15) { min-width: 220px; }

.sync-pair {
  display: grid;
  gap: 2px;
  min-width: 145px;
}

.sync-pair small {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b7280;
}

.sync-pair strong {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.sync-pair.is-different strong:last-child {
  font-weight: 800;
}

.sync-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.sync-groups > span:not(.muted) {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.sync-preserved {
  display: block;
  width: 100%;
  margin-top: 4px;
  color: #4b5563;
  font-size: 0.72rem;
  font-weight: 700;
}

.sync-services {
  display: grid;
  gap: 5px;
}

.sync-differences {
  max-width: 300px;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.sync-result-message {
  margin-top: 6px;
  max-width: 520px;
  color: #4b5563;
  line-height: 1.35;
  overflow-wrap: anywhere;
}


/* v34.4 - Sincronización directa y resultado final */
.sync-final-table th:nth-child(1), .sync-final-table td:nth-child(1) { min-width: 90px; }
.sync-final-table th:nth-child(2), .sync-final-table td:nth-child(2) { min-width: 115px; }
.sync-final-table th:nth-child(3), .sync-final-table td:nth-child(3) { min-width: 150px; }
.sync-final-table th:nth-child(4), .sync-final-table td:nth-child(4) { min-width: 180px; }
.sync-final-table th:nth-child(5), .sync-final-table td:nth-child(5) { min-width: 190px; }
.sync-final-table th:nth-child(6), .sync-final-table td:nth-child(6) { min-width: 170px; }
.sync-final-table th:nth-child(7), .sync-final-table td:nth-child(7) { min-width: 120px; }
.sync-final-table th:nth-child(8), .sync-final-table td:nth-child(8) { min-width: 120px; }
.sync-final-table th:nth-child(9), .sync-final-table td:nth-child(9) { min-width: 180px; }
.sync-final-table th:nth-child(10), .sync-final-table td:nth-child(10) { min-width: 155px; }
.sync-final-table th:nth-child(11), .sync-final-table td:nth-child(11) { min-width: 320px; }
.sync-final-table th:nth-child(12), .sync-final-table td:nth-child(12) { min-width: 330px; }

.sync-cell-subtext,
.sync-imei-note {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  color: #6b7280;
}

.sync-imei-note {
  color: #166534;
  font-weight: 700;
}

.sync-final-remark {
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.sync-programmer-error {
  margin-top: 7px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.sync-programmer-error strong {
  display: block;
  margin-bottom: 4px;
}

.sync-programmer-error small {
  display: block;
  margin-top: 5px;
  color: #6b7280;
  font-weight: 700;
}


/* v34.5 - Detalle visible para cualquier error de sincronización */
.sync-technical-error {
  margin: 8px 0 0;
  padding: 9px 10px;
  max-width: 520px;
  max-height: 230px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff7f7;
  font-size: 0.72rem;
  line-height: 1.35;
}

/* ============================================================
   REALPTT - SINCRONIZACIÓN DE CUENTAS
   ============================================================ */
.real-sync-table-wrapper {
  max-width: 100%;
  overflow-x: auto;
}

.real-sync-final-table th:nth-child(1),
.real-sync-final-table td:nth-child(1) { min-width: 90px; }
.real-sync-final-table th:nth-child(2),
.real-sync-final-table td:nth-child(2) { min-width: 115px; }
.real-sync-final-table th:nth-child(3),
.real-sync-final-table td:nth-child(3) { min-width: 160px; }
.real-sync-final-table th:nth-child(4),
.real-sync-final-table td:nth-child(4) { min-width: 170px; }
.real-sync-final-table th:nth-child(5),
.real-sync-final-table td:nth-child(5) { min-width: 190px; }
.real-sync-final-table th:nth-child(6),
.real-sync-final-table td:nth-child(6) { min-width: 165px; }
.real-sync-final-table th:nth-child(7),
.real-sync-final-table td:nth-child(7) { min-width: 125px; }
.real-sync-final-table th:nth-child(8),
.real-sync-final-table td:nth-child(8),
.real-sync-final-table th:nth-child(9),
.real-sync-final-table td:nth-child(9) { min-width: 85px; }
.real-sync-final-table th:nth-child(10),
.real-sync-final-table td:nth-child(10) { min-width: 210px; }
.real-sync-final-table th:nth-child(11),
.real-sync-final-table td:nth-child(11) { min-width: 260px; }
.real-sync-final-table th:nth-child(12),
.real-sync-final-table td:nth-child(12) { min-width: 360px; }

.real-sync-actions {
  display: grid;
  gap: 5px;
  font-size: 12px;
  line-height: 1.35;
}

.real-sync-actions span {
  display: block;
  overflow-wrap: anywhere;
}

/* ============================================================
   ADMINISTRACIÓN DE USUARIOS Y PERMISOS
   ============================================================ */

.topbar-user-identity {
  display: grid;
  gap: 1px;
  text-align: right;
}

.topbar-user-identity strong {
  color: #101828;
  font-size: 13px;
}

.topbar-user-identity small {
  color: var(--muted);
  font-size: 11px;
}

.admin-user-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

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

.admin-active-field {
  align-self: end;
}

.admin-switch-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.admin-switch-row input {
  width: 17px;
  height: 17px;
}

.admin-permission-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 0 12px;
}

.admin-permission-heading p {
  margin: 4px 0 0;
}

.admin-permission-tree {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.admin-permission-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
  overflow: hidden;
}

.admin-permission-group .admin-permission-group {
  margin-top: 8px;
  background: #fff;
}

.admin-permission-parent,
.admin-permission-leaf {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
}

.admin-permission-parent {
  min-height: 44px;
  padding: 10px 12px;
  color: #344054;
  font-weight: 800;
}

.admin-permission-parent small {
  margin-left: auto;
  color: var(--muted);
  font-weight: 700;
}

.admin-permission-leaf {
  min-height: 38px;
  padding: 8px 12px;
  color: #475467;
  border-top: 1px solid #eef1f4;
}

.admin-permission-parent input,
.admin-permission-leaf input {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.admin-permission-children {
  padding: 0 8px 8px;
}

.admin-permission-children > .admin-permission-leaf {
  border: 0;
  border-radius: 7px;
}

.admin-permission-children > .admin-permission-leaf:hover,
.admin-permission-group .admin-permission-parent:hover {
  background: #f2f4f7;
}

.admin-users-table td {
  vertical-align: middle;
}

.admin-permission-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 230px;
}

.permission-chip {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f2f4f7;
  color: #344054;
  font-size: 11px;
  line-height: 1.2;
}

.permission-chip-more {
  background: #eff6ff;
  color: var(--primary);
  font-weight: 800;
}

.admin-row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 150px;
}

.btn-compact {
  padding: 6px 9px;
  font-size: 12px;
}

.btn-danger-soft {
  border: 1px solid #fecdca;
  background: #fff4f2;
  color: #b42318;
}

.btn-danger-soft:hover {
  background: #fee4e2;
}

@media (max-width: 1100px) {
  .admin-user-form-grid,
  .admin-permission-tree {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .admin-user-form-grid,
  .admin-edit-grid,
  .admin-permission-tree {
    grid-template-columns: 1fr;
  }

  .admin-permission-heading {
    flex-direction: column;
  }
}

/* ============================================================
   SIMCARDS - V37
   ============================================================ */
.simcards-search-panel {
  margin-bottom: 20px;
}

.simcards-search-row {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 190px auto;
  align-items: end;
  gap: 14px;
}

.simcards-search-field,
.simcards-limit-field {
  min-width: 0;
}

.simcards-search-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 1px;
}

.simcards-results-panel {
  min-width: 0;
}

.simcards-results-title {
  align-items: center;
}

.simcards-table-wrapper {
  margin-top: 14px;
  max-height: 620px;
  overflow: auto;
}

.simcards-table {
  min-width: 900px;
}

.simcards-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.simcards-table td {
  vertical-align: middle;
}

.simcards-row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 230px;
}

.simcards-pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.simcards-pagination > span {
  min-width: 115px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

body.simcards-modal-open {
  overflow: hidden;
}

.simcards-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.52);
}

.simcards-modal {
  width: min(1040px, 96vw);
  max-height: 90vh;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.simcards-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.simcards-modal-header h2 {
  margin: 3px 0 0;
}

.simcards-modal-header p {
  margin: 5px 0 0;
}

.simcards-modal-body {
  max-height: calc(90vh - 100px);
  overflow: auto;
  padding: 20px 22px 24px;
}

.simcards-loading {
  min-height: 90px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}

.simcards-details {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #f8fafc;
}

.simcards-details summary {
  cursor: pointer;
  padding: 12px 14px;
  color: #344054;
  font-weight: 800;
}

.simcards-details pre {
  max-height: 320px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.55 Consolas, monospace;
}

.simcards-modal-select {
  width: min(440px, 100%);
  margin-bottom: 16px;
}

.simcards-modal-table-wrapper {
  max-height: 470px;
  overflow: auto;
}

.simcards-modal-table-wrapper table {
  min-width: 760px;
}

.simcards-modal-table-wrapper thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.simcards-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.simcards-kpis > div {
  display: grid;
  gap: 4px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #f8fafc;
}

.simcards-kpis span {
  color: var(--muted);
  font-size: 12px;
}

.simcards-kpis strong {
  color: #101828;
  font-size: 15px;
}

@media (max-width: 900px) {
  .simcards-search-row {
    grid-template-columns: 1fr;
  }

  .simcards-search-actions {
    padding-bottom: 0;
  }

  .simcards-pagination {
    justify-content: flex-start;
  }

  .simcards-kpis {
    grid-template-columns: 1fr;
  }
}

/* SIMCARDS v37.1 */
.simcards-kpis-m2m {
  grid-template-columns: minmax(280px, 2fr) minmax(170px, 1fr) minmax(170px, 1fr);
}

.simcards-consumption-progress {
  width: 100%;
  height: 12px;
  margin-top: 16px;
  border-radius: 999px;
  background: #e8edf4;
  overflow: hidden;
}

.simcards-consumption-progress-bar {
  height: 100%;
  border-radius: inherit;
  background: #4054d8;
  transition: width 180ms ease;
}

@media (max-width: 900px) {
  .simcards-kpis-m2m {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   DIÁLOGOS GLOBALES DEL PORTAL
   Reemplaza alert/confirm/prompt nativos del navegador.
   ========================================================= */
body.portal-dialog-open {
  overflow: hidden;
}

.portal-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.54);
  backdrop-filter: blur(1.5px);
}

.portal-dialog {
  width: min(590px, 96vw);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.3);
}

.portal-dialog-header {
  padding: 22px 24px 12px;
}

.portal-dialog-header h2 {
  margin: 5px 0 0;
  color: #101828;
  font-size: 20px;
  line-height: 1.25;
}

.portal-dialog-body {
  padding: 4px 24px 22px;
}

.portal-dialog-message {
  margin: 0;
  color: #475467;
  white-space: pre-line;
  line-height: 1.62;
  word-break: break-word;
}

.portal-dialog-input-wrap {
  margin-top: 18px;
}

.portal-dialog-input-wrap input {
  width: 100%;
}

.portal-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

.portal-dialog-actions .btn {
  min-width: 108px;
}

@media (max-width: 600px) {
  .portal-dialog-backdrop {
    padding: 14px;
  }

  .portal-dialog-actions {
    flex-direction: column-reverse;
  }

  .portal-dialog-actions .btn {
    width: 100%;
  }
}

/* =========================================================
   CARGA GLOBAL DEL PORTAL
   Overlay reutilizable para consultas y operaciones async.
   ========================================================= */
body.portal-loading-open {
  overflow: hidden;
}

.portal-loading-backdrop {
  position: fixed;
  inset: 0;
  z-index: 12500;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(1.5px);
}

.portal-loading-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(420px, 92vw);
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.portal-loading-spinner {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 4px solid #e5e7eb;
  border-top-color: #4054d8;
  border-radius: 50%;
  animation: portal-loading-spin 0.78s linear infinite;
}

.portal-loading-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.portal-loading-copy strong {
  color: #101828;
  font-size: 16px;
  line-height: 1.25;
}

.portal-loading-copy span {
  color: #667085;
  font-size: 13px;
  line-height: 1.45;
}

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

@media (prefers-reduced-motion: reduce) {
  .portal-loading-spinner {
    animation-duration: 1.8s;
  }
}

@media (max-width: 600px) {
  .portal-loading-backdrop {
    padding: 14px;
  }

  .portal-loading-card {
    width: min(360px, 96vw);
    padding: 20px;
  }
}


/* ============================================================
   ASIGNACION DE GRUPOS - SIN COLUMNA DE ESTADO DE CUENTA
   El state interno se conserva para reglas de negocio, pero no
   se muestra en las previsualizaciones INRICO / RealPTT.
   ============================================================ */
.app-view[data-page="inrico-assignment"] .preview-table {
  min-width: 1865px;
}

.app-view[data-page="inrico-assignment"] .preview-table th:nth-child(1),
.app-view[data-page="inrico-assignment"] .preview-table td:nth-child(1) { width: 100px; }
.app-view[data-page="inrico-assignment"] .preview-table th:nth-child(2),
.app-view[data-page="inrico-assignment"] .preview-table td:nth-child(2) { width: 100px; }
.app-view[data-page="inrico-assignment"] .preview-table th:nth-child(3),
.app-view[data-page="inrico-assignment"] .preview-table td:nth-child(3) { width: 130px; }
.app-view[data-page="inrico-assignment"] .preview-table th:nth-child(4),
.app-view[data-page="inrico-assignment"] .preview-table td:nth-child(4) { width: 135px; }
.app-view[data-page="inrico-assignment"] .preview-table th:nth-child(5),
.app-view[data-page="inrico-assignment"] .preview-table td:nth-child(5) { width: 75px; }
.app-view[data-page="inrico-assignment"] .preview-table th:nth-child(6),
.app-view[data-page="inrico-assignment"] .preview-table td:nth-child(6) { width: 150px; }
.app-view[data-page="inrico-assignment"] .preview-table th:nth-child(7),
.app-view[data-page="inrico-assignment"] .preview-table td:nth-child(7) { width: 230px; }
.app-view[data-page="inrico-assignment"] .preview-table th:nth-child(8),
.app-view[data-page="inrico-assignment"] .preview-table td:nth-child(8) { width: 240px; }
.app-view[data-page="inrico-assignment"] .preview-table th:nth-child(9),
.app-view[data-page="inrico-assignment"] .preview-table td:nth-child(9) { width: 180px; }
.app-view[data-page="inrico-assignment"] .preview-table th:nth-child(10),
.app-view[data-page="inrico-assignment"] .preview-table td:nth-child(10) { width: 260px; }
.app-view[data-page="inrico-assignment"] .preview-table th:nth-child(11),
.app-view[data-page="inrico-assignment"] .preview-table td:nth-child(11) { width: 220px; }

.app-view[data-page="realptt-assignment"] .real-assignment-table {
  min-width: 2315px;
}

.app-view[data-page="realptt-assignment"] .real-assignment-table th:nth-child(1),
.app-view[data-page="realptt-assignment"] .real-assignment-table td:nth-child(1) { width: 100px; }
.app-view[data-page="realptt-assignment"] .real-assignment-table th:nth-child(2),
.app-view[data-page="realptt-assignment"] .real-assignment-table td:nth-child(2) { width: 100px; }
.app-view[data-page="realptt-assignment"] .real-assignment-table th:nth-child(3),
.app-view[data-page="realptt-assignment"] .real-assignment-table td:nth-child(3) { width: 130px; }
.app-view[data-page="realptt-assignment"] .real-assignment-table th:nth-child(4),
.app-view[data-page="realptt-assignment"] .real-assignment-table td:nth-child(4) { width: 135px; }
.app-view[data-page="realptt-assignment"] .real-assignment-table th:nth-child(5),
.app-view[data-page="realptt-assignment"] .real-assignment-table td:nth-child(5) { width: 75px; }
.app-view[data-page="realptt-assignment"] .real-assignment-table th:nth-child(6),
.app-view[data-page="realptt-assignment"] .real-assignment-table td:nth-child(6) { width: 150px; }
.app-view[data-page="realptt-assignment"] .real-assignment-table th:nth-child(7),
.app-view[data-page="realptt-assignment"] .real-assignment-table td:nth-child(7) { width: 230px; }
.app-view[data-page="realptt-assignment"] .real-assignment-table th:nth-child(8),
.app-view[data-page="realptt-assignment"] .real-assignment-table td:nth-child(8) { width: 240px; }
.app-view[data-page="realptt-assignment"] .real-assignment-table th:nth-child(9),
.app-view[data-page="realptt-assignment"] .real-assignment-table td:nth-child(9) { width: 180px; }
.app-view[data-page="realptt-assignment"] .real-assignment-table th:nth-child(10),
.app-view[data-page="realptt-assignment"] .real-assignment-table td:nth-child(10) { width: 190px; }
.app-view[data-page="realptt-assignment"] .real-assignment-table th:nth-child(11),
.app-view[data-page="realptt-assignment"] .real-assignment-table td:nth-child(11) { width: 260px; }
.app-view[data-page="realptt-assignment"] .real-assignment-table th:nth-child(12),
.app-view[data-page="realptt-assignment"] .real-assignment-table td:nth-child(12) { width: 300px; }

/* ============================================================
   INRICO - CAMBIO DE ALIAS
   ============================================================ */
.alias-filter-grid {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(320px, 1fr);
  gap: 16px;
  align-items: end;
}


.alias-client-field select,
#inricoAliasCountry,
#inricoAliasClient {
  width: 100%;
}

.alias-section-title {
  margin-bottom: 16px;
}

.alias-bulk-panel {
  display: grid;
  grid-template-columns: auto minmax(280px, 1fr) auto;
  gap: 16px;
  align-items: end;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--background);
}

.alias-select-all {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}

.alias-select-all input,
.alias-row-check {
  width: 17px;
  height: 17px;
  margin: 0;
}

.alias-bulk-base-field {
  margin: 0;
}

.alias-bulk-base-field small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.alias-inline-help {
  margin-bottom: 14px;
}

.alias-table-wrapper {
  max-height: 62vh;
  overflow: auto;
}

.alias-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.alias-table th,
.alias-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.alias-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
}

.alias-table tbody tr:hover td {
  background: #f8fafc;
}

.alias-check-cell {
  width: 48px;
  min-width: 48px;
  text-align: center !important;
}

.alias-inline-input {
  min-width: 240px;
  padding: 8px 10px;
}

.alias-inline-input:focus {
  outline: 2px solid rgba(23, 92, 211, 0.16);
  border-color: var(--primary);
}

.alias-inline-input:disabled {
  background: #f2f4f7;
  color: var(--muted);
  cursor: not-allowed;
}

.alias-result-cell {
  min-width: 310px;
}

.alias-result-cell small {
  display: block;
  margin-top: 4px;
}

.alias-row-ok {
  color: var(--success);
  font-weight: 700;
}

.alias-row-warning {
  color: var(--warning);
  font-weight: 650;
}

.alias-row-error {
  color: var(--danger);
  display: block;
  font-weight: 700;
}

.alias-row-saving,
.alias-row-muted {
  color: var(--muted);
}

.alias-technical {
  margin-top: 7px;
}

.alias-technical summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}

.alias-technical pre {
  max-width: 520px;
  max-height: 190px;
  overflow: auto;
  margin: 7px 0 0;
  padding: 9px;
  border-radius: 6px;
  background: #f8fafc;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 11px;
}

@media (max-width: 980px) {
  .alias-filter-grid,
  .alias-bulk-panel {
    grid-template-columns: 1fr;
  }

  .alias-bulk-panel .btn {
    width: 100%;
  }
}

/* ============================================================
   INRICO - CAMBIO DE ALIAS / FILTRO DE ANEXOS
   ============================================================ */
.alias-search-panel {
  display: grid;
  grid-template-columns: minmax(320px, 560px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #f8fafc;
}

.alias-search-field {
  margin: 0;
}

.alias-search-field input {
  width: 100%;
}

.alias-search-field small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.alias-empty-filter {
  padding: 28px 16px !important;
  text-align: center !important;
  color: var(--muted);
  background: #fafbfc;
}

@media (max-width: 760px) {
  .alias-search-panel {
    grid-template-columns: 1fr;
  }

  .alias-search-panel .btn {
    width: 100%;
  }
}

/* ============================================================
   INRICO · ADMINISTRACIÓN DE CONSOLAS
   ============================================================ */
.app-view[data-page="inrico-dispatchers"] {
  min-width: 0;
  width: 100%;
}

.dispatcher-input-panel,
.dispatcher-results-panel {
  width: 100%;
  min-width: 0;
}

.dispatcher-panel-header {
  align-items: flex-start;
  margin-bottom: 16px;
}

.dispatcher-counter {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f2f4f7;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.dispatcher-textarea {
  min-height: 132px;
  max-height: 300px;
}

.dispatcher-textarea.dispatcher-processing {
  background: #f8fafc;
  border-color: #98a2b3;
}

.dispatcher-help-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 10px;
}

.dispatcher-help-row .help-text {
  margin: 0;
}

.dispatcher-action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dispatcher-action-buttons .btn {
  margin: 0;
}

.dispatcher-results-heading {
  align-items: flex-start;
  margin-bottom: 18px;
}

.dispatcher-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.dispatcher-table {
  width: 100%;
  min-width: 980px;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}

.dispatcher-table th,
.dispatcher-table td {
  white-space: normal;
  vertical-align: middle;
}

.dispatcher-table th:nth-child(1),
.dispatcher-table td:nth-child(1) {
  width: 90px;
  white-space: nowrap;
}

.dispatcher-table th:nth-child(2),
.dispatcher-table td:nth-child(2) {
  width: 105px;
  white-space: nowrap;
}

.dispatcher-table th:nth-child(5),
.dispatcher-table td:nth-child(5) {
  width: 70px;
  text-align: center;
}

.dispatcher-table th:nth-child(6),
.dispatcher-table td:nth-child(6) {
  width: 130px;
}

.dispatcher-table th:nth-child(8),
.dispatcher-table td:nth-child(8) {
  width: 205px;
}

.dispatcher-action-cell {
  white-space: nowrap !important;
}

.dispatcher-role-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.dispatcher-role-console {
  background: #eff8ff;
  color: #175cd3;
}

.dispatcher-role-main {
  background: var(--success-bg);
  color: var(--success);
}

.dispatcher-role-na {
  background: #f2f4f7;
  color: #667085;
}

.dispatcher-row-ineligible td {
  background: #fcfcfd;
  color: #667085;
}

@media (max-width: 900px) {
  .dispatcher-panel-header,
  .dispatcher-help-row,
  .dispatcher-results-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .dispatcher-counter {
    align-self: flex-start;
  }

  .dispatcher-help-row .btn {
    align-self: flex-start;
  }
}


/* Alcance por país - restaurado para Usuarios y permisos */
.admin-country-heading {
  margin: 4px 0 10px;
}

.admin-country-heading p {
  margin: 4px 0 0;
}

.admin-country-access {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.admin-country-option {
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
}

.admin-country-option:hover {
  background: #f8fafc;
}

.admin-country-option input {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.admin-country-option span {
  display: grid;
  gap: 1px;
}

.admin-country-option small {
  color: var(--muted);
  font-size: 11px;
}

.admin-country-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 120px;
}

.country-chip {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f2f4f7;
  color: #344054;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 700;
}

.admin-permission-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 0 12px;
}

.admin-permission-heading p {
  margin: 4px 0 0;
}

.admin-permission-tree {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.admin-permission-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
  overflow: hidden;
}

.admin-permission-group .admin-permission-group {
  margin-top: 8px;
  background: #fff;
}

.admin-permission-parent,
.admin-permission-leaf {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
}

.admin-permission-parent {
  min-height: 44px;
  padding: 10px 12px;
  color: #344054;
  font-weight: 800;
}

.admin-permission-parent small {
  margin-left: auto;
  color: var(--muted);
  font-weight: 700;
}

.admin-permission-leaf {
  min-height: 38px;
  padding: 8px 12px;
  color: #475467;
  border-top: 1px solid #eef1f4;
}

.admin-permission-parent input,
.admin-permission-leaf input {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.admin-permission-children {
  padding: 0 8px 8px;
}

.admin-permission-children > .admin-permission-leaf {
  border: 0;
  border-radius: 7px;
}

.admin-permission-children > .admin-permission-leaf:hover,
.admin-permission-group .admin-permission-parent:hover {
  background: #f2f4f7;
}
