/* ============================================
   Arla Sweet & Bakery — App Styles
   Color: Rose-gold + Deep Plum + Sage Green
   ============================================ */

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

:root {
  /* Brand colors */
  --plum:       #1E0E2C;
  --plum-mid:   #2D1B40;
  --plum-soft:  #3D2A52;
  --rose:       #C0556A;
  --rose-light: #E8839A;
  --rose-pale:  #FCEEF1;
  --sage:       #3D7A5F;
  --sage-light: #6AAE92;
  --sage-pale:  #EAF5EF;
  --gold:       #D4963A;
  --gold-light: #F0BC6E;
  --gold-pale:  #FDF3E3;
  --red:        #C0392B;
  --red-pale:   #FDECEA;

  /* Surfaces */
  --bg:         #F7F4FF;
  --card:       #FFFFFF;
  --border:     #EDE8F5;
  --border-mid: #D9D0ED;

  /* Text */
  --text:       #1E0E2C;
  --text-mid:   #4A3560;
  --text-muted: #8B7AA0;

  /* UI */
  --radius-sm:  8px;
  --radius:     14px;
  --radius-lg:  20px;
  --shadow:     0 2px 16px rgba(30,14,44,.08);
  --shadow-lg:  0 8px 32px rgba(30,14,44,.14);

  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  background: var(--bg);
  color: var(--text);
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 80px;
  overflow-x: hidden;
}

/* ── TOPBAR ── */
.topbar {
  background: linear-gradient(135deg, var(--plum) 0%, var(--plum-mid) 100%);
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 12px rgba(30,14,44,.3);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--rose) 0%, var(--gold) 100%);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  box-shadow: 0 2px 8px rgba(192,85,106,.4);
}
.brand-name { color: #fff; font-size: 14px; font-weight: 800; letter-spacing: -.01em; }
.brand-sub  { color: rgba(255,255,255,.5); font-size: 10px; font-weight: 600; margin-top: 1px; }
.topbar-meta { display: flex; align-items: center; gap: 8px; }
.topbar-date { color: rgba(255,255,255,.55); font-size: 10px; text-align: right; line-height: 1.5; }
.online-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--sage-light);
  box-shadow: 0 0 0 2px rgba(106,174,146,.3);
}

/* ── SCREENS ── */
.screen { display: none; }
.screen.active { display: block; }

.screen-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 10px;
}
.screen-header h2 { font-size: 16px; font-weight: 800; color: var(--text); }

/* ── STAT GRID ── */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px 14px 6px;
}
.stat-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}
.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
}
.stat-card.accent::before  { background: linear-gradient(90deg, var(--rose), var(--gold)); }
.stat-card.danger::before  { background: var(--red); }
.stat-card.warning::before { background: var(--gold); }
.stat-card.success::before { background: var(--sage); }
.stat-icon { font-size: 20px; margin-bottom: 6px; }
.stat-val  { font-size: 22px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-lbl  { font-size: 10px; color: var(--text-muted); margin-top: 4px; font-weight: 600; }

/* ── SECTION HEAD ── */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 6px;
}
.section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); }
.section-link  { font-size: 11px; color: var(--rose); font-weight: 700; cursor: pointer; }

/* ── CARD ── */
.card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  margin: 0 14px 9px;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.card-row { display: flex; align-items: center; gap: 11px; }
.av {
  width: 42px; height: 42px;
  border-radius: 11px;
  background: var(--rose-pale);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.av.txt { font-size: 16px; font-weight: 800; color: var(--rose); }
.av.sage { background: var(--sage-pale); }
.ci { flex: 1; min-width: 0; }
.ci .cn { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci .cs { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.cr { text-align: right; flex-shrink: 0; }
.cr .ca { font-size: 14px; font-weight: 800; color: var(--rose); }

/* ── BADGES ── */
.badge {
  display: inline-block;
  font-size: 9px; font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  margin-top: 3px;
  letter-spacing: .03em;
}
.badge-pending { background: var(--gold-pale);  color: #7A5010; }
.badge-done    { background: var(--sage-pale);   color: #1A5C3A; }
.badge-deliver { background: #EEF0FF;             color: #2D3A9A; }
.badge-due     { background: var(--red-pale);     color: #8B1A1A; }
.badge-paid    { background: var(--sage-pale);    color: var(--sage); }

/* ── FILTER TABS ── */
.filter-tabs {
  display: flex; gap: 6px;
  padding: 4px 14px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.ftab {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border-mid);
  background: var(--card);
  font-size: 12px; font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.ftab.active {
  background: var(--plum);
  border-color: var(--plum);
  color: #fff;
}

/* ── LEDGER ── */
.ledger-summary {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 8px; padding: 0 14px 10px;
}
.ls-box {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}
.ls-val { font-size: 15px; font-weight: 800; color: var(--red); }
.ls-val.green { color: var(--sage); }
.ls-lbl { font-size: 9px; color: var(--text-muted); font-weight: 600; margin-top: 3px; }

.ledger-block {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin: 0 14px 10px;
  overflow: hidden;
}
.lb-head {
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--plum) 0%, var(--plum-soft) 100%);
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
}
.lb-name { font-size: 13px; font-weight: 700; color: #fff; }
.lb-due  { font-size: 13px; font-weight: 800; color: var(--rose-light); }
.lb-paid { font-size: 13px; font-weight: 800; color: var(--sage-light); }
.lb-entries { display: none; }
.lb-entries.open { display: block; }
.lb-entry {
  padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--border);
}
.le-date  { font-size: 10px; color: var(--text-muted); font-weight: 600; }
.le-items { font-size: 12px; color: var(--text); margin-top: 2px; }
.le-r { text-align: right; }
.le-amt  { font-size: 12px; font-weight: 700; color: var(--text); }
.le-paid { font-size: 10px; color: var(--sage); }
.le-due  { font-size: 10px; color: var(--red); }
.lb-pay-btn {
  margin: 10px 14px 12px;
  width: calc(100% - 28px);
  padding: 9px;
  background: linear-gradient(135deg, var(--sage) 0%, var(--sage-light) 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity .15s;
}
.lb-pay-btn:hover { opacity: .9; }
.whatsapp-btn {
  margin: 0 14px 12px;
  width: calc(100% - 28px);
  padding: 9px;
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

/* ── STOCK ── */
.stock-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 9px; padding: 0 14px 10px;
}
.stk-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.stk-card:hover { box-shadow: var(--shadow); }
.stk-emo { font-size: 26px; margin-bottom: 6px; }
.stk-name { font-size: 12px; font-weight: 700; color: var(--text); }
.stk-price { font-size: 14px; font-weight: 800; color: var(--rose); margin-top: 3px; }
.stk-bar-wrap {
  background: var(--border);
  border-radius: 6px; height: 7px;
  margin-top: 9px; overflow: hidden;
}
.stk-bar-fill {
  height: 100%; border-radius: 6px;
  background: var(--sage);
  transition: width .5s cubic-bezier(.4,0,.2,1);
}
.stk-bar-fill.warn { background: var(--gold); }
.stk-bar-fill.low  { background: var(--red); }
.stk-qty { font-size: 10px; color: var(--text-muted); margin-top: 5px; font-weight: 600; }
.stk-low-tag {
  display: inline-block;
  background: var(--red-pale); color: var(--red);
  font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px;
  margin-top: 4px;
}

/* ── REPORT ── */
.rep-period {
  display: flex; gap: 6px; padding: 4px 14px 10px;
}
.period-btn {
  flex: 1; padding: 8px 4px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-mid);
  background: var(--card);
  font-size: 12px; font-weight: 700;
  color: var(--text-muted); cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.period-btn.active {
  background: var(--plum); border-color: var(--plum); color: #fff;
}
.rep-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 0 14px 6px; }
.rep-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.rep-card .rv { font-size: 20px; font-weight: 800; margin-top: 4px; }
.rep-card .rl { font-size: 10px; color: var(--text-muted); font-weight: 600; margin-top: 3px; }
.rv.green { color: var(--sage); }
.rv.red   { color: var(--red); }
.rv.gold  { color: var(--gold); }

.top-prod-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.top-prod-row:last-child { border-bottom: none; }
.tp-rank { font-size: 14px; font-weight: 800; color: var(--rose-light); width: 22px; }
.tp-emo  { font-size: 20px; }
.tp-info { flex: 1; }
.tp-name { font-size: 12px; font-weight: 700; }
.tp-sold { font-size: 10px; color: var(--text-muted); }
.tp-bar-wrap { background: var(--border); border-radius: 4px; height: 5px; margin-top: 4px; }
.tp-bar { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--rose), var(--gold)); }
.tp-amt { font-size: 13px; font-weight: 800; color: var(--rose); }

.cat-breakdown { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.cat-row { display: flex; align-items: center; gap: 10px; }
.cat-label { font-size: 12px; font-weight: 600; width: 70px; flex-shrink: 0; }
.cat-bar-wrap { flex: 1; background: var(--border); border-radius: 6px; height: 10px; overflow: hidden; }
.cat-bar { height: 100%; border-radius: 6px; }
.cat-pct { font-size: 11px; font-weight: 700; color: var(--text-muted); width: 36px; text-align: right; }

/* ── CHART ── */
.chart-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin: 0 14px 10px;
  padding: 14px;
}
.weekly-chart {
  display: flex; align-items: flex-end;
  gap: 5px; height: 80px;
}
.wc-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wc-bar {
  width: 100%; border-radius: 5px 5px 0 0;
  min-height: 4px;
  background: linear-gradient(180deg, var(--rose-light) 0%, var(--rose) 100%);
  transition: height .5s cubic-bezier(.4,0,.2,1);
}
.wc-bar.today {
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 100%);
}
.wc-lbl { font-size: 9px; color: var(--text-muted); font-weight: 600; }
.wc-val { font-size: 8px; font-weight: 700; color: var(--text-muted); }

/* ── BOTTOM NAV ── */
.bnav {
  position: fixed; bottom: 0;
  left: 50%; transform: translateX(-50%);
  width: 430px; max-width: 100%;
  background: var(--plum);
  display: flex;
  padding: 8px 0 12px;
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(30,14,44,.25);
}
.bni {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 2px;
  cursor: pointer; opacity: .45;
  transition: opacity .15s;
  position: relative;
}
.bni.active { opacity: 1; }
.bni-ico { font-size: 20px; }
.bni-lbl { font-size: 9px; color: #fff; font-weight: 700; letter-spacing: .02em; }
.bni-badge {
  position: absolute; top: 0; right: calc(50% - 18px);
  background: var(--rose);
  color: #fff; font-size: 8px; font-weight: 800;
  width: 14px; height: 14px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.bni-badge:empty { display: none; }

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: 88px; right: calc(50% - 200px);
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--rose) 0%, var(--gold) 100%);
  border-radius: 50%;
  border: none;
  color: #fff; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(192,85,106,.45);
  cursor: pointer; z-index: 150;
  transition: transform .15s, box-shadow .15s;
  font-family: inherit;
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(192,85,106,.55); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(30,14,44,.6);
  z-index: 300;
  display: none;
  backdrop-filter: blur(2px);
}
.modal-overlay.show { display: block; }

.modal {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%) translateY(100%);
  width: 430px; max-width: 100%;
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 400;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  max-height: 90vh;
  overflow-y: auto;
}
.modal.show { transform: translateX(-50%) translateY(0); }

.modal-head {
  padding: 16px 16px 12px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--card); z-index: 1;
}
.modal-head h3 { font-size: 15px; font-weight: 800; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%; border: none;
  background: var(--border); color: var(--text-muted);
  font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
}
.modal-body { padding: 14px 16px; }
.modal-foot {
  padding: 12px 16px 20px;
  display: flex; gap: 8px;
  border-top: 1px solid var(--border);
  position: sticky; bottom: 0; background: var(--card);
}

/* ── FORM FIELDS ── */
.field-label {
  display: block;
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 5px; margin-top: 13px;
}
.field-label:first-child { margin-top: 0; }
.field-input {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  color: var(--text);
  background: var(--bg);
  font-family: inherit;
  transition: border-color .15s;
  outline: none;
}
.field-input:focus { border-color: var(--rose); background: #fff; }

.due-preview {
  background: var(--rose-pale);
  border: 1.5px solid var(--rose-light);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 12px; font-weight: 700;
  color: var(--red);
  margin-top: 10px;
  display: none;
}
.due-preview.show { display: block; }
.due-preview.ok { background: var(--sage-pale); border-color: var(--sage-light); color: var(--sage); }

.payment-info {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px; margin-bottom: 4px;
}
.payment-info .pi-name { font-size: 14px; font-weight: 800; }
.payment-info .pi-due  { font-size: 20px; font-weight: 800; color: var(--red); margin-top: 4px; }
.payment-info .pi-lbl  { font-size: 10px; color: var(--text-muted); }

/* ── BUTTONS ── */
.btn-primary {
  flex: 1; padding: 12px;
  background: linear-gradient(135deg, var(--plum) 0%, var(--plum-soft) 100%);
  color: #fff; border: none;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .9; }
.btn-primary.sm { padding: 7px 14px; font-size: 12px; flex: none; }
.btn-ghost {
  flex: 0 0 80px; padding: 12px;
  background: var(--border);
  color: var(--text-muted); border: none;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 96px;
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--plum);
  color: #fff; padding: 10px 20px;
  border-radius: 20px; font-size: 13px; font-weight: 700;
  z-index: 500; opacity: 0;
  transition: all .3s cubic-bezier(.4,0,.2,1);
  pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
}
.empty-state .es-ico { font-size: 40px; margin-bottom: 10px; }
.empty-state .es-txt { font-size: 13px; font-weight: 600; }
