/* ============================================================
   Loretta's Empanada — Staff Inventory & Sales
   Same family as the customer site, tuned for fast data entry
   ============================================================ */

:root{
  --paper:      #F2E9D5;
  --paper-dark: #E8DBBE;
  --ink:        #23190F;
  --ink-soft:   #3a2f22;
  --annatto:    #C1440E;
  --annatto-dk: #9A3509;
  --turmeric:   #E3A008;
  --kraft:      #7A5230;
  --green:      #445C36;
  --red:        #B3261E;
  --white:      #FFFBF2;
  --line:       #d9c89a;

  --font-display: "Fraunces", serif;
  --font-body: "Work Sans", sans-serif;
  --font-mono: "Space Mono", monospace;

  --radius: 8px;
}

*, *::before, *::after{ box-sizing: border-box; }

body{
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100svh;
  padding-bottom: 84px; /* room for bottom nav */
}

a{ color: inherit; }
button{ font-family: inherit; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible{
  outline: 3px solid var(--turmeric);
  outline-offset: 1px;
}
@media (prefers-reduced-motion: reduce){
  *{ animation: none !important; transition: none !important; }
}

.wrap{ max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* ---------- top bar ---------- */
.topbar{
  position: sticky; top: 0; z-index: 30;
  background: var(--ink);
  border-bottom: 2px solid var(--annatto);
}
.topbar .wrap{
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
}
.brand{ display: flex; align-items: center; gap: 10px; }
.brand img{ width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--turmeric); }
.brand-name{ font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.brand-name small{
  display: block; font-family: var(--font-mono); font-size: 0.6rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--turmeric); font-weight: 400;
}
.status-dot{
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(68,92,54,0.25);
}
.status-dot.offline{ background: var(--red); box-shadow: 0 0 0 3px rgba(179,38,30,0.25); }
.status-row{ display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: #c9bda0; }

/* ---------- main content ---------- */
main{ padding: 20px 0 40px; }
.view{ display: none; }
.view.active{ display: block; }

.page-head{ margin-bottom: 18px; }
.page-head h1{
  font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; margin: 0 0 4px;
}
.page-head p{ margin: 0; color: #c9bda0; font-size: 0.9rem; }

/* ---------- cards ---------- */
.card{
  background: #2e2115;
  border: 1px solid #493523;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card h3{ margin: 0 0 12px; font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; }

/* ---------- dashboard stat grid ---------- */
.stat-grid{
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px;
}
.stat{
  background: #2e2115; border: 1px solid #493523; border-radius: var(--radius);
  padding: 16px;
}
.stat .label{ font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--turmeric); }
.stat .value{ font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; margin-top: 4px; }
.stat .sub{ font-size: 0.78rem; color: #c9bda0; margin-top: 2px; }

.alert-banner{
  background: rgba(179,38,30,0.15);
  border: 1px solid var(--red);
  color: #f3c9c5;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.85rem;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.alert-banner.hidden{ display: none; }

/* ---------- ingredient rows ---------- */
.ingredient-row{
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid #493523;
}
.ingredient-row:last-child{ border-bottom: none; }
.ingredient-name{ font-weight: 500; }
.ingredient-name .unit{ font-family: var(--font-mono); font-size: 0.7rem; color: #c9bda0; text-transform: uppercase; margin-left: 6px; }
.ingredient-row.low .ingredient-name{ color: #ffb4ab; }
.ingredient-row.low::before{ content: "⚠"; margin-right: 6px; color: var(--red); }

.qty-controls{ display: flex; align-items: center; gap: 8px; }
.qty-controls .qty{ font-family: var(--font-mono); font-weight: 700; min-width: 54px; text-align: center; }
.step-btn{
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid #6b5236; background: #23190F; color: var(--paper);
  font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.step-btn:hover{ border-color: var(--turmeric); }

.add-form{ display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.add-form input, .add-form select{
  flex: 1; min-width: 100px;
  background: #23190F; border: 1px solid #493523; color: var(--paper);
  padding: 10px 12px; border-radius: 6px; font-family: var(--font-body); font-size: 0.9rem;
}

/* ---------- buttons ---------- */
.btn{
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-mono); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 12px 16px; border-radius: 6px; border: 1px solid var(--annatto);
  background: var(--annatto); color: var(--white); cursor: pointer; text-decoration: none;
}
.btn:hover{ background: var(--annatto-dk); }
.btn-ghost{ background: transparent; color: var(--paper); border-color: #6b5236; }
.btn-ghost:hover{ border-color: var(--turmeric); }
.btn-block{ width: 100%; }
.btn-sm{ padding: 8px 12px; font-size: 0.7rem; }
.btn-danger{ background: transparent; border-color: var(--red); color: #ffb4ab; }

/* ---------- production/sales table ---------- */
.flavor-entry{
  display: grid; grid-template-columns: 1fr 64px 64px auto; gap: 8px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid #493523;
}
.flavor-entry:last-child{ border-bottom: none; }
.flavor-entry .fname{ font-weight: 500; }
.flavor-entry input{
  width: 100%; background: #23190F; border: 1px solid #493523; color: var(--paper);
  padding: 8px; border-radius: 6px; font-family: var(--font-mono); text-align: center;
}
.flavor-entry .frev{ font-family: var(--font-mono); font-size: 0.8rem; color: var(--turmeric); text-align: right; white-space: nowrap; }
.field-labels{
  display: grid; grid-template-columns: 1fr 64px 64px auto; gap: 8px;
  font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase; color: #c9bda0;
  padding-bottom: 6px; border-bottom: 2px dashed #493523; margin-bottom: 4px;
}

.day-total{
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 14px; padding-top: 14px; border-top: 2px solid var(--annatto);
  font-family: var(--font-mono);
}
.day-total .amount{ font-family: var(--font-display); font-size: 1.4rem; color: var(--turmeric); font-weight: 600; }

/* ---------- history list ---------- */
.history-row{
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid #493523; cursor: pointer;
}
.history-row:last-child{ border-bottom: none; }
.history-row .date{ font-family: var(--font-mono); font-size: 0.85rem; }
.history-row .rev{ font-family: var(--font-display); font-weight: 600; color: var(--turmeric); }
.history-row .meta{ font-size: 0.72rem; color: #c9bda0; }

.empty-state{
  text-align: center; padding: 30px 10px; color: #c9bda0; font-size: 0.9rem;
}

/* ---------- settings ---------- */
.setting-row{
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid #493523;
}
.setting-row:last-child{ border-bottom: none; }
.setting-row label{ font-size: 0.9rem; }
.setting-row input{
  width: 90px; background: #23190F; border: 1px solid #493523; color: var(--paper);
  padding: 8px; border-radius: 6px; font-family: var(--font-mono); text-align: right;
}

.code-box{
  font-family: var(--font-mono); font-size: 0.75rem; background: #23190F;
  border: 1px dashed #6b5236; border-radius: 6px; padding: 12px; word-break: break-all; color: #c9bda0;
}

/* ---------- bottom nav ---------- */
.bottom-nav{
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--ink); border-top: 2px solid var(--annatto);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav button{
  flex: 1; background: none; border: none; color: #c9bda0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 8px; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em;
}
.bottom-nav button.active{ color: var(--turmeric); }
.bottom-nav svg{ width: 20px; height: 20px; }

/* ---------- setup gate ---------- */
.setup-gate{
  min-height: 100svh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.setup-card{
  max-width: 460px; background: #2e2115; border: 1px solid #493523; border-radius: var(--radius); padding: 26px;
}
.setup-card h1{ font-family: var(--font-display); font-size: 1.4rem; margin-top: 0; }
.setup-card ol{ padding-left: 20px; font-size: 0.92rem; color: #ddd0b4; }
.setup-card code{ background: #23190F; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; }

.toast{
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%) translateY(120%);
  background: var(--turmeric); color: var(--ink); font-family: var(--font-mono); font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 10px 16px; border-radius: 6px;
  z-index: 60; transition: transform 0.25s ease; font-weight: 700;
}
.toast.show{ transform: translateX(-50%) translateY(0); }
