/* ==========================================================================
   BURO Digital · Portal administrativo
   Design system: negro #0B0D0C, lime #C8F000, gris #F4F6F4, bordes #E4E7E4.
   Space Grotesk para titulares, Inter para UI. Sin build, sin dependencias.
   ========================================================================== */

/* ------------------------------- Fuentes -------------------------------- */
@font-face {
  font-family: "Inter";
  src: url("assets/fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("assets/fonts/inter-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("assets/fonts/space-grotesk-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("assets/fonts/space-grotesk-latin-ext.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ------------------------------- Tokens --------------------------------- */
:root {
  --ink: #0b0d0c;
  --ink-2: #151816;
  --lime: #c8f000;
  --lime-dark: #b2d800;
  --lime-soft: #f2fbc9;
  --white: #ffffff;
  --bg: #f4f6f4;
  --border: #e4e7e4;
  --border-strong: #d5dad5;
  --text: #101310;
  --text-2: #4e564e;
  --text-3: #6f776f;
  --ok: #1f7a4d;
  --ok-bg: #e9f6ee;
  --warn: #7a4d00;
  --warn-bg: #fdf3e0;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --sidebar-w: 264px;
  --topbar-h: 72px;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Space Grotesk", "Inter", -apple-system, "Segoe UI", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --shadow-lg: 0 30px 80px -28px rgba(11, 13, 12, 0.55);
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

/* ------------------------------- Base ----------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1,
h2,
h3,
h4,
p,
figure,
dl,
dd {
  margin: 0;
}
ul,
ol {
  margin: 0;
  padding: 0;
}
a {
  color: inherit;
  text-decoration: none;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
svg {
  display: block;
}
[hidden] {
  display: none !important;
}
::selection {
  background: var(--lime);
  color: var(--ink);
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--lime);
  color: var(--ink);
  font-weight: 600;
  transform: translateY(-180%);
  transition: transform 0.15s var(--ease);
}
.skip-link:focus {
  transform: translateY(0);
  outline: 2px solid var(--white);
  outline-offset: 2px;
}
body:not(.is-authed) .skip-link {
  display: none;
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.sidebar :where(a, button):focus-visible {
  outline-color: var(--lime);
}
.btn--primary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(200, 240, 0, 0.45);
}

/* ------------------------------- Marca ---------------------------------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand__mark {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 9px;
}
.brand__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1;
  min-width: 0;
}
.brand__text strong {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand__text span {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.brand--dark .brand__text strong {
  color: var(--white);
}
.brand--dark .brand__text span {
  color: var(--lime);
}
.brand--light .brand__text strong {
  color: var(--ink);
}
.brand--light .brand__text span {
  color: var(--text-3);
}

.eyebrow {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ------------------------------- Botones -------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease),
    color 0.15s var(--ease), transform 0.1s var(--ease);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn .icon {
  width: 17px;
  height: 17px;
}
.btn--primary {
  background: var(--lime);
  color: var(--ink);
  border-color: var(--lime);
}
.btn--primary:hover:not(:disabled) {
  background: var(--lime-dark);
  border-color: var(--lime-dark);
}
/* Confirmación explícita de acciones destructivas (cancelar, reabrir…). */
.btn--danger {
  background: var(--danger);
  color: var(--white);
  border-color: var(--danger);
}
.btn--danger:hover:not(:disabled) {
  background: #911b12;
  border-color: #911b12;
}
.btn--ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn--ghost:hover:not(:disabled) {
  background: var(--bg);
  color: var(--ink);
}
.btn--soft {
  background: var(--bg);
  border-color: transparent;
  color: var(--ink);
}
.btn--soft:hover:not(:disabled) {
  background: #e9ede9;
}
.btn--block {
  width: 100%;
}
.btn__label {
  display: inline-flex;
  align-items: center;
}
.spinner {
  display: none;
  width: 15px;
  height: 15px;
  flex: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner--dark {
  display: block;
  color: var(--lime);
}
.btn.is-loading .spinner {
  display: block;
}
.btn.is-loading {
  pointer-events: none;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.icon-btn:hover {
  background: var(--bg);
  color: var(--ink);
}
.sidebar .icon-btn {
  color: #b6bdb6;
}
.sidebar .icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}
.link .icon {
  width: 15px;
  height: 15px;
  transition: transform 0.15s var(--ease);
}
.link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link:hover .icon {
  transform: translateX(2px);
}

/* ------------------------------- Chips ---------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}
.chip__dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}
.chip--ok {
  background: var(--ok-bg);
  color: var(--ok);
}
.chip--progress {
  background: var(--ink);
  color: var(--white);
}
.chip--progress .chip__dot {
  background: var(--lime);
}
.chip--warn {
  background: var(--warn-bg);
  color: var(--warn);
}
.chip--danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.chip--neutral {
  background: #f0f2f0;
  color: var(--text-2);
}
.chip--info {
  background: var(--lime-soft);
  color: #3f4a00;
}
.chip--tenant {
  height: 32px;
  padding: 0 12px;
  border-color: var(--border);
  background: var(--white);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.chip--tenant .chip__dot {
  background: var(--lime-dark);
  box-shadow: 0 0 0 3px rgba(200, 240, 0, 0.25);
}
.chip__meta {
  padding-left: 9px;
  margin-left: 3px;
  border-left: 1px solid var(--border);
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--white);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ------------------------------- Avatares ------------------------------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.avatar--brand {
  width: 34px;
  height: 34px;
  border: 0;
  background: var(--lime);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 15px;
}

/* ------------------------------- Boot ----------------------------------- */
.boot {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--ink);
  color: #b6bdb6;
}
.boot__mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 15px;
  background: var(--lime);
  animation: breathe 2.2s ease-in-out infinite;
}
.boot__mark .icon {
  width: 52px;
  height: 52px;
  border-radius: 15px;
}
.boot__text {
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ------------------------------- Login ---------------------------------- */
.auth {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 40px 20px;
  overflow: hidden;
  background: var(--ink);
}
.auth__decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(620px 440px at 8% 4%, rgba(200, 240, 0, 0.16), transparent 68%),
    radial-gradient(680px 520px at 96% 102%, rgba(200, 240, 0, 0.07), transparent 62%),
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: auto, auto, 56px 56px, 56px 56px;
}
.auth__decor::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -160px;
  width: 520px;
  height: 520px;
  border: 1px solid rgba(200, 240, 0, 0.1);
  border-radius: 50%;
  transform: translateY(-50%);
}
.auth__inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.auth__card {
  width: min(432px, 100%);
  padding: 32px 32px 26px;
  border-radius: 20px;
  background: var(--white);
  box-shadow: var(--shadow-lg);
  animation: fade-up 0.32s var(--ease) both;
}
.auth__brand {
  margin-bottom: 24px;
}
.auth__title {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.12;
  color: var(--ink);
}
.auth__sub {
  margin-top: 8px;
  margin-bottom: 22px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-2);
}
.auth__form {
  display: grid;
  gap: 14px;
}
.auth__foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-3);
}
.auth__foot .icon {
  width: 13px;
  height: 13px;
}
.auth__copy {
  margin-top: 18px;
  font-size: 11px;
  color: #6e766e;
}

/* ------------------------------- Campos --------------------------------- */
.field {
  display: grid;
  gap: 7px;
}
.field__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.field__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.field__hint {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-3);
}
.input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--ink);
  font-size: 13.5px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease),
    background-color 0.15s var(--ease);
}
.input::placeholder {
  color: #9aa29a;
}
.input:hover {
  border-color: #bcc4bc;
}
.input:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(200, 240, 0, 0.5);
}
.input[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fffafa;
}
.input[aria-invalid="true"]:focus-visible {
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.18);
}
.input:disabled {
  background: #f4f6f4;
  color: var(--text-3);
  cursor: not-allowed;
}
.input[readonly] {
  background: #f9faf9;
  border-color: var(--border);
  color: var(--text);
  cursor: default;
}
select.input {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234E564E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}
select.input:disabled {
  opacity: 1;
  background-color: #f4f6f4;
}

.form-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #f6d0ca;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: #8f1d14;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}
.form-error::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--danger);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid__full {
  grid-column: 1 / -1;
}
.callout {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafbf9;
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.5;
}
.callout .icon {
  width: 15px;
  height: 15px;
  margin-top: 1px;
  color: var(--text-3);
}
.callout--info {
  border-color: #dbe8a6;
  background: #f8fce7;
  color: #4c5700;
}
.callout--info .icon {
  color: #6b7a00;
}
.zip-note {
  margin-bottom: 16px;
}
.card__body > .zip-note {
  margin-bottom: 14px;
}
.alert__body {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.alert__title {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
}
.alert__meta {
  font-size: 11.5px;
  line-height: 1.45;
}
.alert__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.alert__action-hint {
  font-size: 11px;
  opacity: 0.85;
}
.model-warning .alert__actions .btn {
  flex: none;
}
.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.5;
}
.alert--error {
  border-color: #f6d0ca;
  background: var(--danger-bg);
  color: #8f1d14;
}
.alert--error::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--danger);
}

/* ------------------------------- Layout app ----------------------------- */
.app {
  min-height: 100vh;
  min-height: 100dvh;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  padding: 18px 14px;
  overflow-y: auto;
  background: var(--ink);
  color: #e7ebe7;
  scrollbar-width: thin;
  scrollbar-color: #2b302b transparent;
}
.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 6px 18px;
}
.sidebar__close {
  display: none;
}
.sidebar__tenant {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.045);
}
.sidebar__tenant-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}
.sidebar__tenant-text strong {
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--white);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__tenant-text span {
  overflow: hidden;
  font-size: 10.5px;
  color: #98a098;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav__label {
  padding: 0 10px;
  margin: 14px 0 7px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: #7c847c;
}
.nav__label:first-child {
  margin-top: 0;
}
.nav__item {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 42px;
  padding: 0 11px;
  border-radius: 11px;
  color: #b6bdb6;
  font-size: 13.5px;
  font-weight: 500;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.nav__item .icon {
  width: 18px;
  height: 18px;
  color: #8b938b;
  transition: color 0.15s var(--ease);
}
.nav__item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--white);
}
.nav__item:hover .icon {
  color: var(--white);
}
.nav__item[aria-current="page"] {
  background: var(--lime);
  color: var(--ink);
  font-weight: 600;
}
.nav__item[aria-current="page"] .icon {
  color: var(--ink);
}
.sidebar__foot {
  padding: 16px 4px 0;
  margin-top: auto;
}
.sidebar__note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 11px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}
.sidebar__note .icon {
  width: 15px;
  height: 15px;
  margin-top: 1px;
  color: var(--lime);
}
.sidebar__note > span {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.4;
}
.sidebar__note strong {
  font-size: 11px;
  font-weight: 600;
  color: #dfe4df;
}
.sidebar__note span span {
  font-size: 10px;
  color: #98a098;
}
.sidebar__version {
  margin-top: 14px;
  padding-left: 4px;
  font-size: 10px;
  color: #6e766e;
}
.scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(11, 13, 12, 0.55);
  animation: fade-in 0.18s var(--ease);
}
.app__body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin-left: var(--sidebar-w);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--topbar-h);
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}
.topbar__menu {
  display: none;
}
.topbar__titles {
  min-width: 0;
}
.topbar__eyebrow {
  margin-bottom: 2px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-3);
}
.topbar__title {
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}
.user__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}
.user__text strong {
  max-width: 170px;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user__text span {
  max-width: 170px;
  overflow: hidden;
  font-size: 11px;
  color: var(--text-3);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.main {
  width: 100%;
  max-width: 1400px;
  padding: 28px 32px 56px;
  margin: 0 auto;
}
.view-root {
  outline: none;
}
.view-root > * {
  animation: fade-up 0.24s var(--ease) both;
}

/* ------------------------------- Página --------------------------------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.page-head__eyebrow {
  margin-bottom: 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-3);
}
.page-head__title {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.page-head__title:focus {
  outline: none;
}
.page-head__desc {
  max-width: 72ch;
  margin-top: 7px;
  font-size: 12.8px;
  line-height: 1.55;
  color: var(--text-2);
}
.page-head__actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 9px;
}

/* ------------------------------- Cards ---------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.stat {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  transition: border-color 0.18s var(--ease), transform 0.18s var(--ease);
}
.stat:hover {
  border-color: var(--border-strong);
}
.stat__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.stat__label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}
.stat__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-2);
}
.stat__icon .icon {
  width: 17px;
  height: 17px;
}
.stat__value {
  margin: 12px 0 4px;
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.stat__hint {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-3);
}
.stat--accent {
  border-color: var(--ink);
  background: var(--ink);
}
.stat--accent .stat__label {
  color: #9aa29a;
}
.stat--accent .stat__value {
  color: var(--white);
}
.stat--accent .stat__hint {
  color: #9aa29a;
}
.stat--accent .stat__icon {
  background: rgba(255, 255, 255, 0.08);
  color: var(--lime);
}
.stat--accent::after {
  content: "";
  position: absolute;
  right: -46px;
  bottom: -70px;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(200, 240, 0, 0.16);
  border-radius: 50%;
}

.layout-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(290px, 0.85fr);
  gap: 18px;
  align-items: start;
}
.layout-2--wide-left {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr);
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
}
.card--table {
  overflow: hidden;
}
.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
}
.card__title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.card__desc {
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-3);
}
.card__head--tight {
  align-items: center;
}
.analysis-head__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
@media (max-width: 620px) {
  .card__head {
    flex-wrap: wrap;
  }
  .analysis-head__actions {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ------------------------------- Tablas --------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #d8ddd8 transparent;
}
.table-hint {
  display: none;
  margin: 0 0 8px;
  font-size: 10.5px;
  color: var(--text-3);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.table--recent {
  min-width: 660px;
}
.table--imports {
  min-width: 900px;
}
.table--audit {
  min-width: 940px;
}
.table thead th {
  position: relative;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #fafbf9;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #eef0ee;
  color: var(--text-2);
  vertical-align: middle;
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table tbody tr {
  transition: background-color 0.12s var(--ease);
}
.table tbody tr:hover {
  background: #fafbf9;
}
.table .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.table .mono {
  font-family: var(--font-mono);
  font-size: 11px;
}
.cell-title {
  font-size: 12.8px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
}
.cell-sub {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
}
.cell-strong {
  font-weight: 600;
  color: var(--ink);
}
.cell-muted {
  color: var(--text-3);
}
.cell-nowrap {
  white-space: nowrap;
}
.cell-actions {
  text-align: right;
}
.table__empty td {
  padding: 0;
  border-bottom: 0;
}
/* Sin filas de datos la tabla no necesita ancho mínimo: el estado vacío
   debe caber en móvil sin desbordar el contenedor. */
.table--imports:has(.table__empty) {
  min-width: 0;
  table-layout: fixed;
}
.table--imports:has(.table__empty) thead {
  display: none;
}
.card--table:has(.table__empty) .table-hint {
  display: none;
}
.progress {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 116px;
}
.progress__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
}
.progress__bar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #ecefec;
}
.progress__fill {
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
}
.progress__fill--done {
  background: var(--lime-dark);
}
.errores {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f0f2f0;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
}
.errores--has {
  background: var(--danger-bg);
  color: var(--danger);
}
.country-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.code-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.ip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
}

/* ------------------------------- Empty / estados ------------------------ */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 44px 24px;
  text-align: center;
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-3);
}
.empty__icon .icon {
  width: 21px;
  height: 21px;
}
.empty__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.empty__desc {
  max-width: 44ch;
  font-size: 11.8px;
  line-height: 1.55;
  color: var(--text-3);
}
.empty__actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 52px 24px;
  text-align: center;
}
.state__icon {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-2);
}
.state__icon .icon {
  width: 23px;
  height: 23px;
}
.state__icon--danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.state__title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}
.state__desc {
  max-width: 52ch;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-3);
}
.state .btn {
  margin-top: 14px;
}

/* ------------------------------- Skeletons ------------------------------ */
.sk {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #ecefec 25%, #f6f8f6 37%, #ecefec 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
.sk--line {
  height: 10px;
}
.sk--sm {
  width: 84px;
}
.sk--title {
  width: min(280px, 60%);
  height: 26px;
  margin-top: 12px;
}
.sk--text {
  width: min(420px, 80%);
  height: 11px;
  margin-top: 12px;
}
.sk--value {
  width: 100px;
  height: 34px;
  margin-top: 16px;
}
.sk--button {
  width: 140px;
  height: 42px;
  border-radius: var(--radius-md);
}
.stat--skeleton:hover {
  transform: none;
}
.card--skeleton {
  padding: 20px;
  margin-top: 18px;
}
.sk-rows {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 22px;
}
.sk-row {
  display: flex;
  align-items: center;
  gap: 18px;
}
.sk-row .sk:first-child {
  width: 34%;
}
.sk-row .sk:nth-child(2) {
  width: 20%;
}
.sk-row .sk:nth-child(3) {
  width: 14%;
}
.sk-row .sk:nth-child(4) {
  width: 12%;
}
.page-head--skeleton {
  align-items: center;
}
.sr-only-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------- IA ------------------------------------- */
.ai-card {
  overflow: hidden;
}
.ai-card__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-card__logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  background: var(--lime);
  color: var(--ink);
}
.ai-card__logo .icon {
  width: 19px;
  height: 19px;
}
.ai-card__model {
  padding: 16px;
  margin: 0 20px 16px;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: var(--white);
}
.ai-card__provider {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lime);
}
.ai-card__model-name {
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.ai-card__body {
  padding: 0 20px 20px;
}
.ai-card .kv {
  margin-bottom: 16px;
}
.ai-card__warning {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: -4px 0 14px;
  font-size: 11.5px;
  line-height: 1.45;
  color: #8a5a00;
}
.ai-card__warning .icon {
  width: 14px;
  height: 14px;
  flex: none;
  margin-top: 1px;
}
.kv {
  display: grid;
  gap: 0;
}
.kv > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px dashed #e9ece9;
}
.kv > div:first-child {
  padding-top: 0;
}
.kv > div:last-child {
  border-bottom: 0;
}
.kv dt {
  flex: none;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 12.5px;
  font-weight: 500;
  text-align: right;
}
.kv dd.mono {
  font-family: var(--font-mono);
  font-size: 11px;
}
.kv--grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 28px;
}
.kv--grid > div {
  align-items: flex-start;
  flex-direction: column;
  gap: 3px;
}
.kv--grid dd {
  text-align: left;
}
.stack .card__body {
  padding: 0 20px 20px;
}
.mcp-card {
  border-style: dashed;
  border-color: #d5dad5;
}
.mcp-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 0;
}
.mcp-card__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-2);
}
.mcp-card p {
  padding: 10px 20px 16px;
  font-size: 11.8px;
  line-height: 1.55;
  color: var(--text-3);
}
.mcp-card .btn {
  margin: 0 20px 20px;
  width: calc(100% - 40px);
}
.notice-card {
  padding: 18px 20px;
  border-color: #e0eaa8;
  background: #f8fce7;
}
.notice-card__head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}
.notice-card__head .icon {
  width: 16px;
  height: 16px;
  color: #556100;
}
.notice-card__title {
  font-size: 12.5px;
  font-weight: 600;
  color: #374000;
}
.notice-card p {
  font-size: 11.5px;
  line-height: 1.55;
  color: #4c5700;
}
.notice-card__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.notice-card .chip {
  border: 1px solid #dce8a0;
  background: rgba(255, 255, 255, 0.6);
  color: #3f4a00;
  font-family: var(--font-mono);
  font-size: 10px;
}
.readonly-form {
  display: grid;
  gap: 14px;
  padding: 0 20px 20px;
}
.shortcut {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 20px;
  border-top: 1px solid #eef0ee;
  transition: background-color 0.12s var(--ease);
}
.shortcut:hover {
  background: #fafbf9;
}
.shortcut__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 9px;
  background: var(--bg);
  color: var(--text-2);
}
.shortcut__icon .icon {
  width: 16px;
  height: 16px;
}
.shortcut__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}
.shortcut__text strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.shortcut__text span {
  font-size: 10.5px;
  color: var(--text-3);
}
.shortcut > .icon {
  width: 15px;
  height: 15px;
  margin-left: auto;
  color: var(--text-3);
}

/* ------------------------------- Toolbar / filtros ---------------------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 20px 16px;
}
.toolbar__group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.filter {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--white);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  transition: background-color 0.12s var(--ease), color 0.12s var(--ease),
    border-color 0.12s var(--ease);
}
.filter:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}
.filter[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--white);
}
.filter__count {
  margin-left: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.7;
}
.toolbar__meta {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
}

/* ------------------------------- Catálogos ------------------------------ */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 46px;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.12s var(--ease), border-color 0.12s var(--ease);
}
.tab:hover {
  color: var(--ink);
}
.tab[aria-selected="true"] {
  border-bottom-color: var(--ink);
  color: var(--ink);
}
.tab__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
}
.tab[aria-selected="true"] .tab__count {
  background: var(--lime);
  color: var(--ink);
}
.tabpanel {
  padding: 20px;
}
.country-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.country-card {
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fbfcfb;
}
.country-card__head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 11px;
}
.country-card__name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.country-card__code {
  min-width: 32px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--lime);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.jurisdiction-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.jurisdiction {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--white);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.45;
}
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip--lg {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
}
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.plan-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fbfcfb;
}
.plan-card__name {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.plan-card__desc {
  margin: -4px 0 10px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-3);
}
.plan-card__caps {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}
.plan-card__caps .chip {
  padding: 3px 8px;
  border: 1px solid var(--border);
  background: var(--white);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-2);
}
.plan-card .kv {
  gap: 0;
}
.plan-card .kv > div {
  padding: 7px 0;
}
.plan-card .kv dd.mono {
  font-size: 10.5px;
}

/* ------------------------------- Dialog --------------------------------- */
.dialog {
  width: min(600px, calc(100vw - 32px));
  max-height: min(92vh, 840px);
  max-height: min(92dvh, 840px);
  padding: 0;
  margin: auto;
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  background: var(--white);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.dialog[open] {
  animation: dialog-in 0.2s var(--ease);
}
.dialog::backdrop {
  background: rgba(11, 13, 12, 0.58);
  backdrop-filter: blur(2px);
}
.dialog__form {
  display: flex;
  flex-direction: column;
  max-height: inherit;
}
.dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 12px;
}
.dialog__title {
  margin-top: 5px;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.dialog__desc {
  max-width: 56ch;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-3);
}
.dialog__body {
  display: grid;
  gap: 15px;
  padding: 10px 24px 22px;
  overflow-y: auto;
}
.dialog__foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: #fafbf9;
}

/* ------------------------------- Toasts --------------------------------- */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 13px;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: var(--white);
  box-shadow: 0 18px 44px -18px rgba(11, 13, 12, 0.6);
  pointer-events: auto;
  animation: toast-in 0.22s var(--ease);
}
.toast__icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  margin-top: 1px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}
.toast__icon .icon {
  width: 13px;
  height: 13px;
}
.toast--success .toast__icon {
  color: var(--lime);
}
.toast--error .toast__icon {
  color: #ff9a90;
}
.toast--info .toast__icon {
  color: #d5dbd5;
}
.toast__text {
  flex: 1;
  padding-top: 1px;
  font-size: 12px;
  line-height: 1.45;
}
.toast__close {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #b6bdb6;
}
.toast__close:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--white);
}
.toast__close .icon {
  width: 13px;
  height: 13px;
}
.noscript {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 200;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--danger);
  color: var(--white);
  font-size: 13px;
}

/* ------------------------------- Utilidades de vistas ------------------- */
body.nav-open,
body.has-dialog {
  overflow: hidden;
}
.main:focus {
  outline: none;
}
.page-head__actions .chip {
  align-self: center;
}
.chip .icon {
  width: 13px;
  height: 13px;
}
.chip--lg .icon {
  width: 14px;
  height: 14px;
  color: var(--text-3);
}
.btn--icon {
  width: 42px;
  flex: none;
  padding: 0;
}
.card__body {
  padding: 0 20px 20px;
}
.card__head + .card__body {
  padding-top: 0;
}
.input--mono {
  font-family: var(--font-mono);
  font-size: 12px;
}
.params {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px;
}
.params__title {
  margin-bottom: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}
.params__empty {
  font-size: 11.5px;
  color: var(--text-3);
}
.roles {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
}
.mcp-card__title {
  padding: 12px 20px 0;
}
.sk--icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}
.progress__fill--0 {
  width: 0;
}
.progress__fill--10 {
  width: 10%;
}
.progress__fill--20 {
  width: 20%;
}
.progress__fill--30 {
  width: 30%;
}
.progress__fill--40 {
  width: 40%;
}
.progress__fill--50 {
  width: 50%;
}
.progress__fill--60 {
  width: 60%;
}
.progress__fill--70 {
  width: 70%;
}
.progress__fill--80 {
  width: 80%;
}
.progress__fill--90 {
  width: 90%;
}
.progress__fill--100 {
  width: 100%;
}

/* ------------------------------- Utilidades nuevas ---------------------- */
.contents {
  display: contents;
}
.btn--sm {
  height: 34px;
  padding: 0 11px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.btn--sm .icon {
  width: 15px;
  height: 15px;
}
.link--mono {
  font-family: var(--font-mono);
  font-size: 11px;
}
.input--num {
  font-variant-numeric: tabular-nums;
}
.cell-error {
  max-width: 260px;
  color: var(--danger);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}
.card__head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}
.state--compact {
  padding: 30px 20px;
}
.alert--warn {
  border-color: #f0dcae;
  background: var(--warn-bg);
  color: #6b4300;
}
.alert--info {
  border-color: #dbe8a6;
  background: #f8fce7;
  color: #4c5700;
}
.alert .icon {
  width: 15px;
  height: 15px;
  margin-top: 1px;
  flex: none;
}

/* ------------------------------- Formularios IA ------------------------ */
.ai-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.ai-form__body {
  display: grid;
  gap: 16px;
}
.fieldset {
  padding: 0;
  margin: 0;
  border: 0;
}
.fieldset + .fieldset {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.fieldset > legend {
  padding: 0;
}
.fieldset > legend + .form-grid {
  margin-top: 12px;
}
.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--white);
  cursor: pointer;
}
.checkbox:hover {
  border-color: #bcc4bc;
}
.checkbox:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(200, 240, 0, 0.5);
}
.checkbox input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.checkbox__box {
  position: relative;
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 1px;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: var(--white);
}
.checkbox input:checked + .checkbox__box {
  border-color: var(--ink);
  background: var(--ink);
}
.checkbox input:checked + .checkbox__box::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 5px;
  width: 4px;
  height: 8px;
  border: solid var(--lime);
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.checkbox__text {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
}
.input-group {
  display: flex;
  gap: 8px;
}
.input-group .input {
  flex: 1;
  min-width: 0;
}
.input-group__btn {
  flex: none;
  height: 46px;
}
.key-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f0f2f0;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
}
.key-state .icon {
  width: 12px;
  height: 12px;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 4px 0 8px;
}
.form-status {
  flex: 1;
  min-width: 200px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-3);
}
.form-status:focus {
  outline: none;
}
.form-status[data-tone="ok"] {
  color: var(--ok);
}
.form-status[data-tone="error"] {
  color: var(--danger);
}
.form-status[data-tone="busy"] {
  color: var(--text-2);
}
.test-card__hint {
  font-size: 11.8px;
  line-height: 1.55;
  color: var(--text-3);
}
.test-card__result {
  display: grid;
  gap: 8px;
}
.test-card__title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
}
.test-card__title .icon {
  width: 16px;
  height: 16px;
}
.test-card__result--ok .test-card__title {
  color: var(--ok);
}
.test-card__result--error .test-card__title {
  color: var(--danger);
}
.test-card .kv {
  margin-top: 2px;
}
.test-card .card__body {
  padding: 0 20px 20px;
}
.test-card__intro {
  display: grid;
  gap: 10px;
}
.test-card__intro .kv {
  margin: 0;
}
.test-card__message {
  display: grid;
  gap: 3px;
  margin-top: 2px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafbf9;
  font-size: 11.8px;
  line-height: 1.5;
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.test-card__message--error {
  border-color: #f6d0ca;
  background: var(--danger-bg);
  color: #8f1d14;
}
.test-card__message-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
}
.test-card__message--error .test-card__message-label {
  color: #a33a30;
}
.test-card__backend-message {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.test-card__last-error {
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
}
.test-card__last-error .alert__title {
  margin: 0;
}
.test-card__last-error .test-card__backend-message {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.5;
}

/* ------------------------------- Carga de archivos ---------------------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 30px 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: #fafbf9;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease),
    box-shadow 0.15s var(--ease);
}
.dropzone:hover {
  border-color: #b7c1b7;
  background: #f6f8f5;
}
.dropzone:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(200, 240, 0, 0.5);
}
.dropzone.is-dragover {
  border-color: var(--ink);
  background: var(--lime-soft);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.dropzone__icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 3px;
  border-radius: 50%;
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.dropzone__icon .icon {
  width: 20px;
  height: 20px;
}
.dropzone__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.dropzone__link {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.dropzone__hint {
  font-size: 11px;
  color: var(--text-3);
}
.upload-count {
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--text-3);
}
.upload-queue {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  list-style: none;
}
.upload-item {
  display: grid;
  gap: 7px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafbf9;
}
.upload-item__top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.upload-item__icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 7px;
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.upload-item__icon .icon {
  width: 14px;
  height: 14px;
}
.upload-item__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-item__size {
  flex: none;
  font-size: 10.5px;
  color: var(--text-3);
}
.upload-item .progress {
  min-width: 0;
}
.upload-item__error {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--danger);
  overflow-wrap: anywhere;
}
.upload-item__actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.upload-item__actions:empty {
  display: none;
}

/* ------------------------------- Detalle de lote ----------------------- */
.detail-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.detail-progress {
  margin-top: 16px;
}
.detail-progress .progress__meta {
  font-size: 10.5px;
}
.table--files {
  min-width: 840px;
}
.table--norms {
  min-width: 760px;
}
.table--zip-norms,
.table--zip-entries {
  min-width: 720px;
}
.analysis-list {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.analysis-file {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fafbf9;
}
.analysis-file__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.analysis-file__head > div {
  min-width: 0;
}
.analysis-file__name {
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.analysis-file__norma {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-2);
}
.analysis-file__sumilla {
  margin-top: 8px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-2);
}
.analysis-file__sumilla:empty {
  display: none;
}
.analysis-file__counts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}
.analysis-file__error {
  margin-top: 10px;
}
.analysis-file__counts .chip .icon {
  width: 12px;
  height: 12px;
}
.analysis-block {
  margin-top: 12px;
}
.analysis-block__title {
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-3);
}
.plain-list,
.problem-list {
  display: grid;
  gap: 5px;
  padding-left: 18px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-2);
}
.plain-list li::marker {
  color: var(--text-3);
}
/* --------------------- Árbol tipado de nodos (v8) ----------------------- */
/* Compartido por la tarjeta de análisis y el editor de estructura. */
.node-tree,
.node-tree__list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.node-tree {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.node-tree__list {
  display: grid;
  gap: 4px;
  margin-top: 5px;
  padding-left: 18px;
  border-left: 1px dashed var(--border-strong);
}
.node-tree__item {
  min-width: 0;
}
.node-tree__omit {
  padding: 1px 0 1px 2px;
  font-size: 10.5px;
  font-style: italic;
  color: var(--text-3);
}
.node-tree__label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  min-width: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
}
.node-tree__text {
  min-width: 0;
  overflow-wrap: anywhere;
}
/* Nivel del tipo (v10): informativo, sólo si el catálogo/backend lo trae. */
.node-tree__level {
  flex: none;
  padding: 1px 6px;
  border: 1px dashed var(--border-strong);
  border-radius: 5px;
  background: transparent;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.5;
  white-space: nowrap;
}
.node-type {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--white);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.5;
  text-transform: uppercase;
  white-space: nowrap;
}
.node-type--documento {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--white);
  letter-spacing: 0.06em;
}
.node-type--bloque {
  border-color: #d7e98a;
  background: var(--lime-soft);
  color: #3f4a00;
}
.node-type--division {
  border-color: var(--border-strong);
  background: var(--bg);
  color: var(--text);
}
.node-type--articulo {
  border-color: #d8e4d2;
  background: #f4faf1;
  color: #2f4a2c;
}
.node-type--concordancia {
  border-style: dashed;
  background: transparent;
  color: var(--text-3);
}
.node-type--otro {
  border-style: dashed;
  background: transparent;
  color: var(--text-3);
}
.analysis-tree__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-bottom: 8px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-3);
}
.analysis-tree__summary .icon {
  width: 12px;
  height: 12px;
  flex: none;
}
.analysis-tree__hint {
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.analysis-tree {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
}
.analysis-tree__note {
  margin-top: 6px;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text-3);
}
.analysis-tree__more {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fbfcfa;
}
.analysis-tree__more > summary {
  padding: 8px 11px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.analysis-tree__more > summary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(200, 240, 0, 0.5);
  border-radius: var(--radius-sm);
}
.analysis-tree__more > .node-tree {
  margin: 0 11px 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.analysis-tree__more > .analysis-tree__note {
  margin: 0 11px 10px;
}
.problem-list {
  padding: 9px 12px 9px 28px;
  border: 1px solid #f0dcae;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  color: #6b4300;
}
.problem-list li::marker {
  color: var(--warn);
}
.preview-counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.preview-count {
  display: grid;
  gap: 1px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafbf9;
}
.preview-count__icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-bottom: 3px;
  border-radius: 6px;
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.preview-count__icon .icon {
  width: 13px;
  height: 13px;
}
.preview-count__value {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.preview-count__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.verification-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.verification-head__text {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-2);
}
.check-list {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  list-style: none;
}
.check-list__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-2);
}
.check-list__item .icon {
  width: 15px;
  height: 15px;
  flex: none;
}
.check-list__item.is-ok .icon {
  color: var(--ok);
}
.check-list__item.is-bad {
  border-color: #f6d0ca;
  background: var(--danger-bg);
}
.check-list__item.is-bad .icon {
  color: var(--danger);
}
.check-list__state {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ------------------------------- Responsive ----------------------------- */
@media (max-width: 1240px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .layout-2,
  .layout-2--wide-left {
    grid-template-columns: minmax(0, 1fr);
  }
  .topbar {
    padding: 0 22px;
  }
  .main {
    padding: 26px 24px 48px;
  }
  .user__text strong,
  .user__text span {
    max-width: 130px;
  }
}
@media (max-width: 1100px) {
  .chip--tenant {
    display: none;
  }
  .country-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 900px) {
  :root {
    --topbar-h: 66px;
  }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .sidebar__close {
    display: inline-flex;
  }
  .app__body {
    margin-left: 0;
  }
  .topbar__menu {
    display: inline-flex;
  }
  .topbar__titles {
    flex: 1;
  }
  .main {
    padding: 22px 20px 48px;
  }
  .user {
    padding-left: 10px;
  }
  .layout-2 {
    gap: 16px;
  }
  .page-head {
    align-items: flex-start;
  }
}
@media (max-width: 760px) {
  .user__text {
    display: none;
  }
  .user {
    padding-left: 0;
    border-left: 0;
  }
  #logout-btn .btn__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  #logout-btn {
    width: 38px;
    padding: 0;
  }
  .topbar {
    gap: 10px;
    padding: 0 16px;
  }
  .topbar__actions {
    gap: 8px;
  }
  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 18px;
  }
  .page-head__title {
    font-size: 23px;
  }
  .page-head__actions {
    flex-wrap: wrap;
  }
  .page-head__actions .btn {
    flex: 1;
    min-width: 150px;
  }
  .page-head__actions .btn--icon {
    flex: 0 0 42px;
    min-width: 42px;
  }
  .main {
    padding: 20px 16px 44px;
  }
  .card__head {
    padding: 16px 16px 12px;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 0 16px 14px;
  }
  .toolbar__meta {
    order: -1;
  }
  .tabpanel {
    padding: 16px;
  }
  .readonly-form {
    padding: 0 16px 16px;
  }
  .ai-card__model {
    margin: 0 16px 14px;
  }
  .ai-card__body {
    padding: 0 16px 16px;
  }
  .mcp-card__head {
    padding: 16px 16px 0;
  }
  .mcp-card p {
    padding: 10px 16px 14px;
  }
  .mcp-card .btn {
    margin: 0 16px 16px;
    width: calc(100% - 32px);
  }
  .shortcut {
    padding: 11px 16px;
  }
  .dialog__head {
    padding: 18px 18px 10px;
  }
  .dialog__body {
    padding: 8px 18px 18px;
  }
  .dialog__foot {
    padding: 14px 18px;
  }
  .card__head-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .card__head--actions {
    flex-wrap: wrap;
  }
  .card__head-actions .btn {
    flex: 1;
    min-width: 132px;
  }
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .form-actions .btn {
    width: 100%;
  }
  .form-status {
    min-width: 0;
    order: 2;
  }
  .detail-stack {
    gap: 16px;
  }
  .table-hint {
    display: block;
  }
  .verification-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
  }
  .alert__actions .btn {
    width: 100%;
  }
  .alert__action-hint {
    flex-basis: 100%;
  }
  .test-card__message {
    font-size: 11.5px;
  }
  .toasts {
    right: 12px;
    bottom: 12px;
  }
}
@media (max-width: 560px) {
  .auth {
    padding: 28px 16px;
  }
  .auth__card {
    padding: 26px 22px 22px;
    border-radius: 18px;
  }
  .auth__title {
    font-size: 24px;
  }
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .form-grid__full {
    grid-column: auto;
  }
  .stats {
    gap: 10px;
  }
  .stat {
    padding: 14px;
    border-radius: 14px;
  }
  .stat__value {
    font-size: 29px;
    margin-top: 9px;
  }
  .stat__label {
    font-size: 9.5px;
  }
  .stat__hint {
    font-size: 10.5px;
  }
  .stat__icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }
  .stat__icon .icon {
    width: 15px;
    height: 15px;
  }
  .card {
    border-radius: 14px;
  }
  .kv--grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .params {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
  .plan-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .empty {
    padding: 34px 16px;
  }
  .state {
    padding: 40px 18px;
  }
  .tabs {
    padding: 0 10px;
  }
  .tab {
    padding: 0 9px;
    font-size: 12px;
  }
  .topbar__title {
    font-size: 16px;
  }
  .topbar__eyebrow {
    font-size: 8.5px;
    letter-spacing: 0.12em;
  }
  .page-head__desc {
    font-size: 12px;
  }
  .dropzone {
    padding: 24px 14px;
  }
  .upload-item__top {
    flex-wrap: wrap;
  }
  .upload-item__size {
    margin-left: 34px;
  }
  .preview-counts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .analysis-file {
    padding: 12px;
  }
  .analysis-file__head {
    flex-direction: column;
    gap: 6px;
  }
  .card__head-actions .btn {
    min-width: 0;
  }
  .dialog {
    width: calc(100vw - 20px);
    max-height: 94dvh;
    border-radius: 16px;
  }
  .dialog--full-mobile {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
  .dialog--full-mobile .dialog__form {
    height: 100%;
  }
  .dialog--full-mobile .dialog__body {
    flex: 1;
  }
  .dialog__title {
    font-size: 19px;
  }
  .dialog__foot .btn {
    flex: 1;
  }
  .toasts {
    width: calc(100vw - 24px);
  }
  .auth__copy {
    text-align: center;
  }
}
@media (max-width: 380px) {
  .stats {
    grid-template-columns: minmax(0, 1fr);
  }
  .main {
    padding: 16px 12px 40px;
  }
  .topbar {
    padding: 0 12px;
  }
  .auth__card {
    padding: 22px 18px;
  }
}

/* ------------------------------- Movimiento ----------------------------- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.94);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .sk {
    background: #ecefec;
  }
}

/* ==========================================================================
   Portal v2 · Visor de normas y cola de trabajos
   Reutiliza los tokens y componentes del portal (cards, chips, tablas, kv).
   ========================================================================== */

/* --------------------------- Diálogo compacto --------------------------- */
.dialog--sm {
  width: min(520px, calc(100vw - 32px));
}
.input--textarea {
  min-height: 108px;
  padding: 10px 12px;
  line-height: 1.55;
  resize: vertical;
}
.despublicar-target,
.confirm-target {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

/* --------------------------- Filtros de normas -------------------------- */
.normas-filters__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px;
  align-items: end;
}
.normas-filters__field {
  min-width: 0;
}
.normas-filters__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 1px;
}
.normas-filters__actions .btn {
  flex: 1;
  min-width: 96px;
}
.normas-filters-card .card__body {
  padding-bottom: 18px;
}
.normas-results__empty {
  padding: 6px 18px 0;
}
.normas-actions {
  flex-wrap: wrap;
}

/* Exportación de la norma: grupo de descargas TXT/PDF junto a «Volver». */
.norma-export {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: none;
}
@media (max-width: 760px) {
  .norma-export {
    flex: 1 1 100%;
  }
  .norma-export .btn {
    flex: 1;
  }
}

/* --------------------------- Paginación --------------------------------- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}
.pagination__meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
}
.pagination__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.pagination__page {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-2);
  white-space: nowrap;
}

/* --------------------------- Detalle de norma --------------------------- */
.norma-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr);
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}
.norma-aside {
  display: grid;
  gap: 18px;
  min-width: 0;
}
.norma-sumilla {
  max-width: 78ch;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  overflow-wrap: anywhere;
}
.unit-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.unit {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fafbf9;
}
.unit__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.unit__title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.unit__body {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.unit__body--empty {
  color: var(--text-3);
  font-style: italic;
}
.tree,
.tree .tree {
  margin: 0;
  padding: 0;
  list-style: none;
}
.tree {
  display: grid;
  gap: 6px;
}
.tree .tree {
  margin-top: 6px;
  padding-left: 16px;
  border-left: 1px dashed var(--border-strong);
}
.tree__item {
  min-width: 0;
}
.tree__label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.tag--xs {
  padding: 1px 6px;
  font-size: 9px;
  border-radius: 5px;
}
.norma-layout .analysis-block {
  margin-top: 16px;
}

/* --------------------------- Historial (timeline) ----------------------- */
.timeline {
  position: relative;
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0 0 0 20px;
  list-style: none;
}
.timeline::before {
  content: "";
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 4px;
  width: 1px;
  background: var(--border-strong);
}
.timeline__item {
  position: relative;
  min-width: 0;
}
.timeline__dot {
  position: absolute;
  top: 4px;
  left: -20px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--white);
  border-radius: 50%;
  background: var(--lime-dark);
  box-shadow: 0 0 0 1px var(--border-strong);
}
.timeline__top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 10px;
}
.timeline__action {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.timeline__date {
  font-family: var(--font-mono);
  font-size: 10px;
  white-space: nowrap;
}
.timeline__meta {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-3);
  overflow-wrap: anywhere;
}
.timeline__states {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--white);
  font-size: 10.5px;
  color: var(--text-2);
}
.timeline__states .icon {
  width: 11px;
  height: 11px;
}
.timeline__detail {
  margin-top: 6px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

/* --------------------------- Preview de norma --------------------------- */
.preview-norma-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
}
.preview-norma-meta .chip .icon {
  width: 12px;
  height: 12px;
}

/* --------------------------- Cola de trabajos --------------------------- */
.job-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fafbf9;
}
.job-panel__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.job-panel__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #dce6ae;
  border-radius: 10px;
  background: var(--lime-soft);
  color: var(--ink);
}
.job-panel__icon .icon {
  width: 18px;
  height: 18px;
}
.job-panel__titles {
  flex: 1;
  min-width: 0;
}
.job-panel__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.job-panel__msg {
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.job-panel__progress {
  gap: 6px;
}
.job-panel__progress .progress__bar {
  height: 8px;
}
.job-panel__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 10.5px;
  color: var(--text-3);
}
.job-panel__meta > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.job-panel__meta .icon {
  width: 12px;
  height: 12px;
}
.job-panel__meta .chip {
  font-size: 10px;
}
.job-panel__meta .chip .spinner {
  width: 11px;
  height: 11px;
  border-width: 1.6px;
}
.job-panel__error {
  margin: 0;
}
.job-panel__result {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
}
.job-panel__result-title {
  margin-bottom: 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-3);
}
.job-result__counts {
  margin-bottom: 0;
}
.job-panel__result .check-list {
  margin-top: 10px;
}
.job-panel__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.job-history {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.job-history__title {
  margin-bottom: 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-3);
}
.job-history__list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.job-history__button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}
.job-history__button:hover {
  border-color: var(--border);
  background: var(--white);
}
.job-history__button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}
.job-history__type {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
}
.job-history__date {
  font-size: 10.5px;
  white-space: nowrap;
}
.job-history__pct {
  min-width: 34px;
  font-size: 10px;
  color: var(--text-3);
  text-align: right;
}
.chip .spinner {
  width: 12px;
  height: 12px;
  border-width: 1.8px;
}

/* --------------------------- Responsive v2 ------------------------------ */
@media (max-width: 1100px) {
  .norma-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 900px) {
  .normas-filters__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 760px) {
  .job-panel__head {
    flex-wrap: wrap;
  }
  .job-panel__head .chip {
    order: 3;
  }
  .job-panel {
    padding: 13px;
  }
  .card__head--actions {
    flex-wrap: wrap;
  }
  .card__head--actions .card__head-actions {
    width: 100%;
    justify-content: flex-start;
  }
  #detail-jobs-card .card__head-actions .btn {
    flex: 1 1 100%;
    justify-content: center;
  }
  .normas-actions .btn {
    flex: 1 1 auto;
  }
}
@media (max-width: 560px) {
  .normas-filters__grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .normas-filters__actions .btn {
    flex: 1;
  }
  .norma-sumilla {
    font-size: 13px;
  }
  .unit {
    padding: 12px;
  }
  .pagination {
    flex-direction: column;
    align-items: stretch;
  }
  .pagination__actions {
    justify-content: space-between;
  }
  .job-panel__actions {
    justify-content: stretch;
  }
  .job-panel__actions .btn {
    flex: 1;
  }
  .job-history__date {
    display: none;
  }
  .timeline {
    padding-left: 18px;
  }
  .timeline__dot {
    left: -18px;
  }
}


/* ==========================================================================
   Portal v4 · Selección múltiple, acciones masivas y borrado
   Reutiliza tokens, cards, tablas, chips y diálogos de confirmación.
   ========================================================================== */

/* --------------------------- Checkbox de fila --------------------------- */
.cell-check {
  width: 54px;
  padding-right: 6px !important;
  text-align: center;
}
.row-check {
  width: 17px;
  height: 17px;
  margin: 0;
  vertical-align: middle;
  accent-color: var(--ink);
  cursor: pointer;
}
.row-check:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.row-check:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.row-check-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.3;
  color: var(--text-3);
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
.table tbody tr.is-selected {
  background: rgba(200, 240, 0, 0.14);
}
.table tbody tr.is-selected:hover {
  background: rgba(200, 240, 0, 0.22);
}

/* --------------------------- Barra masiva ------------------------------- */
.bulk-bar {
  display: grid;
  gap: 9px;
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  background: #fafbf9;
}
.bulk-bar--compact {
  margin: 12px 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  padding: 10px 12px;
  gap: 7px;
}
.bulk-bar__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.bulk-bar__count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
}
.bulk-bar__count strong {
  font-weight: 700;
  color: var(--ink);
}
.bulk-bar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.bulk-bar__actions .btn {
  justify-content: center;
}
.bulk-bar__hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-3);
}
.bulk-summary {
  align-items: flex-start;
}
.bulk-summary__body {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.bulk-summary__title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}
.bulk-summary__msg {
  font-size: 11.5px;
  line-height: 1.5;
}
.bulk-summary__errors {
  margin: 4px 0 0 18px;
  font-size: 11.5px;
  line-height: 1.5;
}
.bulk-summary__errors li {
  overflow-wrap: anywhere;
}
.alert--ok {
  border-color: #cfe39c;
  background: #f4fae8;
  color: #3c4a13;
}
.alert--ok::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  margin-top: 5px;
  border-radius: 50%;
  background: #6f9c18;
}
.normas-actions__note {
  align-self: center;
  font-size: 10.5px;
  color: var(--text-3);
}

/* Tarjeta de normas importadas del lote */
.lote-normas .card__head {
  border-bottom: 1px solid var(--border);
}
.lote-normas .bulk-bar {
  border-top: 0;
  border-bottom: 1px solid var(--border);
}
.lote-normas .bulk-bar__hint {
  padding: 0 18px 12px;
}
.lote-normas > #lote-normas-region > .bulk-bar__hint {
  padding: 10px 18px;
}

/* --------------------------- Responsive v4 ------------------------------ */
@media (max-width: 760px) {
  .bulk-bar {
    padding: 12px;
  }
  .bulk-bar__top {
    align-items: flex-start;
    flex-direction: column;
  }
  .bulk-bar__actions {
    width: 100%;
  }
  .bulk-bar__actions .btn {
    flex: 1 1 calc(50% - 8px);
  }
  .bulk-bar__actions .btn .btn__label {
    white-space: normal;
  }
  .cell-check {
    width: 42px;
    padding-left: 8px !important;
  }
  .row-check-wrap {
    font-size: 9.5px;
  }
  .card__head--actions .card__head-actions .btn {
    flex: 1 1 auto;
  }
}
@media (max-width: 420px) {
  .bulk-bar__actions .btn {
    flex: 1 1 100%;
  }
}

/* ====================== Editor de estructura (análisis) ================= */
/* Botón/selector «Editar estructura» dentro de cada tarjeta de análisis. */
.analysis-file__editor {
  display: grid;
  gap: 6px;
  margin: 12px 0 4px;
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: #fbfcfa;
}
.analysis-file__editor-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}
.analysis-file__editor-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
}
.analysis-file__editor-label .icon {
  width: 13px;
  height: 13px;
}
.analysis-file__editor-norma {
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}
.analysis-file__editor-select {
  flex: 1 1 260px;
  min-width: 0;
  max-width: 560px;
}
.analysis-file__editor-select .input {
  width: 100%;
}
.analysis-file__editor-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--warn-ink, #6b4300);
}
/* Nombre completo de la norma elegida (el <select> recorta su texto). */
.analysis-file__editor-current {
  margin: 0;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  overflow-wrap: anywhere;
}
.input--sm {
  height: 36px;
  padding: 0 32px 0 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.analysis-quality {
  margin-top: 12px;
}
.analysis-quality .analysis-file__counts {
  margin-top: 0;
}
.analysis-quality__alert {
  margin-top: 8px;
}

/* Diálogo grande del editor. */
.dialog--xl {
  width: min(1060px, calc(100vw - 32px));
  max-height: min(94vh, 940px);
  max-height: min(94dvh, 940px);
}
.structure-dialog__body {
  gap: 14px;
  min-width: 0;
}
.structure-dialog__body > #structure-alert {
  position: sticky;
  top: -10px;
  z-index: 3;
  box-shadow: 0 10px 24px -18px rgba(11, 13, 12, 0.7);
}
.structure-meta {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.structure-body {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.structure-optional {
  font-weight: 500;
  color: var(--text-3);
}
.structure-required {
  color: var(--danger);
}
.structure-context {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.structure-context__hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-3);
}
.structure-fieldset {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}
.structure-fieldset:disabled {
  opacity: 0.85;
}
.structure-section {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 16px);
  background: var(--white);
  min-width: 0;
}
.structure-section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 14px;
}
.structure-section__title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.structure-section__desc {
  margin-top: 3px;
  max-width: 72ch;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-3);
}
.structure-section__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.structure-grid {
  row-gap: 14px;
}
.structure-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.structure-empty {
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-3);
  text-align: center;
}
.structure-row {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fcfdfb;
}
.structure-row__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.structure-row__index {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
}
.structure-row__title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.structure-row__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.structure-row__tools .btn--sm {
  height: 30px;
  padding: 0 9px;
  font-size: 11px;
}
.structure-row__delete {
  color: var(--danger);
}
.structure-row__delete:hover:not(:disabled) {
  background: var(--danger-bg);
  color: #8f1d14;
}
.structure-row__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.7fr) minmax(0, 1.4fr) minmax(0, 0.55fr);
  gap: 10px 12px;
}
.structure-row__grid--compact {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) minmax(0, 0.55fr);
}
.structure-row__grid--compact .form-grid__full {
  grid-column: 1 / -1;
}
.structure-row__grid .field {
  gap: 5px;
  min-width: 0;
}
.structure-row__grid .field__label {
  font-size: 11px;
}
.structure-unit-row__body {
  min-height: 120px;
  height: auto;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.55;
  resize: vertical;
}
.structure-row__meta {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text-3);
  overflow-wrap: anywhere;
}
.structure-node-row {
  border-left: 3px solid #c8f000;
  padding-left: calc(12px + var(--node-depth, 0) * 22px);
}
.structure-node-row[data-depth="0"] {
  border-left-color: var(--border-strong);
}
.structure-tree {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: #fbfcfa;
}
.structure-tree__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
}
.structure-tree__title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.structure-tree__desc {
  max-width: 72ch;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-3);
}
.structure-tree__body {
  min-width: 0;
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}
.structure-tree__body .structure-empty {
  padding: 12px;
}
.structure-json {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fbfcfa;
}
.structure-json__summary {
  padding: 11px 13px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.structure-json__summary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(200, 240, 0, 0.5);
  border-radius: var(--radius-md);
}
.structure-json__pre {
  max-width: 100%;
  max-height: 300px;
  margin: 0;
  padding: 12px 13px;
  overflow: auto;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-2);
  white-space: pre;
  tab-size: 2;
}
.structure-json__pre:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(200, 240, 0, 0.6);
}
.structure-retry {
  display: flex;
  justify-content: flex-start;
}
.structure-dialog__foot {
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
}
.structure-dialog__status {
  margin: 0;
  flex: 1 1 200px;
  min-width: 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-3);
}
.structure-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}
.structure-dialog__actions .btn {
  flex: none;
}
@media (max-width: 900px) {
  .structure-row__grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .structure-row__grid--compact {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}
@media (max-width: 760px) {
  .structure-section {
    padding: 13px;
  }
  .structure-row__grid,
  .structure-row__grid--compact {
    grid-template-columns: minmax(0, 1fr);
  }
  .structure-row__tools {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }
  .structure-dialog__foot {
    flex-direction: column;
    align-items: stretch;
  }
  .structure-dialog__actions {
    width: 100%;
  }
  .structure-dialog__actions .btn {
    flex: 1 1 auto;
  }
  .structure-json__pre {
    max-height: 220px;
  }
  .node-tree__list {
    padding-left: 13px;
  }
  .structure-tree {
    padding: 10px;
  }
  .structure-tree__body {
    max-height: 320px;
  }
}
@media (max-width: 420px) {
  .node-tree__list {
    padding-left: 10px;
  }
  .node-tree__label {
    font-size: 11.5px;
    gap: 3px 6px;
  }
  .node-type {
    padding: 1px 4px;
    font-size: 8px;
    letter-spacing: 0.03em;
  }
}
@media (max-width: 560px) {
  .dialog--xl {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
  .dialog--xl .dialog__form {
    height: 100%;
  }
  .dialog--xl .dialog__body {
    flex: 1;
  }
}

/* ==========================================================================
   Portal v6 · Seguridad: Usuarios y Roles (sólo SUPERADMIN)
   Reutiliza tokens, cards, toolbar, tablas, chips y diálogos del portal.
   ========================================================================== */

/* --------------------------- Campos y ayudas ---------------------------- */
.field__error {
  margin: 6px 0 0;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--danger);
}
.checkbox__meta {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--text-3);
}
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 9px;
  margin-top: 10px;
}
.usuario-roles .field__hint {
  margin-top: 4px;
}
.usuario-roles .checkbox {
  min-height: 52px;
}
.chip--inline {
  height: 20px;
  margin-left: 6px;
  padding: 0 7px;
  font-size: 10px;
  vertical-align: middle;
}
.chip--inline .icon {
  width: 11px;
  height: 11px;
  margin-right: 3px;
}

/* ------------------------------- Filtros -------------------------------- */
.toolbar--seguridad {
  align-items: flex-end;
  flex-wrap: wrap;
  row-gap: 10px;
}
.seguridad-filtros {
  display: flex;
  flex: 1 1 420px;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  min-width: 0;
}
.seguridad-filtros__field {
  flex: 1 1 200px;
  min-width: 160px;
}
.seguridad-filtros__field--wide {
  flex-basis: 340px;
}

/* -------------------------- Tablas de seguridad ------------------------- */
.table--usuarios {
  min-width: 860px;
}
.table--roles {
  min-width: 720px;
}
.table--seguridad:has(.table__empty) {
  min-width: 0;
  table-layout: fixed;
}
.table--seguridad:has(.table__empty) thead {
  display: none;
}
.table--seguridad th:first-child,
.table--seguridad td:first-child {
  min-width: 220px;
}
.table--seguridad th:last-child,
.table--seguridad td:last-child {
  min-width: 210px;
}
.table--seguridad .cell-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.table--roles .cell-sub {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.cell-user .avatar {
  width: 32px;
  height: 32px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
}
.cell-user__text {
  min-width: 0;
}
.cell-user__text .cell-sub {
  overflow-wrap: anywhere;
}
.role-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 320px;
}
.role-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--white);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
}
.role-badge--super {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--lime);
}
.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  padding: 0 7px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.row-actions .btn {
  white-space: nowrap;
}
.row-actions__danger:not(:disabled) {
  color: var(--danger);
}
.row-actions__danger:not(:disabled):hover {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

/* --------------------------- Matriz de permisos ------------------------- */
.rol-permisos {
  margin-top: 2px;
}
.rol-permisos > legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.rol-permisos__count {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-3);
  text-transform: none;
}
.rol-permisos__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 10px;
}
.rol-permisos__search {
  flex: 0 1 320px;
  min-width: 0;
}
.rol-permisos__search .field__label {
  margin-bottom: 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.rol-permisos__tools .field__hint {
  flex: 1 1 280px;
  margin: 0 0 4px;
}
.perm-matrix {
  display: grid;
  gap: 12px;
}
.perm-group {
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: #fbfcfa;
}
.perm-group__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}
.perm-group__title-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.perm-group__title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-transform: uppercase;
}
.perm-group__count,
.perm-resource__count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.perm-resource {
  padding: 10px 12px 12px;
  border-top: 1px dashed var(--border);
}
.perm-resource:first-of-type {
  border-top: 0;
}
.perm-resource__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.perm-resource__name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
}
.perm-resource__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}
.perm-check {
  min-height: 48px;
  padding: 8px 10px;
  align-items: flex-start;
}
.perm-check .checkbox__box {
  margin-top: 2px;
}
.perm-check .checkbox__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.perm-check__action {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
}
.perm-check__meta {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-3);
  overflow-wrap: anywhere;
}
.perm-check__desc {
  font-size: 10.5px;
  font-weight: 400;
  line-height: 1.35;
  color: var(--text-2);
}
.perm-check:has(input:disabled) {
  opacity: 0.75;
  cursor: default;
}

/* ----------------------- Diálogo de rol: pie ---------------------------- */
.rol-dialog__foot {
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
}
.rol-dialog__status {
  flex: 1 1 200px;
  min-width: 0;
  margin: 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-3);
}
.rol-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}
.rol-dialog__actions .btn {
  flex: none;
}

/* ------------------------------ Responsive ------------------------------ */
@media (max-width: 900px) {
  .table--seguridad th:first-child,
  .table--seguridad td:first-child {
    min-width: 200px;
  }
}
@media (max-width: 760px) {
  .toolbar--seguridad {
    align-items: stretch;
  }
  .seguridad-filtros {
    flex-direction: column;
    align-items: stretch;
  }
  .seguridad-filtros__field {
    flex: 1 1 auto;
    width: 100%;
  }
  .row-actions {
    justify-content: flex-start;
  }
  .table--seguridad .cell-actions {
    text-align: left;
  }
  .perm-resource__list {
    grid-template-columns: minmax(0, 1fr);
  }
  .rol-permisos__tools {
    flex-direction: column;
    align-items: stretch;
  }
  .rol-permisos__search {
    flex: 1 1 auto;
  }
  .rol-dialog__foot {
    flex-direction: column;
    align-items: stretch;
  }
  .rol-dialog__actions {
    width: 100%;
  }
  .rol-dialog__actions .btn {
    flex: 1 1 auto;
  }
}
@media (max-width: 560px) {
  .checkbox-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .role-badges {
    max-width: 100%;
  }
  .perm-group__head {
    padding: 9px 10px;
  }
  .perm-resource {
    padding: 9px 10px 10px;
  }
  .table--seguridad th:first-child,
  .table--seguridad td:first-child {
    min-width: 180px;
  }
}


/* ---------------------- Catálogos parametrizados (v9) -------------------- */
.catalogo-panel {
  padding: 18px 20px 20px;
}
.catalogo-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.catalogo-toolbar__search {
  flex: 1 1 320px;
  min-width: 200px;
  max-width: 460px;
}
.catalogo-toolbar__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.catalogo-toolbar__meta .toolbar__meta {
  margin: 0;
}
.table--catalogo {
  min-width: 860px;
}
.table--catalogo:has(.table__empty) {
  min-width: 0;
  table-layout: fixed;
}
.table--catalogo:has(.table__empty) thead {
  display: none;
}
.table--catalogo .cell-actions {
  min-width: 230px;
  text-align: right;
}
.catalogo-code {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--white);
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 600;
}
.catalogo-desc {
  display: block;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Nivel jerárquico de tipos de sección/nodo (v10): badge numérico + etiqueta.
   Se mantiene junto a la columna Orden, porque `nivel` (profundidad) y `orden`
   (presentación) son datos distintos. */
.catalogo-nivel {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
}
.catalogo-nivel .chip--inline {
  margin-left: 0;
}
.catalogo-nivel__badge {
  gap: 2px;
  white-space: nowrap;
}
.catalogo-nivel .cell-sub {
  white-space: nowrap;
}
.catalogo-nivel--sin {
  white-space: nowrap;
}
.catalogo-field--switch {
  padding-top: 2px;
}
.catalogo-field--switch .checkbox {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fbfcfb;
}
.catalogo-field--switch .checkbox__meta {
  margin-top: 1px;
}
#catalogo-fields .input.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}
@media (max-width: 900px) {
  .table--catalogo .cell-actions {
    text-align: left;
  }
}
@media (max-width: 760px) {
  .catalogo-panel {
    padding: 14px 14px 16px;
  }
  .catalogo-toolbar {
    align-items: stretch;
  }
  .catalogo-toolbar__search {
    max-width: none;
  }
  .catalogo-toolbar__meta {
    justify-content: space-between;
  }
  .table--catalogo {
    min-width: 780px;
  }
}
@media (max-width: 560px) {
  .catalogo-toolbar__meta {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .catalogo-toolbar__meta .btn {
    width: 100%;
    justify-content: center;
  }
  .catalogo-desc {
    max-width: 220px;
  }
}

/* Las pestañas del mantenedor se ajustan en varias filas para no recortar la
   última pestaña en 1440 y mantener 390 sin desplazamiento de página. */
.catalogs-card .tabs {
  flex-wrap: wrap;
  row-gap: 0;
}
.catalogs-card .tab {
  height: 42px;
}
