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

:root {
  --ink: #1F2A24;
  --ink-soft: #47554B;
  --paper: #FBF9F4;
  --card: #FFFFFF;
  --line: #E4E0D6;
  --turmeric: #C98A00;
  --turmeric-soft: #FBEAC7;
  --teal: #0F5257;
  --teal-soft: #DCEEEE;
  --green: #2F7D4C;
  --green-soft: #DFF3E4;
  --red: #B23A2F;
  --red-soft: #FBE3E0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31,42,36,0.06), 0 4px 14px rgba(31,42,36,0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 72px;
}
h1, h2, h3, .brand { font-family: 'Fraunces', serif; font-weight: 600; letter-spacing: -0.01em; }
a { color: inherit; }
button { font-family: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--ink); color: var(--paper);
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-size: 19px; color: var(--paper); }
.topbar .brand span { color: var(--turmeric); }
.topbar button.icon-btn {
  background: none; border: none; color: var(--paper); font-size: 14px; cursor: pointer;
  opacity: 0.85;
}

/* ---------- Bottom nav ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 2px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav button {
  flex: 1; background: none; border: none; padding: 8px 2px; font-size: 11px;
  color: var(--ink-soft); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.bottomnav button .ic { font-size: 18px; }
.bottomnav button.active { color: var(--teal); font-weight: 600; }

/* ---------- Layout ---------- */
.view { display: none; padding: 16px; max-width: 720px; margin: 0 auto; }
.view.active { display: block; }
.section-title { font-size: 20px; margin: 4px 0 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 4px; font-weight: 600; }
.field { margin-bottom: 12px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 15px; background: #fff; color: var(--ink); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: 1px; border-color: var(--teal); }
.hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.error-text { color: var(--red); font-size: 13px; margin-top: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: 8px; border: none; font-weight: 600; font-size: 14.5px;
  cursor: pointer; transition: transform .05s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-accent { background: var(--turmeric); color: #fff; }
.btn-outline { background: none; border: 1px solid var(--line); color: var(--ink); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-sm { padding: 7px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- Pills / badges ---------- */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; text-transform: capitalize; }
.pill.status-received { background: var(--teal-soft); color: var(--teal); }
.pill.status-preparing { background: var(--turmeric-soft); color: var(--turmeric); }
.pill.status-out_for_delivery { background: #E4DEFB; color: #5B3FBF; }
.pill.status-delivered { background: var(--green-soft); color: var(--green); }
.pill.status-cancelled { background: var(--red-soft); color: var(--red); }
.pill.pay-unpaid { background: var(--red-soft); color: var(--red); }
.pill.pay-partial { background: var(--turmeric-soft); color: var(--turmeric); }
.pill.pay-paid { background: var(--green-soft); color: var(--green); }

/* ---------- Order card ---------- */
.order-card { border-left: 4px solid var(--teal); }
.order-card .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.order-card .oid { font-weight: 700; font-size: 15px; }
.order-card .meta { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.order-card .items-list { font-size: 13.5px; margin: 10px 0; padding-left: 0; list-style: none; }
.order-card .items-list li { display: flex; justify-content: space-between; padding: 2px 0; border-bottom: 1px dashed var(--line); }
.order-card .totals { display: flex; justify-content: space-between; font-weight: 700; margin-top: 8px; }
.order-card .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.order-card .badges { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 8px; margin-bottom: 14px; }
.filters select { width: auto; }

/* ---------- Reports sub-nav ---------- */
.subnav {
  display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 2px;
}
.subnav button {
  flex-shrink: 0; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-soft); font-weight: 600; font-size: 13.5px; cursor: pointer;
}
.subnav button.active { background: var(--teal); border-color: var(--teal); color: #fff; }
.subview { display: none; }
.subview.active { display: block; }

/* ---------- Analytics stat widgets ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat-card .label { font-size: 11.5px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.stat-card .value { font-size: 20px; font-weight: 700; margin-top: 4px; font-family: 'Fraunces', serif; }
.stat-card .sub { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; }
.stat-card.accent { background: var(--teal-soft); border-color: transparent; }
.stat-card.warn { background: var(--red-soft); border-color: transparent; }

/* ---------- Mini bar chart ---------- */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; margin: 14px 0; }
.bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bars .bar { width: 100%; background: var(--teal); border-radius: 4px 4px 0 0; min-height: 3px; }
.bars .bar.negative { background: var(--red); }
.bars .lbl { font-size: 10.5px; color: var(--ink-soft); margin-top: 6px; text-align: center; }
.bars .val { font-size: 10.5px; font-weight: 700; margin-bottom: 3px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { max-width: 380px; width: 100%; text-align: center; }
.login-card h1 { font-size: 26px; margin-bottom: 6px; }
.login-card p.sub { color: var(--ink-soft); margin-bottom: 22px; font-size: 14px; }

/* ---------- Item grid (menu mgmt) ---------- */
.item-row { display: flex; gap: 12px; align-items: center; }
.item-row img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--line); flex-shrink: 0; }
.item-row .info { flex: 1; }
.item-row .info .name { font-weight: 600; font-size: 14.5px; }
.item-row .info .sub { font-size: 12.5px; color: var(--ink-soft); }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--line); border-radius: 999px; cursor: pointer; transition: .15s; }
.switch .slider:before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(18px); }

.category-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--teal-soft); color: var(--teal); font-size: 13px; font-weight: 600; margin: 0 6px 8px 0;
}

.empty-state { text-align: center; padding: 40px 16px; color: var(--ink-soft); }
.empty-state .big { font-size: 34px; margin-bottom: 8px; }

.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13.5px;
  z-index: 100; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(31,42,36,0.45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-backdrop.hidden { display: none; }
.modal-sheet {
  background: var(--card); width: 100%; max-width: 480px; border-radius: 16px 16px 0 0;
  padding: 20px; max-height: 88vh; overflow-y: auto;
}
.modal-sheet h3 { margin-top: 0; }
.multi-item-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 10px; }
.multi-item-row select, .multi-item-row input { flex: 1; }
.remove-item-btn { background: var(--red-soft); color: var(--red); border: none; border-radius: 6px; width: 34px; height: 38px; cursor: pointer; }
