:root {
  --bg: #e8f4f8;
  --surface: #ffffff;
  --border: #d9d9d9;
  --text: #1e1e1e;
  --text-secondary: #757575;
  --accent: #0088b8;
  --btn: #2c2c2c;
  --danger: #c00f0c;
  --warning-bg: #fff4cc;
  --warning-text: #854f0b;
  --brand-bg: #e6f3f8;
  --brand-text: #0b5f7a;
  --positive-bg: #eaf6ed;
  --positive-text: #0f6b3a;
  --danger-bg: #fdeceb;
  --danger-text: #9b1c1c;
  --neutral-bg: #f1f1f1;
  --neutral-text: #5a5a5a;
  --radius: 12px;
  --sidebar: 240px;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --touch: 44px;
}

* {
  box-sizing: border-box;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  height: auto !important;
  max-height: none !important;
  overflow-x: hidden;
  overflow-y: scroll !important;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

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

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

button,
.btn,
.nav a,
.subnav a {
  min-height: var(--touch);
  touch-action: manipulation;
}

img,
video,
canvas {
  max-width: 100%;
  height: auto;
}

.app {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 28px 20px;
  padding-top: calc(28px + var(--safe-top));
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-height: 100vh;
  min-height: 100dvh;
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
  z-index: 20;
}

.session-box .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.subnav a {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.subnav a.active,
.subnav a:hover {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}

.list-header-compras,
.row-compras {
  gap: 12px;
}

.col-provider {
  min-width: 110px;
  font-size: 13px;
  color: var(--text-secondary);
}

.section-block {
  margin-top: 0;
}

.section-head {
  padding: 20px 20px 8px;
}

.section-head h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.section-head p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.breadcrumb {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.breadcrumb a {
  color: var(--accent);
  font-weight: 500;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.qr-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
  align-items: start;
}

.qr-form,
.qr-preview-card {
  padding-bottom: 24px;
}

.qr-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 20px 24px;
}

.qr-form .section-head {
  padding-left: 0;
  padding-right: 0;
}

.qr-type {
  display: flex;
  gap: 10px;
}

.qr-option {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: #fafafa;
  font-size: 14px;
  font-weight: 500;
}

.qr-option:has(input:checked) {
  border-color: var(--accent);
  background: #eef8fc;
}

.qr-preview-card {
  padding: 0 20px 24px;
}

.qr-preview {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  border: 1px dashed var(--border);
  border-radius: 12px;
  margin: 0 0 12px;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  min-height: 200px;
  margin: 0 0 16px;
}

.qr-tile {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.qr-tile-code {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.qr-tile-label {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  word-break: break-all;
  color: var(--text-secondary);
}

.qr-tile-label strong {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.qr-code-label {
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
  color: var(--text);
  margin: 0 0 16px;
}

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

.qr-actions {
  justify-content: center;
}

.locked-card {
  padding-bottom: 12px;
}

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

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  overflow: visible;
  width: 100%;
}

.brand img {
  width: 170px;
  height: auto;
  max-height: none;
  aspect-ratio: 798 / 242;
  object-fit: contain;
  object-position: left center;
  display: block;
  flex-shrink: 0;
}

.brand span {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: normal;
  line-height: 1.3;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
}

.nav a.active {
  background: #f1f1f1;
  font-weight: 600;
}

.nav a:hover:not(.active) {
  background: #f7f7f7;
}

/* Evita flash de menú completo antes de filtrar por rol */
html:not(.auth-ready) .nav {
  visibility: hidden;
}

.content {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow: visible;
  padding-bottom: calc(64px + var(--safe-bottom));
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.2;
}

.page-header .subtitle,
.meta {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

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

.btn-neutral {
  background: #f1f1f1;
  color: var(--text);
}

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

.btn:hover {
  filter: brightness(1.05);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
}

.stat label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.stat strong {
  font-size: 22px;
}

.filters {
  display: flex;
  gap: 12px;
  align-items: center;
}

.filters input {
  flex: 1;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--text);
}

.filters input::placeholder {
  color: #999;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.list-header,
.li-header {
  display: flex;
  gap: 16px;
  padding: 12px 20px;
  background: #ececec;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.list-header .col-main,
.row .col-main,
.li-header .col-main,
.li-row .col-main {
  flex: 1;
  min-width: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 100px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  transition: background 0.15s ease;
}

.row:last-child {
  border-bottom: none;
}

.row:hover {
  background: #fafafa;
}

.row .title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.row .meta {
  font-size: 12px;
}

.row .amount {
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  min-width: 72px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.tag-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.tag-brand {
  background: var(--brand-bg);
  color: var(--brand-text);
}

.tag-positive {
  background: var(--positive-bg);
  color: var(--positive-text);
}

.tag-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.tag-neutral {
  background: var(--neutral-bg);
  color: var(--neutral-text);
}

.detail-header h1 {
  margin: 0 0 8px;
  font-size: 26px;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.actions {
  display: flex;
  gap: 8px;
}

.body {
  display: flex;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

.main-panel,
.timeline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.main-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.timeline {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.timeline h2 {
  margin: 0;
  font-size: 16px;
}

.timeline .hint {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-row {
  display: flex;
  gap: 16px;
}

.field {
  flex: 1;
  min-width: 0;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.field p {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

.line-items {
  border-radius: 8px;
  overflow: hidden;
  background: #ececec;
}

.li-header {
  gap: 12px;
  padding: 12px 16px;
}

.li-row {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  font-size: 13px;
}

.li-row .total {
  font-weight: 600;
}

.comment label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.comment textarea {
  width: 100%;
  min-height: 96px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  resize: vertical;
  background: var(--surface);
}

.steps {
  display: flex;
  flex-direction: column;
}

.step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  font-size: 13px;
}

.step img {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.step.current {
  font-weight: 600;
}

.step.pending {
  color: var(--text-secondary);
}

.login-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(0, 136, 184, 0.18), transparent 40%),
    radial-gradient(circle at bottom right, rgba(0, 136, 184, 0.12), transparent 45%),
    var(--bg);
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px 28px;
  box-shadow: 0 18px 48px rgba(15, 50, 70, 0.08);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 28px;
}

.login-brand img {
  width: 200px;
  height: auto;
  max-height: none;
  aspect-ratio: 798 / 242;
  object-fit: contain;
  object-position: left center;
  display: block;
}

.login-brand p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.login-header h1 {
  margin: 0 0 8px;
  font-size: 26px;
}

.login-header p {
  margin: 0 0 28px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field span {
  font-size: 13px;
  font-weight: 600;
}

.login-field input,
.login-field select {
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  background: #fafafa;
  color: var(--text);
  width: 100%;
}

.login-field select {
  cursor: pointer;
  appearance: auto;
}

.login-field input:focus,
.login-field select:focus {
  outline: 2px solid rgba(0, 136, 184, 0.35);
  border-color: var(--accent);
  background: var(--surface);
}

.qr-type {
  flex-wrap: wrap;
}

.otro-material:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: #eef8fc;
}

.otro-material[hidden] {
  display: none !important;
}

.filters-panel {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.filters-panel .login-field {
  margin: 0;
}

.filters-panel .btn {
  height: 44px;
}

.login-field textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fafafa;
  color: var(--text);
  width: 100%;
  resize: vertical;
  min-height: 80px;
}

.login-field input[type="file"] {
  height: auto;
  padding: 10px;
  background: #fff;
}

.evidencia-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #fafafa;
}

.evidencia-preview img {
  max-width: 100%;
  max-height: 180px;
  object-fit: contain;
  border-radius: 8px;
}

.evidencia-preview span {
  font-size: 12px;
  color: var(--text-secondary);
}

.row-evidencia {
  align-items: flex-start;
}

.row-actions {
  margin-top: 8px;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.evidencia-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(420px, calc(100% - 32px));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.evidencia-dialog::backdrop {
  background: rgba(15, 30, 40, 0.45);
}

.evidencia-dialog-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.evidencia-dialog-body h2 {
  margin: 0;
  font-size: 20px;
}


.scan-panel {
  padding-bottom: 8px;
}

.scan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 20px 16px;
}

.scan-file-btn {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.scan-reader {
  margin: 0 20px 16px;
  min-height: 0;
  border-radius: 12px;
  overflow: hidden;
}

.scan-reader:empty {
  display: none;
}

.scan-result {
  margin: 0 20px 16px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fafafa;
}

.scan-result.empty {
  color: var(--text-secondary);
  text-align: center;
}

.scan-result.ok {
  background: var(--positive-bg);
  border-color: #8fd0a8;
}

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

.scan-result.warn {
  background: var(--warning-bg);
  border-color: #e6c87a;
}

.scan-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
}

.scan-detail {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.4;
}

.scan-data {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.scan-matches {
  margin-top: 12px;
  font-size: 13px;
}

.scan-matches ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.scan-result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 20px 20px;
}

.zona-banner {
  margin: 10px 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.ejecutivo-switcher {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.ejecutivo-switcher select {
  min-width: min(100%, 280px);
  padding: 8px 12px;
  border: 1px solid var(--border, #d7dee7);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: var(--text, #102033);
}

.ejecutivo-switcher-meta {
  width: 100%;
  font-size: 12px;
  color: var(--text-secondary);
}

.zona-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #0b5f7a;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.zona-pill-sm {
  font-size: 11px;
  padding: 4px 8px;
  align-self: center;
}

.login-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.login-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  cursor: pointer;
}

.login-link {
  color: var(--accent);
  font-weight: 500;
}

.login-link:hover {
  text-decoration: underline;
}

.login-submit {
  width: 100%;
  height: 44px;
  margin-top: 4px;
}

.login-footnote {
  margin: 24px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.login-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger-text);
  font-size: 13px;
  font-weight: 500;
}

.login-users {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.login-users-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-users ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}

.login-users li {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.session-box {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.session-box strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.session-box span {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ========== Multiplataforma ========== */

/* Laptop / tablet landscape */
@media (max-width: 1200px) {
  :root {
    --sidebar: 220px;
  }

  .content {
    padding: 24px;
  }

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

/* Tablet */
@media (max-width: 1024px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .body {
    flex-direction: column;
  }

  .timeline {
    width: 100%;
  }

  .qr-layout {
    grid-template-columns: 1fr;
  }

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

  .page-header h1,
  .detail-header h1 {
    font-size: 24px;
  }
}

/* Tablet portrait / phablet */
@media (max-width: 900px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-height: 0;
    max-height: none;
    position: sticky;
    top: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
    padding-top: calc(12px + var(--safe-top));
    gap: 12px;
    box-shadow: 0 4px 16px rgba(15, 40, 60, 0.06);
  }

  .brand {
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }

  .brand img {
    width: 120px;
  }

  .brand span {
    font-size: 11px;
  }

  .nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav a {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 10px 14px;
    border: 1px solid var(--border);
    background: #fafafa;
  }

  .nav a.active {
    background: var(--btn);
    color: #fff;
    border-color: var(--btn);
  }

  .session-box {
    margin-top: 0;
    padding-top: 10px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    align-items: center;
  }

  .session-box strong {
    margin: 0;
  }

  .session-box span {
    margin: 0;
    grid-column: 1;
  }

  .session-box .btn {
    grid-row: 1 / span 2;
    grid-column: 2;
    width: auto;
    min-width: 120px;
    padding-inline: 12px;
  }

  .content {
    padding: 18px 14px calc(40px + var(--safe-bottom));
    gap: 16px;
  }

  .page-header,
  .detail-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .page-header .actions,
  .actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .page-header .btn,
  .page-header .actions .btn,
  .page-header > .btn {
    width: 100%;
    justify-content: center;
  }

  .field-row {
    flex-direction: column;
  }

  .list-header,
  .list-header-compras {
    display: none;
  }

  .row,
  .row-compras {
    flex-wrap: wrap;
    min-height: auto;
    gap: 8px 12px;
    padding: 14px;
  }

  .row .col-main,
  .row-compras .col-main {
    flex: 1 1 100%;
  }

  .row .amount,
  .row-compras .amount,
  .zona-pill-sm,
  .col-provider,
  .tag {
    margin-left: 0;
  }

  .qr-form,
  .qr-preview-card,
  .scan-panel,
  .scan-result-card {
    padding-left: 0;
    padding-right: 0;
  }

  .scan-actions,
  .scan-result,
  .scan-result-actions,
  .scan-reader {
    margin-left: 12px;
    margin-right: 12px;
  }

  .scan-actions {
    padding-left: 0;
    padding-right: 0;
  }

  .scan-actions .btn,
  .scan-file-btn {
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
    text-align: center;
  }

  .login-card {
    max-width: 100%;
    padding: 28px 20px 22px;
  }

  .login-users li {
    font-size: 11px;
    word-break: break-word;
  }
}

/* Celular normal */
@media (max-width: 640px) {
  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat {
    padding: 12px;
  }

  .stat strong {
    font-size: 18px;
  }

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

  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filters .btn {
    width: 100%;
  }

  .subnav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .subnav::-webkit-scrollbar {
    display: none;
  }

  .subnav a {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .page-header h1,
  .detail-header h1,
  .login-header h1 {
    font-size: 22px;
  }

  .qr-type {
    flex-direction: column;
  }

  .qr-option {
    width: 100%;
  }

  .qr-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .login-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .session-box {
    grid-template-columns: 1fr;
  }

  .session-box .btn {
    grid-row: auto;
    grid-column: auto;
    width: 100%;
  }

  .brand span {
    display: none;
  }
}

/* Celular pequeño */
@media (max-width: 380px) {
  .content {
    padding: 14px 10px calc(32px + var(--safe-bottom));
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .brand img {
    width: 110px;
  }

  .nav a {
    padding: 8px 12px;
    font-size: 13px;
  }

  .page-header h1,
  .detail-header h1 {
    font-size: 20px;
  }

  .login-card {
    padding: 22px 14px 18px;
  }

  .scan-actions .btn,
  .scan-file-btn {
    flex: 1 1 100%;
  }
}

/* Preferencia de menos movimiento */
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
