@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #F7F7F5;
  --white: #FFFFFF;
  --surface: #F2F2F0;
  --border: #E8E8E6;
  --border2: #D0D0CE;
  --black: #111111;
  --text: #111111;
  --text2: #6B6B6B;
  --text3: #ABABAB;
  --teal: #017E84;
  --teal-bg: #E8F5F5;
  --danger: #C0392B;
  --danger-bg: #FEF0EE;
  --warn: #E67E22;
  --warn-bg: #FFF4E5;
  --success: #27AE60;
  --success-bg: #EAFAF1;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: var(--bg); font-family: var(--font); color: var(--text); font-size: 16px; line-height: 1.5; }
input, select, button, textarea { font-family: var(--font); }
input[type=number]::-webkit-inner-spin-button { opacity: 1; }

/* ── APP ── */
#app { height: 100vh; height: 100dvh; position: relative; overflow: hidden; max-width: 430px; margin: 0 auto; background: var(--bg); }

/* ── SCREENS ── */
.screen { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; opacity: 0; pointer-events: none; transform: translateX(100%); transition: transform 0.28s cubic-bezier(0.4,0,0.2,1), opacity 0.28s; }
.screen.active { opacity: 1; pointer-events: all; transform: translateX(0); }
.screen.leaving { transform: translateX(-40%); opacity: 0; }
.screen-inner { flex: 1; overflow-y: auto; padding: 0 18px; -webkit-overflow-scrolling: touch; }
.screen-inner.scrollable { overflow-y: auto; }

/* ── LOGIN ── */
.login-header { padding: 52px 0 24px; }
.login-body { display: flex; flex-direction: column; gap: 14px; padding-bottom: 32px; }
.logo-wrap { display: flex; align-items: center; gap: 10px; }
.logo-sq { width: 36px; height: 36px; border-radius: 10px; background: var(--black); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-name { font-size: 18px; font-weight: 700; letter-spacing: -0.03em; color: var(--text); }
.logo-sub { font-size: 11px; color: var(--text3); letter-spacing: 0.04em; margin-top: 1px; }
.greeting { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); line-height: 1.2; margin-top: 24px; }
.greeting-sub { font-size: 13px; color: var(--text3); margin-bottom: 6px; }

/* ── TOPBAR ── */
.topbar { display: flex; align-items: center; gap: 10px; padding: 14px 18px 12px; background: var(--bg); flex-shrink: 0; border-bottom: 1px solid var(--border); }
.back-btn { width: 32px; height: 32px; border-radius: 50%; background: var(--surface); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text); }
.topbar-info { flex: 1; }
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text); }
.topbar-sub { font-size: 11px; color: var(--text3); margin-top: 1px; }
.topbar-badge { background: var(--teal-bg); color: var(--teal); font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-pill); white-space: nowrap; }
.btn-hist { background: none; border: 1px solid var(--border2); border-radius: var(--radius-pill); padding: 5px 12px; font-size: 12px; font-weight: 500; color: var(--text2); cursor: pointer; }

/* ── FIELDS ── */
.field-group { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--text2); display: flex; justify-content: space-between; align-items: center; }
.field-label.with-toggle { flex-direction: row; }
.field-input { background: var(--surface); border: 1px solid transparent; border-radius: var(--radius); padding: 11px 13px; font-size: 14px; color: var(--text); width: 100%; transition: border-color 0.15s; outline: none; appearance: none; -webkit-appearance: none; }
.field-input:focus { border-color: var(--border2); }
.field-input.small { padding: 8px 10px; font-size: 13px; }
select.field-input { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236B6B6B' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* ── TOGGLE ── */
.toggle-wrap { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.toggle-label { font-size: 11px; color: var(--text3); }
.toggle-track { width: 28px; height: 16px; border-radius: 8px; background: var(--border2); position: relative; transition: background 0.2s; flex-shrink: 0; }
.toggle-track.on { background: var(--teal); }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.toggle-track.on .toggle-thumb { transform: translateX(12px); }

/* ── MODE CARDS ── */
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.mode-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 12px; cursor: pointer; transition: all 0.15s; }
.mode-card.active { background: var(--black); border-color: var(--black); }
.mode-icon { width: 32px; height: 32px; border-radius: 8px; background: var(--surface); display: flex; align-items: center; justify-content: center; margin-bottom: 8px; color: var(--text2); }
.mode-card.active .mode-icon { background: rgba(255,255,255,0.12); color: #fff; }
.mode-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.mode-card.active .mode-title, .mode-card.active .mode-desc { color: #fff; }
.mode-desc { font-size: 11px; color: var(--text3); line-height: 1.4; }
.mode-card.active .mode-desc { color: rgba(255,255,255,0.6); }

/* ── BUTTONS ── */
.btn-black { background: var(--black); color: #fff; border: none; border-radius: var(--radius); padding: 14px; font-size: 14px; font-weight: 500; width: 100%; cursor: pointer; margin-top: 6px; transition: opacity 0.15s; }
.btn-black:active { opacity: 0.8; }
.btn-black.btn-green { background: var(--success); }
.btn-outline { background: none; color: var(--text); border: 1px solid var(--border2); border-radius: var(--radius); padding: 13px; font-size: 14px; width: 100%; cursor: pointer; margin-top: 6px; }
.btn-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #F0A500; border-radius: var(--radius); padding: 12px; font-size: 13px; width: 100%; cursor: pointer; margin-top: 4px; }
.btn-sm { background: var(--black); color: #fff; border: none; border-radius: var(--radius-sm); padding: 7px 12px; font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap; flex-shrink: 0; }

/* ── CHIPS ── */
.chips-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { display: flex; align-items: center; gap: 5px; padding: 6px 11px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--white); color: var(--text2); font-size: 12px; cursor: pointer; transition: all 0.15s; user-select: none; }
.chip.on { background: var(--black); border-color: var(--black); color: #fff; font-weight: 500; }
.chip-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* ── CUSTOM COLOR ── */
.custom-color-row { display: flex; align-items: center; gap: 7px; padding: 9px 11px; background: var(--surface); border-radius: var(--radius-sm); margin-top: 8px; }
.custom-color-label { font-size: 12px; color: var(--text3); flex-shrink: 0; }
.color-picker { width: 30px; height: 26px; border: none; border-radius: 6px; cursor: pointer; padding: 1px; background: none; flex-shrink: 0; }
.hint { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ── CODE PREVIEW ── */
.code-preview { background: var(--teal-bg); border-radius: var(--radius-sm); padding: 10px 13px; margin-top: 14px; }
.code-preview-label { font-size: 10px; font-weight: 600; color: var(--teal); text-transform: uppercase; letter-spacing: 0.08em; }
.code-preview-val { font-size: 13px; color: var(--teal); margin-top: 3px; font-family: 'SF Mono', 'Fira Code', monospace; font-weight: 500; }

/* ── SECTION / DIVIDER ── */
.section-title { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 16px; margin-bottom: 2px; }
.divider { height: 1px; background: var(--border); margin: 14px 0 0; }

/* ── VARIANTES TABLE ── */
.quick-fill-row { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.quick-fill-label { font-size: 13px; font-weight: 500; color: var(--text2); }
.quick-fill-controls { display: flex; gap: 6px; align-items: center; }
.var-table-wrap { border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; margin-top: 10px; }
.var-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.var-table th { background: var(--surface); padding: 8px 10px; text-align: left; font-size: 10px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--border); }
.var-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.var-table tr:last-child td { border-bottom: none; }
.loc-select { background: none; border: none; color: var(--teal); font-size: 11px; font-weight: 600; cursor: pointer; font-family: var(--font); padding: 0 2px; }
.col-variante { width: 40%; }
.col-stock { width: 30%; }
.col-agregar { width: 30%; }
.var-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: middle; flex-shrink: 0; }
.stock-qty { color: var(--text2); }
.add-row { display: flex; align-items: center; gap: 4px; }
.add-input { width: 40px; padding: 4px 5px; font-size: 12px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; color: var(--text); }
.add-btn { width: 26px; height: 26px; background: var(--black); color: #fff; border: none; border-radius: 7px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; font-weight: 300; }
.var-totals { display: flex; justify-content: space-between; padding: 10px 12px; background: var(--surface); border-radius: var(--radius-sm); margin-top: 10px; }
.var-total-item { display: flex; align-items: center; gap: 6px; }
.var-total-label { font-size: 12px; color: var(--text2); }
.var-total-val { font-size: 13px; font-weight: 600; color: var(--text); }
.var-total-val.teal { color: var(--teal); }

/* ── STATUS BOX ── */
.status-box { border-radius: var(--radius); padding: 12px 14px; margin-top: 14px; }
.status-box.ok { background: var(--success-bg); border: 1px solid #A9DFBF; }
.status-box.warn { background: var(--warn-bg); border: 1px solid #FAC775; }
.status-box.error { background: var(--danger-bg); border: 1px solid #F5C4B3; }
.status-box-title { font-size: 13px; font-weight: 600; }
.status-box.ok .status-box-title { color: #1A6B3A; }
.status-box.warn .status-box-title { color: #8B5000; }
.status-box.error .status-box-title { color: var(--danger); }
.status-box-sub { font-size: 12px; margin-top: 2px; }
.status-box.ok .status-box-sub { color: #27AE60; }
.status-box.warn .status-box-sub { color: var(--warn); }
.status-box.error .status-box-sub { color: var(--danger); }

/* ── QR GRID ── */
.qr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.qr-card { background: var(--surface); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.qr-img { display: flex; align-items: center; justify-content: center; }
.qr-name { font-size: 11px; font-weight: 600; text-align: center; color: var(--text); }
.qr-info { font-size: 10px; color: var(--text3); text-align: center; }
.qr-more { grid-column: span 2; background: var(--surface); border-radius: var(--radius-sm); padding: 12px; text-align: center; font-size: 12px; color: var(--text3); }

/* ── HISTORIAL ── */
.historial-header { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.hist-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.hist-name { font-size: 13px; font-weight: 500; color: var(--text); }
.hist-code { font-size: 10px; color: var(--text3); font-family: monospace; margin-top: 2px; }
.hist-actions { display: flex; gap: 5px; align-items: center; }
.hist-edit-btn { padding: 4px 9px; font-size: 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: none; cursor: pointer; color: var(--text2); }

/* ── BADGES ── */
.badge { display: inline-block; padding: 3px 9px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 500; }
.badge.ok { background: var(--success-bg); color: #1A6B3A; }
.badge.warn { background: var(--warn-bg); color: #8B5000; }
.badge.error { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: #E3F2FD; color: #0D47A1; }

/* ── METRICS ── */
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.metric-card { background: var(--surface); border-radius: var(--radius-sm); padding: 14px 12px; text-align: center; }
.metric-num { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.metric-num.teal { color: var(--teal); }
.metric-label { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 3px; }

/* ── SYNC SUMMARY ── */
.sync-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 13px; border-radius: var(--radius-sm); margin-top: 6px; }
.sync-row.ok { background: var(--success-bg); }
.sync-row.warn { background: var(--warn-bg); }
.sync-row.error { background: var(--danger-bg); }
.sync-row-label { font-size: 13px; }
.sync-row.ok .sync-row-label { color: #1A6B3A; }
.sync-row.warn .sync-row-label { color: #8B5000; }
.sync-row.error .sync-row-label { color: var(--danger); }
.warn-box { background: var(--warn-bg); border-radius: var(--radius-sm); padding: 10px 13px; font-size: 12px; color: #8B5000; margin-top: 8px; }

/* ── MODO RÁPIDO ── */
.scan-area { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 32px 0 20px; }
.scan-icon { opacity: 0.4; }
.scan-label { font-size: 14px; color: var(--text2); text-align: center; }
.barcode-input { text-align: center; font-family: monospace; font-size: 14px; letter-spacing: 0.05em; }
.found-card { background: var(--success-bg); border: 1px solid #A9DFBF; border-radius: var(--radius); padding: 14px; margin-top: 12px; margin-bottom: 4px; }
.found-name { font-size: 14px; font-weight: 600; color: #1A6B3A; }
.found-code { font-size: 11px; font-family: monospace; color: #27AE60; margin-top: 2px; }
.found-stock { font-size: 12px; color: #27AE60; margin-top: 4px; }

/* ── ROW 2 ── */
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }

/* ── TOAST ── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--black); color: #fff; padding: 10px 20px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 500; opacity: 0; transition: all 0.25s; z-index: 9999; white-space: nowrap; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warn); }

/* ── LOADER ── */
.loader-overlay { position: fixed; inset: 0; background: rgba(247,247,245,0.85); display: flex; align-items: center; justify-content: center; z-index: 9998; backdrop-filter: blur(4px); }
.loader-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loader-spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--black); border-radius: 50%; animation: spin 0.7s linear infinite; }
.loader-text { font-size: 14px; font-weight: 500; color: var(--text2); }
@keyframes spin { to { transform: rotate(360deg); } }
