/* ═══════════════════════════════════════
   TOKENS
═══════════════════════════════════════ */
:root {
  --green: #0a5c47;
  --green-mid: #0f6e56;
  --green-light: #e6f5f0;
  --green-pale: #f0faf6;
  --accent: #1db87a;
  --amber: #f59e0b;
  --red: #ef4444;
  --text: #0f172a;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --border: #e2e8f0;
  --surface: #ffffff;
  --bg: #f8fafc;
  --radius: 14px;
  --radius-sm: 9px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ═══════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════ */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
}

/* ═══════════════════════════════════════
   TOP BAR
═══════════════════════════════════════ */
.topbar {
  background: var(--green);
  color: #fff;
  padding: 12px 16px 10px;
  padding-top: calc(12px + var(--safe-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.topbar-left { display: flex; flex-direction: column; gap: 1px; }
.topbar-location {
  font-size: 10px; opacity: 0.65; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em;
}
.topbar-user { font-size: 14px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.sync-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #f59e0b; flex-shrink: 0;
  transition: background .3s;
}
.sync-dot.online  { background: var(--accent); }
.sync-dot.syncing { background: #60a5fa; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

.cash-pill {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 700;
}

/* ═══════════════════════════════════════
   SCREENS
═══════════════════════════════════════ */
.screen        { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.screen.active { display: flex; }

/* ═══════════════════════════════════════
   LOGIN
═══════════════════════════════════════ */
#screen-login {
  background: var(--green);
  justify-content: center;
  align-items: center;
  padding: 24px;
  gap: 0;
}
.login-logo { font-size: 40px; font-weight: 800; color: #fff; letter-spacing: -1.5px; margin-bottom: 3px; }
.login-sub  { font-size: 13px; color: rgba(255,255,255,0.55); margin-bottom: 36px; }
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 26px 22px 22px;
  width: 100%;
  max-width: 380px;
}
.login-card h2 { font-size: 17px; font-weight: 700; margin-bottom: 18px; }

.field              { margin-bottom: 13px; }
.field label        { font-size: 11px; font-weight: 700; color: var(--text-2); display: block; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .05em; }
.field input,
.field select       { width: 100%; padding: 13px 14px; font-size: 15px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); outline: none; background: var(--bg); color: var(--text); -webkit-appearance: none; appearance: none; }
.field input:focus,
.field select:focus { border-color: var(--green-mid); background: #fff; }

.login-btn          { width: 100%; background: var(--green); color: #fff; border: none; border-radius: var(--radius-sm); padding: 15px; font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 6px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.login-btn:active   { opacity: 0.85; }
.login-btn:disabled { opacity: 0.5; }
.login-err          { font-size: 12px; color: var(--red); margin-top: 8px; text-align: center; min-height: 18px; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════
   COUNTER — PRODUCT GRID
═══════════════════════════════════════ */
.products-scroll { overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; flex: 1; }
.section-label   { font-size: 10px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; margin: 0 0 8px; }

.prod-grid      { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.prod-grid.cols2 { grid-template-columns: repeat(2, 1fr); }

.prod-btn {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 12px 6px 10px;
  cursor: pointer; text-align: center;
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; min-height: 88px; justify-content: center;
  position: relative; overflow: hidden;
  transition: border-color .1s, background .1s, transform .1s;
}
.prod-btn:active   { transform: scale(0.93); background: var(--green-pale); border-color: var(--green-mid); }
.prod-btn.flash    { background: #bbf7d0; border-color: var(--accent); }
.prod-btn .icon    { font-size: 26px; line-height: 1; }
.prod-btn .pname   { font-size: 11px; font-weight: 700; color: var(--text); line-height: 1.2; }
.prod-btn .pprice  { font-size: 10px; font-weight: 600; color: var(--green-mid); }

.cart-badge {
  position: absolute; top: 5px; right: 5px;
  background: var(--green); color: #fff;
  font-size: 10px; font-weight: 800;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: none; align-items: center; justify-content: center; padding: 0 3px;
}

/* ═══════════════════════════════════════
   COUNTER — LITRE WIDGET
═══════════════════════════════════════ */
.litre-row { display: flex; gap: 8px; margin-bottom: 16px; align-items: stretch; }
.litre-box {
  flex: 1; background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px;
}
.litre-box label   { font-size: 10px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.litre-controls    { display: flex; align-items: center; gap: 6px; }
.litre-controls input { border: none; background: transparent; font-size: 24px; font-weight: 700; width: 70px; outline: none; color: var(--text); }
.litre-unit        { font-size: 15px; color: var(--text-2); font-weight: 500; }
.litre-price       { font-size: 11px; color: var(--green-mid); font-weight: 600; }
.litre-add-btn     { background: var(--green); color: #fff; border: none; border-radius: var(--radius); padding: 0 20px; font-size: 28px; font-weight: 300; cursor: pointer; flex-shrink: 0; }
.litre-add-btn:active { opacity: 0.8; transform: scale(0.94); }

/* ═══════════════════════════════════════
   CART FAB
═══════════════════════════════════════ */
.cart-fab {
  position: fixed;
  bottom: calc(58px + var(--safe-bottom) + 14px);
  left: 50%; transform: translateX(-50%);
  background: var(--green);
  color: #fff; border: none; border-radius: 30px;
  padding: 13px 22px; font-size: 14px; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 20px rgba(10,92,71,0.4);
  display: flex; align-items: center; gap: 10px; z-index: 50;
  white-space: nowrap; transition: transform .15s, box-shadow .15s;
  min-width: 220px; justify-content: center;
}
.cart-fab:active { transform: translateX(-50%) scale(0.96); }
.cart-fab.hidden { display: none; }

.fab-count { background: var(--accent); border-radius: 12px; font-size: 11px; font-weight: 800; padding: 2px 7px; }

/* ═══════════════════════════════════════
   DRAWERS (cart & expense)
═══════════════════════════════════════ */
.drawer-overlay       { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.drawer-overlay.open  { pointer-events: all; }
.drawer-bg            { position: absolute; inset: 0; background: rgba(0,0,0,0); transition: background .25s; }
.drawer-overlay.open .drawer-bg    { background: rgba(0,0,0,0.5); }
.drawer-sheet {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--surface); border-radius: 22px 22px 0 0;
  max-height: 88vh; display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.32,.72,0,1);
  padding-bottom: var(--safe-bottom);
}
.drawer-overlay.open .drawer-sheet { transform: translateY(0); }
.drawer-handle  { width: 38px; height: 4px; background: var(--border); border-radius: 2px; margin: 10px auto 0; flex-shrink: 0; }
.drawer-header  { padding: 14px 16px 12px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.drawer-title   { font-size: 15px; font-weight: 700; }
.clear-btn      { font-size: 12px; color: var(--red); background: none; border: none; cursor: pointer; padding: 4px 8px; font-weight: 600; }

.cart-list  { overflow-y: auto; flex: 1; padding: 4px 16px; }
.cart-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px; gap: 10px; color: var(--text-3); font-size: 13px; }

.cart-item           { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.cart-item:last-child { border-bottom: none; }
.ci-info  { flex: 1; }
.ci-name  { font-size: 13px; font-weight: 600; }
.ci-unit  { font-size: 11px; color: var(--text-2); margin-top: 1px; }
.ci-total { font-size: 14px; font-weight: 700; min-width: 72px; text-align: right; }

.qty-row         { display: flex; align-items: center; gap: 6px; }
.qbtn            { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--bg); font-size: 17px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text); }
.qbtn:active     { background: var(--green-light); border-color: var(--green-mid); }
.qnum            { font-size: 15px; font-weight: 700; min-width: 24px; text-align: center; }

.drawer-footer   { padding: 14px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
.total-line      { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.total-label     { font-size: 13px; color: var(--text-2); }
.total-amt       { font-size: 28px; font-weight: 800; letter-spacing: -.5px; }

.encaisser-btn          { width: 100%; background: var(--green); color: #fff; border: none; border-radius: var(--radius); padding: 16px; font-size: 16px; font-weight: 700; cursor: pointer; }
.encaisser-btn:active   { opacity: 0.85; }
.encaisser-btn:disabled { opacity: 0.3; cursor: default; }

.expense-form       { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.expense-form .field { margin-bottom: 0; }

/* ═══════════════════════════════════════
   BOTTOM NAV
═══════════════════════════════════════ */
.bottom-nav { background: var(--surface); border-top: 1px solid var(--border); display: flex; flex-shrink: 0; padding-bottom: var(--safe-bottom); }
.nav-btn        { flex: 1; background: none; border: none; padding: 10px 4px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--text-3); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.nav-btn.active { color: var(--green); }
.nav-btn svg    { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-badge      { position: absolute; top: 6px; background: var(--amber); color: #fff; font-size: 9px; font-weight: 800; min-width: 16px; height: 16px; border-radius: 8px; display: none; align-items: center; justify-content: center; }

/* ═══════════════════════════════════════
   SCREEN HEADER
═══════════════════════════════════════ */
.screen-hdr    { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; border-bottom: 1px solid var(--border); }
.screen-hdr h2 { font-size: 17px; font-weight: 700; }

/* ═══════════════════════════════════════
   LEDGER
═══════════════════════════════════════ */
.ledger-summary { margin: 12px 16px; background: var(--green-light); border-radius: var(--radius); padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.ls-left    { display: flex; flex-direction: column; gap: 3px; }
.ls-label   { font-size: 12px; color: var(--green); font-weight: 600; }
.ls-pending { font-size: 11px; color: var(--amber); font-weight: 600; }
.ls-total   { font-size: 24px; font-weight: 800; color: var(--green); letter-spacing: -.5px; }

.ledger-list  { overflow-y: auto; flex: 1; padding: 0 16px 12px; -webkit-overflow-scrolling: touch; }
.ledger-entry { background: var(--surface); border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 7px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); }
.le-icon  { font-size: 20px; }
.le-info  { flex: 1; min-width: 0; }
.le-items { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.le-meta  { font-size: 11px; color: var(--text-2); margin-top: 1px; }
.le-total { font-size: 14px; font-weight: 700; color: var(--green); white-space: nowrap; }

.local-tag   { font-size: 9px; background: #fef3c7; color: #92400e; border-radius: 4px; padding: 2px 5px; font-weight: 700; white-space: nowrap; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 24px; gap: 10px; color: var(--text-3); font-size: 13px; text-align: center; }

/* ═══════════════════════════════════════
   SETTINGS
═══════════════════════════════════════ */
.settings-scroll    { overflow-y: auto; flex: 1; padding: 12px 16px; }
.settings-section   { margin-bottom: 22px; }
.settings-section h3 { font-size: 10px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.settings-card      { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }

.srow              { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--border); }
.srow:last-child   { border-bottom: none; }
.srow-icon         { font-size: 18px; width: 26px; text-align: center; flex-shrink: 0; }
.srow-info         { flex: 1; }
.srow-label        { font-size: 13px; font-weight: 600; }
.srow-sub          { font-size: 11px; color: var(--text-2); margin-top: 1px; }
.srow-action       { font-size: 12px; font-weight: 600; border: none; background: none; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.srow-action.red   { color: var(--red); }
.srow-action.green { color: var(--green-mid); }

.price-input { width: 90px; border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; font-size: 13px; font-weight: 700; text-align: right; background: var(--bg); color: var(--text); }

/* ═══════════════════════════════════════
   SUCCESS OVERLAY
═══════════════════════════════════════ */
.overlay      { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.55); display: none; align-items: center; justify-content: center; padding: 24px; }
.overlay.open { display: flex; }
.overlay-card { background: #fff; border-radius: 22px; padding: 32px 24px; width: 100%; max-width: 320px; text-align: center; animation: pop .25s cubic-bezier(.34,1.56,.64,1); }
@keyframes pop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.ov-icon   { font-size: 54px; margin-bottom: 12px; }
.ov-title  { font-size: 20px; font-weight: 800; color: var(--green); margin-bottom: 6px; }
.ov-amount { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin-bottom: 4px; }
.ov-sub    { font-size: 12px; color: var(--text-2); margin-bottom: 24px; line-height: 1.5; }
.ov-btn    { width: 100%; background: var(--green); color: #fff; border: none; border-radius: var(--radius-sm); padding: 14px; font-size: 15px; font-weight: 700; cursor: pointer; }

/* ═══════════════════════════════════════
   SHIFT SUMMARY
═══════════════════════════════════════ */
.shift-summary {
  background: var(--green-light);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.4;
}
.shift-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
}
.shift-row.shift-total {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 10px;
  font-size: 14px;
}
.shift-row .green { color: var(--green); }
.shift-row .red   { color: var(--red); }

/* ═══════════════════════════════════════
   TOAST
═══════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: calc(70px + var(--safe-bottom) + 8px);
  left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff;
  padding: 10px 18px; border-radius: 20px;
  font-size: 13px; font-weight: 500; z-index: 300;
  opacity: 0; transition: opacity .2s; white-space: nowrap;
  pointer-events: none;
}
.toast.show { opacity: 1; }
