/* Comercio — sistema visual (tokens de Cero Gestión, Poppins en todo) */
:root {
  --bg: #F5F7FA; --white: #FFFFFF; --border: #EEEEEE; --line: #E6E6E6;
  --text: #4A5568; --text2: #4B5057; --muted: #787D85; --faint: #999999;
  --accent: #01ACB4; --accent-dark: #0D8A90; --accent-light: #E0F7F8;
  --green: #22C55E; --green-soft: #F0FDF4; --amber: #F59E0B; --amber-soft: #FFFBEB;
  --red: #E03E3E; --red-soft: #FFF0F0; --sky: #0EA5E9; --sky-soft: #E0F2FE; --purple: #7C3AED; --purple-soft: #F3EEFF;
  --side-a: #00465B; --side-b: #003A4D; --sidebar-w: 240px; --nav-h: 80px;
  --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sh: 0 2px 6px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.03);
  --sh-m: 0 2px 8px rgba(0,0,0,.04);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
.mi { font-family: 'Material Symbols Rounded'; font-weight: normal; font-style: normal; font-size: 20px; line-height: 1; display: inline-block; vertical-align: middle; font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.mi.sm { font-size: 18px; } .mi.lg { font-size: 24px; }
[hidden] { display: none !important; }

/* ─── Shell ─── */
.app-layout { display: flex; min-height: 100dvh; }
.sidebar { width: var(--sidebar-w); background: linear-gradient(180deg, var(--side-a), var(--side-b)); color: #fff; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; padding: 24px 0; z-index: 100; }
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 0 20px; margin-bottom: 28px; font-size: 18px; font-weight: 700; }
.sidebar-logo .mark { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; }
.sidebar-label { font-size: 10px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; color: rgba(255,255,255,.5); padding: 18px 20px 6px; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 16px; margin: 1px 12px; border-radius: 12px; color: rgba(255,255,255,.6); font-size: 14px; }
.sidebar-nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,.2); color: #fff; font-weight: 600; }
.sidebar-bottom { margin-top: auto; padding: 16px 20px 0; border-top: 1px solid rgba(255,255,255,.15); }
.sidebar-user { display: flex; align-items: center; gap: 12px; }
.sidebar-avatar { width: 34px; height: 34px; border-radius: 8px; background: rgba(255,255,255,.2); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.sidebar-user-name { font-size: 13px; font-weight: 600; } .sidebar-user-role { font-size: 11px; color: rgba(255,255,255,.6); }
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 32px; min-width: 0; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.3px; line-height: 1.25; margin: 0; }
.page-subtitle { font-size: 13px; color: var(--faint); margin-top: 4px; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 500; margin-bottom: 14px; }

/* ─── Componentes ─── */
.card { background: var(--white); border-radius: 16px; border: 1px solid var(--border); padding: 24px; }
.card + .card { margin-top: 20px; }
.card-title { font-size: 16px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-sub { font-size: 12px; color: var(--faint); margin-top: -8px; margin-bottom: 14px; }
.grid { display: grid; gap: 20px; } .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; align-items: start; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi { background: var(--white); border-radius: 16px; box-shadow: var(--sh); padding: 18px 22px; display: flex; flex-direction: column; gap: 10px; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; }
.kpi-label { font-size: 12px; font-weight: 500; color: var(--faint); }
.kpi-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.kpi-value { font-size: 30px; font-weight: 800; letter-spacing: -.5px; line-height: 1; }
.kpi-change { font-size: 12px; font-weight: 500; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; border: 1.5px solid var(--line); background: var(--white); color: var(--text2); white-space: nowrap; transition: .12s; }
.btn:hover { background: #FAFBFC; } .btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: var(--red-soft); border-color: var(--red-soft); color: var(--red); }
.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 10px; }
.btn-block { width: 100%; } .btn-lg { height: 54px; font-size: 16px; border-radius: 16px; box-shadow: 0 4px 12px rgba(1,172,180,.25); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--muted); } .icon-btn:hover { background: #F2F3F5; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.green { background: var(--green-soft); color: var(--green); } .badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); } .badge.sky { background: var(--sky-soft); color: var(--sky); }
.badge.gray { background: #F2F3F5; color: var(--muted); } .badge.teal { background: var(--accent-light); color: var(--accent-dark); }
.badge.nodot::before { display: none; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { padding: 7px 14px; border-radius: 20px; font-size: 13px; font-weight: 600; background: var(--white); border: 1px solid var(--line); color: var(--text2); }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 12px; background: var(--white); border: 1.5px solid var(--line); width: 300px; max-width: 100%; }
.search input { border: none; outline: none; background: none; flex: 1; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--faint); }
.input, .select, .textarea { width: 100%; padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--white); outline: none; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); background: #FAFDFD; }
.textarea { min-height: 80px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.table-card { padding: 0; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--faint); padding: 12px 20px; background: #F8F9FB; }
td { padding: 12px 20px; border-top: 1px solid var(--border); vertical-align: middle; }
tr.row-link { cursor: pointer; } tr.row-link:hover td { background: #FAFBFC; }
.avatar { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-light); color: var(--accent-dark); display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.name-cell { display: flex; align-items: center; gap: 12px; } .name-cell .name { font-weight: 600; } .name-cell .meta { font-size: 12px; color: var(--faint); }
.switch { width: 40px; height: 22px; border-radius: 11px; background: #D1D5DB; position: relative; transition: .15s; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .15s; }
.switch.on { background: var(--accent); } .switch.on::after { left: 20px; }
.kv { display: flex; gap: 12px; align-items: center; padding: 6px 0; } .kv .k { width: 130px; flex-shrink: 0; font-size: 12px; color: var(--faint); } .kv .v { font-size: 13px; }
.option { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--white); cursor: pointer; }
.option.selected { border: 2px solid var(--accent); background: var(--accent-light); }
.option .obox { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: #F2F3F5; color: var(--muted); flex-shrink: 0; }
.option.selected .obox { background: var(--accent); color: #fff; }
.option .otitle { font-weight: 600; font-size: 14px; } .option .odesc { font-size: 12px; color: var(--text2); }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.qr-box { width: 288px; height: 288px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; margin: 0 auto; overflow: hidden; }
.qr-box img { width: 100%; height: 100%; object-fit: contain; }
.code-big { font-size: 34px; font-weight: 800; letter-spacing: 3px; color: var(--accent); text-align: center; }
.steps { display: flex; flex-direction: column; gap: 8px; } .step { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text2); }
.step .n { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-light); color: var(--accent-dark); font-size: 11px; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; }
.note { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--bg); font-size: 12px; color: var(--muted); }
.timeline { display: flex; align-items: flex-start; }
.timeline .st { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 52px; }
.timeline .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--line); display: grid; place-items: center; color: #fff; }
.timeline .st.done .dot { background: var(--green); } .timeline .st.now .dot { background: var(--accent); }
.timeline .lbl { font-size: 9px; font-weight: 500; color: var(--faint); } .timeline .st.now .lbl { color: var(--accent); font-weight: 700; } .timeline .st.done .lbl { color: var(--text2); }
.timeline .conn { flex: 1; height: 2px; background: var(--line); margin-top: 10px; } .timeline .conn.done { background: var(--green); }
.seg { display: inline-flex; padding: 2px; border-radius: 9px; background: #F2F3F5; gap: 0; }
.seg button { padding: 6px 10px; border-radius: 7px; font-size: 11px; font-weight: 600; color: var(--muted); }
.seg button.on-si { background: var(--green); color: #fff; } .seg button.on-no { background: var(--red); color: #fff; } .seg button.on-parcial { background: var(--amber); color: #fff; }
.line-row { padding: 10px 0; border-top: 1px solid #F5F5F5; display: flex; flex-direction: column; gap: 8px; }
.line-top { display: flex; align-items: center; gap: 10px; } .line-top .qty { width: 52px; font-weight: 700; color: var(--accent); } .line-top .nm { flex: 1; } .line-top .pr { font-weight: 600; }
.line-top.off .qty, .line-top.off .nm, .line-top.off .pr { color: var(--faint); text-decoration: line-through; }
.suggest { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--amber-soft); font-size: 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1F2724; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 13px; z-index: 1000; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 900; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--white); border-radius: 16px; padding: 24px; width: 560px; max-width: 100%; max-height: 90dvh; overflow: auto; }
.empty { text-align: center; color: var(--faint); padding: 40px 20px; font-size: 13px; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 380px; max-width: 100%; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; } .b { font-weight: 600; } .right { text-align: right; }
.row { display: flex; align-items: center; gap: 10px; } .row.between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }

/* ─── Móvil (PWA) ─── */
.bottomnav { display: none; }
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px 20px calc(var(--nav-h) + 24px); }
  .page-title { font-size: 22px; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .kpi { padding: 12px 14px; border-radius: 14px; } .kpi-value { font-size: 22px; } .kpi-icon { display: none; }
  .grid-2, .grid-3, .grid-4, .cols, .field-row { grid-template-columns: 1fr; }
  .card { padding: 16px 18px; border-radius: 14px; border: none; box-shadow: var(--sh-m); }
  .search { width: 100%; }
  th { display: none; } table, tbody, tr, td { display: block; } tr { padding: 10px 0; border-top: 1px solid var(--border); } td { padding: 3px 0; border: none; }
  .bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); padding: 8px 0 calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--white); box-shadow: 0 -2px 16px rgba(0,0,0,.04); justify-content: space-around; align-items: center; z-index: 100; }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 56px; color: #BDBDBD; font-size: 9px; font-weight: 500; }
  .bottomnav a .mi { font-size: 24px; } .bottomnav a.active { color: var(--accent); font-weight: 600; }
  .bottomnav .fab { width: 52px; height: 52px; border-radius: 26px; background: var(--accent); color: #fff; display: grid; place-items: center; margin-top: -16px; box-shadow: 0 4px 12px rgba(1,172,180,.25); }
  .qr-box { width: 272px; height: 272px; }
}
