* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: linear-gradient(180deg, #eef3ff 0%, #f7f9fc 100%);
  color: #1a2440;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 290px 1fr;
}

.app-shell-plain {
  grid-template-columns: 1fr;
}

.sidebar {
  padding: 24px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
  border-right: 1px solid rgba(120, 139, 182, 0.16);
}

.brand-card,
.panel,
.auth-card,
.stat-card,
.action-card,
.helper-card,
.result-card,
.chat-shell {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(120, 139, 182, 0.18);
  box-shadow: 0 20px 48px rgba(35, 47, 85, 0.08);
  border-radius: 22px;
}

.brand-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 16px;
  margin-bottom: 22px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #3f66ff, #5d2bf4);
  font-weight: 700;
}

.nav-links {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.nav-links a {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(245, 247, 255, 0.9);
}

.nav-links a.is-active {
  background: #1e4fff;
  color: #fff;
}

.main-content {
  padding: 28px;
}

.app-shell-plain .main-content {
  padding: 0;
}

.page-head,
.two-col-grid,
.stats-grid,
.card-grid,
.button-row,
.inline-actions,
.inline-form {
  display: flex;
  gap: 16px;
}

.page-head,
.inline-form {
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.two-col-grid,
.stats-grid,
.card-grid {
  display: grid;
  margin-top: 20px;
}

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

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card,
.action-card,
.panel,
.helper-card,
.result-card {
  padding: 20px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.5rem;
}

.action-card.is-locked {
  opacity: 0.55;
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 460px);
  gap: 24px;
  align-items: stretch;
}

.auth-shell-single {
  width: min(460px, 100%);
  grid-template-columns: 1fr;
  justify-items: center;
}

.auth-showcase {
  position: relative;
  overflow: hidden;
  padding: 34px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(109, 139, 255, 0.28), transparent 28%),
    linear-gradient(145deg, #1f43d8 0%, #5d2bf4 100%);
  color: #fff;
  box-shadow: 0 26px 60px rgba(45, 63, 128, 0.22);
}

.auth-showcase .eyebrow {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.auth-showcase h1 {
  margin: 18px 0 12px;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1.05;
}

.auth-showcase p {
  max-width: 560px;
  color: rgba(255, 255, 255, 0.9);
}

.showcase-points {
  margin-top: 28px;
  display: grid;
  gap: 14px;
}

.showcase-item {
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.showcase-item strong,
.showcase-item span {
  display: block;
}

.showcase-item span {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.45;
}

.auth-card {
  width: min(100%, 460px);
  padding: 28px;
}

.auth-card-optimized {
  width: 100%;
  padding: 30px;
  display: grid;
  align-content: center;
  min-height: 100%;
}

.brand-hero h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.brand-hero h2 {
  margin: 10px 0 8px;
  font-size: 2rem;
}

.eyebrow {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(63, 102, 255, 0.12);
  color: #3054dc;
  font-size: 0.82rem;
}

.field,
.stack-md,
.stack-lg {
  display: grid;
  gap: 8px;
}

.stack-md {
  gap: 14px;
}

.stack-lg {
  gap: 18px;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid rgba(120, 139, 182, 0.26);
  background: #fff;
}

textarea {
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #1e4fff, #4d73ff);
}

.btn-secondary {
  color: #1a2440;
  background: #ecf1ff;
}

.btn-danger {
  color: #fff;
  background: #d14343;
}

.btn-ghost {
  color: #1a2440;
  background: rgba(245, 247, 255, 0.95);
  border: 1px solid rgba(120, 139, 182, 0.18);
}

.btn-icon {
  justify-content: flex-start;
}

.btn-icon-mark {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(30, 79, 255, 0.12);
  color: #1e4fff;
  font-size: 0.82rem;
  font-weight: 700;
}

.btn-small {
  padding: 8px 12px;
  border-radius: 12px;
}

.btn-block {
  width: 100%;
}

.alert {
  padding: 14px 18px;
  border-radius: 18px;
  margin-bottom: 20px;
}

.alert-error,
.error-soft {
  background: #ffe7e7;
  color: #8d1c1c;
}

.alert-success,
.success-soft {
  background: #e6fff1;
  color: #0c6a41;
}

.alert-warning {
  background: #fff5df;
  color: #895f05;
}

.muted {
  color: #5a6688;
}

.data-list {
  display: grid;
  gap: 12px;
}

.toolbar-panel {
  margin-bottom: 20px;
}

.toolbar-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
  align-items: end;
}

.toolbar-grid-filters {
  margin: 18px 0 22px;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
}

.toolbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.data-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.table-wrap {
  overflow-x: auto;
}

.table-wrap-compact {
  margin-top: 10px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 14px 10px;
  border-bottom: 1px solid rgba(120, 139, 182, 0.18);
  text-align: left;
  vertical-align: top;
}

.arca-table th {
  font-size: 0.95rem;
  font-weight: 700;
  color: #18213f;
  white-space: nowrap;
}

.arca-table td {
  color: #2b3555;
}

.arca-table .text-right,
.text-right {
  text-align: right;
}

.arca-summary-row td {
  background: rgba(255, 255, 255, 0.58);
}

.table-sort-mark {
  color: rgba(26, 36, 64, 0.28);
  font-weight: 700;
}

.table-action-col {
  width: 76px;
  text-align: center !important;
  white-space: nowrap;
}

.detail-toggle-btn {
  width: 32px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: #279bd3;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(39, 155, 211, 0.22);
}

.detail-toggle-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.detail-toggle-btn[aria-expanded="true"] {
  background: #1e4fff;
}

.voucher-photo-thumb {
  width: 46px;
  height: 58px;
  padding: 0;
  border: 1px solid rgba(26, 36, 64, 0.16);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
}

.voucher-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.voucher-photo-empty {
  color: rgba(26, 36, 64, 0.45);
  font-size: 12px;
}

.voucher-photo-card {
  width: min(860px, calc(100vw - 24px));
}

.voucher-photo-full {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 75vh;
  margin: 8px auto 0;
  border-radius: 12px;
  background: #f4f6f8;
}

body.modal-open {
  overflow: hidden;
}

.arca-detail-source {
  display: none;
}

.arca-detail-row td {
  padding: 0 10px 16px;
  background: rgba(244, 247, 255, 0.62);
}

.arca-detail-card {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 16px;
  border: 1px solid rgba(120, 139, 182, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
}

.arca-detail-section {
  display: grid;
  gap: 12px;
}

.arca-detail-section-wide {
  grid-column: 1 / -1;
}

.arca-detail-section h3 {
  margin: 0;
  font-size: 0.98rem;
  color: #18213f;
}

.detail-list,
.detail-totals-grid {
  margin: 0;
  display: grid;
  gap: 10px;
}

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

.detail-totals-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 12px;
}

.detail-list div,
.detail-totals-grid div {
  padding: 12px;
  border-radius: 14px;
  background: rgba(237, 241, 255, 0.72);
}

.detail-list dt,
.detail-totals-grid dt {
  margin-bottom: 5px;
  color: #62708f;
  font-size: 0.82rem;
}

.detail-list dd,
.detail-totals-grid dd {
  margin: 0;
  color: #1a2440;
  font-weight: 700;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 14px;
  background: #fff;
}

.mini-table th,
.mini-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(120, 139, 182, 0.14);
}

.mini-table th {
  color: #3d4a73;
  font-size: 0.86rem;
  background: rgba(237, 241, 255, 0.9);
}

.empty-state {
  text-align: center;
  color: #66728f;
}

.plain-list,
.ordered-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}

.status-chip {
  display: inline-flex;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  margin: 8px 0;
  background: #edf1ff;
}

.status-chip.valido {
  background: #e4fff1;
  color: #15754c;
}

.status-chip.duplicado,
.status-chip.error,
.status-chip.plan_limit {
  background: #ffe6e6;
  color: #9f2121;
}

.status-chip.fuera_periodo {
  background: #fff3dc;
  color: #976300;
}

.status-chip.activo,
.status-chip.habilitado,
.status-chip.conectado {
  background: #e4fff1;
  color: #15754c;
}

.status-chip.inactivo,
.status-chip.bloqueado,
.status-chip.desconectado {
  background: #ffe6e6;
  color: #9f2121;
}

.admin-filter-form {
  align-items: end;
}

.admin-filter-field {
  min-width: min(420px, 100%);
  flex: 1 1 420px;
}

.page-head-compact {
  margin-bottom: 16px;
}

.chat-shell {
  margin-top: 20px;
  padding: 20px;
}

.chat-messages {
  min-height: 380px;
  max-height: 58vh;
  overflow-y: auto;
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.chat-bubble {
  max-width: 78%;
  padding: 14px 16px;
  border-radius: 18px;
  line-height: 1.45;
}

.chat-bubble-user {
  justify-self: end;
  background: #1e4fff;
  color: #fff;
}

.chat-bubble-bot {
  background: #edf2ff;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.is-hidden {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(3px);
}

.modal-card {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 70px rgba(26, 36, 64, 0.24);
}

.modal-card-large {
  width: min(680px, calc(100vw - 24px));
}

.modal-card-wide {
  width: min(1040px, calc(100vw - 24px));
}

.dialog-body {
  padding: 24px;
  display: grid;
  gap: 16px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.dialog-body h2 {
  margin: 0;
}

.dialog-body p {
  margin: 0;
  line-height: 1.55;
}

.dialog-actions {
  padding: 0 24px 24px;
  display: flex;
  justify-content: flex-end;
}

.panel-narrow {
  width: min(720px, 100%);
}

.panel-soft {
  background: rgba(244, 247, 255, 0.72);
}

.modal-summary-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-inline {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
}

.summary-chip.success {
  background: #e4fff1;
  color: #15754c;
}

.summary-chip.warn {
  background: #fff3dc;
  color: #976300;
}

.summary-chip.neutral {
  background: #edf1ff;
  color: #3d4a73;
}

.summary-chip.error {
  background: #ffe6e6;
  color: #9f2121;
}

.scanner-result-card {
  display: grid;
  gap: 14px;
}

.scanner-result-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.scanner-detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.scanner-detail-grid span {
  display: block;
  font-size: 0.85rem;
  color: #62708f;
  margin-bottom: 4px;
}

.scanner-mobile-panel h3 {
  margin: 0 0 6px;
}

.scanner-mobile-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  align-items: start;
}

.scanner-qr-card {
  display: grid;
  place-items: center;
}

.scanner-qr-card img {
  width: min(220px, 100%);
  height: auto;
  border-radius: 18px;
}

.analysis-progress {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(30, 79, 255, 0.08);
  color: #2242a7;
}

.analysis-progress-bar {
  position: relative;
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: rgba(30, 79, 255, 0.14);
}

.analysis-progress-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 38%;
  border-radius: inherit;
  background: linear-gradient(135deg, #1e4fff, #6b8cff);
  animation: progress-slide 1.2s ease-in-out infinite;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(280%);
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid rgba(120, 139, 182, 0.16);
  }

  .two-col-grid,
  .stats-grid,
  .card-grid {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 18px;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .toolbar-grid,
  .toolbar-grid-filters,
  .modal-summary-grid,
  .scanner-mobile-grid,
  .scanner-detail-grid,
  .arca-detail-card,
  .detail-list,
  .detail-totals-grid {
    grid-template-columns: 1fr;
  }


  .chat-bubble {
    max-width: 100%;
  }

  .panel-narrow {
    width: 100%;
  }

  .auth-shell {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .auth-showcase {
    padding: 24px;
    border-radius: 24px;
  }

  .auth-showcase h1 {
    font-size: 2rem;
  }

  .auth-card,
  .auth-card-optimized {
    width: 100%;
    padding: 22px;
  }
}

@media (max-width: 640px) {
  .auth-wrap {
    min-height: auto;
    padding: 14px;
  }

  .auth-showcase {
    padding: 20px;
  }

  .auth-showcase h1,
  .brand-hero h2,
  .brand-hero h1 {
    font-size: 1.6rem;
  }

  .showcase-points {
    gap: 10px;
  }

  .showcase-item {
    padding: 14px;
    border-radius: 16px;
  }

  input,
  select,
  textarea {
    padding: 12px 13px;
    border-radius: 14px;
  }

  .btn {
    width: 100%;
    min-height: 46px;
  }
}
