:root {
  font-family: Montserrat, Avenir, "Segoe UI", Arial, sans-serif;
  color: #1d252c;
  --navy: #003764;
  --blue: #0074c8;
  --sky: #36b4e5;
  --green: #3dae2b;
  --ink: #1d252c;
  --slate: #5b6670;
  --line: #d8e3ea;
  --danger: #b42318;
  --surface: #f3f7fa;
  --card: #ffffff;
  --table-head-bg: #f3f7fa;
  --table-row-bg: #ffffff;
  --table-row-hover: rgba(54, 180, 229, 0.06);
  --table-border: var(--line);
  --table-radius: 8px;
  --chip-bg: #e8f1f8;
  --chip-fg: var(--navy);
  --chip-on-bg: #e8f6e6;
  --chip-on-fg: #1f7a16;
  --chip-mute-bg: #eef2f5;
  --chip-mute-fg: var(--slate);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--surface); }
:focus-visible {
  outline: 2px solid var(--sky);
  outline-offset: 2px;
}
.hidden { display: none !important; }
h1, h2, p { margin-top: 0; }
h1 { color: var(--navy); letter-spacing: -0.025em; font-size: clamp(26px, 3vw, 36px); margin-bottom: 6px; }
.muted { color: var(--slate); }
.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(260px, 42%) minmax(0, 1fr);
  background: #fff;
}
.login-brand-panel {
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 5vw, 64px);
  background: linear-gradient(145deg, #003764 5%, #07548c 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
}
.login-brand-mark { width: clamp(64px, 18vw, 112px); height: auto; }
.login-brand-watermark {
  display: none;
  position: absolute;
  right: -18%;
  bottom: -24%;
  width: min(46%, 300px);
  opacity: 0.1;
  pointer-events: none;
}
.login-brand-copy { max-width: 16ch; }
.login-brand-panel p {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 12px;
  color: #9eddf3;
}
.login-brand-panel strong {
  display: block;
  font-size: clamp(28px, 4.4vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}
.login-card {
  align-self: center;
  width: min(460px, calc(100% - 48px));
  max-height: calc(100dvh - 24px);
  max-height: calc(100vh - 24px);
  margin: auto;
  padding: clamp(24px, 4vw, 48px);
  overflow: auto;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}
.login-card .muted { margin: 8px 0 0; color: #5b6670; line-height: 1.45; }
.form-card {
  display: grid;
  gap: 16px;
}
.form-card .section-title { margin: 0; }
.form-card .row-actions { margin-top: 4px; }
.login-card form { min-width: 0; }
.login-card label:not(.field) {
  display: grid;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
}
.login-card label:not(.field) {
  color: var(--ink);
}
.login-card input,
.login-card .field-control {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.auth-link {
  margin-top: 8px;
  padding: 0;
  min-height: auto;
  background: none;
  color: var(--blue);
  font-weight: 700;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.auth-success { color: #0f7a45; min-height: 18px; font-size: 14px; }
.brand-logo { display: block; width: min(190px, 70%); height: auto; margin-bottom: 28px; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

/* —— Formularios unificados —— */
form {
  display: grid;
  gap: 16px;
  margin-top: 4px;
  min-width: 0;
}
.form-lead {
  margin: 0;
  line-height: 1.45;
  font-size: 13px;
}
.field,
label.field,
.color-field-label {
  display: grid;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  min-width: 0;
}
.field-label,
.field > .field-label,
.color-field-label {
  display: block;
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--slate);
}
.field-group {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--table-border);
  border-radius: 10px;
  background: var(--table-head-bg);
}
.field-group > .field-label {
  margin: 0;
}
input.field-control,
select.field-control,
textarea.field-control,
.field-control,
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.color-picker-input),
select,
textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  height: 44px;
  border: 1px solid var(--table-border);
  border-radius: 8px;
  padding: 0 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: var(--card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea.field-control,
textarea {
  height: auto;
  min-height: 110px;
  padding: 12px 14px;
  line-height: 1.45;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus,
.field-control:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 116, 200, 0.16);
}
input:disabled,
select:disabled,
textarea:disabled {
  background: #f3f6f8;
  color: var(--slate);
  cursor: not-allowed;
}
.password-field {
  position: relative;
  display: grid;
  min-width: 0;
}
.password-field input {
  width: 100%;
  padding-right: 78px;
}
.password-field .password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  min-height: 30px;
  padding: 4px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  box-shadow: none;
}
.password-field .password-toggle:hover,
.password-field .password-toggle:focus-visible {
  background: rgba(0, 116, 200, 0.08);
  text-decoration: underline;
}
button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  padding: 11px 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
button.secondary { background: #fff; color: var(--navy); border: 1px solid var(--table-border); }
button.danger { background: #fff; color: var(--danger); border: 1px solid #f0c8c4; }
button:disabled { opacity: 0.55; }
.error { color: var(--danger); min-height: 18px; margin: 0; }

/* Checks alineados */
.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.25;
  cursor: pointer;
  user-select: none;
}
.check > span { min-width: 0; }
.check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 0;
  padding: 0;
  border: 1.5px solid #9eb4c4;
  border-radius: 5px;
  background: var(--card);
  display: inline-grid;
  place-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.check input[type="checkbox"]::before {
  content: "";
  width: 10px;
  height: 10px;
  transform: scale(0);
  transition: transform 0.12s ease;
  background: #fff;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.check input[type="checkbox"]:checked {
  background: var(--blue);
  border-color: var(--blue);
}
.check input[type="checkbox"]:checked::before {
  transform: scale(1);
}
.check input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 116, 200, 0.2);
}
.check-card {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--table-border);
  border-radius: 8px;
  background: var(--card);
}
.check-card:has(input:checked) {
  border-color: #9ec7e8;
  background: #eef6fc;
}
.check-chip {
  padding: 7px 10px;
  border: 1px solid var(--table-border);
  border-radius: 999px;
  background: var(--card);
  font-size: 12px;
}
.check-chip:has(input:checked) {
  border-color: #9ec7e8;
  background: #eef6fc;
  color: var(--navy);
}
.membership-grid {
  display: grid;
  gap: 8px;
}
.membership-row {
  display: grid;
  gap: 0;
}
.area-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.capability-flags {
  display: grid;
  gap: 8px;
  min-width: 168px;
}
.flag-check {
  width: 100%;
}
.app-shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 260px 1fr;
  overflow: hidden;
}
aside {
  background: var(--navy);
  color: #fff;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 10;
}
.sidebar-brand img {
  display: block;
  width: 160px;
  max-width: 100%;
  background: #fff;
  padding: 10px 12px;
}
.sidebar-brand span {
  display: block;
  margin-top: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: #9eddf3;
}
nav { margin-top: 20px; display: grid; gap: 8px; overflow: auto; }
.nav-group { display: grid; gap: 2px; }
.nav-group-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9eddf3;
  cursor: pointer;
}
.nav-sub { display: grid; gap: 2px; padding-left: 6px; }
.nav-sub.collapsed { display: none; }
.chevron { font-size: 12px; }
nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  font-weight: 600;
  border-radius: 6px;
}
nav button:hover { background: rgba(255, 255, 255, 0.08); }
nav button.nav-active {
  background: #0074c8;
  box-shadow: inset 4px 0 0 var(--green);
}
.user-box { margin-top: auto; display: grid; gap: 6px; }
.user-box small { color: #9eddf3; }
.link-button { padding: 7px 0; text-align: left; background: none; color: #fff; font-weight: 600; }
.content {
  padding: 36px clamp(20px, 4vw, 52px);
  overflow: auto;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}
.content > header { border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 20px; }
.card {
  background: var(--card);
  border: 1px solid var(--table-border);
  border-radius: var(--table-radius);
  padding: 22px;
  margin: 0 0 16px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat {
  background: var(--card);
  border: 1px solid var(--table-border);
  border-radius: var(--table-radius);
  padding: 18px;
}
.stat strong { display: block; font-size: 28px; color: var(--navy); }
.stat span { font-size: 12px; color: var(--slate); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.table-toolbar-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: min(320px, 100%);
}
.table-result-count { margin: 0; font-size: 13px; }
.search-box {
  height: 40px;
  border: 1px solid var(--table-border);
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
  min-width: min(280px, 100%);
  background: var(--card);
  color: var(--ink);
}

/* —— Tablas unificadas (Usuarios, Equipo, Flags, Catálogos) —— */
.table-wrap,
.table-shell {
  background: var(--card);
  border: 1px solid var(--table-border);
  border-radius: var(--table-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: min(72vh, calc(100vh - 240px));
  min-height: 200px;
  padding: 0;
}
.table-shell .team-hint {
  margin: 0;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--table-border);
  background: var(--table-head-bg);
  color: var(--slate);
  font-size: 13px;
}
.table-scroll {
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.table-shell > .table-scroll,
.table-wrap > .table-scroll {
  padding: 0;
}
.table-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-top: 1px solid var(--table-border);
  background: var(--card);
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 3;
}
.table-pager-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.table-pager-meta { font-size: 12px; margin: 0; color: var(--slate); }
.table-page-indicator {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  min-width: 3.5rem;
  text-align: center;
}
.table-page-size {
  height: 34px;
  border: 1px solid var(--table-border);
  border-radius: 6px;
  padding: 0 8px;
  background: var(--card);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--navy);
}
.table-pager .secondary {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.table-wrap table,
.table-shell table,
table.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  color: var(--ink);
  background: var(--table-row-bg);
}
.table-wrap thead th,
.table-shell thead th,
table.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  text-align: left;
  background: var(--table-head-bg);
  color: var(--table-head-color, var(--slate));
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 14px;
  border-bottom: 2px solid var(--table-border);
  box-shadow: none;
  white-space: nowrap;
}
.table-wrap tbody td,
.table-shell tbody td,
table.data-table tbody td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--table-border);
  vertical-align: middle;
  background: var(--table-row-bg);
  color: var(--ink);
}
.table-wrap tbody tr:last-child td,
.table-shell tbody tr:last-child td,
table.data-table tbody tr:last-child td {
  border-bottom: 0;
}
.table-wrap tbody tr:hover td,
.table-shell tbody tr:hover td,
table.data-table tbody tr:hover td {
  background: var(--table-row-hover);
}
.table-wrap tfoot td,
.table-wrap tfoot th,
.table-shell tfoot td,
.table-shell tfoot th,
table.data-table tfoot td,
table.data-table tfoot th {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: var(--card);
  border-top: 1px solid var(--table-border);
}
.empty-cell {
  text-align: center !important;
  color: var(--slate);
  padding: 32px 14px !important;
  background: var(--card) !important;
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-actions button { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.tabs button.active { background: var(--blue); color: #fff; border-color: var(--blue); }
code { font-size: 12px; font-weight: 700; color: var(--slate); }
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 22, 40, 0.45);
  display: grid;
  place-items: center;
  align-content: safe center;
  justify-items: safe center;
  padding: max(12px, env(safe-area-inset-top, 0px))
    max(12px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px))
    max(12px, env(safe-area-inset-left, 0px));
  z-index: 20;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.dialog {
  width: min(520px, 100%);
  max-width: 100%;
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  max-height: calc(100dvh - 24px);
  max-height: calc(100vh - 24px);
  overflow: auto;
  box-sizing: border-box;
  box-shadow: 0 24px 60px rgba(0, 55, 100, 0.22);
}
.dialog h2 {
  color: var(--navy);
  font-size: clamp(18px, 4vw, 22px);
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
.dialog form {
  display: grid;
  gap: 16px;
  min-width: 0;
  margin-top: 12px;
}
.dialog form textarea {
  resize: vertical;
  max-height: 40vh;
}
.dialog .modal-actions,
.dialog .row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #fff 28%);
  padding-top: 12px;
  margin-top: 4px;
}
.dialog .row-actions button {
  min-width: 110px;
}
.dialog-actions-end {
  justify-content: flex-end;
}
.dialog-message {
  margin: 8px 0 0;
  color: #3a4557;
  font-size: 14px;
  line-height: 1.5;
}
.dialog-alert,
.dialog-confirm {
  width: min(440px, 100%);
}
.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(3, 22, 40, 0.55);
}
body.busy-locked {
  overflow: hidden;
}
.busy-card {
  width: min(360px, 100%);
  background: var(--card);
  border-radius: 12px;
  padding: 28px 24px 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 55, 100, 0.28);
}
.busy-card h2 {
  margin: 14px 0 6px;
  color: var(--navy);
  font-size: 18px;
  letter-spacing: -0.02em;
}
.busy-message {
  margin: 0;
  color: #3a4557;
  font-size: 14px;
  line-height: 1.45;
}
.busy-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border: 3px solid #d7e3ef;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: busy-spin 0.75s linear infinite;
}
.busy-check {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border-radius: 50%;
  background: #e8f6e6;
  color: #14532d;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}
.busy-check::before {
  content: "✓";
}
.busy-card-success .busy-message {
  color: #14532d;
}
@keyframes busy-spin {
  to { transform: rotate(360deg); }
}
.toast {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #e8f6e6;
  color: #14532d;
  border: 1px solid #b7e4b0;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 13px;
}
.section-title { color: var(--navy); font-size: 18px; margin: 8px 0 12px; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.product-card {
  text-align: left;
  background: var(--card);
  color: var(--navy);
  border: 1px solid var(--table-border);
  border-radius: 10px;
  padding: 20px;
  display: grid;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 55, 100, 0.06);
}
.product-card span { color: var(--slate); font-weight: 600; font-size: 13px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip,
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  background: var(--chip-bg);
  color: var(--chip-fg);
  border: 1px solid transparent;
}
.chip-on,
.pill-on {
  background: var(--chip-on-bg);
  color: var(--chip-on-fg);
}
.chip-mute,
.pill-off {
  background: var(--chip-mute-bg);
  color: var(--chip-mute-fg);
}
.dialog-wide { width: min(720px, 100%); max-width: 100%; }
@media (min-width: 1200px) {
  .login-brand-watermark { display: block; }
}
@media (max-height: 720px) {
  .dialog,
  .login-card {
    max-height: calc(100dvh - 16px);
    max-height: calc(100vh - 16px);
  }
  .dialog-backdrop {
    padding: 8px;
  }
}
.menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
  min-height: 40px;
}
.nav-scrim {
  display: none;
}
.stack { display: grid; gap: 16px; }
.stack > .card { margin-bottom: 0; }
.switch-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.switch-panel-head .section-title { margin: 0; }
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
  background: var(--chip-bg);
  color: var(--chip-fg);
}
.status-pill-on {
  background: var(--chip-on-bg);
  color: var(--chip-on-fg);
}
.status-pill-off {
  background: var(--chip-mute-bg);
  color: var(--chip-mute-fg);
}
.switch-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  cursor: pointer;
}
.switch-copy { line-height: 1.3; }
.switch-ui {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}
.switch-ui input {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  width: 48px;
  height: 28px;
  opacity: 0;
  cursor: pointer;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}
.switch-track {
  display: block;
  width: 48px;
  height: 28px;
  border-radius: 99px;
  background: #b7c4cd;
  transition: background 0.15s ease;
}
.switch-track::after {
  content: "";
  display: block;
  width: 22px;
  height: 22px;
  margin: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(29, 37, 44, 0.28);
  transition: transform 0.15s ease;
}
.switch-ui input:checked + .switch-track { background: var(--green); }
.switch-ui input:checked + .switch-track::after { transform: translateX(20px); }
.switch-ui input:focus-visible + .switch-track {
  outline: 2px solid var(--sky);
  outline-offset: 3px;
}
.team-hint { margin: 0 0 14px; }
.color-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 8px;
}
.color-swatch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  background: var(--swatch, #5b6670);
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.color-picker-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  pointer-events: none;
  background: transparent !important;
  box-shadow: none !important;
}
.color-swatch-check {
  display: none;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  line-height: 1;
}
.color-swatch:has(.color-picker-input:checked),
.color-swatch.is-selected {
  border-color: var(--navy);
  box-shadow: 0 0 0 2px rgba(0, 55, 100, 0.2), inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.color-swatch:has(.color-picker-input:checked) .color-swatch-check,
.color-swatch.is-selected .color-swatch-check {
  display: flex;
}
.color-swatch:has(.color-picker-input:focus-visible),
.color-swatch:focus-visible {
  outline: 2px solid var(--sky);
  outline-offset: 2px;
}
.color-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  vertical-align: middle;
  background: var(--dot, #5b6670);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.impact-body { display: grid; gap: 10px; }
.impact-warnings { margin: 0; padding-left: 18px; color: #8a5a00; }
.impact-blockers { margin: 0; padding-left: 18px; color: var(--danger); }
.impact-details { margin: 0; padding-left: 18px; }

/* API docs (CRM module) */
.api-intro { display: grid; gap: 10px; }
.api-base {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: #eef5fa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--navy);
}
.api-perm-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.api-perm-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  user-select: none;
}
.api-perm-filter:has(input:checked) {
  border-color: #9ec7e8;
  background: #eef6fc;
  color: var(--navy);
}
.api-perm-filter input {
  width: 15px;
  height: 15px;
  accent-color: var(--blue);
  margin: 0;
}
.api-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  font-size: 13px;
  color: var(--slate);
}
.api-group { display: grid; gap: 12px; margin-top: 4px; }
.api-group-title {
  margin: 0;
  color: var(--navy);
  font-size: 15px;
  font-weight: 700;
}
.api-endpoint {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.api-endpoint-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 14px;
  align-items: start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}
.api-method {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
}
.api-method-get { background: var(--blue); }
.api-method-post { background: var(--green); }
.api-method-patch { background: #ca8a04; }
.api-method-delete { background: var(--danger); }
.api-method-put { background: #7c3aed; }
.api-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--navy);
  word-break: break-all;
}
.api-summary { margin: 2px 0 0; font-size: 13px; color: var(--slate); }
.api-endpoint-body {
  display: grid;
  gap: 12px;
  padding: 12px 14px 14px;
}
.api-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.api-meta-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}
.api-meta-block strong {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate);
  margin-bottom: 6px;
}
.api-meta-block code,
.api-meta-block pre {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  color: var(--ink);
}
.api-perm-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.api-perm-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
  font-size: 12px;
  font-weight: 600;
}
.api-perm-cell span:first-child { color: var(--slate); }
.api-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}
.api-mark-yes {
  background: rgba(61, 174, 43, 0.14);
  color: #2f8a1f;
  border: 1px solid rgba(61, 174, 43, 0.35);
}
.api-mark-no {
  background: rgba(91, 102, 112, 0.08);
  color: #8a939b;
  border: 1px solid var(--line);
}
.api-empty {
  padding: 18px;
  text-align: center;
  color: var(--slate);
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fff;
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .stats, .grid-2, .product-grid, .membership-row { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex; }
  aside {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 88vw);
    height: 100vh;
    height: 100dvh;
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  aside.open { transform: translateX(0); }
  .nav-scrim:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(3, 22, 40, 0.45);
    z-index: 35;
  }
  .content {
    padding: 64px 16px 24px;
    height: 100vh;
    height: 100dvh;
  }
}
@media (max-width: 760px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand-panel { padding: 24px 20px; }
  .login-brand-mark { width: 56px; }
}

/* Teléfono: lo que se abre al tocar no puede salir del área visible. */
@media (max-width: 900px) {
  .modal-root,
  .confirm-root,
  .dialog-backdrop,
  .busy-overlay {
    top: var(--vv-top, 0px);
    height: var(--vvh, 100svh);
    bottom: auto;
    align-content: start;
    justify-items: stretch;
    padding:
      max(8px, env(safe-area-inset-top, 0px))
      max(8px, env(safe-area-inset-right, 0px))
      max(8px, env(safe-area-inset-bottom, 0px))
      max(8px, env(safe-area-inset-left, 0px));
  }
  .modal-card,
  .modal-card.act-modal,
  .confirm-card,
  .dialog,
  .dialog-wide,
  .dialog-alert,
  .dialog-confirm,
  .busy-card,
  .login-card {
    width: 100%;
    max-width: 100%;
    max-height: calc(var(--vvh, 100svh) - 16px);
    margin-top: 0;
    overflow: auto;
    overflow-wrap: anywhere;
  }
  .column-picker-panel,
  .filter-add-menu,
  .act-popover {
    position: fixed;
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    top: auto;
    bottom: calc(100% - var(--vv-top, 0px) - var(--vvh, 100svh) + max(8px, env(safe-area-inset-bottom, 0px)));
    width: auto;
    min-width: 0;
    max-height: min(70svh, calc(var(--vvh, 100svh) - 16px));
    overflow: auto;
    z-index: 80;
  }
  .toast {
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    width: auto;
    max-width: none;
    bottom: calc(100% - var(--vv-top, 0px) - var(--vvh, 100svh) + max(8px, env(safe-area-inset-bottom, 0px)));
    overflow-wrap: anywhere;
  }
}
