/* Cafe ERP - one stylesheet for every page (index, admin, waiter, menu).

   Sections
     1. Design tokens and base
     2. Layout and text helpers
     3. Cards, badges, avatars, empty states
     4. Buttons
     5. Forms and inputs (fields, switch, quantity stepper, hints)
     6. Segmented control, chips and stat boxes
     7. Navigation and action bars
     8. Sheets (dialogs) and toasts
     9. Page parts: login, admin dashboard, lists, waiter, customer menu
    10. Spacing helpers
    11. Print (table QR cards)

   The HTML files hold the page structure. This file holds all the styling,
   so JavaScript never needs inline style="" attributes for static layout. */

/* ======================================================================
   1. Design tokens and base
   ====================================================================== */

:root {
  --bg: #ece8e5;
  --surface: #fff;
  --alt: #f6f3f1;
  --primary: #357b5f;
  --primary-d: #2a6350;
  --tint: #dcebe4;
  --border: #d8d1cb;
  --text: #1c2823;
  --muted: #6c7872;
  --tip: #b97a1f;
  --tip-t: #f6e8cf;
  --danger: #c4493d;
  --danger-t: #f6dcd8;
  --r: 16px;
}
* {
  box-sizing: border-box;
  margin: 0;
}
body {
  font-family: Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}
button,input,select,textarea {
  font: inherit;
  color: inherit;
}

h1 {
  font-size: 22px;
  font-weight: 700;
}
h2 {
  font-size: 17px;
  font-weight: 700;
}

/* The "hidden" attribute must always win, even over display:flex / grid rules */
[hidden] {
  display: none !important;
}

/* ======================================================================
   2. Layout and text helpers
   ====================================================================== */

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px 16px 100px;
  position: relative;
}
.app.wide {
  max-width: 720px;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.green {
  color: var(--primary);
}
.center {
  text-align: center;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.between {
  justify-content: space-between;
}
.grow {
  flex: 1;
  min-width: 0;
}
.col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Page headers: a back button + title row, and the small intro text under a title */
.page-head {
  margin-bottom: 12px;
}
.page-head h1 {
  font-size: 19px;
}
.page-sub {
  margin: 4px 0 12px;
}
.page-sub-tight {
  margin: 0 0 12px;
}
.section-head {
  margin: 16px 0 8px;
}
.row.tight {
  gap: 6px;
}
.break-all {
  word-break: break-all;
}
.tip-text {
  color: var(--tip);
}

/* ======================================================================
   3. Cards, badges, avatars, empty states
   ====================================================================== */

.card {
  background: var(--surface);
  border-radius: var(--r);
  padding: 14px;
  border: 1.5px solid transparent;
}
.card.hl {
  border-color: var(--primary);
}

.card-alt {
  background: var(--alt);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 10px;
}

.empty-screen {
  padding-top: 90px;
}
.empty-screen h2 {
  margin: 12px 0 4px;
}
.empty-note {
  margin-top: 8px;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--tint);
  color: var(--primary-d);
  white-space: nowrap;
}
.badge.tip {
  background: var(--tip-t);
  color: var(--tip);
}
.badge.gray {
  background: var(--alt);
  color: var(--muted);
}
.badge.red {
  background: var(--danger-t);
  color: var(--danger);
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex: none;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 13px;
}
.avatar-lg {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
}
.avatar-tint {
  background: var(--tint);
  color: var(--primary-d);
}

/* Text pieces used inside cards */
.price {
  font-weight: 700;
  margin-top: 4px;
}
.price-tight {
  margin-top: 3px;
}
.order-lines {
  margin: 6px 0;
}
.order-lines.roomy {
  margin: 8px 0;
}
.row-summary {
  margin-top: 8px;
}
.line-total {
  min-width: 70px;
  text-align: right;
}
.profile-card {
  margin: 14px 0;
}
.summary-card {
  margin: 24px 0;
}
.done-head {
  padding-top: 60px;
}

/* ======================================================================
   4. Buttons
   ====================================================================== */

.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--tint);
  color: var(--primary-d);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
.btn.primary {
  background: var(--primary);
  color: #fff;
}
.btn.primary:active {
  background: var(--primary-d);
}
.btn.white {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn.danger {
  background: var(--danger-t);
  color: var(--danger);
}
.btn.big {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  border-radius: 14px;
}
.btn.sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 10px;
}
.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.icon-btn {
  border: 0;
  background: #fff;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}
.link {
  border: 0;
  background: none;
  color: var(--danger);
  font-size: 12px;
  cursor: pointer;
  margin-top: 6px;
  padding: 0;
}

/* ======================================================================
   5. Forms and inputs
   ====================================================================== */

.input,.select {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  outline: none;
}
.input:focus,.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--tint);
}
label.f {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 5px;
}

/* The first label inside a card sits flush with the card's top padding */
.card > label.f:first-child {
  margin-top: 0;
}
.field-help {
  margin-top: 6px;
}
.switch-row {
  margin-top: 14px;
}

/* Error message under the login form */
.form-error {
  margin-top: 12px;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--danger-t);
  color: var(--danger);
}

.hint {
  font-size: 12px;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  display: none;
}
.hint.tip {
  display: block;
  background: var(--tip-t);
  color: var(--tip);
}
.hint.short {
  display: block;
  background: var(--danger-t);
  color: var(--danger);
}

.sw {
  position: relative;
  width: 44px;
  height: 26px;
  flex: none;
  display: inline-block;
}
.sw input {
  opacity: 0;
  width: 0;
  height: 0;
}
.sw span {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 99px;
  transition: .2s;
  cursor: pointer;
}
.sw span:before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
}
.sw input:checked+span {
  background: var(--primary);
}
.sw input:checked+span:before {
  transform: translateX(18px);
}

.qty {
  display: flex;
  align-items: center;
  gap: 9px;
}
.qty button {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.qty button.plus {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.qty b {
  min-width: 18px;
  text-align: center;
}

/* ======================================================================
   6. Segmented control, chips and stat boxes
   ====================================================================== */

.seg {
  display: flex;
  background: #fff;
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.seg button {
  flex: 1;
  border: 0;
  background: none;
  padding: 9px;
  border-radius: 9px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.seg button.on {
  background: var(--primary);
  color: #fff;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 6px;
  scrollbar-width: none;
}
.chip {
  flex: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 99px;
  padding: 7px 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}
.chip.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 8px;
}
.stat {
  background: #fff;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
}
.stat b {
  display: block;
  font-size: 15px;
  margin-top: 3px;
  color: var(--text);
}
.stat.tipc {
  background: var(--tip-t);
}
.stat.tipc b {
  color: var(--tip);
}

/* ======================================================================
   7. Navigation and action bars
   ====================================================================== */

.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-in {
  display: flex;
  max-width: 720px;
  margin: 0 auto;
}
.nav button {
  flex: 1;
  border: 0;
  background: none;
  padding: 9px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  position: relative;
}
.nav button.on {
  color: var(--primary);
  font-weight: 700;
}
.dot {
  position: absolute;
  top: 4px;
  left: calc(50% + 6px);
  background: var(--danger);
  color: #fff;
  border-radius: 99px;
  font-size: 10px;
  padding: 1px 5px;
}

.bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 20px rgba(0,0,0,.07);
  z-index: 20;
}
.bar-in {
  max-width: 480px;
  margin: 0 auto;
}
.total {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
}
.cta {
  position: sticky;
  bottom: 78px;
  margin-top: 16px;
}
.fab {
  position: fixed;
  right: 16px;
  bottom: 82px;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  border: 0;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(53,123,95,.4);
  cursor: pointer;
  z-index: 15;
}

.bar-summary {
  margin-bottom: 10px;
}

/* ======================================================================
   8. Sheets (dialogs) and toasts
   ====================================================================== */

.sheet-bg {
  position: fixed;
  inset: 0;
  background: rgba(20,30,25,.45);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  background: var(--bg);
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow: auto;
  border-radius: 24px 24px 0 0;
  padding: 18px 16px 26px;
  animation: up .2s ease;
}

@keyframes up {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

/* Toasts are stacked inside the #toasts container that every page has */
.toasts {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  z-index: 99;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  max-width: 90vw;
  font-weight: 500;
}

.toast.err {
  background: var(--danger);
}

/* ======================================================================
   9. Page parts
   ====================================================================== */

/* ---- Login page ---- */

.login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 400px;
  margin: 0 auto;
  padding: 24px;
}
.logo {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
}

/* ---- Admin dashboard ---- */

.hero {
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  padding: 18px;
}
.hero .big {
  font-size: 30px;
  font-weight: 800;
  margin: 4px 0;
}

.hero-label {
  opacity: .8;
}
.hero-change {
  opacity: .85;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
}
.bars i {
  flex: 1;
  background: var(--tint);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}
.bars i.max {
  background: var(--primary);
}
.axis {
  display: flex;
  gap: 3px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
}
.axis span {
  flex: 1;
  text-align: center;
  overflow: visible;
  white-space: nowrap;
}
.meter {
  height: 6px;
  background: var(--alt);
  border-radius: 99px;
  margin-top: 6px;
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  background: var(--primary);
}

/* ---- Admin lists: menu, tables, "More" ---- */

.table-grid {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 10px;
}
.tbl {
  background: #fff;
  border: 0;
  border-radius: 16px;
  padding: 16px 8px;
  text-align: center;
  cursor: pointer;
}
.tbl .n {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
}

.table-grid .empty {
  grid-column: 1 / -1;
}
.tbl .qr-mark {
  margin-top: 4px;
}
.cat-actions {
  margin: 4px 0 8px;
}
.qr-image {
  width: 240px;
  max-width: 100%;
  border-radius: 16px;
  margin: 12px 0;
}

.listrow {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  width: 100%;
  border: 0;
  text-align: left;
  cursor: pointer;
}

/* ---- Waiter: checkout payment buttons ---- */

.method {
  padding: 14px;
}

/* ---- Customer menu: order status card and cart ---- */
.order-status-wrap {
  margin: 14px 0 8px;
}
.order-status {
  margin-bottom: 12px;
}
.order-status-text {
  margin-top: 6px;
}
.menu-list {
  margin-top: 6px;
}
.cart-hint {
  margin-top: 12px;
}

/* ---- Admin: order history (summary, filters, table, detail sheet) ---- */

.app.wide.orders-wide {
  max-width: 1120px;                       /* the 9-column table needs more room than the other admin pages */
}
.oh-summary {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.oh-summary .stat b {
  font-size: 17px;
}
.oh-filters .oh-line {
  display: grid;
  gap: 10px;
  align-items: end;
}
.oh-line-top {
  grid-template-columns: 2fr 1fr;
}
.oh-line-dates {
  grid-template-columns: 1fr 1fr auto auto;
  margin-top: 10px;
}
.oh-filters label.f {
  margin: 0 0 5px;
}
.oh-filters .input,
.oh-filters .select,
.oh-filters .btn {
  height: 44px;                            /* search, dropdown, dates and buttons line up */
}
.oh-hint {
  margin: 10px 0 0;
}
.oh-showing {
  margin: 8px 2px;
}

.oh-table-wrap {
  background: var(--surface);
  border-radius: var(--r);
  overflow-x: auto;                        /* small screens: the table scrolls sideways */
  -webkit-overflow-scrolling: touch;
}
.oh-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
  font-size: 13px;
}
.oh-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: var(--alt);
  padding: 11px 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.oh-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--alt);
  vertical-align: middle;
}
.oh-table tbody tr:last-child td {
  border-bottom: 0;
}
.oh-table .num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.oh-row {
  cursor: pointer;
}
.oh-row:hover {
  background: var(--alt);
}
.oh-tip {
  color: var(--tip);
  font-weight: 700;
}

.od-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin: 14px 0;
}
.od-meta dt {
  font-size: 12px;
  color: var(--muted);
}
.od-meta dd {
  margin: 2px 0 0;
  font-weight: 600;
}
.od-lines {
  min-width: 0;
}
.od-totals {
  background: var(--surface);
  border-radius: 14px;
  padding: 4px 14px;
  margin-top: 12px;
}
.od-totals .row {
  padding: 9px 0;
  border-bottom: 1px solid var(--alt);
}
.od-totals .row:last-child {
  border-bottom: 0;
}
.od-final {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

@media (max-width: 640px) {
  .oh-summary {
    grid-template-columns: 1fr 1fr;
  }
  .oh-line-top {
    grid-template-columns: 1fr;
  }
  .oh-line-dates {
    grid-template-columns: 1fr 1fr;
  }
  .oh-line-dates .btn {
    width: 100%;
  }
}

/* ---- Menu item pictures (admin list, customer menu, edit form) ---- */

.thumb {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 12px;
  background: var(--alt);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb img.is-default {
  object-fit: contain;                     /* the team logo is shown whole, never cropped */
  padding: 6px;
}
.thumb.no-img img {
  display: none;                           /* no picture and no logo file: a plain empty tile */
}
.thumb-lg {
  width: 88px;
  height: 88px;
}
.img-field {
  align-items: flex-start;
}
.file-btn {
  cursor: pointer;
}

/* ---- Geo-fencing notice (customer menu) ---- */

.geo-card {
  margin-bottom: 12px;
  border-color: var(--tip);
  background: var(--tip-t);
}
.geo-message {
  margin: 8px 0 10px;
  line-height: 1.4;
}

/* ---- Waiter: active / done order cards, order form ---- */

.row.wrap {
  flex-wrap: wrap;
  margin-top: 6px;
}
.day-note {
  margin: -6px 0 12px;
}
.existing-lines {
  gap: 8px;
}

/* ---- Admin dashboard: browse past days, months and years ---- */

.period-nav {
  margin: 4px 0 12px;
}

/* ======================================================================
   10. Spacing helpers
   ====================================================================== */

.mt-4 { margin-top: 4px; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-18 { margin-top: 18px; }
.mt-20 { margin-top: 20px; }
.mb-6 { margin-bottom: 6px; }
.mb-12 { margin-bottom: 12px; }
.my-10 { margin: 10px 0; }
.my-14 { margin: 14px 0; }

/* ======================================================================
   11. Print (table QR cards)
   ====================================================================== */

#print {
  display: none;
}

@media print {
  body>*:not(#print) {
    display: none!important;
  }
  #print {
    display: grid!important;
    grid-template-columns: repeat(2,1fr);
    gap: 16px;
    padding: 10px;
  }
  .pcard {
    border: 2px solid #357b5f;
    border-radius: 16px;
    padding: 18px;
    text-align: center;
    break-inside: avoid;
  }
  .pcard img {
    width: 100%;
    max-width: 260px;
  }
  .pname {
    font-weight: 700;
    font-size: 20px;
  }
  .pnum {
    font-size: 34px;
    font-weight: 800;
    color: #357b5f;
  }
  .pcard-hint {
    margin-top: 8px;
  }
}
