/* ============================================================================
   SRCG · Contabilidad, Facturación SLA & Conciliación Fiscal — Capa de Diseño
   Identidad visual SRCG v3: banda oscura (#0B1512), esmeralda (#0E5A44) y
   champagne (#9C7E43); Archivo (títulos, ancho 85%) + Public Sans (texto) +
   IBM Plex Mono (folios, RFC, UUID, cronómetros SLA).
   ========================================================================== */
:root {
  --paper: #F4F5F1;
  --surface: #FFFFFF;
  --surface-2: #FAFAF7;
  --ink: #10201B;
  --muted: #4F5F59;
  --line: #D9DDD5;
  --line-soft: #E8EBE4;
  --emerald: #0E5A44;
  --emerald-hi: #0A4635;
  --emerald-soft: #E3EEE9;
  --on-emerald: #F6F2E8;
  --gold: #9C7E43;
  --gold-ink: #7E6532;
  --gold-soft: #F3EDDF;
  --ok: #0E6B4A;
  --ok-soft: #E1F1E9;
  --bad: #A3352B;
  --bad-soft: #F7E4E1;
  --warn: #8A6417;
  --warn-soft: #F6EED9;
  --info: #2F5D8A;
  --info-soft: #E4ECF4;
  --hero-bg: #0B1512;
  --hero-ink: #EDE8DC;
  --hero-muted: #A9B3AD;
  --hero-gold: #D2B97F;
  --hero-line: rgba(210, 185, 127, .18);
  --f-display: "Archivo", "Arial Narrow", Arial, sans-serif;
  --f-body: "Public Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 4px;
  --radius-lg: 6px;
  --shadow: 0 1px 2px rgba(11, 21, 18, .04), 0 8px 24px -14px rgba(11, 21, 18, .16);
  --sidebar-w: 258px;

  /* Bootstrap re-tematizado */
  --bs-body-font-family: var(--f-body);
  --bs-body-bg: var(--paper);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-border-radius: var(--radius);
  --bs-border-radius-sm: 3px;
  --bs-border-radius-lg: var(--radius-lg);
  --bs-primary: #0E5A44;
  --bs-primary-rgb: 14, 90, 68;
  --bs-link-color: var(--emerald);
  --bs-link-hover-color: var(--emerald-hi);
  --bs-secondary-color: var(--muted);
  --bs-emphasis-color: var(--ink);
  --bs-tertiary-bg: var(--surface-2);
  --bs-focus-ring-color: rgba(156, 126, 67, .35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0D1613;
    --surface: #132019;
    --surface-2: #16241D;
    --ink: #ECE8DD;
    --muted: #A3AFA9;
    --line: #26352F;
    --line-soft: #1E2C26;
    --emerald: #3E9E7F;
    --emerald-hi: #52B492;
    --emerald-soft: #16302A;
    --on-emerald: #0B1512;
    --gold: #D2B97F;
    --gold-ink: #E0C994;
    --gold-soft: #2C2A20;
    --ok: #52B492;
    --ok-soft: #15302A;
    --bad: #E58A7F;
    --bad-soft: #3A1F1C;
    --warn: #E0BE6E;
    --warn-soft: #332A15;
    --info: #8DB4DA;
    --info-soft: #1B2836;
    --bs-primary: #3E9E7F;
    --bs-primary-rgb: 62, 158, 127;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #0D1613;
  --surface: #132019;
  --surface-2: #16241D;
  --ink: #ECE8DD;
  --muted: #A3AFA9;
  --line: #26352F;
  --line-soft: #1E2C26;
  --emerald: #3E9E7F;
  --emerald-hi: #52B492;
  --emerald-soft: #16302A;
  --on-emerald: #0B1512;
  --gold: #D2B97F;
  --gold-ink: #E0C994;
  --gold-soft: #2C2A20;
  --ok: #52B492;
  --ok-soft: #15302A;
  --bad: #E58A7F;
  --bad-soft: #3A1F1C;
  --warn: #E0BE6E;
  --warn-soft: #332A15;
  --info: #8DB4DA;
  --info-soft: #1B2836;
  --bs-primary: #3E9E7F;
  --bs-primary-rgb: 62, 158, 127;
  color-scheme: dark;
}

* {
  box-sizing: border-box
}

html {
  -webkit-text-size-adjust: 100%
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased
}

h1,
h2,
h3,
h4,
h5,
.display {
  font-family: var(--f-display);
  font-stretch: 85%;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.12;
  text-wrap: balance;
  color: var(--ink)
}

a {
  color: var(--emerald);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px
}

a:hover {
  color: var(--emerald-hi)
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px
}

.mono {
  font-family: var(--f-mono)
}

.num {
  font-variant-numeric: tabular-nums
}

.muted {
  color: var(--muted) !important
}

.eyebrow {
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500
}

.text-gold {
  color: var(--gold) !important
}

hr {
  border-color: var(--line);
  opacity: 1
}

/* ---------- Estructura: sidebar + contenido ---------- */
.app {
  display: flex;
  min-height: 100vh
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--hero-bg);
  color: var(--hero-ink);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  border-right: 1px solid var(--hero-line);
  transition: transform .2s ease
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--hero-line);
  text-decoration: none;
  color: var(--hero-ink)
}

.sb-brand:hover {
  color: var(--hero-ink)
}

.sb-mark {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--hero-gold);
  color: var(--hero-gold);
  font-family: var(--f-display);
  font-stretch: 85%;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .04em;
  border-radius: 3px
}

.sb-brand b {
  display: block;
  font-family: var(--f-display);
  font-stretch: 85%;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .06em;
  text-transform: uppercase;
  line-height: 1.1
}

.sb-brand small {
  display: block;
  font-size: 12px;
  color: var(--hero-muted);
  margin-top: 2px
}

.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 16px
}

.sb-group {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--hero-gold);
  opacity: .85;
  padding: 16px 10px 6px
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--hero-muted);
  text-decoration: none;
  font-size: 14px;
  border-left: 2px solid transparent;
  transition: background .15s, color .15s
}

.sb-link i {
  font-size: 16px;
  width: 18px;
  text-align: center;
  opacity: .9
}

.sb-link:hover {
  background: rgba(210, 185, 127, .08);
  color: var(--hero-ink)
}

.sb-link.active {
  background: rgba(62, 158, 127, .16);
  color: #fff;
  border-left-color: var(--hero-gold)
}

.sb-link .sb-count {
  margin-left: auto;
  font-family: var(--f-mono);
  font-size: 11px;
  background: rgba(210, 185, 127, .18);
  color: var(--hero-gold);
  padding: 1px 7px;
  border-radius: 10px
}

.sb-link .sb-count.bad {
  background: rgba(229, 138, 127, .22);
  color: #ff9b90
}

.sb-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--hero-line);
  font-size: 12px;
  color: var(--hero-muted)
}

.sb-foot b {
  color: var(--hero-gold);
  font-weight: 500
}

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: rgba(244, 245, 241, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 28px;
  min-height: 60px
}

:root[data-theme="dark"] .topbar {
  background: rgba(13, 22, 19, .92)
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .topbar {
    background: rgba(13, 22, 19, .92)
  }
}

.topbar .search {
  flex: 1;
  max-width: 440px;
  position: relative
}

.topbar .search input {
  padding-left: 36px;
  font-family: var(--f-mono);
  font-size: 13.5px;
  background: var(--surface);
  min-height: 38px
}

.topbar .search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted)
}

.topbar .user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--emerald);
  color: var(--on-emerald);
  display: grid;
  place-items: center;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 13px;
  border: 0;
  cursor: pointer;
  transition: box-shadow .15s
}

.avatar:hover {
  box-shadow: 0 0 0 3px var(--emerald-soft)
}

.user-meta {
  line-height: 1.2;
  text-align: right
}

.user-meta b {
  display: block;
  font-size: 13.5px;
  font-weight: 600
}

.user-meta small {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--gold);
  letter-spacing: .06em;
  text-transform: uppercase
}

.menu-btn {
  display: none;
  width: 40px;
  padding: 0
}

.content {
  padding: 24px 28px 48px;
  width: 100%;
  max-width: 1480px
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%)
  }

  .app.nav-open .sidebar {
    transform: none;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45)
  }

  .main {
    margin-left: 0
  }

  .menu-btn {
    display: inline-flex
  }

  .topbar {
    padding: 10px 16px
  }

  .content {
    padding: 18px 16px 40px
  }

  .user-meta {
    display: none
  }
}

/* ---------- Encabezado de página ---------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px
}

.page-head h1 {
  font-size: 29px;
  margin: 4px 0 0
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 74ch
}

.page-head .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px
}

.crumbs {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 2px
}

.crumbs a {
  color: var(--muted);
  text-decoration: none
}

.crumbs a:hover {
  color: var(--emerald)
}

/* ---------- Tarjetas & KPIs ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  --bs-card-bg: var(--surface)
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft)
}

.card-head h2,
.card-head h3 {
  font-size: 17px;
  margin: 0
}

.card-body {
  padding: 18px
}

.card-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg)
}

.kpi {
  position: relative;
  padding: 16px 18px;
  height: 100%;
  border-top: 3px solid var(--emerald)
}

.kpi.gold {
  border-top-color: var(--gold)
}

.kpi.bad {
  border-top-color: var(--bad)
}

.kpi.warn {
  border-top-color: var(--warn)
}

.kpi.info {
  border-top-color: var(--info)
}

.kpi .label {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted)
}

.kpi .value {
  font-family: var(--f-display);
  font-stretch: 85%;
  font-weight: 700;
  font-size: 29px;
  line-height: 1.1;
  margin-top: 6px;
  font-variant-numeric: tabular-nums
}

.kpi .sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px
}

.kpi i.ico {
  position: absolute;
  right: 16px;
  top: 14px;
  font-size: 20px;
  color: var(--gold);
  opacity: .75
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .48rem;
  min-height: 40px;
  padding: .5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: 600 14px/1.2 var(--f-body);
  letter-spacing: .005em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  color: var(--ink);
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .05s ease
}

.btn i {
  font-size: 1.05em;
  line-height: 1
}

.btn:hover {
  text-decoration: none
}

.btn:active:not(:disabled) {
  transform: translateY(1px)
}

.btn:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--field-ring, rgba(14, 90, 68, .16)), 0 0 0 1px var(--gold)
}

.btn:disabled,
.btn.disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none
}

.btn-sm {
  min-height: 32px;
  padding: .28rem .68rem;
  font-size: 13px;
  gap: .38rem
}

.btn-xs {
  min-height: 26px;
  padding: .18rem .5rem;
  font-size: 12px;
  gap: .3rem
}

.btn-lg {
  min-height: 48px;
  padding: .7rem 1.3rem;
  font-size: 15.5px
}

.w-100.btn {
  width: 100%
}

.btn-primary {
  background: var(--emerald);
  border-color: var(--emerald);
  color: var(--on-emerald);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 1px 2px rgba(11, 21, 18, .18)
}

.btn-primary:hover,
.btn-primary:active {
  background: var(--emerald-hi);
  border-color: var(--emerald-hi);
  color: var(--on-emerald)
}

.btn-gold {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
  box-shadow: 0 1px 2px rgba(11, 21, 18, .18)
}

.btn-gold:hover,
.btn-gold:active {
  background: var(--gold-ink);
  border-color: var(--gold-ink);
  color: #fff
}

.btn-outline,
.btn-secondary,
.btn-light {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: 0 1px 1px rgba(11, 21, 18, .04)
}

.btn-outline i {
  color: var(--gold)
}

.btn-outline:hover,
.btn-outline:active {
  background: var(--emerald-soft);
  border-color: var(--emerald);
  color: var(--emerald)
}

.btn-outline:hover i {
  color: var(--emerald)
}

.btn-danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff
}

.btn-danger:hover,
.btn-danger:active {
  background: #86281F;
  border-color: #86281F;
  color: #fff
}

.btn-warn {
  background: var(--warn);
  border-color: var(--warn);
  color: #fff
}

.btn-warn:hover,
.btn-warn:active {
  background: #6E4F10;
  border-color: #6E4F10;
  color: #fff
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  box-shadow: none
}

.btn-ghost:hover,
.btn-ghost:active {
  background: var(--emerald-soft);
  color: var(--emerald)
}

/* Dropdowns */
.dropdown {
  position: relative
}

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  z-index: 1050;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px -12px rgba(11, 21, 18, .35)
}

.dropdown-menu.show {
  display: block
}

.dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: .5rem .7rem;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font: 500 13.5px var(--f-body);
  text-align: left;
  text-decoration: none;
  cursor: pointer
}

.dropdown-item:hover {
  background: var(--emerald-soft);
  color: var(--emerald)
}

.dropdown-divider {
  height: 0;
  margin: 5px 0;
  border: 0;
  border-top: 1px solid var(--line-soft)
}

.collapse:not(.show) {
  display: none
}

/* ---------- Formularios ---------- */
:root {
  --field-bg: #FBFBF8;
  --field-bg-focus: #FFFFFF;
  --field-line: #CFD5CC;
  --field-line-hover: #A9B3AB;
  --field-ring: rgba(14, 90, 68, .16);
  --field-ph: #8E9A93;
  --field-h: 42px;
  --select-arrow: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239C7E43' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.6' d='m3.5 6 4.5 4.5L12.5 6'/%3e%3c/svg%3e");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --field-bg: #0F1A16;
    --field-bg-focus: #13211B;
    --field-line: #2C3D36;
    --field-line-hover: #41564D;
    --field-ring: rgba(62, 158, 127, .22);
    --field-ph: #6F7E77
  }
}

:root[data-theme="dark"] {
  --field-bg: #0F1A16;
  --field-bg-focus: #13211B;
  --field-line: #2C3D36;
  --field-line-hover: #41564D;
  --field-ring: rgba(62, 158, 127, .22);
  --field-ph: #6F7E77
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  letter-spacing: .01em
}

.form-label .req {
  color: var(--bad)
}

.form-control,
.form-select {
  min-height: var(--field-h);
  padding: .52rem .8rem;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
  background-color: var(--field-bg);
  border: 1px solid var(--field-line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 1px rgba(11, 21, 18, .03);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease
}

.form-control:hover:not(:disabled):not(:focus),
.form-select:hover:not(:disabled):not(:focus) {
  border-color: var(--field-line-hover)
}

.form-control:focus,
.form-select:focus {
  background-color: var(--field-bg-focus);
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px var(--field-ring);
  color: var(--ink);
  outline: 0
}

.form-control::placeholder {
  color: var(--field-ph);
  opacity: 1;
  font-weight: 400
}

.form-control:disabled,
.form-select:disabled {
  background-color: var(--surface-2);
  color: var(--muted);
  border-style: dashed;
  opacity: 1;
  cursor: not-allowed
}

.form-control-sm,
.form-select-sm {
  min-height: 34px;
  padding: .32rem .6rem;
  font-size: 13px
}

textarea.form-control {
  min-height: auto
}

.form-select {
  background-image: var(--select-arrow);
  background-size: 14px 14px;
  background-position: right .7rem center;
  padding-right: 2.2rem
}

.form-select-sm {
  background-position: right .55rem center;
  padding-right: 1.9rem
}

.form-control[type=file] {
  padding: .35rem .4rem;
  cursor: pointer;
  color: var(--muted);
  font-size: 13.5px
}

.form-control[type=file]::file-selector-button {
  margin: 0 .7rem 0 0;
  padding: .38rem .8rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--emerald);
  font: 600 13px var(--f-body);
  cursor: pointer;
  transition: background .15s, border-color .15s
}

.form-control[type=file]:hover::file-selector-button {
  background: var(--emerald-soft);
  border-color: var(--emerald)
}

.form-check-input {
  width: 1.05em;
  height: 1.05em;
  border: 1px solid var(--field-line-hover);
  background-color: var(--field-bg);
  cursor: pointer
}

.form-check-input:checked {
  background-color: var(--emerald);
  border-color: var(--emerald)
}

.form-text {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px
}

.input-group-text {
  background: var(--surface-2);
  border: 1px solid var(--field-line);
  color: var(--gold-ink);
  font-family: var(--f-mono);
  font-size: 13px;
  min-width: 38px;
  justify-content: center
}

.field-icon {
  position: relative
}

.field-icon>i {
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 15px;
  pointer-events: none
}

.field-icon>.form-control {
  padding-left: 2.5rem
}

.field-icon>.reveal {
  position: absolute;
  right: .35rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 3px;
  display: grid;
  place-items: center;
  cursor: pointer
}

.form-section {
  border-top: 1px solid var(--line-soft);
  padding-top: 18px;
  margin-top: 8px
}

.form-section h3 {
  font-size: 15.5px;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px
}

.form-section h3 .n {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 3px;
  padding: 1px 6px;
  font-weight: 500
}

/* ---------- Tablas ---------- */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
  --bs-table-hover-bg: var(--emerald-soft);
  --bs-table-border-color: var(--line-soft);
  margin: 0;
  font-size: 13.8px
}

.table thead th {
  font-family: var(--f-mono);
  font-size: 10.8px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
  padding: .62rem .75rem
}

.table td {
  padding: .58rem .75rem;
  vertical-align: middle
}

.table tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--line);
  background: var(--surface-2)
}

.table .code {
  white-space: nowrap;
  font-family: var(--f-mono);
  font-size: 12.8px;
  color: var(--emerald);
  text-decoration: none;
  font-weight: 600
}

.table a.code:hover {
  text-decoration: underline
}

.table-wrap {
  overflow-x: auto
}

/* ---------- Etiquetas de estatus & Semáforos SLA ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid transparent;
  white-space: nowrap;
  font-weight: 500
}

.tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor
}

.tag-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 25%, transparent)
}

.tag-bad {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 25%, transparent)
}

.tag-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 25%, transparent)
}

.tag-info {
  background: var(--info-soft);
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 25%, transparent)
}

.tag-neutral {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--line)
}

/* Cronómetro SLA en vivo */
.sla-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 3px 9px;
  border-radius: 4px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.sla-pill.ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent)
}

.sla-pill.warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent)
}

.sla-pill.bad {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
  animation: pulse-sla 2s infinite
}

.sla-pill.info {
  background: var(--info-soft);
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 30%, transparent)
}

.sla-pill.lg {
  font-size: 15px;
  padding: 6px 14px
}

@keyframes pulse-sla {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(163, 53, 43, .28)
  }

  50% {
    box-shadow: 0 0 0 4px rgba(163, 53, 43, .0)
  }
}

/* ---------- Tablero Kanban de Facturación (4 columnas) ---------- */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(275px, 1fr));
  gap: 16px;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-col {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: 760px;
}

.kanban-col-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 3px solid var(--line);
}

.kanban-col.col-nueva .kanban-col-head {
  border-top-color: var(--info)
}

.kanban-col.col-proceso .kanban-col-head {
  border-top-color: var(--gold)
}

.kanban-col.col-pausada .kanban-col-head {
  border-top-color: var(--warn)
}

.kanban-col.col-completada .kanban-col-head {
  border-top-color: var(--ok)
}

.kanban-col-title {
  font-family: var(--f-display);
  font-stretch: 85%;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.kanban-col-count {
  font-family: var(--f-mono);
  font-size: 11.5px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.kanban-col-body {
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(11, 21, 18, .04);
  transition: border-color .15s ease, transform .12s ease, box-shadow .15s ease;
  position: relative;
}

.kanban-card:hover {
  border-color: var(--emerald);
  box-shadow: 0 6px 16px -8px rgba(11, 21, 18, .18);
}

.kanban-card.sla-border-bad {
  border-left: 3px solid var(--bad)
}

.kanban-card.sla-border-warn {
  border-left: 3px solid var(--warn)
}

.kanban-card.sla-border-ok {
  border-left: 3px solid var(--ok)
}

.kanban-card.sla-border-info {
  border-left: 3px solid var(--info)
}

.kanban-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px
}

.kanban-card-folio {
  font-family: var(--f-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--emerald);
  text-decoration: none
}

.kanban-card-folio:hover {
  text-decoration: underline
}

.kanban-card-client {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.kanban-card-receptor {
  font-weight: 700;
  font-size: 13.8px;
  line-height: 1.25;
  margin-bottom: 4px;
  color: var(--ink)
}

.kanban-card-concept {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.35;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden
}

.kanban-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line-soft)
}

.kanban-card-amount {
  font-family: var(--f-display);
  font-stretch: 85%;
  font-weight: 700;
  font-size: 15.5px;
  color: var(--ink)
}

/* ---------- Zona Drag & Drop para Entrega XML / PDF y ZIP ---------- */
.dropzone-box {
  border: 2px dashed var(--field-line-hover);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  padding: 18px 16px;
  text-align: center;
  transition: border-color .15s, background-color .15s;
  cursor: pointer;
  position: relative;
}

.dropzone-box:hover,
.dropzone-box.dragover {
  border-color: var(--emerald);
  background: var(--emerald-soft);
}

.dropzone-box i.dz-icon {
  font-size: 26px;
  color: var(--gold);
  display: block;
  margin-bottom: 6px
}

.dropzone-box b {
  display: block;
  font-size: 14px;
  color: var(--ink)
}

.dropzone-box small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px
}

.dropzone-box input[type=file] {
  margin-top: 10px
}

/* ---------- Matriz Anual de Declaraciones (Clientes x 12 Meses) ---------- */
.matrix-table th,
.matrix-table td {
  text-align: center;
  padding: .5rem .4rem;
  font-size: 12.5px
}

.matrix-table th.client-col,
.matrix-table td.client-col {
  text-align: left;
  min-width: 210px;
  padding-left: .85rem
}

.matrix-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 28px;
  border-radius: 4px;
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform .1s ease, box-shadow .12s ease;
}

.matrix-cell:hover {
  transform: scale(1.08);
  text-decoration: none
}

.matrix-cell.ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 35%, transparent)
}

.matrix-cell.warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent)
}

.matrix-cell.bad {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 35%, transparent)
}

.matrix-cell.neutral {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--line-soft)
}

/* ---------- Avisos, Listas y Línea de Tiempo ---------- */
.notice {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14px;
  margin-bottom: 16px
}

.notice i {
  font-size: 18px;
  line-height: 1.2
}

.notice.ok {
  background: var(--ok-soft);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent)
}

.notice.ok i {
  color: var(--ok)
}

.notice.bad {
  background: var(--bad-soft);
  border-color: color-mix(in srgb, var(--bad) 30%, transparent)
}

.notice.bad i {
  color: var(--bad)
}

.notice.warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent)
}

.notice.warn i {
  color: var(--warn)
}

.notice.info {
  background: var(--info-soft);
  border-color: color-mix(in srgb, var(--info) 30%, transparent)
}

.notice.info i {
  color: var(--info)
}

.dl {
  display: grid;
  grid-template-columns: minmax(125px, 38%) 1fr;
  gap: 7px 14px;
  margin: 0;
  font-size: 13.8px
}

.dl dt {
  color: var(--muted);
  font-weight: 500
}

.dl dd {
  margin: 0;
  font-weight: 500
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(115px, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden
}

.stat-strip>div {
  padding: 12px 14px;
  border-right: 1px solid var(--line-soft)
}

.stat-strip>div:last-child {
  border-right: 0
}

.stat-strip .label {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted)
}

.stat-strip .value {
  font-family: var(--f-display);
  font-stretch: 85%;
  font-weight: 700;
  font-size: clamp(17px, 1.55vw, 21px);
  font-variant-numeric: tabular-nums
}

.stat-strip .value.pos {
  color: var(--ok)
}

.stat-strip .value.neg {
  color: var(--bad)
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 14px;
  border-left: 1px solid var(--line)
}

.timeline li {
  position: relative;
  padding: 0 0 14px 14px;
  font-size: 13.5px
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -19px;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--gold)
}

.timeline time {
  display: block;
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--muted)
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2)
}

.filters .f {
  min-width: 145px;
  flex: 1
}

.filters .f.sm {
  flex: 0 0 125px;
  min-width: 105px
}

.filters label {
  font-size: 11.8px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 3px;
  display: block
}

.chart-box {
  position: relative;
  height: 260px
}

.chart-box.sm {
  height: 210px
}

.bar {
  height: 6px;
  background: var(--line-soft);
  border-radius: 3px;
  overflow: hidden
}

.bar>span {
  display: block;
  height: 100%;
  background: var(--emerald)
}

.bar.gold>span {
  background: var(--gold)
}

.bar.bad>span {
  background: var(--bad)
}

.empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted)
}

.empty i {
  font-size: 28px;
  color: var(--gold);
  display: block;
  margin-bottom: 8px
}

/* Copiar dato fiscal al portapapeles */
.copy-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}

.copy-chip:hover {
  background: var(--emerald-soft);
  border-color: var(--emerald);
  color: var(--emerald)
}

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.12fr 1fr;
  background: var(--paper)
}

.login-hero {
  background: var(--hero-bg);
  color: var(--hero-ink);
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden
}

.login-hero::after {
  content: "";
  position: absolute;
  right: -120px;
  bottom: -120px;
  width: 420px;
  height: 420px;
  border: 1px solid var(--hero-line);
  border-radius: 50%
}

.login-hero::before {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -40px;
  width: 260px;
  height: 260px;
  border: 1px solid var(--hero-line);
  border-radius: 50%
}

.login-hero h1 {
  color: var(--hero-ink);
  font-size: 40px;
  max-width: 16ch;
  margin: 14px 0 16px
}

.login-hero p {
  color: var(--hero-muted);
  max-width: 48ch;
  font-size: 15.5px
}

.login-hero ul {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: grid;
  gap: 10px;
  font-size: 14px;
  color: var(--hero-muted)
}

.login-hero li i {
  color: var(--hero-gold);
  margin-right: 8px
}

.login-form {
  display: grid;
  place-items: center;
  padding: 36px 24px
}

.login-form .box {
  width: 100%;
  max-width: 410px
}

.login-form h2 {
  font-size: 28px;
  margin: 6px 0 4px
}

.demo-users {
  margin-top: 20px;
  font-size: 12.5px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface)
}

.demo-users code {
  font-family: var(--f-mono);
  color: var(--emerald);
  font-size: 12px
}

@media (max-width: 860px) {
  .login {
    grid-template-columns: 1fr
  }

  .login-hero {
    padding: 32px 20px
  }

  .login-hero h1 {
    font-size: 30px
  }

  .login-hero ul {
    display: none
  }
}

@media print {

  .sidebar,
  .topbar,
  .no-print,
  .page-head .actions {
    display: none !important
  }

  .main {
    margin: 0
  }

  .content {
    padding: 0;
    max-width: none
  }

  body {
    background: #fff
  }

  .card {
    box-shadow: none;
    border: 1px solid #ccc
  }
}