:root {
  --bg: #F0F9FF;
  --card: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --line: #E0F2FE;
  --primary: #0EA5E9;
  --primary-dark: #0284C7;
  --accent: #22C55E;
  --red: #EF4444;
  --red-bg: #FEE2E2;
  --amber: #F59E0B;
  --amber-bg: #FEF3C7;
  --shadow-sm: 0 2px 6px rgba(14, 165, 233, .08);
  --shadow-md: 0 10px 30px rgba(14, 165, 233, .16);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, sans-serif; color: var(--text); font-size: 15px; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---- Login PIN ---- */
.pin-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }
.pin-page .logo { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 10px; }
.pin-page h1 { margin: 0 0 4px; font-size: 1.3rem; }
.pin-page .sub { color: var(--muted); font-size: .85rem; margin-bottom: 20px; }
.pin-dots { display: flex; gap: 14px; margin-bottom: 22px; }
.pin-dots .dot { width: 16px; height: 16px; border-radius: 99px; border: 2px solid var(--primary); }
.pin-dots .dot.filled { background: var(--primary); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 70px); gap: 12px; }
.pin-pad button { width: 70px; height: 70px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); font-size: 1.4rem; font-weight: 700; box-shadow: var(--shadow-sm); cursor: pointer; }
.pin-pad button:active { background: var(--line); }
.pin-pad button.action { background: none; box-shadow: none; border: 0; color: var(--muted); }
.pin-error { color: var(--red); font-size: .84rem; min-height: 1.4em; margin-top: 10px; }

/* ---- App shell ---- */
header.app-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: linear-gradient(135deg, var(--primary), var(--accent)); position: sticky; top: 0; z-index: 10; }
header.app-header .brand { font-weight: 800; color: #fff; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
header.app-header .brand img { width: 26px; height: 26px; border-radius: 7px; }
.offline-pill { font-size: .68rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: rgba(255,255,255,.25); color: #fff; }
.offline-pill.offline { background: var(--red); }
.icon-btn { border: 1px solid rgba(255,255,255,.5); background: rgba(255,255,255,.15); color: #fff; border-radius: 10px; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; }

.tabs { display: flex; gap: 2px; padding: 6px 6px 0; background: var(--card); position: sticky; top: 58px; z-index: 9; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 10px; font-weight: 700; color: var(--muted); font-size: .82rem; border-bottom: 3px solid transparent; white-space: nowrap; cursor: pointer; }
.tabs button.active { color: var(--primary); border-color: var(--primary); }

.page { max-width: 560px; margin: 0 auto; padding: 14px 14px 30px; }

/* ---- Dashboard ---- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: var(--shadow-sm); }
.stat-card .label { font-size: .74rem; color: var(--muted); font-weight: 600; }
.stat-card .value { font-size: 1.25rem; font-weight: 800; margin-top: 4px; }
.section-title { font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 800; margin: 20px 0 10px; }

/* ---- POS ---- */
.pos-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 90px; }
.pos-product { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: left; cursor: pointer; box-shadow: var(--shadow-sm); }
.pos-product .name { font-weight: 700; font-size: .88rem; }
.pos-product .price { color: var(--primary); font-weight: 800; margin-top: 4px; }
.pos-product .stock { font-size: .7rem; color: var(--muted); margin-top: 2px; }
.pos-product.low .stock { color: var(--red); font-weight: 700; }
.cart-bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 -6px 20px rgba(14,165,233,.12); z-index: 15; }
.cart-bar .total { font-weight: 800; font-size: 1.1rem; }
.cart-bar .count { font-size: .78rem; color: var(--muted); }

/* ---- Cards genéricas ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.card .row-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card .title { font-weight: 700; }
.card .meta { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.card .amount { font-weight: 800; font-size: 1.02rem; white-space: nowrap; }
.card .actions { display: flex; gap: 8px; margin-top: 10px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .7rem; font-weight: 700; border-radius: 99px; padding: 3px 9px; }
.badge.low { background: var(--red-bg); color: #991b1b; }
.badge.pending { background: var(--amber-bg); color: #92400e; }

.btn { border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 700; cursor: pointer; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.btn-danger { color: var(--red); }
.btn-sm { padding: 7px 10px; font-size: .8rem; }
.btn-full { width: 100%; }

.fab-add { position: fixed; bottom: 20px; right: 20px; width: 56px; height: 56px; border-radius: 99px; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; border: 0; font-size: 1.7rem; box-shadow: var(--shadow-md); cursor: pointer; z-index: 20; }

.scrim { position: fixed; inset: 0; background: rgba(15,23,42,.35); opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 40; }
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-radius: 20px 20px 0 0; box-shadow: 0 -12px 40px rgba(15,23,42,.2); transform: translateY(100%); transition: transform .2s ease-out; z-index: 41; max-height: 90vh; overflow-y: auto; }
.sheet.open { transform: translateY(0); }
.sheet-inner { padding: 18px 18px 26px; }
.sheet-inner h2 { margin: 0 0 14px; font-size: 1.1rem; }
.sheet-inner label { display: grid; gap: 6px; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 12px; }
.sheet-inner input, .sheet-inner select, .sheet-inner textarea { border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 12px; background: var(--bg); color: var(--text); }

.cart-line { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cart-line:last-child { border-bottom: 0; }
.qty-ctl { display: flex; align-items: center; gap: 8px; }
.qty-ctl button { width: 26px; height: 26px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); font-weight: 800; cursor: pointer; }

.toast-stack { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: 100%; max-width: 500px; padding: 0 16px; }
.toast { background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .84rem; box-shadow: var(--shadow-md); text-align: center; }
.empty-note { color: var(--muted); font-size: .86rem; text-align: center; padding: 24px 0; }
