/* =====================================================================
   Component library — buttons, cards, forms, badges, tables, overlays.
   ===================================================================== */

/* ------------------------------------------------------------ buttons */

.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-bd: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  height: 42px;
  border-radius: var(--r-sm);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--t-base);
  font-weight: 650;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: transform var(--fast), box-shadow var(--fast), background var(--fast), border-color var(--fast), opacity var(--fast);
  user-select: none;
}
.btn:hover { color: var(--btn-fg); box-shadow: var(--sh-2); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn[disabled], .btn.is-disabled {
  opacity: 0.5;
  pointer-events: none;
  box-shadow: none;
}

.btn-primary {
  --btn-bg: var(--brand);
  --btn-fg: #fff;
  --btn-bd: transparent;
  box-shadow: var(--sh-brand);
}
.btn-primary:hover { --btn-bg: var(--brand-strong); }

.btn-accent {
  --btn-bg: var(--orange-500);
  --btn-fg: #fff;
  --btn-bd: transparent;
  box-shadow: 0 6px 18px rgba(244, 98, 31, 0.3);
}
.btn-accent:hover { --btn-bg: var(--orange-600); }

.btn-dark   { --btn-bg: var(--slate-900); --btn-fg: #fff; --btn-bd: transparent; }
.btn-ok     { --btn-bg: var(--ok-500);   --btn-fg: #fff; --btn-bd: transparent; }
.btn-bad    { --btn-bg: var(--bad-500);  --btn-fg: #fff; --btn-bd: transparent; }
.btn-warn   { --btn-bg: var(--warn-500); --btn-fg: #fff; --btn-bd: transparent; }

.btn-soft   { --btn-bg: var(--brand-soft); --btn-fg: var(--brand-deep); --btn-bd: transparent; }
.btn-ghost  { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--ink-soft); }
.btn-ghost:hover { --btn-bg: var(--surface-3); box-shadow: none; }
.btn-outline{ --btn-bg: transparent; --btn-bd: var(--brand); --btn-fg: var(--brand-strong); }
.btn-danger-soft { --btn-bg: var(--bad-50); --btn-fg: var(--bad-700); --btn-bd: transparent; }

.btn-sm  { height: 34px; padding: 0 12px; font-size: var(--t-sm); border-radius: var(--r-xs); gap: 6px; }
.btn-xs  { height: 28px; padding: 0 10px; font-size: var(--t-xs); border-radius: var(--r-xs); gap: 5px; }
.btn-lg  { height: 50px; padding: 0 22px; font-size: var(--t-md); border-radius: var(--r-md); }
.btn-block { width: 100%; }

.btn-icon { width: 42px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }
.btn-icon.btn-xs { width: 28px; }

.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* Inverted buttons for coloured hero areas */
.on-dark .btn-outline { --btn-bd: rgba(255, 255, 255, 0.5); --btn-fg: #fff; }
.on-dark .btn-outline:hover { --btn-bg: rgba(255, 255, 255, 0.14); }
.on-dark .btn-light { --btn-bg: #fff; --btn-fg: var(--brand-deep); --btn-bd: transparent; }

/* --------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.card-flat  { box-shadow: none; }
.card-raised{ box-shadow: var(--sh-2); border-color: transparent; }
.card-pad   { padding: 18px; }
.card-tight { padding: 14px; }

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.card-head h3, .card-head h4 { font-size: var(--t-md); margin: 0; }
.card-head .card-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.card-body { padding: 18px; }
.card-body + .card-body { border-top: 1px solid var(--line); }

.card-foot {
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.card-link { display: block; color: inherit; }
.card-link:hover {
  color: inherit;
  box-shadow: var(--sh-3);
  border-color: var(--brand-300);
  transform: translateY(-2px);
}
.card-link { transition: transform var(--med), box-shadow var(--med), border-color var(--med); }

.card-accent { border-left: 3px solid var(--brand); }
.card-warn   { border-left: 3px solid var(--warn-500); }
.card-bad    { border-left: 3px solid var(--bad-500); }
.card-ok     { border-left: 3px solid var(--ok-500); }

/* Section heading above a group of cards */
.section-head {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h2, .section-head h3 { margin: 0; }
.section-head .section-sub { color: var(--ink-muted); font-size: var(--t-sm); }
.section-head > *:last-child.section-action { margin-left: auto; }

/* --------------------------------------------------------------- stats */

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  transition: transform var(--med), box-shadow var(--med);
}
a.stat { color: inherit; }
a.stat:hover { transform: translateY(-2px); box-shadow: var(--sh-2); color: inherit; }

.stat-top { display: flex; align-items: center; gap: 8px; }
.stat-ic {
  width: 30px; height: 30px;
  border-radius: var(--r-xs);
  display: grid; place-items: center;
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.stat-label {
  font-size: var(--t-xs);
  font-weight: 650;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-value {
  font-size: var(--t-xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat-note { font-size: var(--t-xs); color: var(--ink-muted); }

.stat-ok  .stat-ic { background: var(--ok-50);  color: var(--ok-700); }
.stat-bad .stat-ic { background: var(--bad-50); color: var(--bad-700); }
.stat-warn .stat-ic{ background: var(--warn-50);color: var(--warn-700); }
.stat-info .stat-ic{ background: var(--info-50);color: var(--info-700); }

/* -------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: var(--t-xs);
  font-weight: 700;
  line-height: 1.5;
  background: var(--surface-3);
  color: var(--ink-soft);
  white-space: nowrap;
}
.badge-brand { background: var(--brand-soft); color: var(--brand-deep); }
.badge-ok    { background: var(--ok-50);   color: var(--ok-700); }
.badge-warn  { background: var(--warn-50); color: var(--warn-700); }
.badge-bad   { background: var(--bad-50);  color: var(--bad-700); }
.badge-info  { background: var(--info-50); color: var(--info-700); }
.badge-dark  { background: var(--slate-800); color: #fff; }
.badge-solid { background: var(--brand); color: #fff; }
.badge-lg    { font-size: var(--t-sm); padding: 5px 12px; }

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}
.dot-live { box-shadow: 0 0 0 0 currentColor; animation: pulse-dot 1.9s infinite; }
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(18, 163, 95, 0.5); }
  70%  { box-shadow: 0 0 0 7px rgba(18, 163, 95, 0); }
  100% { box-shadow: 0 0 0 0 rgba(18, 163, 95, 0); }
}

.count-bubble {
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--bad-500);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: inline-grid;
  place-items: center;
  line-height: 1;
}

/* --------------------------------------------------------------- chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: var(--t-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--fast);
}
.chip:hover { border-color: var(--brand-300); color: var(--brand-strong); }
.chip.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.chip-sm { height: 28px; padding: 0 10px; font-size: var(--t-xs); }

/* Radio group that looks like chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-radio { position: relative; display: inline-flex; cursor: pointer; }
.chip-radio input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.chip-radio input:checked + .chip {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.chip-radio input:focus-visible + .chip { outline: 2px solid var(--brand); outline-offset: 2px; }

.offer-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-xs);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.01em;
  background: var(--orange-50);
  color: var(--orange-700);
  border: 1px dashed var(--orange-200);
}
.offer-chip.is-delivery { background: var(--ok-50); color: var(--ok-700); border-color: var(--green-200); }

/* --------------------------------------------------------------- forms */

.field { display: flex; flex-direction: column; gap: 6px; }

.label {
  font-size: var(--t-sm);
  font-weight: 650;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 5px;
}
.label .req { color: var(--bad-500); }

.hint { display: block; font-size: var(--t-xs); color: var(--ink-muted); }
.error-text { font-size: var(--t-xs); color: var(--bad-700); font-weight: 600; }

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-base);
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
  appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.input[readonly], .input[disabled] { background: var(--surface-2); color: var(--ink-muted); }
.input.has-error, .select.has-error, .textarea.has-error { border-color: var(--bad-500); }

.textarea { min-height: 92px; resize: vertical; line-height: 1.5; }

.select {
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7686' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m5 9 7 7 7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}

.input-group { display: flex; align-items: stretch; }
.input-group > .input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group > .btn   { border-radius: 0 var(--r-sm) var(--r-sm) 0; margin-left: -1px; height: auto; }

.input-icon { position: relative; }
.input-icon > .icon {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  pointer-events: none;
}
.input-icon > .input { padding-left: 40px; }

.input-affix { position: relative; }
.input-affix .affix {
  position: absolute; right: 13px; top: 50%;
  transform: translateY(-50%);
  font-size: var(--t-sm);
  color: var(--ink-muted);
  font-weight: 600;
}
.input-affix .input { padding-right: 46px; }

.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}

.form-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 4px;
}
.form-section-title {
  font-size: var(--t-sm);
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: 12px;
}

/* Checkbox & radio */
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: var(--t-base);
  color: var(--ink-soft);
}
.check input[type="checkbox"], .check input[type="radio"] {
  appearance: none;
  width: 20px; height: 20px;
  flex: 0 0 auto;
  margin-top: 1px;
  border: 1.5px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  transition: all var(--fast);
  position: relative;
}
.check input[type="radio"] { border-radius: 50%; }
.check input:checked {
  background: var(--brand);
  border-color: var(--brand);
}
.check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 13 4.5 4.5L19 7'/%3E%3C/svg%3E") center / 14px no-repeat;
}
.check input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #fff;
}

/* Selectable card (payment mode, address pick) */
.pick {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--fast);
}
.pick:hover { border-color: var(--brand-300); }
.pick.is-active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.pick-ic {
  width: 38px; height: 38px;
  border-radius: var(--r-xs);
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--ink-soft);
  flex: 0 0 auto;
}
.pick.is-active .pick-ic { background: var(--brand); color: #fff; }
/* Block so the sub-line always starts below the title. Kept off .pick-sub
   because that one is often paired with .clamp-1 / .clamp-2, which need to
   keep their own display value. */
.pick-title { display: block; font-weight: 700; font-size: var(--t-base); }
.pick-sub { font-size: var(--t-xs); color: var(--ink-muted); }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 44px; height: 25px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  position: relative;
  transition: background var(--med);
  flex: 0 0 auto;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--sh-1);
  transition: transform var(--med);
}
.switch input:checked + .switch-track { background: var(--ok-500); }
.switch input:checked + .switch-track::after { transform: translateX(19px); }

/* Quantity stepper */
.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--brand);
  border-radius: var(--r-pill);
  overflow: hidden;
  background: var(--surface);
  height: 34px;
}
.stepper button {
  width: 32px; height: 100%;
  display: grid; place-items: center;
  color: var(--brand-strong);
  background: var(--brand-soft);
  transition: background var(--fast);
}
.stepper button:hover { background: var(--brand-muted); }
.stepper .qty {
  min-width: 32px;
  text-align: center;
  font-weight: 750;
  font-size: var(--t-sm);
  font-variant-numeric: tabular-nums;
}
.stepper-sm { height: 29px; }
.stepper-sm button { width: 27px; }

/* File / image picker */
.filepick {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  transition: all var(--fast);
}
.filepick:hover { border-color: var(--brand); background: var(--brand-soft); }
.filepick input[type="file"] { display: none; }
.filepick-preview {
  width: 46px; height: 46px;
  border-radius: var(--r-xs);
  object-fit: cover;
  background: var(--surface-3);
  flex: 0 0 auto;
}

/* -------------------------------------------------------------- alerts */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border-radius: var(--r-md);
  font-size: var(--t-base);
  border: 1px solid transparent;
  line-height: 1.5;
}
.alert .icon { margin-top: 2px; }
.alert-body { flex: 1 1 auto; min-width: 0; }
.alert strong { font-weight: 750; }
.alert-success { background: var(--ok-50);   color: var(--ok-700);   border-color: var(--green-200); }
.alert-danger  { background: var(--bad-50);  color: var(--bad-700);  border-color: #f3c9c9; }
.alert-warning { background: var(--warn-50); color: var(--warn-700); border-color: #f4dfa4; }
.alert-info    { background: var(--info-50); color: var(--info-700); border-color: #c6dcfb; }
.alert-brand   { background: var(--brand-soft); color: var(--brand-deep); border-color: var(--brand-muted); }
.alert-close { margin-left: auto; color: inherit; opacity: 0.6; }
.alert-close:hover { opacity: 1; }

/* -------------------------------------------------------------- tables */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-sm);
}
.table th {
  text-align: left;
  padding: 11px 14px;
  font-size: var(--t-xs);
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink-soft);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tfoot td {
  background: var(--surface-2);
  font-weight: 750;
  color: var(--ink);
  border-top: 2px solid var(--line-strong);
  border-bottom: 0;
}
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-compact th, .table-compact td { padding: 8px 11px; }

/* ------------------------------------------------------- bill / totals */

.bill { display: flex; flex-direction: column; gap: 9px; }
.bill-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: var(--t-base);
  color: var(--ink-soft);
}
.bill-row .bill-label { flex: 1 1 auto; min-width: 0; }
.bill-row .bill-value { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.bill-row.is-credit .bill-value { color: var(--ok-700); }
.bill-row.is-muted { font-size: var(--t-sm); color: var(--ink-muted); }
.bill-total {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1.5px dashed var(--line-strong);
  font-size: var(--t-md);
  font-weight: 800;
  color: var(--ink);
}
.bill-total .bill-value { font-size: var(--t-lg); color: var(--brand-strong); font-weight: 850; }

/* ------------------------------------------------------------ avatars */

.avatar {
  width: 42px; height: 42px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--surface-3);
  flex: 0 0 auto;
}
.avatar-round { border-radius: 50%; }
.avatar-xs { width: 28px; height: 28px; border-radius: var(--r-xs); }
.avatar-sm { width: 34px; height: 34px; }
.avatar-lg { width: 58px; height: 58px; border-radius: var(--r-md); }
.avatar-xl { width: 78px; height: 78px; border-radius: var(--r-lg); }

.avatar-text {
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: var(--t-sm);
  color: var(--brand-deep);
  background: var(--brand-muted);
  letter-spacing: 0.02em;
}
.avatar-lg.avatar-text { font-size: var(--t-lg); }
.avatar-xl.avatar-text { font-size: var(--t-xl); }

/* ------------------------------------------------------ notification row */

.notice-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: inherit;
}
a.notice-row:hover { border-color: var(--brand-300); color: inherit; }
.notice-row.is-new { background: var(--brand-soft); border-color: var(--brand-300); }
.notice-row.is-new .dot { color: var(--brand); }

/* --------------------------------------------------------------- stars */

.stars { display: inline-flex; gap: 1px; color: var(--warn-500); }
.stars .icon { fill: currentColor; }
.stars .is-empty { color: var(--line-strong); fill: none; }

/* Tappable version used in rating forms. */
.stars-pick { display: inline-flex; gap: 4px; }
.star-pick {
  border: 0;
  background: none;
  padding: 2px;
  color: var(--line-strong);
  cursor: pointer;
  transition: transform var(--fast), color var(--fast);
}
.star-pick:active { transform: scale(0.88); }
.star-pick.is-on { color: var(--warn-500); }
.star-pick.is-on .icon { fill: currentColor; }

.rating-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: var(--r-xs);
  background: var(--ok-500);
  color: #fff;
  font-size: var(--t-xs);
  font-weight: 800;
}
.rating-pill .icon { fill: currentColor; }
.rating-pill.is-empty { background: var(--surface-3); color: var(--ink-muted); }

/* -------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--surface-3);
  border-radius: var(--r-md);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button {
  flex: 1 1 auto;
  padding: 8px 14px;
  border-radius: var(--r-xs);
  font-size: var(--t-sm);
  font-weight: 650;
  color: var(--ink-muted);
  text-align: center;
  white-space: nowrap;
  transition: all var(--fast);
}
.tabs a.is-active, .tabs button.is-active {
  background: var(--surface);
  color: var(--brand-strong);
  box-shadow: var(--sh-1);
}

.pill-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
}
/* Grow to fill each row; the cap stops a lone chip on the last row from
   stretching into a full-width bar. */
.pill-nav > * { flex: 1 1 auto; max-width: 220px; justify-content: center; }

@media (max-width: 640px) {
  .pill-nav { gap: 6px; }
  .pill-nav > * { flex: 1 1 calc(50% - 6px); max-width: calc(50% - 3px); }
  .pill-nav .chip {
    height: auto;
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
    line-height: 1.25;
    white-space: normal;
    text-align: center;
  }
}

/* ------------------------------------------------------------ progress */

.meter {
  height: 7px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.meter > span {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--ok-500);
  transition: width var(--slow);
}
.meter.is-warn > span { background: var(--warn-500); }
.meter.is-bad  > span { background: var(--bad-500); }

/* ------------------------------------------------------------ timeline */

.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-step {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 12px;
  position: relative;
  padding-bottom: 18px;
}
.tl-step:last-child { padding-bottom: 0; }
.tl-step::before {
  content: "";
  position: absolute;
  left: 12px; top: 26px; bottom: 0;
  width: 2px;
  background: var(--line);
}
.tl-step:last-child::before { display: none; }
.tl-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--ink-faint);
  border: 2px solid var(--surface);
  z-index: 1;
}
.tl-step.is-done .tl-dot { background: var(--ok-500); color: #fff; }
.tl-step.is-done::before { background: var(--green-300); }
.tl-step.is-current .tl-dot {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 0 0 4px var(--brand-glow);
}
.tl-step.is-fail .tl-dot { background: var(--bad-500); color: #fff; }
.tl-title { font-weight: 700; font-size: var(--t-base); }
.tl-step:not(.is-done):not(.is-current) .tl-title { color: var(--ink-faint); font-weight: 600; }
.tl-time { font-size: var(--t-xs); color: var(--ink-muted); }

/* Compact horizontal tracker for order cards */
.track {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 2px 0;
}
.track-node {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--surface-3);
  display: grid; place-items: center;
  color: var(--ink-faint);
  flex: 0 0 auto;
}
.track-node .icon { width: 11px; height: 11px; }
.track-bar { flex: 1 1 auto; height: 2px; background: var(--surface-3); }
.track-node.is-done { background: var(--ok-500); color: #fff; }
.track-bar.is-done { background: var(--green-300); }
.track-node.is-current { background: var(--brand); color: #fff; box-shadow: 0 0 0 3px var(--brand-glow); }

/* ---------------------------------------------------------- empty state */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 44px 22px;
}
.empty-ic {
  width: 62px; height: 62px;
  border-radius: var(--r-lg);
  display: grid; place-items: center;
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.empty h1, .empty h2, .empty h3 { font-size: var(--t-md); }
.empty p { font-size: var(--t-sm); color: var(--ink-muted); max-width: 34ch; }

/* ------------------------------------------------------------- skeleton */

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
  border-radius: var(--r-xs);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* --------------------------------------------------------------- modal */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 22, 0.52);
  backdrop-filter: blur(3px);
  display: none;
  z-index: 800;
  padding: 20px;
  overflow-y: auto;
  align-items: center;
  justify-content: center;
}
.overlay.is-open { display: flex; animation: fade-in var(--med) both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--sh-4);
  overflow: hidden;
  animation: pop-in var(--med) both;
  margin: auto;
}
.modal-md { max-width: 620px; }
.modal-lg { max-width: 820px; }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}
.modal-head h3 { font-size: var(--t-md); margin: 0; }
.modal-head .modal-x { margin-left: auto; color: var(--ink-muted); }
.modal-head .modal-x:hover { color: var(--ink); }
.modal-body { padding: 20px; }
.modal-foot {
  padding: 15px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  background: var(--surface-2);
}
.modal-foot .btn { flex: 1 1 auto; }

/* Bottom sheet on phones */
@media (max-width: 640px) {
  .overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: none;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: 92vh;
    overflow-y: auto;
    animation: slide-up var(--med) both;
    margin: 0;
  }
  @keyframes slide-up { from { transform: translateY(100%); } to { transform: none; } }
  .modal-head::before {
    content: "";
    position: absolute;
    top: 7px; left: 50%;
    transform: translateX(-50%);
    width: 38px; height: 4px;
    border-radius: var(--r-pill);
    background: var(--line-strong);
  }
  .modal-head { padding-top: 20px; }
}

/* Right-side drawer (cart) */
.drawer-wrap {
  position: fixed;
  inset: 0;
  z-index: 820;
  display: none;
}
.drawer-wrap.is-open { display: block; }
.drawer-scrim {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 22, 0.5);
  animation: fade-in var(--med) both;
}
.drawer {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 100%);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-4);
  animation: slide-left var(--med) both;
}
@keyframes slide-left { from { transform: translateX(100%); } to { transform: none; } }
.drawer-head {
  padding: 16px 18px;
  background: var(--brand-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
}
.drawer-head h3 { color: #fff; font-size: var(--t-md); margin: 0; }
.drawer-head .drawer-x { margin-left: auto; color: rgba(255, 255, 255, 0.85); }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 16px 18px; }
.drawer-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
@media (max-width: 640px) {
  .drawer { border-radius: var(--r-xl) var(--r-xl) 0 0; top: auto; height: 86vh; width: 100%; animation: slide-up var(--med) both; }
}

/* -------------------------------------------------------------- toasts */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 16px);
  transform: translateX(-50%);
  z-index: 950;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(440px, calc(100vw - 28px));
}
@media (min-width: 860px) {
  .toast-host { bottom: auto; top: 18px; }
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  border-radius: var(--r-pill);
  background: var(--slate-900);
  color: #fff;
  font-size: var(--t-sm);
  font-weight: 600;
  box-shadow: var(--sh-3);
  animation: toast-in var(--med) both;
  pointer-events: auto;
  max-width: 100%;
}
.toast.is-out { animation: toast-out var(--fast) both; }
.toast-success { background: var(--ok-700); }
.toast-error   { background: var(--bad-700); }
.toast-warning { background: var(--warn-700); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }

/* --------------------------------------------------------- announce bar */

.announce {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 900;
  padding: 11px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: #fff;
  font-size: var(--t-sm);
  font-weight: 650;
  background: var(--ok-700);
  box-shadow: var(--sh-2);
  animation: drop-in var(--med) both;
}
.announce-bad { background: var(--bad-700); }
.announce a { color: #fff; text-decoration: underline; }
.announce .announce-x { margin-left: auto; color: rgba(255, 255, 255, 0.8); }
@keyframes drop-in { from { transform: translateY(-100%); } to { transform: none; } }

/* ------------------------------------------------------------- tooltip */

.help {
  display: inline-grid;
  place-items: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-muted);
  font-size: 10px;
  font-weight: 800;
  cursor: help;
}

/* ------------------------------------------------------------ QR frame */

.qr-frame {
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  display: inline-block;
  box-shadow: var(--sh-1);
}
.qr-frame img { width: 100%; max-width: 240px; }

/* -------------------------------------------------------------- misc */

.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-faint);
  font-size: var(--t-xs);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.divider-text::before, .divider-text::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--line);
}

.kv { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv-k { font-size: var(--t-xs); color: var(--ink-muted); font-weight: 600; }
.kv-v { font-size: var(--t-base); font-weight: 650; color: var(--ink); }

.pin-display {
  display: inline-flex;
  gap: 8px;
}
.pin-display span {
  width: 38px; height: 46px;
  display: grid; place-items: center;
  border-radius: var(--r-xs);
  background: var(--surface);
  border: 1.5px solid var(--brand-300);
  font-size: var(--t-xl);
  font-weight: 800;
  color: var(--brand-deep);
  font-variant-numeric: tabular-nums;
}

.pin-input {
  letter-spacing: 0.55em;
  text-align: center;
  font-size: var(--t-xl);
  font-weight: 800;
  height: 56px;
  font-variant-numeric: tabular-nums;
}

.map-box {
  height: 220px;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-3);
}
.map-box.is-tall { height: 320px; }
body.map-full .map-box.is-expandable {
  position: fixed;
  inset: 0;
  height: 100vh;
  z-index: 700;
  border-radius: 0;
}
