:root {
  --bg: #f0f7fb;
  --card: #ffffff;
  --ink: #10344d;
  --ink-soft: #5b7a8f;
  --line: #d7e6ef;
  --brand: #12587f;
  --brand-dark: #0b1e2d;
  --accent: #0e8abf;
  --ok: #1a8f5c;
  --warn: #c2820a;
  --bad: #c0392b;
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 480px; margin: 0 auto; padding: 16px 16px 40px; }
.wrap-wide { max-width: 960px; margin: 0 auto; padding: 16px 16px 40px; }

header.topbar {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #e8f6ff;
  padding: 18px 16px;
}
.topbar-inner { max-width: 960px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-weight: 700; letter-spacing: 0.18em; font-size: 1.05rem; }
.topbar .who { font-size: 0.85rem; opacity: 0.85; }

h1 { font-size: 1.35rem; margin: 8px 0 4px; }
.sub { color: var(--ink-soft); font-size: 0.9rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 14px;
}

label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); margin: 12px 0 6px; }

input[type='text'], input[type='password'], input[type='tel'], input[type='number'], input[type='time'], select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fbfdfe;
  color: var(--ink);
}
textarea { resize: vertical; font-family: inherit; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.fix-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fix-grid label { margin-top: 8px; }
.reply-row { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; }
.reply-row textarea { flex: 1; }
.reply-row .btn { flex-shrink: 0; height: 46px; }

/* QR payment receipts */
.receipt-row {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  background: #fbfdfe;
}
.receipt-row.pending { border-color: #e8c973; background: #fdf8ec; }
.receipt-row .sub { margin-top: 6px; }
.receipt-row input[type='file'] { margin-top: 8px; font-size: 0.9rem; }
.receipt-check { margin-top: 10px; }
.receipt-img { margin-top: 8px; max-width: 260px; max-height: 260px; border-radius: 10px; border: 1px solid var(--line); display: block; }

/* Big keypad-style PIN entry */
.pin-input {
  width: 100%;
  min-height: 64px;
  font-size: 2rem;
  letter-spacing: 1.2em;
  text-indent: 0.6em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  min-width: 44px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--brand); }
.btn-ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-danger { background: var(--bad); }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }

.toggle-row { display: flex; gap: 8px; margin-top: 14px; font-size: 0.9rem; }
.toggle-row button {
  flex: 1;
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fbfdfe;
  color: var(--ink-soft);
  font-weight: 600;
  cursor: pointer;
}
.toggle-row button.active { border-color: var(--accent); color: var(--accent); background: #eef7fc; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.pills label {
  margin: 0;
  padding: 10px 14px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.pills input { position: absolute; opacity: 0; pointer-events: none; }
.pills label:has(input:checked) { border-color: var(--accent); background: #eef7fc; color: var(--accent); }

.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button {
  width: 52px;
  height: 52px;
  font-size: 1.5rem;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fbfdfe;
  color: var(--brand);
  cursor: pointer;
}
.stepper .count { font-size: 1.5rem; font-weight: 700; min-width: 60px; text-align: center; font-variant-numeric: tabular-nums; }
.stepper .unit-label { color: var(--ink-soft); font-size: 0.9rem; }

.status-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.st-pending { background: #fdf3dc; color: var(--warn); }
.st-confirmed { background: #e2f0fb; color: var(--brand); }
.st-ready { background: #e2f7ec; color: var(--ok); }
.st-picked_up { background: #e8e8ee; color: #55556b; }
.st-cancelled { background: #fbe4e1; color: var(--bad); }
.pay-unpaid { background: #fbe4e1; color: var(--bad); }
.pay-paid { background: #e2f7ec; color: var(--ok); }
.src-chip { background: #eef2f5; color: var(--ink-soft); }

.order-card { padding: 14px 16px; }
.order-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.order-id { font-weight: 700; }
.order-meta { color: var(--ink-soft); font-size: 0.85rem; margin-top: 6px; line-height: 1.5; }
.order-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.filters { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; -webkit-overflow-scrolling: touch; }
.filters button {
  flex-shrink: 0;
  min-height: 40px;
  padding: 8px 16px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.filters button.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.notice {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  background: #fdf3dc;
  color: var(--warn);
  border: 1px solid #f0dcae;
}
.notice.error { background: #fbe4e1; color: var(--bad); border-color: #efc4bf; }
.notice.ok { background: #e2f7ec; color: var(--ok); border-color: #bfe8d2; }

.empty { text-align: center; color: var(--ink-soft); padding: 30px 10px; font-size: 0.95rem; }

/* Buildings directory */
.bldg-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.bldg-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fbfdfe;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
}
.bldg-chip.selected { border-color: var(--accent); background: #eef7fc; color: var(--accent); }
.bldg-chip.inactive { opacity: 0.45; }
.bldg-count {
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  font-variant-numeric: tabular-nums;
}
.bldg-chip.selected .bldg-count { background: var(--accent); }

/* Payment QR */
.qr-holder {
  margin-top: 10px;
  padding: 12px;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  background: #fff;
  display: flex;
  justify-content: center;
}
.qr-holder img { max-width: 240px; max-height: 240px; width: auto; height: auto; display: block; }
.qr-holder.small img { max-width: 140px; max-height: 140px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 30, 45, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal {
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(11, 30, 45, 0.4);
}

.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: linear-gradient(180deg, #0b1e2d 0%, #10344d 55%, #12587f 100%);
  color: #e8f6ff;
}
.landing h1 {
  font-size: clamp(2.6rem, 9vw, 4.5rem);
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  background: linear-gradient(90deg, #7fd8ff, #ffffff, #7fd8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.landing p { opacity: 0.75; margin: 10px 0 30px; font-weight: 300; }
.landing .choices { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 340px; }
.landing a.choice {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
}
.landing a.customer { background: #e8f6ff; color: var(--brand-dark); }
.landing a.admin { background: transparent; color: #e8f6ff; border: 1.5px solid rgba(232, 246, 255, 0.45); }

.timeline { display: flex; gap: 4px; margin-top: 10px; }
.timeline span {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
}
.timeline span.done { background: var(--accent); }
.timeline-labels { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--ink-soft); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.03em; }

@media (min-width: 720px) {
  .wrap { max-width: 560px; }
  h1 { font-size: 1.6rem; }
}
