/* ==========================================================================
   Sistema visual — app móvil de referidos
   Tokens, layout (barra superior, barra inferior, hoja de menú) y componentes.
   ========================================================================== */
:root {
  --brand: #af1723;
  --brand-dark: #86121b;
  --brand-soft: #FBE9EA;
  --ground: #F7F3F2;
  --surface: #FFFFFF;
  --surface-2: #FBF9F8;
  --ink: #1E1416;
  --ink-2: #4A3F42;
  --muted: #6E6164;
  --line: #EDE3E4;
  --line-2: #F1E8E9;
  --field: #E4D9DA;
  --danger: #8C2E27;
  --danger-soft: #FBEAE8;
  --ok: #1F6B44;
  --ok-soft: #E7F3EC;
  --tabbar-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Bricolage Grotesque', 'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.app { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
button, a, input, select, textarea, label { touch-action: manipulation; }
button:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; box-shadow: none; }
:focus-visible { outline: 3px solid #d64752; outline-offset: 3px; }
p, td, h1, h2, h3 { overflow-wrap: anywhere; }
.display { font-family: var(--font-display); letter-spacing: -0.01em; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
.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; }

/* ---------- Layout ---------- */
.app-layout { min-height: 100vh; display: flex; }
main.app-main { flex: 1; min-width: 0; padding-bottom: 2.5rem; }
.page { width: 100%; max-width: 1120px; margin: 0 auto; padding: 22px 20px 0; }
.page-narrow { max-width: 680px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-title { margin: 0; font-family: var(--font-display); font-size: 30px; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; }
.page-sub { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.page-count { font-size: 13px; color: var(--muted); padding-bottom: 5px; }
.section { margin-top: 22px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-title { margin: 0; font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.section-link { font-size: 14px; font-weight: 700; color: var(--brand); padding: 10px 0; text-decoration: none; }
.eyebrow { margin: 0 0 8px 4px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* Barra superior (móvil) */
.mobile-header { display: none; }
.topbar-title { font-size: 16px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 36px; height: 36px; object-fit: contain; flex-shrink: 0; border-radius: 10px; background: #fff; }
.brand-tile { width: 36px; height: 36px; flex-shrink: 0; border-radius: 11px; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; font-size: 15px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 16px; overflow-wrap: anywhere; min-width: 0; }
.company-logo { max-width: 160px; max-height: 120px; object-fit: contain; }

/* Barra lateral (escritorio) / hoja de menú (móvil) */
.app-sidebar { width: 248px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-wrap: anywhere; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 18px; }
.sidebar-nav { flex: 1; padding: 4px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; font-size: 14.5px; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.sidebar-nav a:hover { background: var(--ground); }
.sidebar-nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.sidebar-group { margin: 14px 12px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.sheet-profile { display: flex; align-items: center; gap: 12px; padding: 8px; }
.sheet-profile-text { display: flex; flex-direction: column; min-width: 0; }
.sheet-profile-text strong { font-size: 15px; }
.sheet-company { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--ground); font-size: 13px; color: var(--muted); }
.sheet-company p { margin: 0; color: var(--ink); font-weight: 700; font-size: 14px; }
.sheet-grabber, .icon-btn.sheet-close { display: none; }
.install-help { font-size: 13px; color: var(--muted); padding: 0 4px; }
.install-help summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.install-help p { margin: 0 0 8px; }
.sheet-backdrop { display: none; }

/* Barra inferior (móvil) */
.tabbar { display: none; }

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; }
.card-pad { padding: 16px; }
.avatar { width: 46px; height: 46px; flex-shrink: 0; border-radius: 50%; background: #F3ECEC; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.avatar-sm { width: 38px; height: 38px; font-size: 13px; }
.avatar-lg { width: 72px; height: 72px; font-size: 24px; font-family: var(--font-display); font-weight: 800; }
.avatar-brand { background: var(--brand-soft); color: var(--brand); font-family: var(--font-display); font-weight: 800; }
.avatar-ink { background: var(--ink); color: #fff; font-family: var(--font-display); font-weight: 800; }

/* Píldoras de estado */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; line-height: 1.3; }
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill-nuevo { background: #E6F1FB; color: #1D5182; } .pill-nuevo .pill-dot { background: #2F6FB0; }
.pill-seguimiento { background: #FAEEDA; color: #8A5C10; } .pill-seguimiento .pill-dot { background: #C98A1D; }
.pill-finalizado { background: #E7F3EC; color: #1F6B44; } .pill-finalizado .pill-dot { background: #2F8F5B; }
.pill-perdido { background: #FBEAE8; color: #8C2E27; } .pill-perdido .pill-dot { background: #C4453A; }
.pill-activo { background: var(--ok-soft); color: var(--ok); }
.pill-inactivo { background: #EFEBEA; color: #5E5154; }
.pill-ink { background: var(--ink); color: #fff; }
.pill-brand { background: var(--brand-soft); color: var(--brand); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-nuevo { background: #2F6FB0; } .dot-seguimiento { background: #C98A1D; } .dot-finalizado { background: #2F8F5B; } .dot-perdido { background: #C4453A; }
.tint-nuevo { background: #E6F1FB; } .tint-seguimiento { background: #FAEEDA; } .tint-finalizado { background: #E7F3EC; } .tint-perdido { background: #FBEAE8; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 15px; border: 1.5px solid transparent; font: inherit; font-size: 15px; font-weight: 700; line-height: 1.2; text-decoration: none; cursor: pointer; text-align: center; transition: background-color .15s, transform .1s; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 8px 18px rgba(175,23,35,.24); }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--field); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-tonal { background: var(--brand-soft); color: var(--brand); }
.btn-soft { background: var(--ground); color: var(--ink); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-ok { background: var(--ok-soft); color: var(--ok); }
.btn-danger-text { color: var(--danger); }
.btn-white { background: #fff; color: var(--brand); }
.btn-glass { background: rgba(255,255,255,.16); color: #fff; }
.btn-lg { min-height: 56px; border-radius: 16px; font-size: 16px; }
.btn-sm { min-height: 44px; padding: 0 14px; border-radius: 13px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1 1 0; min-width: 0; }
.icon-btn { width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; padding: 0; }
.icon-btn-tonal { border-color: transparent; background: var(--brand-soft); color: var(--brand); }
.fab-plus { font-size: 24px; font-weight: 500; line-height: 1; margin-top: -2px; }
.fab { display: inline-flex; }

/* Formularios */
.form-stack { display: flex; flex-direction: column; gap: 18px; }
.form-section { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.form-section > legend { padding: 0 0 10px; font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: 12.5px; color: var(--muted); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.input, .app-main input:not([type]), .app-main input[type=text], .app-main input[type=email], .app-main input[type=tel], .app-main input[type=password], .app-main input[type=number], .app-main input[type=date], .app-main input[type=search]:not(.search-input), .app-main select, .app-main textarea {
  width: 100%; min-width: 0; min-height: 52px; border-radius: 14px; border: 1.5px solid var(--field); background: var(--surface); padding: 0 14px; font: inherit; font-size: 16px; color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s;
}
.app-main textarea { padding: 12px 14px; min-height: 104px; resize: vertical; }
.app-main select { appearance: none; -webkit-appearance: none; padding-right: 42px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236E6164' 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 14px center; }
.app-main input:focus, .app-main select:focus, .app-main textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(175,23,35,.12); }
.app-main input[readonly] { background: var(--ground); color: var(--ink-2); }
.app-main input::placeholder, .app-main textarea::placeholder { color: #9A8C8F; }
.app-main input[type=file] { min-height: 0; padding: 0; border: 0; background: none; font-size: 14px; }
.file-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 140px; padding: 16px; border-radius: 20px; border: 2px dashed var(--field); background: var(--surface-2); text-align: center; cursor: pointer; }
.file-drop-icon { width: 48px; height: 48px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; }
[data-file-name] { position: relative; cursor: pointer; }
[data-file-name] input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
[data-file-name]:focus-within { outline: 3px solid #d64752; outline-offset: 2px; }

/* Opciones tipo chip (radio) */
.option-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.option-chip { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 14px; border: 1.5px solid var(--field); background: var(--surface); font-size: 14px; font-weight: 700; cursor: pointer; }
.option-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.option-chip .check { display: none; }
.option-chip:has(input:checked) { border: 2px solid var(--brand); background: var(--brand-soft); color: var(--brand); }
.option-chip:has(input:checked) .check { display: inline-block; }
.option-chip:has(input:focus-visible) { outline: 3px solid #d64752; outline-offset: 2px; }

/* Selector de estado (seguimiento) */
.estado-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.estado-option { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 12px; border-radius: 14px; border: 1.5px solid var(--field); background: var(--surface); font-size: 14px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.estado-option input { width: 18px; height: 18px; margin: 0; flex-shrink: 0; }
.estado-option-nuevo { accent-color: #2F6FB0; } .estado-option-seguimiento { accent-color: #C98A1D; } .estado-option-finalizado { accent-color: #2F8F5B; } .estado-option-perdido { accent-color: #C4453A; }
.estado-option-nuevo:has(input:checked) { background: #E6F1FB; color: #1D5182; border: 2px solid #2F6FB0; }
.estado-option-seguimiento:has(input:checked) { background: #FAEEDA; color: #8A5C10; border: 2px solid #C98A1D; }
.estado-option-finalizado:has(input:checked) { background: #E7F3EC; color: #1F6B44; border: 2px solid #2F8F5B; }
.estado-option-perdido:has(input:checked) { background: #FBEAE8; color: #8C2E27; border: 2px solid #C4453A; }

/* Búsqueda y filtros */
.search { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 0 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--field); color: var(--muted); }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(175,23,35,.12); }
.search-input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: inherit; font-size: 16px; color: var(--ink); min-height: 48px; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 12px -20px 0; padding: 0 20px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--field); background: var(--surface); color: var(--ink); font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer; }
.chip-count { font-weight: 600; opacity: .7; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Resumen */
.hero { position: relative; overflow: hidden; background: var(--brand); color: #fff; border-radius: 26px; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.hero::before { content: ''; position: absolute; right: -50px; top: -50px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.08); pointer-events: none; }
.hero > * { position: relative; }
.hero-label { font-size: 14px; font-weight: 600; opacity: .9; }
.hero-number { font-family: var(--font-display); font-size: 52px; font-weight: 800; line-height: 1; }
.hero-side { text-align: right; }
.hero-side strong { display: block; font-family: var(--font-display); font-size: 26px; font-weight: 800; line-height: 1; }
.hero-note { font-size: 13px; opacity: .9; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat-tile { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; min-width: 0; }
.stat-icon { width: 40px; height: 40px; flex-shrink: 0; border-radius: 13px; display: flex; align-items: center; justify-content: center; }
.stat-value { display: block; font-family: var(--font-display); font-size: 24px; font-weight: 800; line-height: 1.05; }
.stat-label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.rows { padding: 4px 16px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-2); color: var(--ink); text-decoration: none; min-width: 0; }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-size: 15px; font-weight: 700; }
.row-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { display: block; height: 6px; border-radius: 3px; background: #F3ECEC; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 3px; background: var(--brand); }
.dash-grid { display: grid; gap: 0 20px; }

/* Listas en tarjetas */
.list-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 14px; }
.list-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.list-card[hidden] { display: none; }
.list-card-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.list-card-link { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: var(--ink); text-decoration: none; }
.list-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.list-card-title { font-size: 15.5px; font-weight: 700; margin: 0; }
.list-card-meta { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); min-width: 0; flex-wrap: wrap; }
.list-card-meta span { min-width: 0; overflow-wrap: anywhere; }
.list-card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.list-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.list-card-actions > * { flex: 1 1 0; min-width: 88px; }
.list-card-note { margin: -4px 0 0; font-size: 12px; color: var(--muted); }
.empty-state { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.empty-state[hidden] { display: none; }

/* Productos */
.product-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.product-card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; overflow: hidden; display: flex; flex-direction: column; }
.product-media { height: 160px; background: #F6ECEC; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #8A7C7F; font-size: 12px; font-weight: 600; overflow: hidden; }
.product-media img { width: 100%; height: 100%; object-fit: cover; }
.product-body { padding: 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-title { margin: 0; font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.product-desc { margin: 0; font-size: 14px; color: #5E5154; line-height: 1.45; flex: 1; }

/* Detalle / gestión */
.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-head h1 { margin: 0; font-family: var(--font-display); font-size: 24px; font-weight: 800; }
.info-list { padding: 4px 16px; }
.info-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.info-row:last-child { border-bottom: 0; }
.info-icon { width: 38px; height: 38px; flex-shrink: 0; border-radius: 12px; background: var(--ground); color: var(--muted); display: flex; align-items: center; justify-content: center; }
.info-label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.info-value { display: block; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.timeline { padding: 16px 16px 4px; }
.timeline-item { display: flex; gap: 14px; }
.timeline-rail { display: flex; flex-direction: column; align-items: center; width: 14px; flex-shrink: 0; }
.timeline-rail .dot { width: 12px; height: 12px; margin-top: 5px; }
.timeline-line { flex: 1; width: 2px; background: var(--line); margin: 4px 0; }
.timeline-item:last-child .timeline-line { background: transparent; }
.timeline-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding-bottom: 16px; }
.timeline-body p { margin: 0; font-size: 14px; color: var(--ink-2); }
.timeline-meta { font-size: 12px; color: var(--muted); }
.detail-grid { display: grid; gap: 18px; }
.detail-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 1023px) {
  .detail-col { display: contents; }
  .o-1 { order: 1; } .o-2 { order: 2; } .o-3 { order: 3; } .o-4 { order: 4; } .o-5 { order: 5; }
}

/* Acordeón (empresa) */
.accordion { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; }
.accordion > summary { list-style: none; min-height: 60px; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.accordion > summary::-webkit-details-marker { display: none; }
.accordion > summary svg { transition: transform .2s; color: var(--muted); flex-shrink: 0; }
.accordion[open] > summary svg { transform: rotate(180deg); }
.accordion-title { display: block; font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.accordion-sub { display: block; font-size: 12px; color: var(--muted); }
.accordion-body { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 12px; }

/* Cabecera de formulario y acciones */
.form-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.form-head h1 { margin: 0; font-family: var(--font-display); font-size: 24px; font-weight: 800; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.form-actions .btn-primary { flex: 1; }
.notice { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.notice strong { color: var(--ink); font-size: 14px; }
.notice-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }

/* QR */
.qr-card { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 20px; border-radius: 28px; box-shadow: 0 10px 28px rgba(30,20,22,.06); }
.qr-preview { text-align: center; padding: 12px; border: 1.5px solid var(--line); border-radius: 22px; background: #fff; }
.qr-preview canvas { display: block; max-width: 100%; width: 240px; height: auto; image-rendering: pixelated; }
.link-field { align-self: stretch; display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 4px 0 14px; border-radius: 14px; background: var(--ground); }
.link-field input { flex: 1; min-width: 0; border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; min-height: 44px !important; font-size: 13.5px !important; color: var(--ink-2); }

/* Mensaje flotante */
#toast { position: fixed; z-index: 100; top: 16px; right: 16px; max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 14px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 600; box-shadow: 0 10px 24px rgba(30,20,22,.2); display: flex; align-items: center; gap: 10px; }
#toast.hidden { display: none; }
#toast::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: #2F8F5B; flex-shrink: 0; }
#toast.toast-error::before { background: #E0564A; }

/* Modal (producto) */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(30,20,22,.45); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.modal.hidden { display: none; }
.modal > div { width: 100%; max-width: 440px; max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--surface); border-radius: 26px; padding: 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 800; }
.sheet-grabber-static { display: none; }

/* Campo con ícono / acción */
.input-wrap { position: relative; display: block; }
.input-wrap .input-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #8A7C7F; pointer-events: none; }
.app-main .input-wrap input { padding-left: 44px; }
.app-main .input-wrap input:has(+ .input-action) { padding-right: 52px; }
.input-action { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.input-action[aria-pressed="true"] { color: var(--brand); }

/* Ingreso */
.login-page { min-height: 100vh; }
.login-main { max-width: 460px; margin: 0 auto; padding-bottom: 32px; }
.login-hero { position: relative; overflow: hidden; background: var(--brand); color: #fff; border-radius: 0 0 36px 36px; padding: calc(48px + env(safe-area-inset-top, 0px)) 28px 84px; display: flex; flex-direction: column; gap: 8px; }
.login-hero::before, .login-hero::after { content: ''; position: absolute; border-radius: 50%; background: rgba(255,255,255,.07); pointer-events: none; }
.login-hero::before { right: -80px; top: -60px; width: 240px; height: 240px; }
.login-hero::after { right: 40px; bottom: -40px; width: 120px; height: 120px; }
.login-logo { width: 68px; height: 68px; border-radius: 20px; background: #fff; object-fit: contain; padding: 6px; margin-bottom: 14px; position: relative; }
.login-logo-tile { display: flex; align-items: center; justify-content: center; color: var(--brand); font-family: var(--font-display); font-weight: 800; font-size: 30px; padding: 0; }
.login-company { margin: 0; font-size: 14px; font-weight: 600; opacity: .9; position: relative; }
.login-title { margin: 0; font-family: var(--font-display); font-size: 36px; line-height: 1.05; font-weight: 800; letter-spacing: -0.02em; position: relative; }
.login-sub { margin: 0; font-size: 15px; opacity: .92; position: relative; }
.login-card { position: relative; margin: -56px 20px 0; padding: 24px 20px; border: 0; border-radius: 26px; box-shadow: 0 14px 36px rgba(30,20,22,.10); }
.install-card { margin: 16px 20px 0; padding: 14px 14px 14px 16px; display: flex; align-items: center; gap: 12px; }
@media (min-width: 640px) { .login-hero { margin-top: 32px; border-radius: 32px; } }

/* Clases heredadas (compatibilidad) */
.action { display: inline-flex; align-items: center; min-height: 44px; padding: .5rem .75rem; color: var(--brand); font-weight: 600; }
[hidden].action { display: none; }
.danger { color: #a52b24; }
.primary { background: var(--brand); color: #fff; padding: .75rem 1rem; border-radius: 12px; min-height: 44px; font-weight: 700; border: 0; }

/* ---------- Escritorio ---------- */
@media (min-width: 640px) {
  .list-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
@media (min-width: 1024px) {
  .page { padding: 32px 32px 0; }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; }
  .hero .btn-row, .hero > .btn-block { max-width: 440px; }
}

/* ---------- Móvil y tableta ---------- */
@media (max-width: 1023px) {
  .app-layout { display: block; }
  main.app-main { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 96px); }
  body.no-tabbar main.app-main { padding-bottom: calc(104px + var(--safe-b)); }
  body.login-page main.app-main { padding-bottom: calc(32px + var(--safe-b)); }

  .mobile-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 30; min-height: 62px; padding: 9px 16px; background: rgba(247,243,242,.92); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); }
  .mobile-header .icon-btn.avatar { font-size: 14px; }
  body.menu-open .mobile-header { z-index: 90; }
  body.menu-open { overflow: hidden; }
  .page { padding-top: 6px; }

  /* Hoja de menú */
  aside.app-sidebar { display: none; position: fixed; z-index: 80; left: 0; right: 0; bottom: 0; top: auto; width: 100%; height: auto; max-height: calc(100dvh - 72px); border-right: 0; border-radius: 28px 28px 0 0; padding-bottom: var(--safe-b); box-shadow: 0 -12px 40px rgba(30,20,22,.18); }
  aside.app-sidebar.is-open { display: flex; animation: sheet-up .22s ease-out; }
  .sheet-backdrop.is-open { display: block; position: fixed; inset: 0; z-index: 70; background: rgba(30,20,22,.45); border: 0; padding: 0; }
  .sheet-grabber { display: block; align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--field); margin: 10px 0 2px; flex-shrink: 0; }
  .icon-btn.sheet-close { display: inline-flex; margin-left: auto; }
  .sidebar-brand { padding: 10px 16px 6px; }
  .sidebar-nav a { min-height: 50px; }

  /* Barra inferior */
  .tabbar { display: flex; position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + var(--safe-b)); padding: 6px 6px var(--safe-b); background: var(--surface); border-top: 1px solid var(--line); justify-content: space-around; align-items: flex-start; }
  body.no-tabbar .tabbar { display: none; }
  .tab { flex: 1; max-width: 84px; min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font: inherit; font-size: 11px; font-weight: 600; text-decoration: none; background: none; border: 0; padding: 0; cursor: pointer; }
  .tab-icon { width: 54px; height: 30px; border-radius: 15px; display: flex; align-items: center; justify-content: center; }
  .tab[aria-current="page"] { color: var(--brand); font-weight: 700; }
  .tab[aria-current="page"] .tab-icon { background: var(--brand-soft); }
  .tab-center { position: relative; justify-content: flex-end; padding-bottom: 6px; color: var(--ink); font-weight: 700; }
  .tab-center .tab-fab { position: absolute; top: -28px; width: 60px; height: 60px; border-radius: 50%; background: var(--brand); color: #fff; border: 4px solid var(--ground); box-shadow: 0 8px 20px rgba(175,23,35,.35); display: flex; align-items: center; justify-content: center; }
  .tab-center[aria-current="page"] .tab-fab { background: var(--brand-dark); }

  /* Botón flotante de crear */
  .fab { position: fixed; z-index: 35; right: 20px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); min-height: 56px; padding: 0 20px 0 16px; border-radius: 18px; box-shadow: 0 10px 24px rgba(175,23,35,.35); }

  /* Acciones de formulario fijas */
  .form-actions { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; margin: 0; padding: 12px 20px calc(16px + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--line); }
  .form-actions .btn { min-height: 56px; }
  .form-actions .btn-secondary { flex: 0 0 auto; }

  /* Modal como hoja inferior */
  .modal { align-items: flex-end; padding: 0; }
  .modal > div { max-width: none; border-radius: 28px 28px 0 0; padding: 12px 20px calc(24px + var(--safe-b)); max-height: 92dvh; }
  .sheet-grabber-static { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--field); margin: 0 auto 10px; }

  #toast { top: auto; right: 16px; left: 16px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); max-width: none; }
  body.no-tabbar #toast { bottom: calc(100px + var(--safe-b)); }
}
@media (max-width: 380px) {
  .page { padding-left: 16px; padding-right: 16px; }
  .chips { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .page-title { font-size: 26px; }
  .hero-number { font-size: 44px; }
  .tab { font-size: 10.5px; }
  .tab-icon { width: 46px; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
