/* askIT Partner — design tokens + workbench components.
 *
 * Tokens are the customer app's (webapp/app.css), which are the website's — one brand,
 * three surfaces. What differs is the layout register: this is a WORKBENCH, so the
 * components lean denser (tables of rows, chips, KPI tiles) than the customer app's
 * conversational cards. Tokens are bare HSL triplets consumed as hsl(var(--x) / a).
 * Light and dark are both defined at token level; no component hard-codes a colour.
 */

:root {
  --background: 150 30% 98%;
  --foreground: 175 35% 12%;
  --card: 0 0% 100%;
  --primary: 168 76% 28%;
  --primary-foreground: 150 30% 98%;
  --primary-glow: 158 70% 55%;
  --secondary: 158 45% 92%;
  --muted: 150 25% 95%;
  --muted-foreground: 175 15% 40%;
  --accent: 14 90% 64%;
  --destructive: 0 72% 46%;
  --border: 158 25% 88%;
  --ring: 168 76% 38%;

  --brand-ink: 0 0% 5%;
  --brand-pop: 55 100% 55%;

  --gradient-primary: linear-gradient(135deg, hsl(168 76% 28%), hsl(158 70% 42%));

  --shadow-soft: 0 8px 30px -8px hsl(168 60% 25% / .12);
  --shadow-card: 0 16px 50px -18px hsl(168 60% 22% / .18);

  --ease: cubic-bezier(.22, 1, .36, 1);
  --r-pill: 9999px;
  --r-md: 1rem;
  --r-lg: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: 174 30% 7%;
    --foreground: 150 25% 93%;
    --card: 174 26% 11%;
    --primary: 158 60% 46%;
    --primary-foreground: 174 30% 7%;
    --primary-glow: 158 70% 55%;
    --secondary: 168 25% 17%;
    --muted: 172 22% 15%;
    --muted-foreground: 158 12% 70%;
    --accent: 14 85% 66%;
    --destructive: 0 70% 62%;
    --border: 170 20% 22%;
    --ring: 158 60% 50%;
    --gradient-primary: linear-gradient(135deg, hsl(168 55% 32%), hsl(158 60% 46%));
    --shadow-soft: 0 8px 30px -8px hsl(0 0% 0% / .45);
    --shadow-card: 0 16px 50px -18px hsl(0 0% 0% / .55);
  }
}

:root[data-theme="dark"] {
  --background: 174 30% 7%;
  --foreground: 150 25% 93%;
  --card: 174 26% 11%;
  --primary: 158 60% 46%;
  --primary-foreground: 174 30% 7%;
  --primary-glow: 158 70% 55%;
  --secondary: 168 25% 17%;
  --muted: 172 22% 15%;
  --muted-foreground: 158 12% 70%;
  --accent: 14 85% 66%;
  --destructive: 0 70% 62%;
  --border: 170 20% 22%;
  --ring: 158 60% 50%;
  --gradient-primary: linear-gradient(135deg, hsl(168 55% 32%), hsl(158 60% 46%));
  --shadow-soft: 0 8px 30px -8px hsl(0 0% 0% / .45);
  --shadow-card: 0 16px 50px -18px hsl(0 0% 0% / .55);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  min-height: 100dvh;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: 'Mulish', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.18; font-weight: 800; text-wrap: balance; }
h1 { font-size: 1.45rem; letter-spacing: -.015em; }
p  { margin: 0; }

:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; border-radius: var(--r-md); }
[hidden] { display: none !important; }

/* ── Shell ─────────────────────────────────────────────────────────────────── */
.app {
  max-width: 34rem;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.appbar {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem 1.1rem;
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
  position: sticky; top: 0; z-index: 10;
}
.appbar-logo { width: 2rem; height: 2rem; border-radius: .6rem; flex: none; }
/* One row, centred as a unit — the old markup stacked a title over a truncating
   shop name and nudged the pill with vertical-align, which never sat right. */
.appbar-brand { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.appbar-title { font-size: 1rem; font-weight: 900; letter-spacing: -.01em; line-height: 1; }
.appbar-partner {
  font-weight: 800; font-size: .66rem; text-transform: uppercase; letter-spacing: .07em;
  line-height: 1;
  color: hsl(var(--primary)); background: hsl(var(--secondary));
  border-radius: var(--r-pill); padding: .25rem .5rem .2rem;
  white-space: nowrap;
}
.appbar-back {
  border: 0; background: hsl(var(--secondary)); color: hsl(var(--primary));
  width: 2.1rem; height: 2.1rem; border-radius: var(--r-md); flex: none;
  font-size: 1.35rem; line-height: 1; font-weight: 800; cursor: pointer;
  display: grid; place-items: center; padding-bottom: .15rem;
}
.appbar-nav { margin-left: auto; display: flex; gap: .2rem; }
.appbar-nav a {
  display: inline-flex; align-items: center;
  padding: .35rem .55rem; border-radius: var(--r-pill);
  text-decoration: none; color: hsl(var(--muted-foreground));
  font-size: .72rem; font-weight: 800; white-space: nowrap;
}
.appbar-nav a.active { background: hsl(var(--secondary)); color: hsl(var(--primary)); }
/* Narrow phones: the brand shrinks to the mark + pill so the four section links
   keep their tap targets instead of wrapping into a second row. */
@media (max-width: 460px) {
  .appbar { gap: .5rem; padding: .7rem .8rem; }
  .appbar-title { font-size: .92rem; }
  .appbar-nav { gap: .1rem; }
  .appbar-nav a { padding: .32rem .4rem; font-size: .67rem; }
}
@media (max-width: 380px) {
  .appbar-title { display: none; }        /* the logo already says askit */
}

.screen { flex: 1; padding: 1.1rem 1.1rem 1.6rem; display: none; }
.screen.active { display: block; animation: rise .4s var(--ease) both; }
/* Sign-in and code entry fill the viewport and centre their content — a short form
   floating at the top of a tall dark page reads as a rendering mistake. */
.screen.centered.active {
  display: flex; flex-direction: column; justify-content: center;
  min-height: calc(100dvh - 2rem);
}
.screen.centered .card { width: 100%; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen.active { animation: none; } }

.lede { color: hsl(var(--muted-foreground)); font-size: .92rem; margin: .35rem 0 1rem; }
.empty { color: hsl(var(--muted-foreground)); text-align: center; padding: 2rem 1rem; font-size: .92rem; }
.backlink {
  display: inline-block; margin-bottom: .6rem;
  color: hsl(var(--primary)); text-decoration: none; font-weight: 700; font-size: .88rem;
}

/* ── Cards / fields / buttons ──────────────────────────────────────────────── */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--r-lg);
  padding: 1.15rem;
  box-shadow: var(--shadow-soft);
  margin-bottom: .9rem;
}
.card.slim { padding: .95rem 1rem; }
.card-title { font-size: .98rem; font-weight: 800; display: block; }
.card-help { font-size: .84rem; color: hsl(var(--muted-foreground)); margin: .25rem 0 .8rem; }

.field {
  width: 100%; min-height: 3rem;
  border: 1.5px solid hsl(var(--border));
  border-radius: var(--r-md);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font: inherit; padding: .55rem .9rem; margin: .35rem 0;
}
.field::placeholder { color: hsl(var(--muted-foreground) / .65); }
.field:focus { outline: none; border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / .18); }
.field-code { text-align: center; letter-spacing: .35em; font-size: 1.35rem; font-weight: 800; }
.field-area { min-height: 4.6rem; resize: vertical; line-height: 1.5; }
.lbl { display: block; font-size: .8rem; font-weight: 800; margin-top: .55rem; }

.stack { display: flex; flex-direction: column; gap: .55rem; margin-top: .8rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 3rem; padding: .55rem 1.2rem;
  border: 0; border-radius: var(--r-pill);
  font: inherit; font-weight: 800; font-size: .95rem;
  cursor: pointer; transition: transform .18s var(--ease), filter .18s var(--ease);
}
.btn:disabled { opacity: .55; cursor: progress; transform: none; }
.btn-primary { background: var(--gradient-primary); color: hsl(var(--primary-foreground)); box-shadow: var(--shadow-soft); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.05); }
.btn-solid { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-ghost { background: transparent; color: hsl(var(--foreground)); border: 1.5px solid hsl(var(--border)); }
.btn-ghost:hover:not(:disabled) { background: hsl(var(--secondary)); }
.btn.slim { min-height: 2.5rem; font-size: .86rem; }
.btn.danger { color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / .4); }
.btn.danger-solid { background: hsl(var(--destructive)); color: hsl(0 0% 100%); }

.note {
  border-radius: var(--r-md); padding: .6rem .9rem; margin: .5rem 0;
  font-size: .87rem; font-weight: 600;
}
.note-bad { background: hsl(var(--destructive) / .1); color: hsl(var(--destructive)); }
.note-good { background: hsl(var(--secondary)); color: hsl(var(--primary)); }

.spinner {
  width: 1.15rem; height: 1.15rem; border-radius: 50%;
  border: 2.5px solid hsl(var(--primary-foreground) / .35);
  border-top-color: hsl(var(--primary-foreground));
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Sign-in ───────────────────────────────────────────────────────────────── */
.signin-hero { text-align: center; padding: 1.2rem 0 1rem; }
.signin-hero .brand-logo { border-radius: 1.1rem; margin-bottom: .6rem; }

/* ── KPI tiles ─────────────────────────────────────────────────────────────── */
.kpis {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: .45rem;
  margin: .8rem 0 1rem;
}
.kpis.big { grid-template-columns: repeat(2, 1fr); gap: .7rem; }
.kpi {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: var(--r-md); padding: .5rem .3rem; text-align: center;
}
.kpis.big .kpi { padding: 1rem .6rem; }
.kpi b { display: block; font-size: 1.15rem; font-weight: 900; }
.kpis.big .kpi b { font-size: 1.7rem; }
.kpi.warn b { color: hsl(var(--accent)); }
.kpi span { font-size: .62rem; color: hsl(var(--muted-foreground)); text-transform: uppercase; letter-spacing: .05em; }
.kpis.big .kpi span { font-size: .74rem; }

/* ── Tabs + rows ───────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: .35rem; margin-bottom: .8rem; }
.tab {
  flex: 1; min-height: 2.5rem; border: 1.5px solid hsl(var(--border));
  border-radius: var(--r-pill); background: transparent; color: hsl(var(--foreground));
  font: inherit; font-weight: 800; font-size: .86rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
.tab.active { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.tab-count {
  background: hsl(var(--accent)); color: hsl(0 0% 100%);
  border-radius: var(--r-pill); font-size: .68rem; padding: 0 .45rem; min-width: 1.15rem;
}

.rows { display: flex; flex-direction: column; gap: .55rem; }
.row {
  display: flex; align-items: center; gap: .7rem;
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: var(--r-md); padding: .75rem .9rem;
  text-decoration: none; color: inherit;
}
.row:active { background: hsl(var(--muted)); }
.row-main { flex: 1; min-width: 0; }
.row-ref { font-weight: 800; font-size: .92rem; }
.row-sub { font-size: .78rem; color: hsl(var(--muted-foreground)); }
.row-side { text-align: right; flex: none; }

.chip {
  display: inline-block; border-radius: var(--r-pill);
  padding: .12rem .6rem; font-size: .72rem; font-weight: 800;
  background: hsl(var(--secondary)); color: hsl(var(--primary));
  white-space: nowrap;
}
.chip.warn { background: hsl(var(--accent) / .15); color: hsl(var(--accent)); }
.chip.bad  { background: hsl(var(--destructive) / .12); color: hsl(var(--destructive)); }
.chip.dim  { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.shopbadge {
  display: inline-block; font-size: .66rem; font-weight: 800;
  background: hsl(var(--muted)); color: hsl(var(--muted-foreground));
  border-radius: .4rem; padding: .05rem .4rem; margin-left: .35rem;
  vertical-align: 1px;
}
.countdown { font-weight: 800; font-size: .9rem; color: hsl(var(--accent)); margin: .3rem 0 .8rem; }

/* ── Order detail ──────────────────────────────────────────────────────────── */
.order-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.med-list { list-style: none; margin: .5rem 0 0; padding: 0; }
.med-list li {
  display: flex; justify-content: space-between; gap: .6rem;
  padding: .35rem 0; border-bottom: 1px dashed hsl(var(--border));
  font-size: .92rem;
}
.med-list li:last-child { border-bottom: 0; }
.kv { margin: 0; }
.kv > div { display: flex; gap: .8rem; padding: .3rem 0; }
.kv dt { flex: none; width: 8.5rem; font-size: .8rem; font-weight: 800; color: hsl(var(--muted-foreground)); }
.kv dd { margin: 0; font-size: .9rem; min-width: 0; }
.quote-note { font-size: .86rem; font-style: italic; color: hsl(var(--muted-foreground)); margin-top: .3rem; }

.rx-thumbs { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.rx-thumbs img {
  width: 5.2rem; height: 6.5rem; object-fit: cover;
  border-radius: var(--r-md); border: 1px solid hsl(var(--border));
  cursor: zoom-in; background: hsl(var(--muted));
}

/* Full-page viewer: native pinch/scroll zoom — the one thing WhatsApp's inline image
   viewer does badly for a dense prescription. */
.rxviewer {
  position: fixed; inset: 0; z-index: 60;
  background: hsl(0 0% 0% / .92);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.rxviewer-pages { padding: 3.4rem .6rem 1rem; display: flex; flex-direction: column; gap: .8rem; }
.rxviewer-pages img { width: 100%; border-radius: .4rem; touch-action: pinch-zoom; }
.rxviewer-x {
  position: fixed; top: .8rem; right: .8rem; z-index: 61;
  width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 0;
  background: hsl(0 0% 100% / .15); color: hsl(0 0% 100%);
  font-size: 1.1rem; cursor: pointer;
}

/* ── Quote grid ────────────────────────────────────────────────────────────── */
.qrows { display: flex; flex-direction: column; gap: .7rem; margin-bottom: .9rem; }
.qrow {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: var(--r-lg); padding: .85rem .95rem;
}
.qrow.off { opacity: .65; }
.qrow-head { display: flex; align-items: center; gap: .6rem; }
.qrow-name { font-weight: 800; font-size: .95rem; flex: 1; min-width: 0; }
.qrow-qty { font-size: .78rem; color: hsl(var(--muted-foreground)); flex: none; }
.qrow-grid { display: grid; grid-template-columns: 3.6rem 1fr 1fr; gap: .5rem; margin-top: .55rem; }
.qrow-grid .cell { min-width: 0; }
.cell small {
  display: block; font-size: .68rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .05em; color: hsl(var(--muted-foreground)); margin-bottom: .15rem;
}
.cell .field, .cell select.field { margin: 0; min-height: 2.7rem; padding: .35rem .7rem; }
.cell .prov { font-size: .66rem; color: hsl(var(--primary)); font-weight: 700; }
.qrow-sub { margin-top: .5rem; }
.qrow-sub .field { margin: 0; min-height: 2.7rem; font-size: .88rem; }

.avail { display: inline-flex; align-items: center; gap: .35rem; flex: none; }
.avail input { width: 1.25rem; height: 1.25rem; accent-color: hsl(var(--primary)); }
.avail span { font-size: .74rem; font-weight: 700; }

.eta-chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .5rem; }
.eta-chips button {
  border: 1.5px solid hsl(var(--border)); background: transparent; color: hsl(var(--foreground));
  border-radius: var(--r-pill); min-height: 2.4rem; padding: 0 .95rem;
  font: inherit; font-size: .85rem; font-weight: 800; cursor: pointer;
}
.eta-chips button.active { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.quote-total { font-weight: 900; font-size: 1.05rem; margin: .3rem 0; }

/* ── Sheet (reject) ────────────────────────────────────────────────────────── */
.sheet {
  position: fixed; inset: 0; z-index: 50;
  background: hsl(0 0% 0% / .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  background: hsl(var(--card)); width: 100%; max-width: 34rem;
  border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 1.2rem 1.1rem 1.6rem;
  box-shadow: var(--shadow-card);
}
.rej.picked { background: hsl(var(--secondary)); border-color: hsl(var(--primary)); }

/* ── Settings / price book ─────────────────────────────────────────────────── */
.switch-row { display: flex; align-items: center; gap: .8rem; cursor: pointer; }
.switch-row span { flex: 1; }
.switch-row small { display: block; color: hsl(var(--muted-foreground)); font-size: .78rem; }
.switch { width: 2.9rem; height: 1.65rem; accent-color: hsl(var(--primary)); flex: none; }

.shop-switch { display: flex; gap: .4rem; margin-bottom: .8rem; flex-wrap: wrap; }
.shop-switch button {
  border: 1.5px solid hsl(var(--border)); background: transparent; color: hsl(var(--foreground));
  border-radius: var(--r-pill); min-height: 2.3rem; padding: 0 .9rem;
  font: inherit; font-size: .8rem; font-weight: 800; cursor: pointer;
}
.shop-switch button.active { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }

.pb-add { display: grid; grid-template-columns: 1fr 4.6rem 4.2rem auto; gap: .4rem; align-items: center; }
.pb-add .field { margin: 0; min-height: 2.6rem; padding: .3rem .6rem; font-size: .88rem; }
.pb-row { display: flex; align-items: center; gap: .55rem; background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--r-md); padding: .55rem .8rem; }
.pb-row-name { flex: 1; min-width: 0; font-size: .88rem; font-weight: 700; }
.pb-row-name small { display: block; font-weight: 600; font-size: .68rem; color: hsl(var(--muted-foreground)); }
.pb-row .field { margin: 0; min-height: 2.4rem; width: 4.6rem; padding: .25rem .5rem; font-size: .86rem; }
.pb-row .field.pb-d { width: 4rem; }
.pb-row .warn { color: hsl(var(--accent)); font-size: .68rem; font-weight: 700; }

@media (max-width: 380px) {
  .kpis { grid-template-columns: repeat(5, 1fr); gap: .3rem; }
  .kpi b { font-size: 1rem; }
  .pb-add { grid-template-columns: 1fr 4rem 3.6rem auto; }
  .qrow-grid { grid-template-columns: 3.2rem 1fr 1fr; gap: .4rem; }
}

/* ── Delivery-time custom entry ────────────────────────────────────────────── */
.eta-custom {
  display: flex; align-items: center; gap: .45rem; margin-top: .6rem;
  padding-top: .6rem; border-top: 1px dashed hsl(var(--border));
}
.eta-custom-lbl { font-size: .78rem; font-weight: 800; color: hsl(var(--muted-foreground)); flex: 1; }
.eta-num { margin: 0; min-height: 2.5rem; width: 5.2rem; padding: .3rem .6rem; text-align: center; }

/* ── Delivery-location map preview (winner only) ───────────────────────────── */
.map-wrap { margin-top: .7rem; }
.map-wrap iframe {
  width: 100%; height: 100%; border: 0;
  display: block; background: hsl(var(--muted));
}
.map-open { margin-top: .5rem; width: 100%; text-decoration: none; }
.map-fallback {
  display: grid; place-items: center; text-align: center;
  height: 100%; padding: 1rem; margin: 0;
  color: hsl(var(--muted-foreground)); font-size: .84rem;
}
#order-map {
  height: 11rem; border-radius: var(--r-md); overflow: hidden;
  border: 1px solid hsl(var(--border)); background: hsl(var(--muted));
}

/* ── Confirmation dialog (centred, unlike the bottom reject sheet) ─────────── */
.sheet.confirm { align-items: center; padding: 1.2rem; }
.sheet.confirm .sheet-card { border-radius: var(--r-lg); max-width: 24rem; }
