/* ============================================================
   Plantstism · Sales — design tokens
   Taken from the mascot: sky blue, hot-pink lettering, lime cactus,
   sunny yellow, all held together by thick black ink outlines.
   Light is a bright summer sky; dark is the same sky at night.
   ============================================================ */
:root {
  color-scheme: light;
  --bg: #e6f5ff;
  --bg-glow: rgba(255, 31, 143, 0.12);
  --surface: #ffffff;
  --surface-2: #f1f9ff;
  --surface-3: #ddf0fc;
  --border: #c9e1f0;
  --border-strong: #9cc4dc;
  --text: #121622;
  --text-2: #3d4a5e;
  --text-3: #6b7a90;
  --accent: #ff1f8f;
  --accent-hover: #e80f7d;
  --accent-soft: #ffe0f0;
  --accent-ink: #ffffff;
  --accent-text: #c8006c;
  --good: #137a3d;
  --good-soft: #e1f8cf;
  --owed: #d61f3a;
  --owed-soft: #ffe1e5;
  --series-1: #ff1f8f;
  --series-2: #1aa3e8;
  --shadow-sm: 0 1px 2px rgba(10, 30, 60, 0.08);
  --shadow: 0 1px 2px rgba(10, 30, 60, 0.06), 0 8px 28px -10px rgba(10, 30, 60, 0.18);
  --shadow-lg: 0 24px 60px -16px rgba(10, 30, 60, 0.4);
  /* Sticker look from the mascot: inked outlines and hard offset shadows. */
  --ink: #121622;
  --edge: #121622;
  --pop: 4px 4px 0 var(--ink);
  --pop-sm: 3px 3px 0 var(--ink);
  --sky: #29b6f6;
  --sky-soft: #d6f0ff;
  --lime: #9be03b;
  --lime-soft: #e8f9d2;
  --sun: #ffe74a;
  --sun-soft: #fff7c2;
  --hero-sky: linear-gradient(160deg, #5fd0ff 0%, #2bb3f3 55%, #1a96e0 100%);
  --hero-text: #0d1220;
  --dots: rgba(18, 22, 34, 0.09);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1120;
  --bg-glow: rgba(255, 63, 164, 0.18);
  --surface: #111a2c;
  --surface-2: #17233a;
  --surface-3: #1f2e4a;
  --border: #24344f;
  --border-strong: #3a5072;
  --text: #f2f7ff;
  --text-2: #bccadf;
  --text-3: #8293ad;
  --accent: #ff3fa4;
  --accent-hover: #ff64b6;
  --accent-soft: #3d1431;
  --accent-ink: #1a0712;
  --accent-text: #ff7cc0;
  --good: #a5ec55;
  --good-soft: #1f3416;
  --owed: #ff7a85;
  --owed-soft: #3d1a22;
  --series-1: #ff3fa4;
  --series-2: #4cc7ff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -12px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, 0.85);
  --ink: #000000;
  --edge: #34496b;
  --pop: 4px 4px 0 var(--ink);
  --pop-sm: 3px 3px 0 var(--ink);
  --sky: #4cc7ff;
  --sky-soft: #10304a;
  --lime: #a5ec55;
  --lime-soft: #1f3416;
  --sun: #ffe74a;
  --sun-soft: #3a3412;
  --hero-sky: linear-gradient(160deg, #123d6b 0%, #0e2a4f 55%, #0a1a33 100%);
  --hero-text: #f2f7ff;
  --dots: rgba(255, 255, 255, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a1120;
    --bg-glow: rgba(255, 63, 164, 0.18);
    --surface: #111a2c;
    --surface-2: #17233a;
    --surface-3: #1f2e4a;
    --border: #24344f;
    --border-strong: #3a5072;
    --text: #f2f7ff;
    --text-2: #bccadf;
    --text-3: #8293ad;
    --accent: #ff3fa4;
    --accent-hover: #ff64b6;
    --accent-soft: #3d1431;
    --accent-ink: #1a0712;
    --accent-text: #ff7cc0;
    --good: #a5ec55;
    --good-soft: #1f3416;
    --owed: #ff7a85;
    --owed-soft: #3d1a22;
    --series-1: #ff3fa4;
    --series-2: #4cc7ff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -12px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, 0.85);
    --ink: #000000;
    --edge: #34496b;
    --pop: 4px 4px 0 var(--ink);
    --pop-sm: 3px 3px 0 var(--ink);
    --sky: #4cc7ff;
    --sky-soft: #10304a;
    --lime: #a5ec55;
    --lime-soft: #1f3416;
    --sun: #ffe74a;
    --sun-soft: #3a3412;
    --hero-sky: linear-gradient(160deg, #123d6b 0%, #0e2a4f 55%, #0a1a33 100%);
    --hero-text: #f2f7ff;
    --dots: rgba(255, 255, 255, 0.05);
  }
}

/* ============================================================
   Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

textarea { height: auto; padding: 12px 14px; line-height: 1.55; resize: vertical; }
textarea::placeholder { color: var(--text-3); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Components set their own display; the hidden attribute must still win. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 0;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.glow {
  position: fixed;
  inset: -20vh -10vw auto auto;
  width: 70vw;
  height: 70vh;
  background: radial-gradient(closest-side, var(--bg-glow), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.num, .stat-value, .sale-price, .summary-value, td.num { font-variant-numeric: tabular-nums; }

h1, h2, h3, p { margin: 0; }

code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 6px;
}

.i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 28px 6px;
}

/* Installed on a phone's home screen the page runs full-screen, under the clock and the notch,
   so the top bar and the corners keep clear of them. */
@media (display-mode: standalone) {
  html .topbar { padding-top: max(18px, calc(env(safe-area-inset-top) + 6px)); padding-left: max(28px, env(safe-area-inset-left)); padding-right: max(28px, env(safe-area-inset-right)); }
  .page { padding-bottom: max(40px, calc(env(safe-area-inset-bottom) + 24px)); }
  .toasts { bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px)); }
}
@media (display-mode: standalone) and (max-width: 640px) {
  html .topbar { padding-top: max(14px, calc(env(safe-area-inset-top) + 4px)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}

.offline-page { display: flex; flex-direction: column; align-items: center; gap: 12px; min-height: 80vh; justify-content: center; text-align: center; }
.offline-mascot { width: min(220px, 50vw); height: auto; }
.offline-page .dash-sub { max-width: 420px; }


.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.tabs a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: var(--text-2);
  transition: background-color 0.15s ease, color 0.15s ease;
}
.tabs a:hover { background: var(--surface-2); color: var(--text); }
.tabs a .i { width: 16px; height: 16px; }
.tabs a[aria-current="page"] {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px -6px var(--accent);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  font-size: 12.5px;
  color: var(--text-2);
  max-width: 52vw;
}
.status-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}
.status.ok .status-dot { background: var(--good); }
.status.ok .status-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--good);
  opacity: 0;
  animation: ping 2.4s ease-out infinite;
}
.status.err { border-color: var(--owed); color: var(--owed); background: var(--owed-soft); }
.status.err .status-dot { background: var(--owed); }
@keyframes ping { 0% { transform: scale(0.6); opacity: 0.7; } 80%, 100% { transform: scale(1.5); opacity: 0; } }

/* ============================================================
   Buttons & inputs
   ============================================================ */
button { font: inherit; color: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-block { width: 100%; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 20px -8px var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 10px 26px -8px var(--accent); }

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }

.btn-danger { background: var(--owed); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

#themeToggle .i-sun { display: none; }
:root[data-theme="dark"] #themeToggle .i-sun { display: block; }
:root[data-theme="dark"] #themeToggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #themeToggle .i-sun { display: block; }
  :root:not([data-theme="light"]) #themeToggle .i-moon { display: none; }
}

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

label, .label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.01em;
}
.optional { font-weight: 400; color: var(--text-3); margin-left: 4px; }

input[type="text"], input[type="number"], input[type="date"], input[type="password"], input[type="datetime-local"], textarea {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  -moz-appearance: textfield;
}
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input::placeholder { color: var(--text-3); }
input:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
input[aria-invalid="true"] { border-color: var(--owed); }
input[type="date"]::-webkit-calendar-picker-indicator, input[type="datetime-local"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.6; }
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator, :root[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator { filter: invert(1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) input[type="date"]::-webkit-calendar-picker-indicator, :root:not([data-theme="light"]) input[type="datetime-local"]::-webkit-calendar-picker-indicator { filter: invert(1); }
}

.input-affix { position: relative; }
.input-affix .affix {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-weight: 600;
  pointer-events: none;
}
.input-affix input { padding-left: 32px; font-variant-numeric: tabular-nums; }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.segmented label { position: relative; margin: 0; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: grid;
  place-items: center;
  height: 34px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.segmented label:hover span { color: var(--text); }
.segmented input:checked + span { background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.toggles { display: flex; gap: 22px; flex-wrap: wrap; }
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  transition: background-color 0.18s ease, border-color 0.18s ease;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s cubic-bezier(.3, 1.4, .5, 1);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.form-error {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--owed-soft);
  color: var(--owed);
  font-size: 13px;
  font-weight: 500;
}

/* ============================================================
   Layout
   ============================================================ */
.page {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 28px 40px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-top: 20px;
}
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.col-entry { position: sticky; top: 16px; }

.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 10px 0 20px;
}
.dash-title {
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-top: 4px;
}
.dash-sub { font-size: 14px; color: var(--text-3); margin-top: 4px; }
.stats.kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpis .stat { background: var(--surface); box-shadow: var(--shadow); padding: 18px 20px; }
.kpis .stat-sub { white-space: normal; line-height: 1.45; }
@media (max-width: 1280px) { .stats.kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .stats.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.dash-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.range {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.range button {
  height: 32px;
  min-width: 48px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.range button:hover { background: var(--surface-2); color: var(--text); }
.range button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }

.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; }
.delta .i { width: 12px; height: 12px; stroke-width: 2.6; }
.delta.up { color: var(--good); }
.delta.down { color: var(--owed); }
.delta.flat { color: var(--text-2); }

.takeaways-card { margin-top: 20px; }
.takeaways {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 10px;
}
.takeaways li:not(.empty) {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-2);
}
.takeaways b { color: var(--text); font-weight: 700; }
.takeaways .empty { grid-column: 1 / -1; }
.tk-ic {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent-text);
}
.tk-ic .i { width: 15px; height: 15px; }

.card-note { font-size: 12.5px; color: var(--text-3); margin: -8px 0 10px; }

/* Sortable data tables */
.data-table tbody tr { cursor: default; }
.data-table th { padding: 0; }
.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 9px 8px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  cursor: pointer;
}
th.num .sort-btn { justify-content: flex-end; }
.sort-btn:hover, .sort-btn.is-active { color: var(--text); }
.sort-arrow { font-size: 8px; width: 8px; }
.data-table td strong { font-weight: 650; }
.data-table td.owes { color: var(--owed); font-weight: 700; }
.data-table td.muted { color: var(--text-3); }
.share-cell { min-width: 120px; }
.share-bar {
  display: inline-block;
  vertical-align: middle;
  width: 64px;
  height: 6px;
  margin-right: 8px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}
.share-fill { display: block; height: 100%; border-radius: 3px; background: var(--series-1); }
.kpis .stat-accent { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); }
.kpis .stat-ic { background: var(--accent-soft); border-color: transparent; }

.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: stretch;
  margin-top: 20px;
}
.span-2 { grid-column: 1 / -1; }

@media (max-width: 820px) {
  .topbar { padding: 14px 16px 4px; flex-wrap: wrap; }
  
  .tabs { order: 3; width: 100%; }
  .tabs a { flex: 1; }
  .page { padding: 10px 16px 32px; }
  .grid, .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .dash-head .btn { width: 100%; }
  .col-entry { position: static; }
  .status-text { max-width: 34vw; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 22px;
  min-width: 0;
}
.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--text);
  margin-bottom: 16px;
}

.title-ic {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-text);
  flex-shrink: 0;
}
.title-ic .i { width: 16px; height: 16px; }

/* ============================================================
   Hero
   ============================================================ */
.hero {
  position: relative;
  display: grid;
  padding: 26px 30px;
  overflow: hidden;
  background:
    radial-gradient(120% 140% at 100% 0%, var(--accent-soft), transparent 55%),
    var(--surface);
}
.hero::before {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -120px;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--bg-glow), transparent);
  pointer-events: none;
}
.hero-copy { position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: center; gap: 6px; min-width: 0; }
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.hero-title {
  font-size: clamp(24px, 3.1vw, 36px);
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 18px;
  text-wrap: balance;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  transition: transform 0.18s ease, border-color 0.18s ease;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  min-width: 0;
}
.stat:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.stat-ic {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 8px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent-text);
}
.stat-ic .i { width: 16px; height: 16px; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.stat-value {
  font-size: clamp(20px, 2.1vw, 26px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-owed.has-owed { background: var(--owed-soft); border-color: transparent; }
.stat-owed.has-owed .stat-value { color: var(--owed); }
.stat-owed.has-owed .stat-ic { color: var(--owed); background: transparent; }
.stat-accent {
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-2) 70%);
  border-color: transparent;
}
.stat-accent .stat-value { color: var(--accent-text); }

@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .hero { padding: 22px 18px; }
  .hero-title { margin-bottom: 14px; }
  .stat { padding: 12px 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ============================================================
   Day view
   ============================================================ */
.day-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.day-head .card-title { margin-bottom: 2px; font-size: 18px; }
.day-sub { font-size: 13px; color: var(--text-3); }
.day-nav { display: flex; align-items: center; gap: 6px; }
.day-nav input[type="date"] { width: 152px; height: 36px; border-radius: 10px; font-size: 13.5px; padding: 0 10px; }

.day-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 14px;
}
.summary-cell { background: var(--surface-2); padding: 12px 14px; min-width: 0; }
.summary-label { display: block; font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.summary-value { display: block; font-size: 18px; font-weight: 700; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-value.accent { color: var(--accent-text); }
.summary-value.good { color: var(--good); display: flex; align-items: center; gap: 6px; }
.summary-value.good .i { width: 16px; height: 16px; flex: none; }
.summary-note { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.summary-note.owed { color: var(--owed); font-weight: 600; }
.payback-btn { margin-top: 6px; height: 30px; }
.payback-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.payback-pay-modal { width: min(380px, calc(100vw - 32px)); }
.payback-pay-qr { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.payback-pay-qr img { width: 100%; max-width: 260px; aspect-ratio: 1; border-radius: 10px; background: #fff; }
.payback-pay-amount { font-size: 26px; font-weight: 800; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-text); font-weight: 600; text-decoration: underline; cursor: pointer; }

.sales { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sale {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.2s ease;
  animation: rise 0.28s cubic-bezier(.2, .8, .2, 1) both;
}
.sale:hover { border-color: var(--border-strong); background: var(--surface-2); }
.sale.is-new { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.sale-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 800;
  font-size: 16px;
}
.sale-main { min-width: 0; }
.sale-name { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sale-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-size: 12.5px; color: var(--text-3); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.chip-var { background: var(--good-soft); color: var(--good); }
.chip-owed { background: var(--owed-soft); color: var(--owed); }
.chip-paid { background: var(--good-soft); color: var(--good); }

.sale-side { display: flex; align-items: center; gap: 10px; }
.sale-price { font-weight: 750; font-size: 16px; white-space: nowrap; }
.sale-actions { display: flex; gap: 4px; }
.sale-actions .icon-btn { width: 32px; height: 32px; border-radius: 9px; background: transparent; border-color: transparent; }
.sale-actions .icon-btn:hover { background: var(--surface-3); border-color: var(--border); }
.sale-actions .icon-btn.danger:hover { color: var(--owed); background: var(--owed-soft); }
.sale-actions .icon-btn.paid-on { color: var(--good); }
.sale-actions .icon-btn.paid-off { color: var(--owed); }
.sale-actions .i { width: 16px; height: 16px; }

@media (max-width: 520px) {
  .sale { grid-template-columns: 34px minmax(0, 1fr); }
  .sale-avatar { width: 34px; height: 34px; font-size: 14px; }
  .sale-side { grid-column: 2; justify-content: space-between; }
  .day-summary { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .day-summary .summary-cell:first-child { grid-column: 1 / -1; }
  .day-summary .payback-cell { grid-column: 1 / -1; }
  .day-nav { width: 100%; }
  .day-nav input[type="date"] { flex: 1; width: auto; }
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 12px;
  text-align: center;
  color: var(--text-3);
  font-size: 13.5px;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
}
.empty strong { color: var(--text-2); font-size: 14px; }
.empty-sm { padding: 16px 12px; }

/* History table */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; transition: background-color 0.12s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.is-current { background: var(--accent-soft); }
tbody tr.is-current td:first-child { color: var(--accent-text); font-weight: 700; }
tbody tr:last-child td { border-bottom: none; }
.more-btn { margin-top: 10px; }

/* Unpaid */
.owed-group { padding: 12px 0; border-bottom: 1px solid var(--border); }
.owed-group:first-child { padding-top: 0; }
.owed-group:last-child { border-bottom: none; padding-bottom: 0; }
.owed-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.owed-name { font-weight: 650; display: flex; align-items: center; gap: 8px; min-width: 0; }
.owed-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.owed-initial {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--owed-soft); color: var(--owed); font-size: 12px; font-weight: 800;
}
.owed-total { font-weight: 750; color: var(--owed); font-variant-numeric: tabular-nums; }
.owed-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0 3px 34px; font-size: 13px; color: var(--text-2); }
.owed-item-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.owed-item-text small { color: var(--text-3); margin-left: 4px; }
.pay-btn {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--good);
  background: transparent;
  color: var(--good);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}
.pay-btn:hover { background: var(--good-soft); }
.owed-head-side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.bill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent-text);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.bill-btn .i { width: 14px; height: 14px; }
.bill-btn:hover { background: var(--accent-soft); }

/* Bill dialog */
.bill-modal { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
.bill-fieldset { border: 0; margin: 0; padding: 0; }
.bill-fieldset legend { padding: 0; margin-bottom: 7px; }
.bill-items { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; max-height: 190px; overflow-y: auto; }
.bill-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.bill-item + .bill-item { border-top: 1px solid var(--border); }
.bill-item input { width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; }
.bill-item-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.bill-item-name small { color: var(--text-3); font-weight: 400; margin-left: 4px; }
.bill-item-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.bill-preview {
  display: grid;
  place-items: center;
  min-height: 160px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-2);
}
.bill-preview img { display: block; width: 100%; max-width: 300px; border-radius: 10px; box-shadow: var(--shadow); }
.bill-preview:not(:has(img[src])) img { display: none; }
.bill-preview.is-empty::before { content: attr(data-empty); color: var(--text-3); font-size: 13px; }
.bill-actions { flex-wrap: wrap; }

/* ============================================================
   Charts
   ============================================================ */
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.chart-head .card-title { margin-bottom: 0; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.key-line { width: 14px; height: 3px; border-radius: 2px; }
.key-1 { background: var(--series-1); }
.key-2 { background: var(--series-2); }

.chart { position: relative; min-height: 180px; }
.chart svg { display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart .axis { fill: var(--text-3); font-size: 11px; font-family: inherit; font-variant-numeric: tabular-nums; }
.chart .axis-strong { fill: var(--text-2); font-weight: 600; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit-band { fill: var(--text); opacity: 0; transition: opacity 0.12s ease; }
.chart .col-group:hover .hit-band, .chart .col-group:focus .hit-band { opacity: 0.05; }
.chart .col-group:focus { outline: none; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: 0.12; }
.chart .ring { fill: var(--surface); }
.chart .crosshair { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chart .end-label { fill: var(--text-2); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; }
.bar-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; }
.bar-rank { font-size: 11px; font-weight: 800; color: var(--text-3); width: 14px; }
.bar-value { font-size: 13px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.bar-track { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--series-1);
  transform-origin: left;
  animation: grow 0.6s cubic-bezier(.2, .8, .2, 1) both;
}
.bar-fill.alt { background: var(--series-2); }
.bar-row:hover .bar-fill { filter: brightness(1.12); }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Sales mix */
.mix + .mix { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.mix-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); margin-bottom: 10px; }
.mix-bar { display: flex; gap: 3px; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.mix-seg { flex-basis: 0; min-width: 4px; transform-origin: left; animation: grow 0.6s cubic-bezier(.2, .8, .2, 1) both; }
.mix-1 { background: var(--series-1); }
.mix-2 { background: var(--series-2); }
.mix-3 { background: var(--text-3); }
.mix-legend { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mix-legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto 40px; align-items: center; gap: 10px; font-size: 13px; }
.mix-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mix-count { color: var(--text-3); font-variant-numeric: tabular-nums; }
.mix-legend b { font-variant-numeric: tabular-nums; }
.mix-pct { text-align: right; color: var(--text-2); font-weight: 700; font-variant-numeric: tabular-nums; }

.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  min-width: 150px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
}
.tt-title { font-size: 11.5px; font-weight: 700; color: var(--text-3); margin-bottom: 6px; }
.tt-row { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.tt-row + .tt-row { margin-top: 3px; }
.tt-row b { margin-left: auto; padding-left: 14px; color: var(--text); font-variant-numeric: tabular-nums; }

/* ============================================================
   Dialogs & toasts
   ============================================================ */
.modal {
  width: min(480px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.modal-sm { width: min(380px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(10, 4, 10, 0.55); backdrop-filter: blur(3px); }
.modal[open] { animation: pop 0.22s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head .card-title { margin: 0; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.confirm-text { color: var(--text-2); font-size: 14px; margin-top: -8px; }

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: calc(100vw - 32px);
}
.toast {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 460px;
  padding: 11px 16px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s cubic-bezier(.2, .9, .3, 1.2) both;
}
.toast.err { background: var(--owed); color: #fff; }
.toast.leaving { animation: toast-out 0.25s ease forwards; }
.toast .i { width: 16px; height: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

.foot {
  margin-top: 28px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
}

/* ============================================================
   Photos
   ============================================================ */
.photo-field { position: relative; }
.photo-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.photo-drop {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.photo-drop .i { width: 22px; height: 22px; color: var(--accent-text); }
.photo-drop span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.photo-drop strong { font-size: 13.5px; font-weight: 650; color: var(--text); }
.photo-drop small { font-size: 12px; color: var(--text-3); }
.photo-drop:hover, .photo-field.is-drag .photo-drop { border-color: var(--accent); background: var(--accent-soft); }
.photo-input:focus-visible + .photo-drop { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-drop[hidden], .photo-preview[hidden] { display: none; }

.photo-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.photo-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 9px;
  background: var(--surface-3);
  flex-shrink: 0;
}
.photo-preview-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.photo-preview-actions .i { width: 14px; height: 14px; }

.sale-avatar.has-photo {
  padding: 0;
  border: 0;
  overflow: hidden;
  cursor: zoom-in;
  background: var(--surface-3);
}
.sale-avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.2s ease; }
.sale-avatar.has-photo:hover img { transform: scale(1.08); }

.lightbox {
  width: auto;
  max-width: min(900px, calc(100vw - 32px));
  padding: 10px;
  cursor: zoom-out;
}
.lightbox img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 120px);
  margin: 0 auto;
  border-radius: 14px;
}
.lightbox-caption { padding: 10px 6px 4px; text-align: center; font-size: 13.5px; font-weight: 600; color: var(--text-2); }

.name-cell { display: inline-flex; align-items: center; gap: 10px; }
.tbl-thumb {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* Four page tabs need to squeeze on phones. */
@media (max-width: 560px) {
  .tabs a { padding: 8px 6px; gap: 5px; font-size: 12.5px; }
  .tabs a .i { width: 14px; height: 14px; }
}
@media (max-width: 460px) {
  .tabs a .i { display: none; }
}

/* ============================================================
   Resale
   ============================================================ */
.select {
  height: 42px;
  min-width: 190px;
  padding: 0 36px 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a7a86' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  appearance: none;
  cursor: pointer;
}
.select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.resale-log { margin-top: 20px; }
.btn-soft { background: var(--accent-soft); color: var(--accent-text); }
.btn-soft:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); }
.data-table .btn-sm { height: 30px; font-size: 12.5px; }

.gain { color: var(--good); font-weight: 700; }
.loss { color: var(--owed); font-weight: 700; }
.flat { color: var(--text-2); font-weight: 700; }
.muted { color: var(--text-3); }
.stat-value.gain, .stat-value.loss { font-weight: 800; }

.key-gain { background: var(--good); }
.key-loss { background: var(--owed); }

/* Diverging bars */
.div-bars { display: flex; flex-direction: column; gap: 12px; }
.div-row {
  display: grid;
  grid-template-columns: minmax(90px, 150px) minmax(0, 1fr) 76px;
  align-items: center;
  gap: 12px;
  border-radius: 10px;
  outline: none;
}
.div-row:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.div-name { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; font-weight: 650; }
.div-name small { font-size: 11.5px; font-weight: 500; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.div-track { display: grid; grid-template-columns: 1fr 1fr; height: 14px; }
.div-bars.no-loss .div-track { grid-template-columns: 0 1fr; }
.div-half { position: relative; background: var(--surface-2); }
.div-neg { border-radius: 7px 0 0 7px; border-right: 2px solid var(--border-strong); }
.div-pos { border-radius: 0 7px 7px 0; }
.div-bars.no-loss .div-pos { border-radius: 7px; }
.div-bars.no-loss .div-neg { border: 0; }
.div-fill { position: absolute; top: 0; bottom: 0; animation: grow 0.6s cubic-bezier(.2, .8, .2, 1) both; }
.div-fill.gain { left: 0; background: var(--good); border-radius: 0 4px 4px 0; }
.div-fill.loss { right: 0; background: var(--owed); border-radius: 4px 0 0 4px; transform-origin: right; }
.div-row:hover .div-fill { filter: brightness(1.12); }
.div-value { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }

/* Scatter */
.chart .profit-zone { fill: var(--good); opacity: 0.06; }
.chart .break-even { stroke: var(--text-3); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .zone-label { fill: var(--text-3); font-size: 11px; font-weight: 600; }
.chart .dot { cursor: pointer; outline: none; }
.chart .dot:hover circle:last-child, .chart .dot:focus circle:last-child { r: 7; }

/* Resale dialog */
.resale-context {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.resale-context img, .resale-initial {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}
.resale-initial { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-weight: 800; }
.resale-context span { display: flex; flex-direction: column; min-width: 0; }
.resale-context small { font-size: 12.5px; color: var(--text-3); }
.resale-preview:empty { display: none; }
.resale-preview {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface-2);
}
.resale-preview.gain { background: var(--good-soft); }
.resale-preview.loss { background: var(--owed-soft); }
.resale-preview.gain b { color: var(--good); }
.resale-preview.loss b { color: var(--owed); }
.modal-actions .spacer { flex: 1; }
.danger-text { color: var(--owed); }
.danger-text:hover:not(:disabled) { background: var(--owed-soft) !important; color: var(--owed) !important; }

@media (max-width: 560px) {
  .div-row { grid-template-columns: minmax(70px, 100px) minmax(0, 1fr) 64px; gap: 8px; }
  .select { width: 100%; }
  .dash-actions { width: 100%; }
}

/* ============================================================
   News
   ============================================================ */
.news-refresh .i { transition: transform 0.2s ease; }
.news-refresh.is-spinning .i { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.news-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.news-topics { flex-wrap: wrap; }
.news-topics button { min-width: 0; padding: 0 14px; }
.news-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  min-width: 240px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--text-3);
}
.news-search:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.news-search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; outline: none; }

.news-banner {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--owed-soft);
  color: var(--owed);
  font-size: 13.5px;
  font-weight: 600;
}

.news-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.news-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 170px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.news-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.news-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.news-card.featured {
  grid-column: 1 / -1;
  min-height: 0;
  padding: 28px 30px;
  background:
    radial-gradient(120% 160% at 100% 0%, var(--accent-soft), transparent 60%),
    var(--surface);
}
.news-meta { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12.5px; color: var(--text-3); }
.news-source { font-weight: 700; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot-sep { color: var(--border-strong); }
.news-meta time { white-space: nowrap; }
.src-badge {
  --hue: 330;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 800;
  background: hsl(var(--hue) 70% 50% / 0.16);
  color: hsl(var(--hue) 55% 42%);
}
:root[data-theme="dark"] .src-badge { color: hsl(var(--hue) 80% 72%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .src-badge { color: hsl(var(--hue) 80% 72%); } }
.news-title {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.01em;
  text-wrap: pretty;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.news-card.featured .news-title { font-size: clamp(20px, 2.2vw, 27px); line-height: 1.25; letter-spacing: -0.02em; -webkit-line-clamp: 3; }
.news-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-3); }
.news-open { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--accent-text); opacity: 0; transition: opacity 0.15s ease; }
.news-open .i { width: 13px; height: 13px; }
.news-card:hover .news-open, .news-card:focus-visible .news-open { opacity: 1; }
@media (hover: none) { .news-open { opacity: 1; } }

.news-empty { padding: 48px 16px; }
.news-empty .btn { margin-top: 8px; }

.news-card.skeleton { pointer-events: none; }
.news-card.skeleton span { display: block; height: 14px; border-radius: 7px; background: var(--surface-2); animation: pulse 1.2s ease-in-out infinite; }
.news-card.skeleton span:nth-child(1) { width: 40%; }
.news-card.skeleton span:nth-child(2) { width: 95%; height: 20px; }
.news-card.skeleton span:nth-child(3) { width: 70%; height: 20px; }
@keyframes pulse { 50% { opacity: 0.45; } }

@media (max-width: 560px) {
  .news-search { min-width: 0; width: 100%; }
  .news-card.featured { padding: 22px 20px; }
}

/* ============================================================
   Shipping
   ============================================================ */
.stats.kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .stats.kpis.kpis-3 { grid-template-columns: minmax(0, 1fr); } }
.ship-card { margin-top: 20px; }

.addr-cell { display: flex; align-items: flex-start; gap: 8px; min-width: 200px; max-width: 320px; }
.addr-text { flex: 1; font-size: 13px; line-height: 1.45; white-space: normal; color: var(--text-2); }
.addr-phone { display: block; font-weight: 650; color: var(--text); }
.addr-copy { flex: none; width: 30px; height: 30px; border-radius: 9px; }
.addr-copy .i { width: 15px; height: 15px; }
.cust-note { display: block; margin-top: 2px; font-size: 12px; color: var(--text-3); white-space: normal; }
.ship-age { font-size: 12px; white-space: nowrap; }
.ship-pdf-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.ship-pdf-info { margin: 10px 0 0; font-size: 13px; color: var(--text-2); }
.ship-pdf-info .warn { color: var(--owed); }
@media (max-width: 640px) { #pdfMake { width: 100%; } }
#customerForm textarea { height: auto; min-height: 112px; }
#receiptPick { cursor: pointer; }
#receiptPick[aria-disabled="true"] { opacity: 0.6; pointer-events: none; }
.ship-track { display: block; text-decoration: none; margin-top: 4px; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.modal-wide { width: min(720px, calc(100vw - 32px)); }
.parcel-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.parcel-actions .range button { min-width: 48px; }
.parcel-who small { display: block; margin-top: 2px; font-size: 12px; color: var(--text-3); white-space: normal; }
.parcel-code { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; color: var(--accent-text); text-decoration: none; font-weight: 600; }
.parcel-code:hover { text-decoration: underline; }
.parcel-state small { display: block; margin-top: 3px; font-size: 12px; color: var(--text-3); white-space: normal; }
.chip-transit { background: var(--surface-3); color: var(--text-2); }

/* A parcel's trip: Posted - In transit - Out for delivery - Delivered, as dots on a line. */
.trip { display: block; width: 100%; min-width: 200px; max-width: 280px; padding: 6px 8px; margin: -6px -8px; border: 0; border-radius: 12px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.trip:hover { background: var(--surface-2); }
.trip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.steps { display: flex; align-items: center; }
.step { display: flex; flex: 1; align-items: center; }
.step:first-child { flex: 0 0 auto; }
.step::before { content: ""; flex: 1; height: 3px; margin: 0 3px; border-radius: 2px; background: var(--border-strong); }
.step:first-child::before { display: none; }
.step i { flex: none; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); }
.step.done i { border-color: var(--good); background: var(--good); }
.step.done::before, .step.now::before, .step.bad::before { background: var(--good); }
.step.now i { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); animation: step-pulse 1.8s ease-in-out infinite; }
.step.bad i { border-color: var(--owed); background: var(--owed); box-shadow: 0 0 0 4px var(--owed-soft); }
@keyframes step-pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
@media (prefers-reduced-motion: reduce) { .step.now i { animation: none; } }
.step-names { display: flex; justify-content: space-between; margin-top: 5px; font-size: 10.5px; color: var(--text-3); }
.step-names .is-here { color: var(--text); font-weight: 700; }
.trip-title { display: block; margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--text); }
.trip-title.bad { color: var(--owed); }
.trip small { display: block; margin-top: 2px; font-size: 12px; color: var(--text-3); white-space: normal; }

.trip-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: -6px 0 0; font-size: 13px; color: var(--text-2); }
.trip-big { padding: 16px 6px 0; }
.steps-big .step i { width: 18px; height: 18px; border-width: 3px; }
.steps-big .step::before { height: 4px; }
.step-names.steps-big { margin-top: 8px; font-size: 12px; }
.step-names.steps-big span { flex: 1; text-align: center; }
.step-names.steps-big span:first-child { text-align: left; }
.step-names.steps-big span:last-child { text-align: right; }
#tripNow { margin: 4px 0 0; font-size: 15px; }
.timeline { list-style: none; margin: 4px 0 0; padding: 0; max-height: min(45vh, 420px); overflow-y: auto; }
.tl-item { position: relative; display: flex; gap: 12px; padding: 0 0 16px; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--border-strong); }
.tl-dot { flex: none; width: 14px; height: 14px; margin-top: 2px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); }
.tl-item.is-latest .tl-dot { border-color: var(--accent); background: var(--accent); }
.tl-item.is-latest.tl-delivered .tl-dot { border-color: var(--good); background: var(--good); }
.tl-item.is-latest.tl-failed .tl-dot, .tl-item.is-latest.tl-returned .tl-dot { border-color: var(--owed); background: var(--owed); }
.tl-body { min-width: 0; font-size: 13.5px; line-height: 1.4; }
.tl-body small { display: block; color: var(--text-3); font-size: 12px; }
.trip-hint { margin: 0; font-size: 13px; }
.setup-list { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.6; color: var(--text-2); }
.setup-list a { color: var(--accent-text); }
#thaiPostForm textarea { height: auto; min-height: 80px; font-family: ui-monospace, monospace; font-size: 12.5px; word-break: break-all; }
@media (max-width: 640px) {
  .parcel-actions { width: 100%; }
  .parcel-actions .btn { flex: 1; }
  .ship-card #parcelTable tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who when" "code code" "state action"; }
  .ship-card #parcelTable td:nth-child(1) { grid-area: who; }
  .ship-card #parcelTable td:nth-child(2) { grid-area: code; }
  .ship-card #parcelTable td:nth-child(3) { grid-area: when; text-align: right; font-size: 12.5px; color: var(--text-3); }
  .ship-card #parcelTable td:nth-child(4) { grid-area: state; }
  .ship-card #parcelTable td:nth-child(5) { grid-area: action; text-align: right; }
}
.receipt-list { display: grid; gap: 8px; max-height: min(52vh, 520px); overflow-y: auto; }
.receipt-row { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 150px) minmax(0, 170px); gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.receipt-row.off { opacity: 0.55; }
.receipt-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.receipt-read { min-width: 0; font-size: 13px; line-height: 1.4; }
.receipt-read strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt-read small { display: block; color: var(--text-3); }
.receipt-read .warn { color: var(--owed); }
.receipt-row input[type="text"], .receipt-row .select { width: 100%; min-width: 0; height: 38px; font-size: 13px; }
.receipt-date { max-width: 220px; margin-top: 12px; }
@media (max-width: 640px) {
  .receipt-row { grid-template-columns: auto minmax(0, 1fr); }
  .receipt-row > :nth-child(n + 3) { grid-column: 2; }
  .receipt-date { max-width: none; }
}
#customerForm input[readonly] { color: var(--text-2); background: var(--surface-2); cursor: default; }

/* Five page tabs: let the bar scroll sideways on the narrowest phones rather than overflow. */
@media (max-width: 460px) {
  .tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { flex: none; padding: 8px 9px; }
}

/* Shipping on phones: each table row becomes a card, so buttons and addresses fit without sideways scrolling. */
@media (max-width: 640px) {
  .stats.kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .kpis-3 .stat { padding: 12px; }
  .kpis-3 .stat-ic { display: none; }
  .kpis-3 .stat-value { font-size: 20px; }
  .kpis-3 .stat-sub { font-size: 11px; }

  .ship-card .table-wrap { overflow: visible; margin: 0; }
  .ship-card thead { display: none; }
  .ship-card table, .ship-card tbody { display: block; }
  .ship-card tbody tr { display: grid; gap: 8px 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
  .ship-card tbody tr:hover { background: none; }
  .ship-card tbody tr:last-child { border-bottom: none; }
  .ship-card td { display: block; padding: 0; border: 0; white-space: normal; text-align: left; min-width: 0; }
  .ship-card .addr-cell { min-width: 0; max-width: none; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
  .ship-card .data-table .btn-sm { height: 38px; padding: 0 14px; font-size: 13px; }
  .ship-card .more-btn { width: 100%; }

  /* Orders: cactus + price / customer + date / address / status + button */
  .ship-card #orderTable tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name price" "who when" "addr addr" "status action"; }
  .ship-card #orderTable td:nth-child(1) { grid-area: name; }
  .ship-card #orderTable td:nth-child(2) { grid-area: who; }
  .ship-card #orderTable td:nth-child(3) { grid-area: when; text-align: right; font-size: 12.5px; color: var(--text-3); }
  .ship-card #orderTable td:nth-child(4) { grid-area: price; text-align: right; font-weight: 750; }
  .ship-card #orderTable td:nth-child(5) { grid-area: addr; }
  .ship-card #orderTable td:nth-child(6) { grid-area: status; }
  .ship-card #orderTable td:nth-child(7) { grid-area: action; text-align: right; }
  .ship-card #orderTable td:nth-child(2)::before { content: "To "; color: var(--text-3); font-size: 12.5px; }

  /* Customers: name + tier / address / counts / button */
  .ship-card #customerTable tr { grid-template-columns: auto auto minmax(0, 1fr) auto; grid-template-areas: "name name tier tier" "addr addr addr addr" "orders waiting last last" "action action action action"; }
  .ship-card #customerTable td:nth-child(1) { grid-area: name; }
  .ship-card #customerTable td:nth-child(2) { grid-area: addr; }
  .ship-card #customerTable td:nth-child(3) { grid-area: orders; }
  .ship-card #customerTable td:nth-child(4) { grid-area: tier; text-align: right; }
  .ship-card #customerTable td:nth-child(5) { grid-area: waiting; }
  .ship-card #customerTable td:nth-child(6) { grid-area: last; text-align: right; }
  .ship-card #customerTable td:nth-child(7) { grid-area: action; text-align: right; }
  .ship-card #customerTable td:nth-child(3), .ship-card #customerTable td:nth-child(n+5):nth-child(-n+6) { font-size: 12.5px; color: var(--text-2); }
  .ship-card #customerTable td:nth-child(3)::before { content: "Orders "; color: var(--text-3); }
  .ship-card #customerTable td:nth-child(5)::before { content: "To ship "; color: var(--text-3); }
  .ship-card #customerTable td:nth-child(6)::before { content: "Last "; color: var(--text-3); }
}

/* Dashboard and Resale tables on phones (and an iPad held upright, where a wide table would run off the
   side with no scroll bar showing): each row becomes a card - the first column as its title, the rest as
   small labelled values three to a line, and any action button on its own line.
   (Shipping has its own layout above.) */
@media (max-width: 640px), (max-width: 1024px) and (orientation: portrait) and (hover: none) {
  .card:not(.ship-card) .data-table thead { display: none; }
  .card:not(.ship-card) .data-table, .card:not(.ship-card) .data-table tbody { display: block; }
  .card:not(.ship-card) .table-wrap:has(> .data-table) { overflow: visible; margin: 0; }
  .card:not(.ship-card) .data-table tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
  }
  .card:not(.ship-card) .data-table tr:last-child { border-bottom: none; }
  .card:not(.ship-card) .data-table tr:hover { background: none; }
  .card:not(.ship-card) .data-table td { display: block; padding: 0; border: 0; text-align: left; white-space: normal; min-width: 0; }
  .card:not(.ship-card) .data-table td:first-child { grid-column: 1 / -1; font-size: 14.5px; }
  .card:not(.ship-card) .data-table td:not(:first-child)[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-3);
  }
  /* Unlabelled columns hold buttons: give them a full-width line. */
  .card:not(.ship-card) .data-table td[data-label=""]:not(:first-child) { grid-column: 1 / -1; }
  .card:not(.ship-card) .data-table td[data-label=""] .btn { width: 100%; height: 38px; }
  .card:not(.ship-card) .share-cell { min-width: 0; }
  .card:not(.ship-card) .share-bar { display: block; width: 100%; margin: 0 0 4px; }
  .card:not(.ship-card) .more-btn { width: 100%; }
}
@media (max-width: 640px), (max-width: 1024px) and (orientation: portrait) and (hover: none) {
  /* Empty "–" values just add height on a phone card. */
  .card:not(.ship-card) .data-table td.is-blank { display: none; }
}

/* ============================================================
   Chat (ask your data)
   ============================================================ */
.chat-model { display: inline-flex; align-items: center; gap: 8px; }
.chat-model select {
  height: 36px;
  max-width: 260px;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  cursor: pointer;
}
.chat-model select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.chat-model select:disabled { opacity: 0.6; cursor: default; }

.chat-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: min(62vh, 640px);
  min-height: 320px;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.chat-empty { margin: auto; text-align: center; color: var(--text-3); font-size: 13.5px; }
.chat-empty strong { display: block; margin-bottom: 12px; color: var(--text-2); font-size: 14px; }
.chat-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 560px; }
.chat-suggestions button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chat-suggestions button:hover { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }

.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-bubble {
  max-width: min(78%, 680px);
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.chat-msg.user .chat-bubble { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.chat-msg.assistant .chat-bubble { background: var(--surface-2); color: var(--text); border-bottom-left-radius: 6px; }
.chat-msg.error .chat-bubble { background: var(--owed-soft); color: var(--owed); font-weight: 600; }
.chat-bubble p + p, .chat-bubble p + ul, .chat-bubble p + ol, .chat-bubble ul + p, .chat-bubble ol + p { margin-top: 8px; }
.chat-bubble ul, .chat-bubble ol { padding-left: 20px; }
.chat-bubble code { padding: 1px 5px; border-radius: 6px; background: var(--surface-3); font-size: 0.9em; }
/* Photos under an answer, shown whole (not cropped) and big enough to see without opening them. */
.chat-refs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  flex-shrink: 0;
  gap: 10px;
  max-width: 760px;
  margin-top: -4px;
}
.chat-refs.is-single { grid-template-columns: minmax(0, 360px); }
.chat-ref {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: zoom-in;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.chat-ref:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-ref img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 9px; background: var(--surface-2); }
.chat-ref span, .chat-ref small { display: block; padding: 0 2px; overflow-wrap: anywhere; }
.chat-ref span { margin-top: 6px; font-size: 13px; font-weight: 600; }
.chat-ref small { display: block; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-ref span { margin-top: 6px; font-size: 12.5px; font-weight: 600; }
.chat-ref small { font-size: 11.5px; color: var(--text-3); }
/* All of an answer's photos combined into one picture to save or send. */
.chat-grid { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; flex-shrink: 0; max-width: 760px; margin-top: -4px; }
.chat-grid img { width: 100%; height: auto; border: 1px solid var(--border); border-radius: 12px; }
.chat-grid-actions { display: flex; gap: 8px; }
.chat-tool { align-self: flex-start; font-size: 12.5px; color: var(--text-3); font-style: italic; }

.chat-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.chat-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: chat-dot 1.2s infinite ease-in-out; }
.chat-typing i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .chat-typing i { animation: none; opacity: 0.6; } }

.chat-form { display: flex; align-items: flex-end; gap: 10px; padding: 14px; border-top: 1px solid var(--border); }
.chat-form textarea { height: 44px; min-height: 44px; padding: 11px 14px; resize: none; line-height: 1.4; }
.chat-form .btn { width: 44px; height: 44px; padding: 0; flex-shrink: 0; }
.chat-form .btn.stop { background: var(--owed); box-shadow: none; color: #fff; }

/* Saved chats and memory, beside the chat on wide screens and under it on narrow ones. */
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.chat-side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.chat-panel { padding: 18px; }
.chat-panel .card-title { margin-bottom: 10px; }
.chat-side-note { font-size: 12.5px; line-height: 1.5; color: var(--text-3); }
.chat-panel .chat-side-note + .chat-list:not(:empty) { margin-top: 10px; }
.chat-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; list-style: none; margin: 0; padding: 0; }
.chat-list li { display: flex; align-items: center; gap: 4px; min-width: 0; }
.chat-list .icon-btn { width: 30px; height: 30px; border-color: transparent; background: transparent; opacity: 0.6; }
.chat-list li:hover .icon-btn, .chat-list .icon-btn:focus-visible { opacity: 1; }
.chat-list .icon-btn .i { width: 15px; height: 15px; }
.chat-open {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.chat-open:hover { background: var(--surface-2); color: var(--text); }
.chat-open.is-active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.chat-open span, .chat-open small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-open small { color: var(--text-3); font-size: 11.5px; font-weight: 400; }
.chat-list .chat-rename { flex: 1; min-width: 0; height: 34px; padding: 0 10px; font-size: 13px; }
.chat-memory { flex: 1; min-width: 0; padding: 6px 10px; font-size: 13px; line-height: 1.45; color: var(--text-2); overflow-wrap: anywhere; }
.chat-memory-form { display: flex; gap: 8px; margin-top: 12px; }
.chat-memory-form input { flex: 1; min-width: 0; height: 36px; padding: 0 12px; font-size: 13px; }
@media (max-width: 960px) {
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .chat-list .icon-btn { opacity: 1; }
}

@media (max-width: 640px) {
  .chat-log { height: 58vh; padding: 14px; }
  .chat-bubble { max-width: 88%; }
  .chat-refs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat-refs.is-single { grid-template-columns: minmax(0, 1fr); }
  .chat-model select { max-width: 180px; }
}

.segmented.segmented-2 { grid-template-columns: repeat(2, 1fr); }
.switch:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }

/* ---------- Sets: several plants sold together for one price ---------- */
.field-hint { margin: 0; font-size: 12.5px; color: var(--text-3); }
.set-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: set-item; }
.set-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}
.set-item-head { display: flex; align-items: center; gap: 8px; }
.set-item-head input { flex: 1; min-width: 0; }
.set-item-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12.5px;
  font-weight: 800;
}
.set-item-remove { width: 32px; height: 32px; background: transparent; border-color: transparent; }
.set-item-remove:hover:not(:disabled) { color: var(--owed); background: var(--owed-soft); }
.set-item-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.set-item-opts .segmented { flex: 1 1 220px; background: var(--surface); }
.set-item-opts .segmented input:checked + span { background: var(--surface-2); }
.set-item-opts .toggles { gap: 16px; }
.set-item-photo {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px 0 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  overflow: hidden;
}
.set-item-photo:hover { border-color: var(--accent); background: var(--accent-soft); }
.set-item-photo .i { width: 16px; height: 16px; color: var(--accent-text); }
.set-item-photo img { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; }
.set-item-photo:has(img:not([hidden])) .i { display: none; }
.set-item-photo:has(.photo-input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.set-add { align-self: flex-start; }

/* A set in the day list: one card, its plants listed inside. */
.sale-set {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  animation: rise 0.28s cubic-bezier(.2, .8, .2, 1) both;
}
.sale-set-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 4px 4px; }
.sale-set-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.sale-set-title .i { width: 16px; height: 16px; color: var(--accent-text); }
.sale-set-total { font-weight: 800; font-size: 16px; white-space: nowrap; }
.sale-set .sales { gap: 6px; }
.sale-set .sale-price { font-weight: 600; font-size: 14px; color: var(--text-2); }
.sale-set-buyer { font-weight: 500; font-size: 12.5px; color: var(--text-3); }

/* ============================================================
   Sticker layer — the mascot's look across every page:
   inked outlines, hard offset shadows, halftone dots.
   ============================================================ */
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(var(--dots) 1.2px, transparent 1.6px),
    radial-gradient(60% 45% at 85% -5%, color-mix(in srgb, var(--sky) 28%, transparent), transparent 70%),
    radial-gradient(50% 40% at 0% 100%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%);
  background-size: 14px 14px, 100% 100%, 100% 100%;
  background-attachment: fixed;
}
.glow { display: none; }

/* Cards, tabs and status pill become stickers. */
.card,
.tabs,
.status,
.modal,
.toast {
  border: 2px solid var(--edge);
  box-shadow: var(--pop);
}
.card { border-radius: 18px; }
.tabs a { font-weight: 700; }
.tabs a[aria-current="page"] {
  background: var(--accent);
  color: #fff;
  box-shadow: inset 0 0 0 2px var(--ink);
  text-shadow: 1px 1px 0 var(--ink);
}
.tabs a:hover:not([aria-current="page"]) { background: var(--sky-soft); }

.card-title { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.title-ic {
  background: var(--sun);
  color: #121622;
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  transform: rotate(-4deg);
}

/* Buttons: press down into their shadow. */
.btn { border-width: 2px; font-weight: 700; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--ink);
  box-shadow: var(--pop-sm);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.35);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 5px 5px 0 var(--ink); transform: translate(-1px, -1px); }
.btn-primary:active:not(:disabled) { box-shadow: 1px 1px 0 var(--ink); transform: translate(2px, 2px); }
.btn-ghost { border-color: var(--edge); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--sky-soft); box-shadow: var(--pop-sm); transform: translate(-1px, -1px); }
.btn-danger { border-color: var(--ink); box-shadow: var(--pop-sm); }
.icon-btn { border-width: 2px; border-color: var(--edge); }
.icon-btn:hover:not(:disabled) { background: var(--sky-soft); border-color: var(--edge); }

/* Inputs get the same ink edge and a pink "pop" when focused. */
input[type="text"], input[type="number"], input[type="date"], input[type="password"], input[type="datetime-local"], textarea, .select {
  border-width: 2px;
}
input:focus, textarea:focus { border-color: var(--ink); box-shadow: 3px 3px 0 var(--accent); }
.segmented { border: 2px solid var(--edge); }
.segmented input:checked + span { background: var(--accent); color: #fff; box-shadow: inset 0 0 0 2px var(--ink); }
.set-item-opts .segmented input:checked + span { background: var(--accent); }
.switch input:checked + .track { background: var(--lime); border-color: var(--ink); }
.switch .track { border-width: 2px; }

/* Lists and rows. */
.sale, .set-item, .sale-set, .owed-group { border-width: 2px; }
.sale:hover { border-color: var(--edge); box-shadow: var(--pop-sm); transform: translate(-1px, -1px); }
.sale-avatar { background: var(--lime-soft); color: var(--text); border: 2px solid var(--edge); }
.sale-set { background: var(--sky-soft); border-color: var(--edge); }
.sale-set-title .i { color: var(--accent); }
.chip { border: 1.5px solid currentColor; }
.chip-var { background: var(--lime-soft); }
.day-summary { border: 2px solid var(--edge); }
.set-item-num { background: var(--sun); color: #121622; border: 2px solid var(--ink); }
.set-item-photo { border-width: 2px; }
th { color: var(--text-2); }

/* ---------- Sales hero: the mascot on a sunny comic sky ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 8px;
  overflow: hidden;
  background:
    radial-gradient(rgba(255, 255, 255, 0.16) 1.4px, transparent 1.8px) 0 0 / 12px 12px,
    radial-gradient(28% 22% at 12% 18%, rgba(255, 255, 255, 0.55), transparent 70%),
    radial-gradient(22% 18% at 46% 8%, rgba(255, 255, 255, 0.4), transparent 70%),
    radial-gradient(30% 26% at 70% 92%, rgba(255, 255, 255, 0.45), transparent 70%),
    var(--hero-sky);
}
:root[data-theme="dark"] .hero {
  background: radial-gradient(rgba(255, 255, 255, 0.07) 1.4px, transparent 1.8px) 0 0 / 12px 12px, var(--hero-sky);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero {
    background: radial-gradient(rgba(255, 255, 255, 0.07) 1.4px, transparent 1.8px) 0 0 / 12px 12px, var(--hero-sky);
  }
}
.hero::before { display: none; }
.hero .eyebrow {
  align-self: flex-start;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  transform: rotate(-2deg);
}
.hero-title {
  color: var(--hero-text);
  font-weight: 900;
  font-size: clamp(26px, 3.4vw, 42px);
  letter-spacing: -0.03em;
}
.hero .stat {
  background: var(--surface);
  border: 2px solid var(--ink);
  box-shadow: var(--pop-sm);
}
.hero .stat:hover { transform: translate(-2px, -2px) rotate(-0.6deg); box-shadow: 5px 5px 0 var(--ink); }
.hero .stat-ic { border: 2px solid var(--ink); color: #121622; }
.hero .stat:nth-child(1) .stat-ic { background: var(--sky); }
.hero .stat:nth-child(2) .stat-ic { background: var(--lime); }
.hero .stat:nth-child(3) .stat-ic { background: var(--sun); }
.hero .stat-owed .stat-ic,
.hero .stat-owed.has-owed .stat-ic { background: var(--accent); color: #fff; }
.hero .stat-owed.has-owed { background: var(--surface); }

.hero-art {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: end center;
  margin: -18px -22px -30px 0;
  perspective: 900px;
}
.mascot {
  width: 100%;
  max-width: 250px;
  height: auto;
  filter: drop-shadow(5px 6px 0 rgba(0, 0, 0, 0.85));
  transform-origin: 50% 95%;
  animation: strut 3.2s ease-in-out infinite;
  transition: transform 0.3s ease-out;
}
@keyframes strut {
  0%, 100% { translate: 0 4px; rotate: -2deg; }
  50% { translate: 0 -6px; rotate: 2deg; }
}

@media (max-width: 1080px) {
  .hero { grid-template-columns: minmax(0, 1fr) 200px; }
}
@media (max-width: 640px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  /* On phones the mascot peeks in beside the greeting, clear of the stat cards. */
  .hero-art {
    position: absolute; right: -4px; top: 6px; width: 112px; height: 132px; margin: 0;
    place-items: start center; overflow: hidden;
  }
  .mascot { max-width: none; width: 112px; animation: none; }
  .hero-title { padding-right: 104px; min-height: 2.3em; }
}

/* ---------- Dashboard, Shipping and Resale stat cards and filters ---------- */
.kpis .stat { border: 2px solid var(--edge); box-shadow: var(--pop-sm); }
.kpis .stat:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); border-color: var(--edge); }
.kpis .stat-ic { border: 2px solid var(--ink); color: #121622; background: var(--sky); }
.kpis .stat:nth-child(3n + 2) .stat-ic { background: var(--lime); }
.kpis .stat:nth-child(3n + 3) .stat-ic { background: var(--sun); }
.kpis .stat.stat-accent .stat-ic, .kpis .stat.stat-owed .stat-ic { background: var(--accent); color: #fff; }
.range { border: 2px solid var(--edge); box-shadow: var(--pop-sm); }
.range button { font-weight: 700; }
.range button[aria-pressed="true"] { background: var(--accent); color: #fff; box-shadow: inset 0 0 0 2px var(--ink); }

/* ---------- Mascot everywhere ---------- */

/* Sales banner: the full sky picture as a tilted sticker card. */
.hero-art { margin: 0; place-items: center; }
.mascot {
  max-width: 230px;
  aspect-ratio: 1;
  border-radius: 24px;
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  filter: none;
  transform-origin: 50% 50%;
  animation: sway 4s ease-in-out infinite;
}
@keyframes sway {
  0%, 100% { rotate: 3deg; translate: 0 2px; }
  50% { rotate: -1deg; translate: 0 -4px; }
}

/* Other pages: the cut-out mascot struts beside the page title. */
.head-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.head-mascot {
  width: 78px;
  height: auto;
  flex-shrink: 0;
  margin: -10px 0 -14px -6px;
  filter: drop-shadow(3px 4px 0 rgba(0, 0, 0, 0.85));
  transform-origin: 50% 95%;
  animation: strut 3.2s ease-in-out infinite;
}

@media (max-width: 640px) {
  
  .hero-art { width: 96px; height: 96px; top: 14px; right: 14px; overflow: visible; }
  .mascot { width: 92px; border-radius: 16px; border-width: 2.5px; box-shadow: 4px 4px 0 var(--ink); animation: none; rotate: 4deg; }
  .hero-title { padding-right: 104px; }
  .head-mascot { width: 58px; }
}

.mascot {
  max-width: 240px;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  filter: drop-shadow(5px 6px 0 rgba(0, 0, 0, 0.85));
  transform-origin: 50% 95%;
  animation: strut 3.2s ease-in-out infinite;
}
.hero-art { margin: -14px -14px -24px 0; place-items: end center; }

@media (max-width: 640px) {
  
  .hero-art { width: 104px; height: auto; top: 10px; right: 8px; margin: 0; }
  .mascot { width: 100px; border: 0; box-shadow: none; rotate: 0deg; animation: none; }
}

/* ---------- Chat: Mr. Plants answers ---------- */
.chat-msg.assistant { align-items: flex-start; gap: 10px; }
.chat-avatar {
  width: 44px;
  height: auto;
  flex-shrink: 0;
  margin-top: 2px;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.8));
}
.chat-from { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: min(82%, 700px); }
.chat-name { font-size: 12px; font-weight: 800; color: var(--accent-text); letter-spacing: 0.01em; }
.chat-from .chat-bubble { max-width: 100%; border: 2px solid var(--edge); box-shadow: var(--pop-sm); }
.chat-msg.user .chat-bubble { border: 2px solid var(--ink); box-shadow: var(--pop-sm); color: #fff; }
/* Photos and tool notes line up under the bubble, past the avatar. */
.chat-msg.assistant + .chat-refs, .chat-msg.assistant ~ .chat-grid { margin-left: 54px; }
.chat-from .chat-tool { margin: 0; }
/* How the answer did in the check it gets before it's shown. */
.chat-check { font-size: 11.5px; color: var(--text-3); }
.chat-check.is-warn { color: var(--owed); font-weight: 600; }

.chat-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.chat-empty-mascot {
  width: 120px;
  height: auto;
  filter: drop-shadow(4px 5px 0 rgba(0, 0, 0, 0.85));
  transform-origin: 50% 95%;
  animation: strut 3.2s ease-in-out infinite;
}
.chat-hello { max-width: 420px; color: var(--text-2); font-size: 14px; }
.chat-hello strong { display: block; margin-bottom: 2px; color: var(--text); font-size: 20px; font-weight: 900; letter-spacing: -0.02em; }
.chat-try { margin-top: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }

@media (max-width: 640px) {
  .chat-avatar { width: 34px; }
  .chat-msg.assistant + .chat-refs, .chat-msg.assistant ~ .chat-grid { margin-left: 0; }
}

/* ---------- Chat: the LangGraph graph, lit up live ---------- */
.graph-panel #graphView { margin-top: 10px; }
.graph-svg { display: block; width: 100%; height: auto; overflow: visible; }
.g-node rect { fill: var(--surface-2); stroke: var(--edge); stroke-width: 2; transition: fill 0.2s ease; }
.g-node.g-end rect { fill: var(--surface-3); }
.g-label { fill: var(--text); font-size: 13px; font-weight: 800; text-anchor: middle; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.g-note { fill: var(--text-3); font-size: 9.5px; text-anchor: middle; }
.g-edge { fill: none; stroke: var(--text-3); stroke-width: 2; }
.g-edge.is-cond { stroke-dasharray: 5 4; }
.g-edge.is-walked { stroke: var(--accent); }
#g-arrow path { fill: var(--text-3); }
.g-edge-label { fill: var(--text-3); font-size: 9.5px; font-weight: 600; text-anchor: middle; }
.g-node.is-visited rect { fill: var(--lime-soft); }
.g-node.is-active rect { fill: var(--accent); stroke: var(--ink); }
.g-node.is-active .g-label, .g-node.is-active .g-note { fill: #fff; }
.g-node.is-active { animation: node-pulse 1s ease-in-out infinite; transform-box: fill-box; }
@keyframes node-pulse { 50% { opacity: 0.75; } }

.graph-legend { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 11.5px; color: var(--text-3); }
.g-key { display: inline-block; width: 22px; border-top: 2px solid var(--text-3); }
.g-key.is-cond { border-top-style: dashed; margin-left: 8px; }
.graph-tools-title { margin-top: 12px; font-size: 12px; color: var(--text-2); }
.graph-tools { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 0; padding: 0; list-style: none; }
.graph-tools li {
  padding: 2px 8px;
  border: 1.5px solid var(--border-strong);
  border-radius: 999px;
  font: 600 11px ui-monospace, "Cascadia Code", Consolas, monospace;
  color: var(--text-2);
  cursor: help;
}
.graph-tools li.is-used { background: var(--sun); border-color: var(--ink); color: #121622; }
.graph-trace { margin: 12px 0 0; padding: 10px 10px 10px 28px; border-radius: 10px; background: var(--surface-2); font-size: 12px; color: var(--text-2); }
.graph-trace li + li { margin-top: 2px; }
.graph-trace b { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; color: var(--text); }
.graph-trace code { font-size: 11px; }
.graph-legend + .chat-side-note { margin-top: 8px; }

/* Dashboard: deeper numbers, "What to do better" and week-by-week mini charts */
.stats.kpis-deep { margin-top: 14px; }
.kpis-deep .stat-value { font-size: 24px; }

.opps-card { margin-top: 20px; border: 2px solid var(--edge); box-shadow: var(--pop-sm); }
.opps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  gap: 10px;
}
.opp {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--sky);
}
.opp-now { border-left-color: var(--owed); }
.opp-week { border-left-color: var(--sun); }
.opp-grow { border-left-color: var(--lime); }
.opp-num {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  font-size: 12px;
  font-weight: 800;
  color: var(--text-2);
}
.opp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 4px; }
.opp h3 { margin: 0; font-size: 14.5px; font-weight: 750; color: var(--text); line-height: 1.35; }
.opp p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--text-2); }
.opp b { color: var(--text); font-weight: 700; }
.opp-tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.opp-now .opp-tag { background: var(--owed-soft); color: var(--owed); }
.opp-week .opp-tag { background: var(--sun-soft); color: var(--text); }
.opp-grow .opp-tag { background: var(--good-soft); color: var(--good); }
.opps .empty { grid-column: 1 / -1; }

.mini-charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.mini-title { margin: 0 0 6px; font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }
@media (max-width: 1000px) { .mini-charts { grid-template-columns: minmax(0, 1fr); } }
.dash-grid .tbl-thumb { width: 44px; height: 44px; border-radius: 10px; }

/* Most expensive by variety: big photo cards */
#topPriced { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 28px; }
.tp-group { padding-top: 14px; border-top: 1px solid var(--border); }
.tp-group:nth-child(-n + 2) { border-top: 0; padding-top: 0; }
@media (max-width: 1000px) { #topPriced { grid-template-columns: minmax(0, 1fr); } .tp-group:nth-child(2) { border-top: 1px solid var(--border); padding-top: 14px; } }
.tp-name { margin: 0 0 10px; font-size: 15px; font-weight: 750; color: var(--text); }
.tp-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tp-card { position: relative; margin: 0; border-radius: 14px; overflow: hidden; background: var(--surface-2); border: 2px solid var(--edge); box-shadow: var(--pop-sm); }
.tp-card img, .tp-noimg { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--surface-3); }
.tp-noimg { display: grid; place-items: center; font-size: 13px; font-weight: 600; color: var(--text-3); }
.tp-rank { position: absolute; top: 8px; left: 8px; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 800; }
.tp-card figcaption { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px 12px; }
.tp-card figcaption b { font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
.tp-card figcaption > span { font-size: 12px; color: var(--text-3); }
.tp-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
@media (max-width: 640px) { .tp-row { gap: 8px; } .tp-card figcaption b { font-size: 14px; } }

/* ============================================================
   Phones: a fixed app layout
   A slim top bar that stays put, the pages as a tab bar along the bottom (like an iPhone app),
   pop-ups that slide up from the bottom, and nothing that scrolls sideways or zooms by itself.
   ============================================================ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

@media (max-width: 640px) {
  html, body { overflow-x: clip; }
  body { overscroll-behavior-x: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

  /* iPhone zooms into any text box under 16px and leaves the page zoomed; at 16px it stays put. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
  select,
  textarea,
  .select { font-size: 16px !important; }

  /* Top bar: the shop name, the save status and the theme switch, always at the top. */
  html .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    flex-wrap: nowrap;
    gap: 10px;
    margin: 0;
    padding: calc(env(safe-area-inset-top) + 8px) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
    /* No blur here: a blurred bar would also pin the tab bar inside it (to its own bottom edge). */
    background: color-mix(in srgb, var(--bg) 96%, transparent);
    border-bottom: 1px solid var(--border);
  }
  html .topbar::before {
    content: "Plantstism";
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
  }
  .topbar .icon-btn { width: 38px; height: 38px; }
  /* The save status shrinks to its dot; problems still spell themselves out. */
  .status { height: 38px; padding: 0 13px; max-width: 60vw; }
  .status:not(.err) { padding: 0; width: 38px; justify-content: center; }
  .status:not(.err) .status-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .status-dot { width: 10px; height: 10px; }

  /* Page tabs: a bar fixed along the bottom with an icon over each name. */
  html .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    order: 0;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 2px;
    width: auto;
    max-width: none;
    margin: 0;
    overflow: visible;
    padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    border: 0;
    border-top: 2px solid var(--edge);
    border-radius: 0;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: 0 -10px 30px -18px rgba(0, 0, 0, 0.6);
  }
  html .tabs a {
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    padding: 6px 2px 4px;
    border-radius: 14px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--text-3);
    box-shadow: none;
    text-shadow: none;
  }
  html .tabs a .i { display: block; width: 23px; height: 23px; }
  html .tabs a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  html .tabs a:hover:not([aria-current="page"]) { background: none; }
  html .tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); box-shadow: none; text-shadow: none; }
  html .tabs a[aria-current="page"] .i { stroke-width: 2.4; }

  /* Room under the last card for the tab bar, and toasts just above it. */
  .page { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(82px + env(safe-area-inset-bottom)); }

  /* Plant photos big enough to tell apart. */
  .sale { grid-template-columns: 56px minmax(0, 1fr); column-gap: 12px; }
  .sale-avatar { width: 56px; height: 56px; border-radius: 14px; font-size: 18px; }
  .tbl-thumb { width: 48px; height: 48px; border-radius: 12px; }
  /* Three numbers side by side (Shipping): small enough that "514 of 592" fits whole. */
  .kpis-3 .stat-value { font-size: 17px; white-space: normal; overflow: visible; text-overflow: clip; }

  /* Pop-ups slide up from the bottom as sheets, like iPhone ones (the photo viewer stays centred). */
  .modal:not(.lightbox) {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - env(safe-area-inset-top) - 24px);
    margin: auto 0 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 22px max(18px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    border-bottom: 0;
    border-radius: 24px 24px 0 0;
  }
  .modal:not(.lightbox)[open] { animation: sheet-up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1); }
  .modal:not(.lightbox)::before {
    content: "";
    display: block;
    width: 40px;
    height: 5px;
    margin: -10px auto 12px;
    border-radius: 3px;
    background: var(--border-strong);
  }
  .modal-actions { flex-wrap: wrap; }

  /* iPhone draws date boxes its own way: wider than the card, taller, and the date centred.
     Switched to a plain box they match the other fields. */
  input[type="date"], input[type="datetime-local"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 44px;
    line-height: 40px;
    text-align: left;
  }
  input[type="date"]::-webkit-date-and-time-value, input[type="datetime-local"]::-webkit-date-and-time-value { margin: 0; text-align: left; }
  .day-nav input[type="date"] { height: 38px; line-height: 34px; }
}
@keyframes sheet-up { from { transform: translateY(60px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@media (max-width: 640px) and (prefers-reduced-motion: reduce) { .modal:not(.lightbox)[open] { animation: none; } }

/* ============================================================
   Login, and a customer's own page
   ============================================================ */
.login-body { min-height: 100dvh; }
.login {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 24px) 16px calc(env(safe-area-inset-bottom) + 24px);
}
.login-card { width: 100%; max-width: 400px; gap: 16px; text-align: left; }
.login-mascot { display: block; width: 96px; height: 96px; margin: 0 auto -4px; object-fit: contain; }
.login-title { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.02em; text-align: center; }
.login-sub { margin: -8px 0 4px; color: var(--text-2); font-size: 14px; line-height: 1.5; text-align: center; }
.login-sub span { color: var(--text-3); font-size: 13px; }

/* The customer page: the shop name, its own five tabs, and a Thai / English switch. */
.topbar-plain::before { content: "Plantstism"; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; color: var(--text); }
.lang-switch { padding: 3px; }
.lang-switch button { height: 32px; padding: 0 11px; font-size: 13px; }
.my-page { max-width: 860px; }
.my-view { display: flex; flex-direction: column; gap: 18px; }
.my-view[hidden] { display: none; }
.my-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* Totals are shown in full, however long: a smaller size before ever cutting a digit off. */
.my-stats .stat-value { white-space: normal; overflow: visible; overflow-wrap: anywhere; font-size: clamp(18px, 2.4vw, 24px); }
.my-pay { text-align: center; }
.my-pay-amount { margin: 4px 0 12px; font-size: 15px; color: var(--text-2); }
.my-pay-amount strong { display: block; font-size: 30px; color: var(--owed); }
.my-qr { display: block; width: 240px; height: 240px; max-width: 100%; margin: 0 auto 10px; border-radius: 16px; background: #fff; }
.my-pay-to { margin: 0 0 6px; font-size: 13px; }
.my-pdf { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.my-pdf .card-title { margin-bottom: 4px; }
.my-pdf p { margin: 0; font-size: 13.5px; }
.my-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.my-head .card-title { margin: 0; }
.my-search { flex: 1 1 200px; max-width: 320px; }
.my-month + .my-month { margin-top: 20px; }
.my-month-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 0 10px; font-size: 15px; font-weight: 750; }
.my-month-head small { font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.my-parcels { display: flex; flex-direction: column; gap: 14px; }
.my-parcel { padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.my-parcel .trip-meta { margin: 0; }
.my-parcel .trip-big { padding-top: 14px; }
.my-trip-detail { margin: 2px 0 0; font-size: 13px; }
.my-trip { margin-top: 10px; font-size: 13.5px; }
.my-trip summary { cursor: pointer; color: var(--accent-text); font-weight: 650; margin-bottom: 10px; }
.my-orders { display: flex; flex-direction: column; gap: 10px; }
.my-orders .sale-avatar { font-size: 20px; }
.my-profit { color: var(--good); text-align: right; }
.my-profit.is-loss { color: var(--owed); }
.my-profit small { display: block; font-size: 11.5px; font-weight: 650; }
.news-topics { flex-wrap: wrap; }
.my-chart-sub { margin: -6px 0 10px; font-size: 13px; }
.my-search-full { max-width: none; margin-bottom: 12px; }
.my-orders .sale-side .btn { flex: none; }
.my-chat-hint { margin: -4px 0 12px; font-size: 13px; }
.my-chat-log { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; overscroll-behavior: contain; }
.my-chat-log:empty { display: none; }
.my-chat-msg { display: flex; flex-direction: column; max-width: 88%; }
.my-chat-msg.is-me { align-self: flex-end; align-items: flex-end; }
.my-chat-msg.is-bot { align-self: flex-start; }
.my-chat-bubble { padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.is-me .my-chat-bubble { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.is-bot .my-chat-bubble { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.is-error .my-chat-bubble { background: var(--owed-soft); color: var(--owed); border-color: transparent; }
.my-chat-refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.my-chat-refs img { display: block; width: 72px; height: 72px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }
.my-chat-ideas { display: flex; flex-wrap: wrap; gap: 8px; }
.my-chat-ideas[hidden] { display: none; }
.my-idea { height: auto; min-height: 32px; padding: 6px 12px; font-size: 13px; cursor: pointer; border: 1px solid var(--border); white-space: normal; text-align: left; }
.my-idea:hover { border-color: var(--accent); color: var(--accent-text); }
.my-chat-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.my-chat-form textarea { flex: 1; min-height: 44px; max-height: 140px; resize: none; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 15px; }
.my-chat-form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.my-chat-form .btn { flex: none; height: 44px; }
@media (max-width: 640px) {
  .topbar-plain::before { font-size: 19px; }
  html .tabs.my-tabs { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .my-chat-log { max-height: calc(100dvh - 380px); }
  .my-view { gap: 14px; }
  .my-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .my-stats .stat-value { font-size: 20px; }
  .lang-switch button { height: 30px; padding: 0 9px; }
  .my-pdf .btn { width: 100%; }
  .my-search { max-width: none; }
}

/* ============================================================
   Customer tiers: a numbered badge per level, from bronze to diamond
   ============================================================ */
.tier-badge {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  color: #1b1405;
  background: var(--surface-3);
  border: 2px solid var(--edge);
}
.tier-0 { color: var(--text-3); }
.tier-1 { background: linear-gradient(135deg, #e3a36b, #b06a35); }
.tier-2 { background: linear-gradient(135deg, #f1f4f8, #a9b4c2); }
.tier-3 { background: linear-gradient(135deg, #ffe27a, #e0a810); }
.tier-4 { background: linear-gradient(135deg, #d9f3f4, #7fc1c9); }
.tier-5 { background: linear-gradient(135deg, #c9f0ff, #7aa8ff 55%, #c38bff); }
.tier-cell { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.tier-cell small { display: block; font-size: 11.5px; color: var(--text-3); }
.eyebrow-plain { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-3); }
.my-tier-top { display: flex; align-items: center; gap: 14px; }
.my-tier-top .tier-badge { width: 56px; height: 56px; font-size: 24px; border-width: 3px; box-shadow: var(--pop-sm); }
.my-tier-name { margin: 2px 0 0; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.tier-track { height: 10px; margin: 16px 0 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.tier-fill { height: 100%; width: 0; border-radius: 99px; background: var(--accent); transition: width 0.6s cubic-bezier(.2, .8, .2, 1); }
.my-tier-next { margin: 0 0 14px; font-size: 13.5px; }
.tier-ladder { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.tier-ladder li { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 14px; border: 1px solid var(--border); text-align: center; opacity: 0.55; }
.tier-ladder li.is-reached { opacity: 1; }
.tier-ladder li.is-current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tier-ladder b { display: block; font-size: 12.5px; }
.tier-ladder small { display: block; font-size: 10.5px; color: var(--text-3); line-height: 1.3; }
@media (max-width: 640px) {
  .tier-ladder { gap: 5px; }
  .tier-ladder li { padding: 8px 2px; }
  .tier-ladder b { font-size: 11px; }
  .tier-ladder small { font-size: 9.5px; }
}

/* ============================================================
   iPad and other tablets (touch screens wider than a phone)
   Text boxes big enough that Safari doesn't zoom in, buttons and tabs a finger's size,
   and the page tabs pinned at the top so another page is always one tap away.
   ============================================================ */
@media (min-width: 641px) and (hover: none), (min-width: 641px) and (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
  select,
  textarea,
  .select { font-size: 16px !important; }
  input[type="date"] { min-height: 44px; }

  html .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    max-width: none;
    padding: calc(env(safe-area-inset-top) + 10px) max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
    /* Solid, so the page scrolling under it never shows through and looks like sections on top of each other. */
    background: var(--bg);
    border-bottom: 1px solid var(--border-strong);
    box-shadow: 0 8px 18px -12px rgba(0, 0, 0, 0.55);
  }
  /* A text box or section jumped to stops below the pinned bar instead of under it. */
  html { scroll-padding-top: 96px; }
  .tabs a { min-height: 44px; padding: 0 18px; font-size: 15px; }
  .tabs a .i { width: 19px; height: 19px; }
  .icon-btn { width: 44px; height: 44px; }
  .status { min-height: 44px; }
  .btn { height: 46px; font-size: 15px; }
  .btn-sm { height: 40px; font-size: 14px; }
  .segmented span { height: 42px; font-size: 15px; }
  .range button { height: 40px; padding: 0 14px; font-size: 14px; }
  .sale-actions .icon-btn { width: 40px; height: 40px; }
  .sale-avatar { width: 52px; height: 52px; }
  .sale { grid-template-columns: 52px minmax(0, 1fr) auto; }
  .tbl-thumb { width: 52px; height: 52px; }
  .page { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
}

/* iPad held upright: wider cards for table rows (five values to a line), and the top bar on one line,
   with the save status shrunk to its dot as on a phone, so the tabs and buttons fit side by side. */
@media (min-width: 641px) and (max-width: 1024px) and (orientation: portrait) and (hover: none) {
  .card:not(.ship-card) .data-table tr { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px 16px; padding: 16px 0; }
  .card:not(.ship-card) .data-table td:first-child { font-size: 16px; }
  .card:not(.ship-card) .data-table td[data-label=""] .btn { width: auto; min-width: 180px; height: 42px; }
  html .topbar { flex-wrap: nowrap; gap: 10px; }
  html .tabs { order: 0; width: auto; flex: 1; min-width: 0; }
  html .tabs a { flex: 1; padding: 0 8px; gap: 6px; }
  .status { padding: 0; width: 44px; justify-content: center; }
  .status:not(.err) .status-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .status.err { width: auto; padding: 0 14px; }
}
/* The customer page's bar also holds the shop name and the language switch: too much for one line on
   an upright iPad, so its tabs get their own full-width line under them instead of being squeezed. */
@media (min-width: 641px) and (max-width: 1024px) and (orientation: portrait) and (hover: none) {
  html .topbar.topbar-plain { flex-wrap: wrap; row-gap: 10px; }
  html .topbar-plain .tabs { order: 3; flex: 1 1 100%; width: 100%; }
  html .topbar-plain .tabs a .i { display: inline-block; }
  html .topbar-plain .tabs a { padding: 0 10px; font-size: 15px; }
  html { scroll-padding-top: 150px; }
}
/* iPad mini and narrower upright tablets: the tab names alone, so all six fit beside the buttons. */
@media (min-width: 641px) and (max-width: 800px) and (orientation: portrait) and (hover: none) {
  html .topbar:not(.topbar-plain) .tabs a .i { display: none; }
  html .topbar:not(.topbar-plain) .tabs a { padding: 0 4px; font-size: 14.5px; }
}


/* The customer page's greeting has no mascot beside it, so its numbers take the full width. */
.my-page .hero { grid-template-columns: minmax(0, 1fr); }

/* The photo viewer: a close button in its corner, and photos that look tappable. */
.photo-viewer { position: relative; padding: 12px; }
.photo-viewer .viewer-close { position: absolute; top: 18px; right: 18px; z-index: 1; width: 44px; height: 44px; border-radius: 50%; background: rgba(10, 17, 32, 0.75); color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.photo-viewer img { max-height: calc(100dvh - 140px); }
img.tbl-thumb, .tp-card img, .sale-avatar.has-photo img, .my-chat-refs img, .resale-card img { cursor: zoom-in; }

/* ============================================================
   Shop: plants for sale (the shop's side on the Sales page, the customers' on their page)
   ============================================================ */
.shop-card { margin-top: 20px; }
.shop-hint { margin: -4px 0 14px; font-size: 13px; }
.shop-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 18px; align-items: end; padding-bottom: 18px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.shop-form .form-error, .shop-form-actions { grid-column: 1 / -1; }
.shop-form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.shop-grid, .my-shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.shop-item, .my-shop-item { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--surface-2); }
.shop-photo, .my-shop-photo { aspect-ratio: 1; background: var(--surface-3); display: grid; place-items: center; font-size: 42px; }
.shop-photo img, .my-shop-photo img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.shop-nophoto { font-size: 13px; color: var(--text-3); }
.shop-item-body, .my-shop-body { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 8px; flex: 1; }
.shop-item-body strong, .my-shop-body strong { font-size: 15px; }
.shop-price, .my-shop-price { font-size: 18px; font-weight: 800; color: var(--accent-text); }
.shop-tags, .my-shop-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.shop-item-actions { display: flex; gap: 8px; padding: 0 14px 14px; }
.shop-item-actions .btn { flex: 1; }
.shop-item-actions .danger:hover { color: var(--owed); }
.my-shop-item > .btn { margin: 0 14px 14px; width: auto; }
.my-shop-item.is-mine { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.my-shop-wait { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 0 14px 14px; }
.my-shop-wait .chip { justify-content: center; }
.shop-orders { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.shop-order-list { display: flex; flex-direction: column; gap: 10px; }
.shop-order { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.shop-thumb { width: 56px; height: 56px; border-radius: 12px; overflow: hidden; background: var(--surface-3); display: grid; place-items: center; }
.shop-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.shop-thumb .shop-nophoto { font-size: 10px; }
.shop-order-main { font-size: 14px; line-height: 1.4; min-width: 0; }
.shop-order-main small { display: block; color: var(--text-3); font-size: 12px; }
.shop-order-actions { display: flex; gap: 6px; }
@media (max-width: 640px) {
  html .tabs.my-tabs { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  html .tabs.my-tabs a { font-size: 9.5px; }
  .shop-grid, .my-shop { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .shop-order { grid-template-columns: 48px minmax(0, 1fr); }
  .shop-order-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .shop-item-actions { flex-direction: column; }
}

/* Facebook: the shop's contact button on the customer and login pages. */
.btn-fb { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: #1877f2; color: #fff; text-decoration: none; border-color: var(--edge); }
.btn-fb:hover { background: #166fe0; color: #fff; }
.btn-fb .fb-i { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.my-fb { margin-top: 12px; }
.my-pay .my-fb { display: flex; justify-content: center; }
.my-contact { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.my-contact .card-title { margin-bottom: 4px; }
.my-contact p { margin: 0; font-size: 13.5px; }
.my-contact .my-fb { margin-top: 0; }
.login-help { margin: 4px 0 -4px; text-align: center; font-size: 13px; color: var(--text-3); }
.login-fb { display: flex; justify-content: center; }
@media (max-width: 640px) {
  .my-contact .my-fb, .my-contact .btn-fb { width: 100%; }
}

/* Instagram beside Facebook, and the follow-us bar under every customer tab. */
.btn-ig { display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: #fff; text-decoration: none; border-color: var(--edge);
  background: linear-gradient(45deg, #f9a825 0%, #e1306c 45%, #833ab4 100%); }
.btn-ig:hover { color: #fff; filter: brightness(1.06); }
.btn-ig .ig-i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.my-social-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.my-social-btns > span { display: contents; }
.my-follow { margin-top: 18px; padding: 18px 16px 6px; text-align: center; border-top: 1px solid var(--border); }
.my-follow p { margin: 0 0 12px; font-size: 14px; font-weight: 650; color: var(--text-2); }
.my-follow .my-social-btns { justify-content: center; }
@media (max-width: 640px) {
  .my-contact .my-social-btns { width: 100%; }
  .my-contact .my-social-btns .btn { flex: 1; }
  .my-contact .my-fb, .my-contact .btn-fb { width: auto; }
}

/* Dashboard: who has opened the app. */
.visitors-card { margin-top: 20px; }
.visitors-stats { margin: 4px 0 16px; }
.vis-who { display: flex; flex-direction: column; }
.vis-who small, .vis-ips small { color: var(--text-3); font-size: 12px; }
.vis-ips { font-variant-numeric: tabular-nums; font-size: 12.5px; word-break: break-all; }
.vis-guest { color: var(--text-3); font-style: italic; }
.visitors-card th:nth-child(4), .visitors-card td:nth-child(4) { padding-left: 28px; }

/* The shop card's LINE alerts button, green once alerts are on. */
.shop-card .card-head #alertsBtn { margin-top: -4px; margin-bottom: 14px; }
#alertsBtn.is-on { color: #06c755; border-color: #06c755; }
