:root {
  --orange: #2f4f3f;
  --orange-dark: #22392c;
  --accent: #c8973f;
  --green: #3f7d51;
  --red: #b5543f;
  --bg: #f6f1e4;
  --card-bg: #fffcf5;
  --text: #2c2a22;
  --muted: #8a8170;
  --border: #e6ddc8;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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: #fdf9ee;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 10px rgba(34, 57, 44, 0.18);
}

header.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
  letter-spacing: 0.01em;
}

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

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

.topbar-logo-slot {
  width: 20px;
  display: inline-block;
}

.topbar-logo {
  height: 28px;
  width: auto;
  display: block;
}

/* ---------- Login screen (centered, no nav) ---------- */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 28px;
  box-shadow: 0 10px 28px rgba(44, 42, 34, 0.1);
  text-align: center;
}

.login-card .login-brand {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--orange-dark);
  margin: 0 0 4px;
  letter-spacing: 0.01em;
}

.login-card .subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 0 26px;
}

.login-card .order-name-field {
  text-align: left;
}

/* ---------- Greeting ---------- */
.greeting {
  margin: 6px 0 22px;
}

.greeting .greeting-hi {
  display: block;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--orange-dark);
  line-height: 1.25;
}

.greeting .greeting-sub {
  display: block;
  font-size: 1rem;
  color: var(--muted);
  margin-top: 4px;
}

.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: #fdf9ee;
  text-decoration: none;
  font-size: 1.3rem;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(34, 57, 44, 0.22);
}

.big-link.secondary {
  background: var(--orange-dark);
}

.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-name-field {
  margin-bottom: 14px;
}

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

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

.order-name-field input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(47, 79, 63, 0.12);
}

.section-title {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--orange-dark);
  font-weight: 700;
  margin: 20px 0 8px;
}

.section-hint {
  font-size: 0.95rem;
  color: var(--text);
  margin: -4px 0 14px;
}

.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: 14px;
  padding: 14px 12px;
  text-align: left;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 70px;
  box-shadow: 0 1px 3px rgba(44, 42, 34, 0.05);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.menu-item-btn:active {
  background: #eef2e9;
  border-color: var(--orange);
  transform: scale(0.98);
}

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

.cart {
  background: var(--card-bg);
  border-radius: 14px;
  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: var(--bg);
  color: var(--orange-dark);
  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: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 -2px 12px rgba(44, 42, 34, 0.08);
}

.cart-footer .total {
  font-size: 1.2rem;
  font-weight: 700;
  flex: 1;
  color: var(--orange-dark);
}

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

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

.btn-primary:disabled {
  background: #cfc9b8;
  color: #8a8170;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg);
  color: var(--orange-dark);
  border: 1px solid var(--border);
}

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

.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: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 0.92rem;
  cursor: pointer;
}

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

.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: #f3e6c8;
  color: #8a6a1f;
}

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

.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: 12px;
  border: none;
  background: var(--green);
  color: #fdf9ee;
  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-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 16px;
}

.menu-form input {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 1rem;
  background: var(--card-bg);
  color: var(--text);
}

.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: 10px;
  border: 1px solid var(--border);
  font-size: 1rem;
  background: var(--card-bg);
  color: var(--text);
}

.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: 12px;
  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: var(--card-bg);
}

.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: var(--orange-dark);
  color: #fdf9ee;
  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;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(34, 30, 20, 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: 20px 20px 0 0;
  padding: 20px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-sheet h2 {
  margin: 0 0 4px;
  font-size: 1.2rem;
  color: var(--text);
}

.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;
  accent-color: var(--orange);
}

.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;
}

.history-search {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  margin-bottom: 14px;
  color: var(--text);
}

.history-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  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;
  color: var(--orange-dark);
}

.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: #fdf9ee;
  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;
}

.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: 14px;
  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: 14px;
  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;
}

.bar-chart-vertical {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 160px;
  border-bottom: 1px solid var(--border);
  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;
}

.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);
}

.chart-tooltip {
  position: fixed;
  background: var(--orange-dark);
  color: #fdf9ee;
  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-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;
}

.warning-banner {
  background: #faf3e0;
  border: 1px solid #e3c789;
  color: #7a5a1f;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  margin-top: 16px;
  line-height: 1.4;
}

.confirm-summary-items {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.confirm-summary-items li .item-line {
  display: flex;
  justify-content: space-between;
  font-size: 1rem;
}

.confirm-summary-items li .addons {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
}

.success-screen {
  text-align: center;
  padding: 40px 20px;
}

.success-screen .checkmark {
  font-size: 3rem;
  margin-bottom: 12px;
}

.success-screen h2 {
  margin: 0 0 8px;
  color: var(--orange-dark);
}

.success-screen p {
  color: var(--muted);
  margin: 0 0 24px;
}

.tracker-steps {
  display: flex;
  justify-content: space-between;
  margin: 16px 0 4px;
  position: relative;
}

.tracker-steps::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 6%;
  right: 6%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}

.tracker-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  text-align: center;
}

.tracker-step .dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.tracker-step.done .dot {
  background: var(--green);
  border-color: var(--green);
  color: #fdf9ee;
}

.tracker-step.current .dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fdf9ee;
}

.tracker-step .step-label {
  font-size: 0.72rem;
  color: var(--muted);
  max-width: 70px;
}

.tracker-step.done .step-label,
.tracker-step.current .step-label {
  color: var(--text);
  font-weight: 600;
}

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

.track-order-card .order-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.track-order-card .order-meta .time {
  font-size: 0.8rem;
  color: var(--muted);
}

.source-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #e4ecdf;
  color: var(--green);
}

/* ---------- Cancelled order notice ---------- */
.cancelled-notice {
  background: #f7e3df;
  border: 1px solid #e0a99b;
  color: var(--red);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 16px 0 4px;
  text-align: center;
}
