/* =====================================================================
   Components and the logged-in app shell.
   Mobile first; desktop rules live at the bottom (min-width: 1024px).
   ===================================================================== */

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 1.5px solid transparent;
  border-radius: var(--r-sm);
  font-weight: 700;
  font-size: var(--fs-md);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: transform var(--t-fast) var(--ease), background-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn.is-disabled { opacity: 0.45; pointer-events: none; }
.btn .icon { width: 20px; height: 20px; }
.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 25%, transparent); }
.btn--primary:hover { background: var(--brand-600); }
.btn--accent { background: var(--accent); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn--secondary { background: var(--brand-100); color: var(--brand); }
.btn--secondary:hover { background: var(--brand-200); }
.btn--outline { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn--ghost { background: transparent; color: var(--brand); }
.btn--ghost:hover { background: var(--brand-50); }
.btn--danger { background: var(--danger-soft); color: var(--danger); }
.btn--success { background: var(--success); color: #fff; }
.btn--sm { min-height: 38px; padding: 0 14px; font-size: var(--fs-sm); border-radius: 10px; }
.btn--lg { min-height: 56px; padding: 0 24px; font-size: var(--fs-lg); border-radius: var(--r-md); }
.btn--block { width: 100%; }
.btn--icon { width: 44px; min-height: 44px; padding: 0; border-radius: var(--r-full); }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2.5px solid currentColor;
  border-color: #fff #fff transparent transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.link-btn { padding: 0; border: 0; background: none; color: var(--brand); font-weight: 700; cursor: pointer; }
.link-btn:disabled { color: var(--faint); cursor: default; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin: 18px 0; }
.field > label, .field__label { font-weight: 700; font-size: var(--fs-sm); color: var(--text-2); }
.field__help { color: var(--muted); font-size: var(--fs-xs); }
.field__error { color: var(--danger); font-size: var(--fs-sm); font-weight: 500; }
.field input, .field select, .field textarea, .input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
  appearance: none;
}
.field textarea { padding: 12px 16px; min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent);
}
.field input::placeholder, .input::placeholder { color: var(--faint); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.code-input { text-align: center; font-size: 1.75rem !important; font-weight: 800; letter-spacing: 0.55em; padding-inline-start: 0.55em !important; }

.input-group { position: relative; display: flex; align-items: center; }
.input-group > .icon { position: absolute; inset-inline-start: 14px; width: 22px; height: 22px; color: var(--faint); pointer-events: none; }
.input-group > .input { padding-inline-start: 46px; }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch__track { width: 46px; height: 28px; border-radius: var(--r-full); background: var(--border-strong); transition: background var(--t) var(--ease); position: relative; flex: none; }
.switch__track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-xs); transition: transform var(--t) var(--ease); }
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(-18px); }
[dir="ltr"] .switch input:checked + .switch__track::after { transform: translateX(18px); }

/* Checkbox row */
.check { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--brand); flex: none; }

/* ---------- Search bar ---------- */
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 18px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--r-full);
  color: var(--muted);
  transition: border-color var(--t), background var(--t);
}
.search > .icon { order: 2; }
.search:focus-within { border-color: var(--brand-200); background: var(--surface); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; color: var(--text); }
.search .icon { width: 22px; height: 22px; flex: none; }
.search--elevated { background: var(--surface); border-color: var(--border); }
.search__btn { display: grid; place-items: center; flex: none; width: 36px; height: 36px; margin-inline-end: -6px; border: 0; border-radius: 10px; background: var(--brand-100); color: var(--brand); cursor: pointer; }
.search__btn .icon { width: 20px; height: 20px; }

/* ---------- Chips, badges ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.chip .icon { width: 18px; height: 18px; }
.chip.is-selected, .chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-50); color: var(--brand); }
.chip--soft { border-color: transparent; background: var(--brand-100); color: var(--brand); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--r-full);
  background: #eef0f4;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: middle;
}
.badge--lg { padding: 4px 14px; font-size: var(--fs-sm); }
.badge--brand { background: var(--brand-100); color: var(--brand); }
.badge--accent { background: var(--accent); color: #fff; }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.role-chip { padding: 4px 12px; border-radius: var(--r-full); background: var(--brand-100); color: var(--brand); font-size: var(--fs-xs); font-weight: 800; white-space: nowrap; }

/* Radio/checkbox styled as chips and segments (work without JavaScript) */
.chip-radio, .chip-check, .seg-radio { position: relative; cursor: pointer; }
.chip-radio input, .chip-check input, .seg-radio input { position: absolute; opacity: 0; pointer-events: none; }
.chip-radio span, .chip-check span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px;
  border: 1.5px solid var(--border); border-radius: var(--r-full); background: var(--surface);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: 700; white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.chip-check span .icon { display: none; width: 16px; height: 16px; }
.chip-radio input:checked + span, .chip-check input:checked + span { border-color: var(--brand); background: var(--brand-50); color: var(--brand); }
.chip-check input:checked + span .icon { display: block; }
.chip-radio input:focus-visible + span, .chip-check input:focus-visible + span, .seg-radio input:focus-visible + span { outline: 2.5px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
.seg-radio { flex: 1; display: grid; }
.seg-radio span { display: grid; place-items: center; min-height: 38px; padding: 0 12px; border-radius: 9px; color: var(--muted); font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; }
.seg-radio input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.role-picks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.filter-chips { padding-bottom: 4px; }

/* Forms laid out in cards */
.user-form { display: flex; flex-direction: column; gap: 12px; }
.user-form .card .field:first-of-type { margin-top: 10px; }
.user-form .card .field:last-child { margin-bottom: 0; }
.card-heading { font-size: var(--fs-md); font-weight: 800; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 12px; }
.req { color: var(--danger); }
.small { font-size: var(--fs-sm); }
.results-count { margin: 16px 4px 8px; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }

/* ---------- Cards, lists, sections ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.card--pad { padding: 16px; }
.card--flat { box-shadow: none; }
.card--active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card__title { font-weight: 800; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 2px 12px; }
.section-head h2, .section-title { font-size: var(--fs-lg); font-weight: 800; }
.section-title { margin: 26px 2px 12px; }
.section-head a { display: inline-flex; align-items: center; gap: 2px; color: var(--brand); font-size: var(--fs-sm); font-weight: 700; }
.section-head a .icon { width: 16px; height: 16px; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.divider { height: 1px; background: var(--border); margin: 12px 0; border: 0; }

.list { overflow: hidden; }
.list form { margin: 0; }
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--divider);
  background: none;
  text-align: start;
  cursor: pointer;
  transition: background var(--t-fast);
}
.list > :last-child .list-item, .list > .list-item:last-child { border-bottom: 0; }
.list-item:active { background: var(--surface-2); }
.list-item__lead { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: var(--r-sm); background: var(--brand-50); color: var(--brand); }
.list-item__body { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.5; }
.list-item__title { font-weight: 700; font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item__sub { color: var(--muted); font-size: var(--fs-sm); line-height: 1.8; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Flat list: rows straight on the page, like a native app */
.list--flat { border: 0; border-radius: 0; background: none; margin-inline: -16px; }
.list--flat .list-item { padding-inline: 16px; }
.list-item__end { flex: none; display: flex; align-items: center; gap: 6px; color: var(--faint); }
.list-item__check { color: var(--brand); }
.list-item--danger { color: var(--danger); }
.list-item--danger .list-item__lead { background: var(--danger-soft); color: var(--danger); }

.avatar { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--brand-100); color: var(--brand); font-weight: 800; }
.avatar--lg { width: 64px; height: 64px; font-size: 1.5rem; }

/* ---------- KPI / stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 14px; background: var(--surface-2); border-radius: var(--r-lg); min-width: 0; }
.stats.home-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 18px; }
a.stat:active { transform: scale(0.98); }
.stat__label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.stat__label .icon { width: 18px; height: 18px; }
.stat__value { margin-top: 6px; font-size: var(--fs-xl); font-weight: 800; line-height: 1.3; }
.stat__value small { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.stat__delta { font-size: var(--fs-xs); font-weight: 700; }
.stat__delta--up { color: var(--success); }
.stat__delta--down { color: var(--danger); }

/* Tiny bar chart */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.bars span { flex: 1; border-radius: 6px 6px 3px 3px; background: var(--brand-200); min-height: 6px; }
.bars span.is-today { background: var(--brand); }
.bars-labels { display: flex; gap: 6px; margin-top: 6px; color: var(--faint); font-size: 0.7rem; text-align: center; }
.bars-labels span { flex: 1; }

/* Progress */
.progress { height: 8px; border-radius: var(--r-full); background: var(--brand-100); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }

/* ---------- Segmented control ---------- */
.segmented { display: flex; padding: 4px; gap: 4px; background: #eceef2; border-radius: var(--r-sm); overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented a, .segmented button { flex: 1; min-height: 38px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; display: grid; place-items: center; cursor: pointer; }
.segmented .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* ---------- Horizontal scroller ---------- */
.h-scroll {
  display: flex;
  gap: 12px;
  margin-inline: -16px;
  padding: 2px 16px 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 16px;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.h-scroll::-webkit-scrollbar { display: none; }
.h-scroll > * { scroll-snap-align: start; flex: none; }

/* Category circles */
.cat { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 74px; text-align: center; font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); line-height: 1.4; }
.cat__icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); color: var(--brand); box-shadow: var(--shadow-xs); }
.cat__icon .icon { width: 30px; height: 30px; }

/* Promo banner */
.banner {
  position: relative;
  width: 86%;
  max-width: 520px;
  min-height: 150px;
  padding: 20px;
  border-radius: var(--r-lg);
  color: #fff;
  overflow: hidden;
  background: linear-gradient(135deg, var(--brand) 0%, color-mix(in srgb, var(--brand) 60%, #3b82f6) 100%);
}
.banner--accent { background: linear-gradient(135deg, var(--accent) 0%, #f59e0b 100%); }
.banner--dark { background: linear-gradient(135deg, #1f2937 0%, #374151 100%); }
.banner h3 { font-size: var(--fs-xl); font-weight: 900; line-height: 1.4; max-width: 70%; }
.banner p { margin-top: 4px; opacity: 0.9; font-size: var(--fs-sm); max-width: 65%; }
.banner .btn { margin-top: 14px; background: #fff; color: var(--text); min-height: 38px; font-size: var(--fs-sm); }
.banner__art { position: absolute; inset-inline-end: -18px; bottom: -18px; width: 130px; height: 130px; opacity: 0.22; }

/* ---------- Product card ---------- */
.product {
  display: flex;
  flex-direction: column;
  width: 168px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.product__img { position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: var(--r-sm); background: var(--surface-2); color: var(--brand-400); }
.product__img .icon { width: 56px; height: 56px; stroke-width: 1.3; }
.product__img .badge { position: absolute; top: 8px; inset-inline-start: 8px; }
.product__brand { margin-top: 10px; color: var(--muted); font-size: var(--fs-xs); font-weight: 700; }
.product__name { margin-top: 2px; font-weight: 700; font-size: var(--fs-sm); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.product__code { color: var(--faint); font-size: var(--fs-xs); direction: ltr; text-align: end; }
.product__foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; margin-top: 8px; }
.product__add { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--brand); color: #fff; border: 0; flex: none; cursor: pointer; }
.product__add .icon { width: 20px; height: 20px; }
.product--wide { width: auto; flex-direction: row; gap: 12px; align-items: center; }
.product--wide .product__img { width: 84px; flex: none; }
.product--wide .product__name { min-height: 0; }
.product-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }

/* Price */
.price { display: flex; flex-direction: column; line-height: 1.35; }
.price__old { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: var(--fs-xs); }
.price__old s { text-decoration-thickness: 1px; }
.price__off { padding: 0 6px; border-radius: var(--r-full); background: var(--danger); color: #fff; font-size: 0.68rem; font-weight: 800; }
.price__now { font-weight: 800; font-size: var(--fs-md); }
.price__now small { font-size: 0.7rem; font-weight: 600; color: var(--muted); }

/* Quantity stepper */
.qty { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1.5px solid var(--border); border-radius: var(--r-sm); background: var(--surface); }
.qty button { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 9px; background: var(--brand-50); color: var(--brand); font-size: 1.2rem; font-weight: 800; cursor: pointer; }
.qty output { min-width: 32px; text-align: center; font-weight: 800; }

/* Vehicle picker pill */
.vehicle { width: 100%; margin-top: 12px; border: 0; cursor: pointer; text-align: start; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r-md); background: var(--brand-50); color: var(--brand); font-weight: 700; font-size: var(--fs-sm); }
.vehicle .icon { width: 22px; height: 22px; }
.vehicle__change { margin-inline-start: auto; color: var(--brand); font-weight: 800; }

/* ---------- Timeline (order tracking) ---------- */
.timeline { position: relative; display: flex; flex-direction: column; padding: 4px 0; }
.step { position: relative; display: flex; gap: 14px; padding-bottom: 22px; }
.step:last-child { padding-bottom: 0; }
.step::before { content: ""; position: absolute; top: 30px; bottom: 2px; inset-inline-start: 14px; width: 2px; background: var(--border); border-radius: 2px; }
.step:last-child::before { display: none; }
.step__dot { position: relative; z-index: 1; display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); color: var(--faint); }
.step__dot .icon { width: 16px; height: 16px; stroke-width: 2.4; }
.step__body { flex: 1; min-width: 0; padding-top: 3px; }
.step__title { font-weight: 700; line-height: 1.5; }
.step__meta { color: var(--muted); font-size: var(--fs-sm); }
.step--done .step__dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.step--done::before { background: var(--brand); }
.step--current .step__dot { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 5px var(--brand-100); }
.step--current .step__dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); animation: pulse 1.6s ease-in-out infinite; }
.step--current .step__title { color: var(--brand); }
.step--todo .step__title { color: var(--faint); font-weight: 600; }
@keyframes pulse { 50% { transform: scale(0.6); opacity: 0.6; } }

/* Tracking hero */
.track-hero { padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-xs); }
.track-hero__eta { font-size: var(--fs-2xl); font-weight: 900; color: var(--brand); line-height: 1.3; }
.track-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 14px; }
.track-bar span { height: 6px; border-radius: var(--r-full); background: var(--brand-100); }
.track-bar span.is-done { background: var(--brand); }
.track-bar span.is-current { background: linear-gradient(90deg, var(--brand-100), var(--brand), var(--brand-100)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }

/* ---------- Bottom sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgb(15 18 25 / 0.45); opacity: 0; pointer-events: none; transition: opacity var(--t) var(--ease); }
.sheet {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 61;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(105%);
  visibility: hidden;
  transition: transform 280ms var(--ease), visibility 0s linear 280ms;
  overscroll-behavior: contain;
}
.sheet::before { content: ""; display: block; width: 40px; height: 5px; margin: 0 auto 14px; border-radius: var(--r-full); background: var(--border-strong); }
.sheet.is-open { transform: translateY(0); visibility: visible; transition: transform 280ms var(--ease), visibility 0s; }
.sheet.is-open + .sheet-backdrop, .sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }
.sheet h2 { font-size: var(--fs-xl); font-weight: 800; }
body.has-sheet { overflow: hidden; }

/* Sheet header: close, title, action (like the reference design) */
.sheet__head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.sheet__head h2 { flex: 1; min-width: 0; }
.sheet__close { display: grid; place-items: center; width: 40px; height: 40px; margin-inline-start: -8px; border: 0; border-radius: 50%; background: none; color: var(--text); cursor: pointer; }
.sheet__close:active { background: var(--surface-2); }
.sheet__action { display: inline-flex; align-items: center; gap: 4px; color: var(--brand); font-weight: 700; white-space: nowrap; }
.sheet__action .icon { width: 20px; height: 20px; }

/* Main button stays visible at the bottom of a tall sheet */
.sheet__actions { position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); margin: 8px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--divider); }
.sheet .field { margin: 14px 0; }

/* Round radio, as in the reference */
.radio { appearance: none; flex: none; width: 24px; height: 24px; margin: 0; border: 2px solid var(--border-strong); border-radius: 50%; background: var(--surface); display: grid; place-items: center; cursor: pointer; transition: border-color var(--t-fast); }
.radio::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); transform: scale(0); transition: transform var(--t-fast) var(--ease); }
.radio:checked { border-color: var(--brand); }
.radio:checked::after { transform: scale(1); }
label.list-item { cursor: pointer; }

/* ---------- Floating action button ---------- */
.fab {
  position: fixed;
  inset-inline-start: 16px;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--r-full);
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow-brand);
  cursor: pointer;
}
.fab .icon { width: 24px; height: 24px; }
/* Leave room so the floating button never hides the last item of a list. */
.content:has(.fab) { padding-bottom: calc(var(--tabbar-h) + 104px + env(safe-area-inset-bottom)); }

/* Sticky action bar at the bottom of a page (above the tab bar) */
.action-bar {
  position: sticky;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px -16px 0;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

/* ---------- Skeleton loading ---------- */
.skeleton { border-radius: var(--r-xs); background: linear-gradient(90deg, #eceef2 25%, #f6f7f9 50%, #eceef2 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Toasts ---------- */
.toasts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--r-sm); background: var(--brand-100); color: var(--brand); font-weight: 700; animation: toast-in 260ms var(--ease); }
.toast--success { background: var(--success-soft); color: var(--success); }
.toast--error { background: var(--danger-soft); color: var(--danger); }
.toast--warning { background: var(--warning-soft); color: var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- Empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 16px; text-align: center; }
.empty h2 { margin-top: 4px; font-size: var(--fs-xl); font-weight: 800; }
.empty p { max-width: 360px; color: var(--muted); }
.empty__icon { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 26px; background: var(--brand-100); color: var(--brand); }

/* ---------- Auth pages ---------- */
body.auth {
  justify-content: center;
  align-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(90% 50% at 50% 0%, var(--brand-100) 0%, transparent 70%),
    var(--bg);
}
.auth__wrap { width: min(100%, 420px); }
.auth__brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 24px; font-size: 1.35rem; font-weight: 900; }
.auth__card { padding: 28px 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow); }
.auth__card h1 { margin-bottom: 4px; font-size: var(--fs-2xl); font-weight: 900; }
.auth__links { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; font-size: var(--fs-sm); }
.auth__links form { margin: 0; }
.auth__links a { color: var(--muted); font-weight: 600; }
.auth__links--center { justify-content: center; }

/* =====================================================================
   App shell
   ===================================================================== */
:root { --tabbar-h: 64px; --appbar-h: 58px; }

body.app { display: block; }

.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: calc(var(--appbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.8) blur(14px);
  -webkit-backdrop-filter: saturate(1.8) blur(14px);
  border-bottom: 1px solid var(--border);
}
.appbar__title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.appbar__title .brand-name { font-size: var(--fs-lg); }
.appbar__back { display: grid; place-items: center; width: 40px; height: 40px; margin-inline-start: -8px; border-radius: 50%; color: var(--text); transform: scaleX(-1); }
.appbar__back:active { background: var(--surface-2); }
.page-title { font-size: var(--fs-lg); font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar__actions { display: flex; align-items: center; gap: 4px; }
.icon-btn { position: relative; padding: 0; border: 0; background: none; cursor: pointer; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--text-2); }
.icon-btn:active { background: var(--surface-2); }
.icon-btn .dot { position: absolute; top: 8px; inset-inline-end: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }

.content {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom));
}

.tabbar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0 4px env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: saturate(1.8) blur(14px);
  -webkit-backdrop-filter: saturate(1.8) blur(14px);
  border-top: 1px solid var(--border);
  /* never move while the page scrolls or bounces */
  transform: translateZ(0);
}
.tab {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #8b919d;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}
.tab > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tab .icon { width: 24px; height: 24px; transition: transform var(--t) var(--ease); }
.tab:active .icon { transform: scale(0.88); }
.tab.is-active { color: var(--brand); }
.tab.is-active .icon { stroke-width: 2.2; }
.tab.is-active::before { content: ""; position: absolute; top: 0; width: 26px; height: 3px; border-radius: 0 0 4px 4px; background: var(--brand); }

.sidebar { display: none; }

/* Dashboard hero */
.hero-card { padding: 4px 2px 6px; }
.hero-card h1 { margin: 4px 0 2px; font-size: var(--fs-2xl); font-weight: 900; }
.hero-card__date { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); }
.hero-card__date .icon { width: 18px; height: 18px; }
.hero-card__sub { color: var(--muted); }
.hero-card__sub strong { color: var(--brand); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: transform var(--t-fast) var(--ease), border-color var(--t) var(--ease);
}
.tile:active { transform: scale(0.98); }
.tile__icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--brand-100); color: var(--brand); }
.tile__label { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 800; }
.tile__desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); font-size: var(--fs-xs); line-height: 1.7; }

/* Profile */
.profile-card { display: flex; align-items: center; gap: 16px; padding: 20px; }
.profile-card h2 { font-size: var(--fs-lg); font-weight: 800; }
.install-card { display: flex; gap: 14px; padding: 16px; }
.install-card__icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 14px; background: var(--brand-100); color: var(--brand); }
.install-card__title { margin-bottom: 4px; font-weight: 700; }
.install-card p { margin-bottom: 8px; }
.install-card .icon { display: inline; vertical-align: -3px; }

/* ---------- Catalogue ---------- */
.pthumb { display: grid; place-items: center; flex: none; width: 72px; height: 72px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--brand-400); overflow: hidden; }
.pthumb img { width: 100%; height: 100%; object-fit: cover; }
.pthumb .icon { width: 34px; height: 34px; stroke-width: 1.4; }
.pthumb--big { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: var(--r-lg); }
.pthumb--big img { object-fit: contain; background: #fff; }
.pthumb--big .icon { width: 96px; height: 96px; }

.plist { display: flex; flex-direction: column; margin-inline: -16px; }
.prow { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--divider); transition: background var(--t-fast); }
.prow:active { background: var(--surface-2); }
.prow__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.prow__name { font-weight: 700; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prow__meta { color: var(--muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.prow__price { font-weight: 800; }
.prow__price small { color: var(--muted); font-weight: 500; font-size: var(--fs-xs); }

.filter-row { display: flex; gap: 8px; }
.select-pill { flex: 1; min-width: 0; min-height: 42px; padding: 0 14px; border: 1.5px solid var(--border); border-radius: var(--r-full); background: var(--surface); font-size: 16px; color: var(--text-2); }
.tools-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.tools-row form { margin: 0; }

.badges-row { flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pd-title { margin-top: 10px; font-size: var(--fs-xl); font-weight: 800; line-height: 1.6; }
.pd-code { color: var(--muted); margin-top: 2px; }
.pd-code [data-copy] { cursor: copy; color: var(--text); font-weight: 600; }
.pd-section { padding: 18px 0; border-bottom: 8px solid var(--surface-2); margin-inline: -16px; padding-inline: 16px; }
.pd-section:last-child { border-bottom: 0; }
.pd-desc { color: var(--text-2); margin-top: 6px; }
.pd-qty { font-size: var(--fs-lg); white-space: nowrap; }
.price-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.price-grid > div { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: var(--r-sm); background: var(--surface-2); }
.price-grid strong { font-size: var(--fs-md); font-weight: 800; }
.price-grid > div:first-child { background: var(--brand-50); }
.price-grid > div:first-child strong { color: var(--brand); }
.move-sign { display: grid; place-items: center; flex: none; min-width: 52px; height: 36px; padding: 0 8px; border-radius: 10px; background: var(--surface-2); font-weight: 800; direction: ltr; }
.move-sign.is-in { background: var(--success-soft); color: var(--success); }
.move-sign.is-out { background: var(--danger-soft); color: var(--danger); }
.move-hint { margin: 8px 2px 0; }

.photo-pick { display: flex; align-items: center; gap: 14px; margin-top: 10px; padding: 12px; border: 1.5px dashed var(--border-strong); border-radius: var(--r-md); cursor: pointer; }
.photo-pick__text { display: flex; flex-direction: column; }
.vehicle-group__title { margin: 14px 2px 0; font-weight: 700; }
.vehicle-group[hidden] { display: none; }

/* Design gallery */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.swatch { border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--border); background: var(--surface); font-size: var(--fs-xs); }
.swatch i { display: block; height: 48px; }
.swatch span { display: block; padding: 6px 8px; font-weight: 700; }
.demo-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.design-note { padding: 12px 14px; border-radius: var(--r-sm); background: var(--warning-soft); color: var(--warning); font-size: var(--fs-sm); font-weight: 600; }

/* =====================================================================
   Desktop
   ===================================================================== */
@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .field-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .banner { width: 420px; }
}

@media (min-width: 1024px) {
  body.app { display: grid; grid-template-columns: 268px minmax(0, 1fr); }
  .tabbar { display: none; }
  .content { padding: 28px 32px 56px; }
  .appbar { padding: 0 32px; }
  .appbar .brand { visibility: hidden; }
  .fab { bottom: 32px; inset-inline-start: 32px; }
  .action-bar { bottom: 0; margin-inline: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .h-scroll { margin-inline: 0; padding-inline: 0; flex-wrap: wrap; overflow: visible; }
  .sheet { inset-inline: auto; left: 50%; bottom: 50%; width: 460px; border-radius: var(--r-xl); transform: translate(-50%, 60%) scale(0.96); opacity: 0; transition: transform 220ms var(--ease), opacity 220ms var(--ease); pointer-events: none; }
  .sheet.is-open { transform: translate(-50%, 50%) scale(1); opacity: 1; pointer-events: auto; visibility: visible; }
  .sheet::before { display: none; }

  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100dvh;
    padding: 20px 14px;
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
  }
  .sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-size: 1.15rem; font-weight: 900; }
  .sidebar__nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
  .sidebar__group { margin: 14px 12px 4px; color: var(--faint); font-size: var(--fs-xs); font-weight: 800; }
  .side-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm); color: var(--text-2); font-weight: 600; transition: background var(--t-fast); }
  .side-link:hover { background: var(--surface-2); }
  .side-link.is-active { background: var(--brand-100); color: var(--brand); font-weight: 800; }
  .soon-dot { margin-inline-start: auto; color: var(--faint); font-size: 0.7rem; font-weight: 600; }
  .sidebar__user { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--r-md); background: var(--surface-2); }
  .sidebar__user-text { display: flex; flex-direction: column; line-height: 1.4; min-width: 0; }
  .sidebar__user-text strong { font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar__user-text small { color: var(--muted); }

  .tiles { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
  .tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
  .hero-card { padding: 28px; }
  .product:hover { box-shadow: var(--shadow); }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .plist { margin-inline: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
  .pd-section { margin-inline: 0; padding-inline: 0; border-bottom-width: 1px; border-bottom-color: var(--divider); }
  .grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
}
