/* MARISA Karinderia. Same deep-sea colours as AnyJuanPOS, kept calm: white surfaces, thin lines, one strong colour for actions.
   Rules of thumb: text 16px or bigger (never tiny), touch targets 44px or bigger, lists with dividers instead of boxes. */
:root {
  /* colours */
  --abyss: #071b2e;
  --brand: #0f4c75;          /* main buttons, active tab, links */
  --brand-strong: #0b3a5c;
  --brand-soft: #e8f1f8;
  --bg: #f3f6f9;             /* page background (soft blue-gray) */
  --paper: #ffffff;          /* surfaces */
  --foam: #eef3f7;           /* quiet fills */
  --mist: #dbe6ef;
  --ink: #0a2236;
  --ink-soft: #4a6379;
  --line: #dce5ed;
  --line-strong: #b7c8d8;
  --good: #0b7a6f;
  --good-bg: #dff3f0;
  --warn: #7a4d00;
  --warn-bg: #fdf0d2;
  --bad: #b3261e;
  --bad-bg: #fbe4e2;
  /* type scale */
  --fs-title: 1.5rem;        /* 24px page titles */
  --fs-h: 1.25rem;           /* 20px section headings */
  --fs-body: 1rem;           /* 16px */
  --fs-small: .875rem;       /* 14px notes */
  --fs-price: 1.375rem;      /* 22px prices */
  --fs-hero: 2.5rem;         /* 40px the one big number */
  /* spacing, corners */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(7, 27, 46, .06);
  --shadow-up: 0 -2px 12px rgba(7, 27, 46, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-h: 60px;
  --top-h: 48px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); font-size: var(--fs-body); line-height: 1.45; color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; /* no double-tap zoom delay */
}
#app { height: 100%; height: 100dvh; display: flex; flex-direction: column; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: var(--fs-h); font-weight: 700; }
h3 { font-size: 1.0625rem; font-weight: 700; }
p { margin: 0 0 .5rem; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #5ab0e6; outline-offset: 2px; }
.muted { color: var(--ink-soft); }
small, .small { font-size: var(--fs-small); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.boot, .loading { padding: 2rem; text-align: center; color: var(--ink-soft); }
.row { display: flex; gap: var(--s3); align-items: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; flex-wrap: wrap; }
.row.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: var(--s3); }
.label { font-weight: 600; font-size: var(--fs-small); color: var(--ink-soft); }
.block { display: block; }
[hidden] { display: none !important; }
.icon { display: block; flex: none; }

/* ---------- top bar ---------- */
.topbar {
  flex: none; height: calc(var(--top-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) var(--s4) 0;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--abyss); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.0625rem; letter-spacing: .01em; min-width: 0; }
.brand img { border-radius: 7px; flex: none; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 8px; flex: none; }
.pill { background: var(--warn-bg); color: var(--warn); border-radius: 6px; padding: 4px 10px; font-size: var(--fs-small); font-weight: 600; white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 48px; padding: .5rem 1.1rem;
  border-radius: var(--radius); border: 1px solid var(--brand); background: var(--brand); color: #fff; font-weight: 600; text-decoration: none; line-height: 1.2;
}
.btn:active { background: var(--brand-strong); transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.secondary { background: var(--paper); color: var(--brand); border-color: var(--line-strong); }
.btn.secondary:active { background: var(--brand-soft); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.big { min-height: 50px; font-size: 1rem; }
.btn.wide { width: 100%; }
.btn.dim { opacity: .5; }
.btn.small { min-height: 44px; padding: 0 14px; font-size: var(--fs-body); }
.btn.danger-text { color: var(--bad); border-color: #e5b5b1; }
.btn.install { min-height: 40px; background: #fff; color: var(--abyss); border-color: #fff; padding: .25rem .8rem; font-size: var(--fs-small); }

/* ---------- bottom tabs (always visible, never on top of the page) ---------- */
.tabs {
  flex: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  min-width: 0; min-height: var(--nav-h); padding: 0 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: var(--fs-small); position: relative;
}
.tab-icon { display: flex; }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab.on { color: var(--brand); }
.tab.on::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand); }

/* ---------- main area ---------- */
.view { flex: 1 1 auto; min-height: 0; overflow: hidden; position: relative; }
.view-inner { height: 100%; }
.page, .records { height: 100%; overflow-y: auto; padding: var(--s4); max-width: 820px; margin: 0 auto; -webkit-overflow-scrolling: touch; }
.page > * + *, .records > * + * { margin-top: var(--s3); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); }
.error-card { border-color: var(--bad); background: var(--bad-bg); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.empty-state { text-align: center; color: var(--ink-soft); padding: 28px 12px; }

/* ---------- segmented control (Ngayon | Linggo | ...; Bayad nang buo | Utang) ---------- */
.seg, .segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; background: var(--foam); border: 1px solid var(--line); border-radius: var(--radius); }
.seg { margin: var(--s1) 0 var(--s3); }
.seg-btn, .seg-link {
  min-height: 44px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 8px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-soft); font-weight: 600; font-size: var(--fs-body); text-decoration: none;
}
.seg-btn.on, .seg-link.on { background: var(--brand); color: #fff; }
/* Buod | Talaan: plain tabs with an underline, so it does not look like the date row */
.report-switch { display: flex; gap: var(--s5); padding: 0; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.report-switch .seg-link { min-height: 46px; padding: 0 2px; border-radius: 0; font-size: 1.0625rem; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.report-switch .seg-link.on { background: none; color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- chips (filters) ---------- */
.chip { min-height: 44px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.cat { width: 100%; padding: 0 8px; }
.filters { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.filters.cats { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.filters.cats::-webkit-scrollbar { display: none; }
.filters.cats .chip { flex: none; }
.date-input { min-height: 48px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 10px; background: var(--paper); }

/* ---------- inputs ---------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.text-input { width: 100%; min-height: 48px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper); font-size: var(--fs-body); }
.text-input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px #bfe0f6; }
textarea.text-input.msg { min-height: 140px; resize: vertical; line-height: 1.4; }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; font-weight: 600; }
.check input { width: 24px; height: 24px; }

/* ---------- SELL (Benta) ---------- */
.sell { height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.menu-pane { overflow-y: auto; padding: var(--s3); -webkit-overflow-scrolling: touch; }
.food-tools { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s3); }
.food-tools .text-input { margin: 0; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s2); }
.food {
  position: relative; min-height: 92px; padding: 12px 10px; border-radius: var(--radius); background: var(--paper);
  border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  user-select: none; -webkit-user-select: none; text-align: center;
}
.food:active { background: var(--brand-soft); }
.food.picked { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: var(--brand-soft); }
.food-name { font-size: 1.0625rem; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.food-price { font-size: 1.0625rem; color: var(--brand); font-weight: 700; }
.food-stock { font-size: var(--fs-small); font-weight: 600; color: var(--ink-soft); }
.food.low { border-color: #e0b84a; }
.food.low .food-stock { color: var(--warn); }
.food.out { opacity: .55; background: var(--foam); border-style: dashed; }
.food.out .food-stock { color: var(--bad); }
.food.out:active { background: var(--foam); }
.badge {
  position: absolute; top: 6px; right: 6px; min-width: 28px; height: 28px; padding: 0 7px; border-radius: 14px; background: var(--brand); color: #fff;
  font-weight: 700; font-size: var(--fs-small); display: none; align-items: center; justify-content: center;
}
.food.picked .badge { display: inline-flex; }

/* order list: at the side on wide tablets, in a pop-up on phones */
.order-pane { display: none; flex-direction: column; background: var(--paper); border-left: 1px solid var(--line); min-height: 0; }
.order-head { padding: var(--s3) var(--s4) 0; }
.order-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px var(--s4); }
.empty-order { padding: 8px 0; }
.line { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.line-name { display: flex; flex-direction: column; min-width: 0; font-weight: 600; }
.line-name span { overflow-wrap: anywhere; }
.stepper { display: flex; align-items: center; gap: 6px; flex: none; }
.step { width: 44px; height: 44px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--paper); color: var(--brand); font-size: 1.5rem; font-weight: 600; line-height: 1; padding: 0; }
.step:active { background: var(--brand-soft); }
.step:disabled { opacity: .35; }
.step.remove { border-color: #e5b5b1; color: var(--bad); font-size: 1rem; margin-left: 4px; }
.qty { min-width: 32px; text-align: center; font-size: 1.25rem; font-weight: 700; }
.order-foot { flex: none; padding: var(--s3) var(--s4) var(--s4); border-top: 1px solid var(--line); background: var(--paper); }
.total-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.0625rem; font-weight: 600; margin: var(--s2) 0; }
.total-amt { font-size: 1.75rem; font-weight: 800; color: var(--abyss); }
.order-btns { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; }
.sheet-order { max-height: calc(94vh - 290px); max-height: calc(94dvh - 290px); min-height: 90px; border-top: 1px solid var(--line); }
.sheet-body .order-btns { margin-top: var(--s3); }

/* the bar at the bottom of Benta on phones: always shows the order and Bayad */
.checkbar { display: flex; align-items: center; gap: var(--s3); padding: 8px var(--s3); background: var(--paper); border-top: 1px solid var(--line); box-shadow: var(--shadow-up); }
.bar-sum { flex: 1 1 auto; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; text-align: left; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--foam); }
.bar-line { display: flex; align-items: center; gap: 8px; }
.bar-count { font-size: .8125rem; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.bar-view { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; font-size: .8125rem; font-weight: 700; color: var(--brand); }
.bar-total { font-size: 1.5rem; font-weight: 800; color: var(--abyss); line-height: 1.15; }
.checkbar.empty .bar-total { color: var(--ink-soft); }
.checkbar #bar-pay { flex: 0 0 38%; }
.icon-btn { flex: 0 0 48px; width: 48px; min-height: 48px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

@media (min-width: 900px) and (orientation: landscape) {
  .sell { grid-template-rows: none; grid-template-columns: minmax(0, 1fr) 380px; }
  .order-pane { display: flex; }
  .checkbar { display: none; }
  .menu-pane { padding: var(--s4); }
  .menu-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--s3); }
  .food { min-height: 112px; }
  .food-name { font-size: 1.1875rem; }
}

/* ---------- pop-ups: slide up from the bottom on phones, centred on tablets ---------- */
.sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(7, 27, 46, .55); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 94%; max-height: 94dvh; overflow-y: auto; background: var(--paper); border-radius: 16px 16px 0 0; outline: none;
  padding-bottom: env(safe-area-inset-bottom); animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) and (min-height: 560px) {
  .sheet-back { align-items: center; padding: var(--s3); }
  .sheet { border-radius: 14px; max-height: 100%; box-shadow: 0 10px 40px rgba(7, 27, 46, .25); }
}
.sheet-body { padding: var(--s4); }
.sheet-body h3 { margin: 6px 0 0; }
.due { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0; font-size: 1.0625rem; font-weight: 600; }
.due strong { font-size: 1.75rem; font-weight: 800; color: var(--abyss); }
.cash-amt { font-size: 2.1rem; font-weight: 800; text-align: right; padding: 6px 14px; margin: 4px 0 var(--s2); border: 2px solid var(--brand); border-radius: var(--radius); background: #f6fafd; min-height: 54px; }
.quick-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: var(--s2); margin-bottom: var(--s2); }
.quick { min-height: 44px; padding: .25rem .3rem; font-size: .9375rem; line-height: 1.15; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); margin-bottom: var(--s2); }
.key { height: 52px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--foam); font-size: 1.5rem; font-weight: 700; }
.key:active { background: var(--mist); }
.change { text-align: center; font-size: 1.25rem; font-weight: 700; padding: 10px; border-radius: var(--radius); margin-bottom: var(--s2); background: var(--foam); color: var(--ink-soft); }
.change.ok { background: var(--good-bg); color: var(--good); font-size: 1.75rem; }
.change.short { background: var(--bad-bg); color: var(--bad); font-size: 1.0625rem; }
.change.credit { background: var(--warn-bg); color: var(--warn); font-size: 1.0625rem; }
.detail-line { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.detail-sum div { display: flex; justify-content: space-between; padding: 6px 0; font-size: 1.0625rem; }
.utang-box { margin: 0 0 var(--s3); padding: var(--s3); background: var(--warn-bg); border-radius: var(--radius); }
.utang-box .label { color: var(--warn); }
@media (max-height: 840px) {
  .key { height: 46px; font-size: 1.3rem; }
  .cash-amt { min-height: 46px; font-size: 1.6rem; }
  .change { padding: 8px; }
  .btn.big { min-height: 48px; }
}

/* Wide tablets: form on the left, number pad on the right, so nothing needs scrolling */
.pay { display: grid; grid-template-columns: 1fr; }
/* the green button stays visible while the rest scrolls */
.pay > .btn.wide:last-child { position: sticky; bottom: 0; box-shadow: 0 -8px 8px -4px var(--paper); }
@media (min-width: 880px) and (min-height: 560px) {
  .sheet.wide { max-width: 900px; }
  .pay { grid-template-columns: 1fr 1fr; column-gap: 22px; align-items: start; }
  .pay > * { grid-column: 1; }
  .pay > .row.between { grid-column: 1 / -1; }
  .pay > .keypad { grid-column: 2; grid-row: 2 / span 12; margin-top: 8px; }
  .key { height: 58px; }
  .pay > .qr-box { grid-column: 2; grid-row: 2 / span 12; margin-top: 8px; }
}

/* ---------- list rows (Talaan, Pagkain, gastos, utang): one white block, thin dividers ---------- */
.summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.summary-count { font-size: 1.1875rem; font-weight: 700; }
.summary-total { font-size: 1.75rem; font-weight: 800; color: var(--abyss); }
.sale-list, .menu-list, .exp-list, .debt-list { display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.sale-list:empty, .menu-list:empty, .exp-list:empty, .debt-list:empty { display: none; }
.sale-row { display: flex; align-items: center; gap: var(--s3); width: 100%; text-align: left; padding: var(--s3) var(--s4); min-height: 64px; background: var(--paper); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.sale-row:last-child, .menu-row:last-child, .exp-row:last-child, .debt-row:last-child { border-bottom: 0; }
.sale-row:active, .exp-row:active { background: var(--foam); }
.sale-row.cancelled { opacity: .6; text-decoration: line-through; }
.sale-no { font-weight: 700; color: var(--brand); min-width: 48px; }
.sale-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sale-items { overflow-wrap: anywhere; font-weight: 600; }
.sale-total { font-size: 1.1875rem; }
.sale-amts { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.owed-line { color: var(--warn); font-weight: 700; font-size: var(--fs-small); }
.owe-row strong { color: var(--bad); }
.owe-row { font-weight: 700; }

.menu-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.menu-row.is-hidden { opacity: .65; }
.menu-info { display: flex; flex-direction: column; flex: 1 1 200px; min-width: 0; }
.menu-info strong { overflow-wrap: anywhere; font-size: 1.0625rem; }
.menu-btns { display: flex; gap: 6px; align-items: center; flex: none; }
.menu-btns.wrap { flex-wrap: wrap; justify-content: flex-end; }
.stock-now { font-size: 1.4rem; font-weight: 800; margin: 0; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--s2); margin-bottom: var(--s2); }

.exp-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); width: 100%; text-align: left; min-height: 60px; padding: var(--s3) var(--s4); background: var(--paper); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.exp-main { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.total-line { font-size: 1.0625rem; padding: 10px 2px; }
.dates { gap: var(--s3); }
.period-label { margin: 2px 2px 0; font-size: var(--fs-small); }

.debt-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.debt-main { flex: 1 1 140px; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; text-align: left; background: none; border: 0; padding: 4px 0; min-height: 48px; justify-content: center; }
.debt-name { font-weight: 700; font-size: 1.0625rem; overflow-wrap: break-word; }
.debt-amt { font-size: 1.1875rem; color: var(--bad); flex: none; }
.debt-row .btn { flex: none; }
@media (max-width: 560px) {
  .debt-main { flex: 1 1 55%; }
  .debt-row .btn { flex: 1 1 100%; }
  .utang-total { flex-wrap: wrap; }
}
.utang-total { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); margin-bottom: var(--s2); }
.big-num { font-size: 2rem; font-weight: 800; color: var(--bad); line-height: 1.1; }
.tools { margin: 10px 0; }
.tools .text-input { flex: 1 1 200px; width: auto; }
.unpaid-sale { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.grow { flex: 1 1 140px; min-width: 0; }
.refund-item { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; }

/* tags */
.tag { display: inline-block; margin-top: 2px; padding: 2px 8px; border-radius: 6px; font-size: var(--fs-small); font-weight: 600; white-space: nowrap; }
.tag.partial, .tag.unpaid { background: var(--warn-bg); color: var(--warn); }
.tag.unpaid { background: var(--bad-bg); color: var(--bad); }
.tag.qr { background: var(--mist); color: var(--brand); }
.tag.refunded { background: var(--mist); color: var(--abyss); }
.tag.out { background: var(--bad-bg); color: var(--bad); }
.tag.low { background: var(--warn-bg); color: var(--warn); }
.tag.good { background: var(--good-bg); color: var(--good); }
.tag.soft { background: var(--foam); color: var(--ink-soft); }
.tags { gap: 6px; margin-top: 2px; }

/* notes and messages */
.note { margin: 0; padding: 10px 12px; background: var(--warn-bg); border-radius: var(--radius); font-size: var(--fs-small); color: var(--warn); }
.note.muted { background: transparent; padding: 0 2px; color: var(--ink-soft); }
.note.bad { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.void-money { background: var(--warn-bg); padding: 10px 12px; border-radius: var(--radius); font-weight: 600; margin: 0; }
.void-note { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: var(--radius); font-weight: 600; margin: 0; }

/* ---------- BUOD ---------- */
.datebar { display: grid; grid-template-columns: minmax(0, 1fr) 52px; gap: var(--s2); align-items: stretch; }
.cal-btn { display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--foam); color: var(--ink-soft); border-radius: var(--radius); }
.cal-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.stat-label { font-weight: 600; color: var(--ink-soft); font-size: var(--fs-small); }
.stat-val { color: var(--abyss); overflow-wrap: anywhere; line-height: 1.15; font-weight: 700; }
.hero { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); }
.hero > .stat-label { font-size: 1rem; }
.hero > .stat-val { display: block; font-size: var(--fs-hero); font-weight: 800; margin: 2px 0; }
.hero-sub { display: grid; grid-template-columns: 1fr 1fr; margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line); gap: var(--s3); }
.mini { display: flex; flex-direction: column; }
.mini .stat-val { font-size: 1.375rem; }
.metrics { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.metric { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); border-top: 1px solid var(--line); }
.metric:first-child { border-top: 0; }
.metric-name { display: flex; flex-direction: column; min-width: 0; }
.metric .stat-val { font-size: 1.25rem; text-align: right; flex: none; }
.metric.incomplete .stat-val { font-size: 1rem; color: var(--warn); }
.metric.neg .stat-val, .metric.owed .stat-val { color: var(--bad); }

/* folded sections */
.folds { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.acc + .acc { border-top: 1px solid var(--line); }
.acc-sum { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: 0 var(--s4); cursor: pointer; list-style: none; font-weight: 600; font-size: 1.0625rem; }
.acc-sum::-webkit-details-marker { display: none; }
.acc-title { flex: 1 1 auto; min-width: 0; }
.acc-right { font-weight: 700; color: var(--ink-soft); font-size: var(--fs-body); text-align: right; }
.acc-sum .icon { color: var(--ink-soft); transition: transform .15s; }
.acc[open] > .acc-sum .icon { transform: rotate(180deg); }
.acc.alert .acc-right { color: var(--warn); font-size: var(--fs-small); }
.acc.owed .acc-right { color: var(--bad); }
.acc-body { padding: 0 var(--s4) var(--s4); }
.acc-body > * + * { margin-top: var(--s3); }
.acc-body .exp-list, .acc-body .debt-list { margin-top: var(--s2); }

/* graphs */
.charts { display: grid; gap: var(--s4); grid-template-columns: 1fr; }
@media (min-width: 900px) { .charts { grid-template-columns: 1fr 1fr; } .charts .chart:first-child { grid-column: 1 / -1; } }
.chart { padding: var(--s3) 0 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: none; }
.chart:first-child { border-top: 0; padding-top: 0; }
.chart h3 { margin: 0 0 var(--s2); font-size: 1rem; }
.chart-top { display: flex; justify-content: space-between; font-size: var(--fs-small); }
.vchart { display: flex; align-items: flex-end; gap: 3px; height: 150px; border-bottom: 1px solid var(--line-strong); border-top: 1px dashed var(--line); padding-top: 2px; }
.vcol { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; padding: 0; border: 0; background: transparent; border-radius: 4px 4px 0 0; }
.vbar { display: block; width: 100%; background: var(--brand); border-radius: 4px 4px 0 0; }
.vcol:hover .vbar, .vcol.on .vbar { background: var(--abyss); }
.vcol.on { background: var(--foam); }
.vlabels { display: flex; gap: 3px; margin-top: 4px; font-size: .75rem; color: var(--ink-soft); }
.vlabels span { flex: 1 1 0; min-width: 0; text-align: center; white-space: nowrap; overflow: visible; }
.chart-read { margin: 8px 0 0; min-height: 1.4em; font-weight: 600; color: var(--ink-soft); font-size: var(--fs-small); }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hrow-top { display: flex; justify-content: space-between; gap: 10px; }
.hrow-label { overflow-wrap: anywhere; font-weight: 600; }
.hbar-track { height: 10px; background: var(--foam); border-radius: 5px; overflow: hidden; margin: 3px 0; }
.hbar { display: block; height: 100%; border-radius: 5px; background: var(--brand); }
.hbar.amber { background: #c98a00; }
.acc-body .hbars .kv:first-child { border-top: 0; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { font-size: var(--fs-small); color: var(--ink-soft); font-weight: 600; }
.table .r { text-align: right; white-space: nowrap; }
.table td:first-child { overflow-wrap: anywhere; min-width: 90px; }

/* ---------- PIN ---------- */
.pin-page { text-align: center; max-width: 420px; margin: 0 auto; }
.pin-page .keypad { max-width: 340px; margin: 6px auto; width: 100%; }
.lock-page { padding-top: var(--s3); }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 6px 0; }
.pin-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--brand); background: var(--paper); }
.pin-dot.on { background: var(--brand); }
.pin-msg { min-height: 1.4em; color: var(--bad); font-weight: 600; }
.pin-msg.warn { color: var(--warn); }
.code-box { font-size: 2rem; font-weight: 800; letter-spacing: .12em; padding: var(--s4); border: 2px dashed var(--brand); border-radius: var(--radius); background: var(--paper); user-select: all; }
.code-input { text-align: center; font-size: 1.5rem; letter-spacing: .1em; text-transform: uppercase; }
@media (max-height: 700px) {
  .pin-page { gap: 6px; }
  .pin-page h2 { font-size: 1.25rem; margin: 0; }
  .pin-page p { margin: 0; font-size: var(--fs-small); }
  .pin-page .key { height: 48px; font-size: 1.35rem; }
  .pin-page .keypad { gap: 6px; margin: 2px auto; }
  .pin-page .pin-msg { min-height: 1.2em; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(var(--top-h) + env(safe-area-inset-top) + 10px); transform: translate(-50%, -16px); z-index: 80;
  max-width: min(92vw, 520px); padding: 12px 16px; border-radius: var(--radius); background: var(--abyss); color: #fff; font-weight: 600; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; box-shadow: 0 6px 20px rgba(7, 27, 46, .25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--good); }
.toast.bad { background: var(--bad); }

@media (max-width: 380px) {
  .brand { font-size: 1rem; }
  .menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :root { --fs-hero: 2.125rem; }
  .checkbar #bar-pay { flex-basis: 36%; padding: 0 .6rem; }
  .checkbar { gap: var(--s2); }
  .bar-view-text { display: none; }
}
a.btn { text-decoration: none; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Stage B: backup pill, printer settings, printing ---------- */
a.pill.backup { text-decoration: none; background: var(--warn-bg); color: var(--warn); min-height: 44px; display: inline-flex; align-items: center; }
.period-row { align-items: center; gap: var(--s2); flex-wrap: wrap; }
.period-row .period-label { margin: 0; }
.btn .icon { margin-right: 2px; }
.last-backup { font-weight: 600; margin: 0; }

.print-root { display: none; }
.rc { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; line-height: 1.3; color: #000; }
.rc-shop { text-align: center; font-weight: 800; font-size: 1.2em; overflow-wrap: anywhere; }
.rc-center { text-align: center; overflow-wrap: anywhere; }
.rc-title { text-align: center; font-weight: 700; margin-top: 2px; }
.rc-sub { text-align: center; margin-bottom: 2px; }
.rc-hr { border-top: 1px dashed #000; margin: 5px 0; }
.rc-line { display: flex; justify-content: space-between; gap: 8px; }
.rc-line > span:first-child { overflow-wrap: anywhere; }
.rc-line > span:last-child { flex: none; text-align: right; }
.rc-big { font-weight: 800; font-size: 1.1em; }
.rc-note { font-size: .85em; padding-left: 6px; margin-bottom: 3px; overflow-wrap: anywhere; }
.rc-void { text-align: center; font-weight: 800; border: 1px solid #000; margin: 4px 0; padding: 2px; }

/* the page size comes from css/paper-58.css, paper-80.css or paper-a4.css (one is linked while printing) */
@media print {
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; }
  body.printing #app, body.printing .toast, body.printing .sheet-back { display: none !important; }
  body.printing .print-root { display: block; }
  .paper-58 { width: 50mm; font-size: 9.5pt; }
  .paper-80 { width: 72mm; font-size: 10.5pt; }
  .paper-a4 { max-width: 150mm; margin: 0 auto; font-size: 12pt; }
}

/* ---------- payment QR (Bayad > QR, and Setting) ---------- */
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 0 0 var(--s3); padding: var(--s3); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.qr-img { display: block; width: min(100%, clamp(180px, 32vh, 280px)); width: min(100%, clamp(180px, 32dvh, 280px)); aspect-ratio: 1; object-fit: contain; background: #fff; }
.qr-name { font-size: 1rem; color: var(--abyss); }
.change.verify { display: flex; align-items: flex-start; justify-content: center; gap: 8px; text-align: left; font-size: .9375rem; font-weight: 700; line-height: 1.35; padding: 10px; background: var(--warn-bg); color: var(--warn); }
.change.verify .icon { flex: 0 0 auto; margin-top: 1px; }
.qr-ask { margin: 0; text-align: center; font-weight: 600; font-size: .9375rem; color: var(--ink-soft); }
@media (min-width: 880px) { .qr-img { width: min(100%, clamp(220px, 50dvh, 340px)); } }
.qr-preview { display: flex; justify-content: center; padding: var(--s3); border: 1px dashed var(--line-strong); border-radius: var(--radius); background: #fff; }
.qr-preview .qr-img { width: min(100%, 200px); }

/* ---------- HOME (picture + Mag-sign in) ---------- */
.home { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: calc(28px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(7, 27, 46, .72) 0%, rgba(7, 27, 46, .08) 32%, rgba(7, 27, 46, .12) 60%, rgba(7, 27, 46, .78) 100%), url("/img/home.jpg") center 38% / cover no-repeat, #071b2e;
  color: #fff; text-align: center; transition: opacity .18s; }
.home.leaving { opacity: 0; }
.home-top { display: flex; flex-direction: column; align-items: center; gap: 6px; text-shadow: 0 1px 8px rgba(0, 0, 0, .55); }
.home-top img { border-radius: 10px; }
.home-top h1 { margin: 0; font-size: 1.5rem; letter-spacing: .01em; }
.home-top p { margin: 0; font-size: .9375rem; opacity: .92; }
.home-mid { flex: 1; display: flex; align-items: flex-end; justify-content: center; width: 100%; padding-bottom: 10vh; }
.home-btn { min-width: 220px; padding-left: 36px; padding-right: 36px; background: #fff; color: var(--abyss); box-shadow: 0 6px 22px rgba(0, 0, 0, .35); }
.home-btn:active { background: var(--foam); }
@media (orientation: landscape) and (max-height: 520px) { .home-top { flex-direction: row; gap: 10px; } .home-top p { display: none; } .home-mid { padding-bottom: 0; align-items: flex-end; } .home-btn { min-height: 46px; } }

/* ---------- payment choices with icons ---------- */
.pay .seg-btn { flex-direction: column; gap: 2px; min-height: 56px; padding: 6px 4px; font-size: .8125rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
@media (max-height: 840px) { .pay .seg-btn { min-height: 50px; padding: 4px; } }

/* ---------- the "sale saved" window ---------- */
.done-box { text-align: center; }
.done-head { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.done-head h2 { margin: 0; font-size: 1.0625rem; color: var(--ink-soft); font-weight: 600; }
.done-tick { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--good-bg); color: var(--good); }
.done-big { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--s4) var(--s3); border-radius: var(--radius); background: var(--good-bg); color: var(--good); }
.done-big.owed { background: var(--warn-bg); color: var(--warn); }
.done-big.exact { background: var(--foam); color: var(--ink-soft); }
.done-label { font-size: .9375rem; font-weight: 800; letter-spacing: .08em; }
.done-amt { font-size: 3rem; line-height: 1.1; font-weight: 800; }
.done-sub { font-size: 1rem; font-weight: 600; }
.done-note { margin: 0; color: var(--ink-soft); font-weight: 600; }
.done-rows { display: grid; gap: 4px; padding: var(--s2) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.done-rows > div { display: flex; justify-content: space-between; gap: 12px; }
.done-btns { display: grid; gap: var(--s2); }
.done-btns .btn { gap: 8px; }
@media (min-width: 560px) { .done-btns { grid-template-columns: 1fr 1fr; } }
@media (max-height: 560px) { .done-amt { font-size: 2.25rem; } .done-big { padding: var(--s2); } }
