:root {
  --orange: #ff6b35;
  --orange-dark: #e0551f;
  --green: #2e9e5b;
  --red: #d64545;
  --bg: #f4f4f6;
  --card-bg: #ffffff;
  --text: #222;
  --muted: #777;
  --border: #e2e2e6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

header.topbar {
  background: var(--orange);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

header.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
}

header.topbar a.back,
header.topbar a.topbar-link {
  color: #fff;
  text-decoration: none;
  font-size: 0.95rem;
  opacity: 0.9;
  white-space: nowrap;
}

main {
  padding: 12px;
  max-width: 1100px;
  margin: 0 auto;
  padding-bottom: 100px;
}

/* ---------- Landing page ---------- */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 20px;
  padding: 24px;
  text-align: center;
}

.landing h1 {
  font-size: 1.8rem;
  margin-bottom: 4px;
}

.landing p.subtitle {
  color: var(--muted);
  margin-top: 0;
}

.big-link {
  display: block;
  width: 100%;
  max-width: 360px;
  padding: 24px;
  border-radius: 16px;
  background: var(--orange);
  color: #fff;
  text-decoration: none;
  font-size: 1.3rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.big-link.secondary {
  background: #3a3a4a;
}

.big-link small {
  display: block;
  font-weight: 400;
  font-size: 0.9rem;
  opacity: 0.85;
  margin-top: 4px;
}

.menu-manage-link {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Order (cashier) page ---------- */
.order-name-field {
  margin-bottom: 14px;
}

.order-name-field label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.order-name-field input {
  width: 100%;
  padding: 14px;
  font-size: 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
}

.section-title {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 18px 0 8px;
}

.section-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: -4px 0 10px;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.menu-item-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: left;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 70px;
}

.menu-item-btn:active {
  background: #fff0e8;
  border-color: var(--orange);
}

.menu-item-btn .price {
  color: var(--orange-dark);
  font-weight: 600;
}

.cart {
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 14px;
}

.cart-empty {
  color: var(--muted);
  padding: 12px 0;
  text-align: center;
}

.cart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.cart-row:last-child { border-bottom: none; }

.cart-row .name {
  flex: 1;
  font-size: 0.98rem;
}

.cart-row .name .addons {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}

.cart-row .line-total {
  width: 70px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qty-controls button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.qty-controls span {
  min-width: 18px;
  text-align: center;
}

.cart-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}

.cart-footer .total {
  font-size: 1.2rem;
  font-weight: 700;
  flex: 1;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn-primary {
  background: var(--orange);
  color: #fff;
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-secondary {
  background: #eee;
  color: #333;
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

.recent-orders {
  margin-top: 20px;
}

.recent-order-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 0.92rem;
  cursor: pointer;
}

.recent-order-row:active {
  background: #fff0e8;
}

.view-history-link {
  display: block;
  text-align: center;
  padding: 10px;
  color: var(--orange-dark);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-pending {
  background: #fff2e0;
  color: var(--orange-dark);
}

.badge-done {
  background: #e4f7ea;
  color: var(--green);
}

/* ---------- Kitchen page ---------- */
.kitchen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.ticket {
  background: var(--card-bg);
  border-radius: 14px;
  border: 1px solid var(--border);
  border-left: 6px solid var(--orange);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ticket.overdue {
  border-left-color: var(--red);
}

.ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.ticket-header .order-name {
  font-size: 1.25rem;
  font-weight: 700;
}

.ticket-header .elapsed {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.95rem;
}

.ticket-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ticket-items li {
  font-size: 1.05rem;
}

.ticket-items li .item-line {
  display: flex;
  justify-content: space-between;
}

.ticket-items li .addons {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  padding-left: 24px;
}

.ticket-items li .qty {
  color: var(--orange-dark);
  font-weight: 700;
  margin-right: 8px;
}

.ticket-total {
  text-align: right;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.9rem;
}

.done-btn {
  margin-top: 4px;
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: none;
  background: var(--green);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 1.1rem;
}

/* ---------- Menu management page ---------- */
.menu-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
}

.menu-form input {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
}

.menu-form input[name="name"] { flex: 2; min-width: 140px; }
.menu-form input[name="price"] { flex: 1; min-width: 90px; }

.menu-form select {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
  background: #fff;
}

.category-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  padding: 0 4px;
}

.category-check input {
  width: 18px;
  height: 18px;
}

.menu-list-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
}

.menu-list-row .name { flex: 1; min-width: 100px; font-weight: 600; }
.menu-list-row .price { color: var(--orange-dark); width: 90px; text-align: right; }

.menu-list-row select.category-select {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.88rem;
  background: #fff;
}

.category-tags {
  display: flex;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.category-tags label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.category-tags input {
  width: 16px;
  height: 16px;
}

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.92rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
}

/* ---------- Add-on picker modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
}

.modal-sheet {
  background: var(--card-bg);
  width: 100%;
  max-width: 480px;
  border-radius: 18px 18px 0 0;
  padding: 20px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-sheet h2 {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

.modal-sheet .base-price {
  color: var(--muted);
  margin: 0 0 14px;
}

.addon-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
}

.addon-option:last-of-type {
  border-bottom: none;
}

.addon-option input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.addon-option .addon-name {
  flex: 1;
}

.addon-option .addon-price {
  color: var(--orange-dark);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-actions .btn {
  flex: 1;
}

/* ---------- Order history page ---------- */
.history-search {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  margin-bottom: 14px;
}

.history-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.history-card-header .name {
  font-size: 1.1rem;
  font-weight: 700;
}

.history-card-header .time {
  font-size: 0.82rem;
  color: var(--muted);
}

.history-items {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-items li {
  font-size: 0.98rem;
}

.history-items li .item-line {
  display: flex;
  justify-content: space-between;
}

.history-items li .addons {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  padding-left: 22px;
}

.history-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.history-card-footer .total {
  font-weight: 700;
}

/* ---------- Date range filter (shared: history + dashboard) ---------- */
.date-filter-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  margin-bottom: 10px;
}

.date-pill {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.88rem;
  cursor: pointer;
  white-space: nowrap;
}

.date-pill.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
  font-weight: 600;
}

.date-custom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.date-custom-row[hidden] {
  display: none;
}

.date-custom-row input[type="date"] {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.92rem;
  background: var(--card-bg);
}

.date-custom-row span {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Dashboard ---------- */
.stat-tile-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat-tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}

.stat-tile .label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-tile .value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.chart-card h3 {
  margin: 0 0 14px;
  font-size: 1rem;
}

.chart-empty {
  color: var(--muted);
  text-align: center;
  padding: 30px 0;
}

/* Vertical bar chart (revenue by day) */
.bar-chart-vertical {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 160px;
  border-bottom: 1px solid var(--baseline, #c3c2b7);
  overflow-x: auto;
  padding-top: 20px;
}

.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  width: 22px;
  height: 100%;
  position: relative;
}

.bar-col .bar {
  width: 100%;
  max-width: 22px;
  background: var(--orange);
  border-radius: 4px 4px 0 0;
  cursor: pointer;
}

.bar-col .bar.peak {
  background: var(--orange-dark);
}

.bar-col .peak-label {
  position: absolute;
  top: -18px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.bar-col:hover .bar {
  opacity: 0.85;
}

.bar-axis-labels {
  display: flex;
  gap: 3px;
  margin-top: 4px;
  overflow-x: auto;
}

.bar-axis-labels span {
  flex-shrink: 0;
  width: 22px;
  font-size: 0.62rem;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

/* Horizontal bar chart (top items) */
.bar-chart-horizontal {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hbar-row .hbar-label {
  width: 110px;
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hbar-row .hbar-track {
  flex: 1;
  position: relative;
  height: 22px;
}

.hbar-row .hbar-fill {
  height: 100%;
  background: var(--orange);
  border-radius: 0 4px 4px 0;
  min-width: 2px;
}

.hbar-row .hbar-value {
  flex-shrink: 0;
  width: 48px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

/* Shared chart tooltip */
.chart-tooltip {
  position: fixed;
  background: #222;
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  pointer-events: none;
  z-index: 80;
  opacity: 0;
  transition: opacity 0.1s ease;
  white-space: nowrap;
}

.chart-tooltip.show {
  opacity: 1;
}

/* Items sold table */
.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.items-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.items-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.items-table td:first-child,
.items-table th:first-child {
  font-variant-numeric: normal;
}

.items-table tr:last-child td {
  border-bottom: none;
}

.items-table td.num,
.items-table th.num {
  text-align: right;
}

.source-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #e3ecfb;
  color: #2a56b0;
  margin-left: 6px;
}

.ticket-stage-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.ticket-stage-actions .btn {
  flex: 1;
  padding: 10px;
  font-size: 0.95rem;
}

.delivery-section {
  margin-top: 24px;
}

.delivery-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 6px solid #2a56b0;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}

.delivery-card .order-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.delivery-card .phone {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}
