/*
 * Al-Fatah Metal House — admin portal styles.
 *
 * 1. Design tokens (light + dark)      6. Tables (cards on phones)
 * 2. Base                              7. Forms, dialogs, toasts
 * 3. App shell: sidebar, topbar        8. Charts
 * 4. Metal selector                    9. Sign-in screen
 * 5. Page parts: headers, cards, KPIs 10. Responsive rules
 *                                     11. Printing a page
 */

/* ── 1. Design tokens ─────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --font-sans: 'Inter Variable', Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Sora Variable', 'Inter Variable', ui-sans-serif, system-ui, sans-serif;

  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-2: #f6f8f5;
  --surface-3: #ecf0eb;
  --ink: #13201a;
  --ink-2: #45544c;
  --muted: #6f7d75;
  --line: #e1e6e0;
  --line-strong: #cbd4cb;
  --focus: #2f7dd1;

  --brand: #0f3d2e;
  --brand-2: #175a43;
  --brand-3: #1f7a5a;
  --brand-soft: #e2efe8;
  --brand-ink: #ffffff;
  --gold: #e2ad4f;
  --gold-2: #f6dc9b;
  --gold-ink: #3a2905;

  /* The selected metal's colour; main.js updates it when the selector changes. */
  --metal: #1f7a5a;

  --good: #0b7a35;
  --good-bg: #e3f3e8;
  --warn: #8a5a00;
  --warn-bg: #fcf0d4;
  --bad: #b3261e;
  --bad-bg: #fbe6e3;
  --info: #255a9b;
  --info-bg: #e5eefa;

  --shadow-sm: 0 1px 2px rgb(16 40 30 / 6%);
  --shadow: 0 1px 2px rgb(16 40 30 / 5%), 0 10px 28px rgb(16 40 30 / 7%);
  --shadow-lg: 0 28px 70px rgb(8 26 19 / 26%);
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;

  --sidebar-w: 268px;
  --topbar-h: 64px;
  --gutter: 28px;

  /* Chart chrome (series colours live in js/components/charts.js) */
  --chart-surface: #ffffff;
  --chart-grid: #e9ece8;
  --chart-axis: #cfd5ce;
  --chart-muted: #77837c;
  --chart-ink: #13201a;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0a110e;
  --surface: #121b17;
  --surface-2: #16211c;
  --surface-3: #1c2923;
  --ink: #e8efea;
  --ink-2: #b6c4bc;
  --muted: #8b9a91;
  --line: #233029;
  --line-strong: #314139;
  --focus: #7fb3f0;

  --brand: #1f7a5a;
  --brand-2: #279370;
  --brand-3: #34a981;
  --brand-soft: #16342a;

  --good: #67d394;
  --good-bg: #12301f;
  --warn: #f0c35f;
  --warn-bg: #33280f;
  --bad: #ff9289;
  --bad-bg: #3b1c1a;
  --info: #93bbf1;
  --info-bg: #17283b;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
  --shadow: 0 1px 2px rgb(0 0 0 / 35%), 0 12px 30px rgb(0 0 0 / 28%);
  --shadow-lg: 0 30px 80px rgb(0 0 0 / 55%);

  --chart-surface: #121b17;
  --chart-grid: #222d27;
  --chart-axis: #33413a;
  --chart-muted: #8b9a91;
  --chart-ink: #e8efea;
}

/* ── 2. Base ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
/* The scrollbar's room is kept while a dialog holds the page still, so nothing shifts sideways. */
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font: 400 14.5px/1.55 var(--font-sans);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--gold) 45%, transparent); }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.positive { color: var(--good); }
.negative { color: var(--bad); }
.nowrap { white-space: nowrap; }
.noscript { padding: 24px; text-align: center; }

.boot-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.boot-screen img { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(0.92); opacity: 0.7; } }

/* ── 3. App shell ─────────────────────────────────────────────────────────── */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(120% 60% at 0% 0%, rgb(226 173 79 / 12%), transparent 60%),
    linear-gradient(180deg, #0d3628 0%, #0a281e 100%);
  color: #cfe0d6;
  scrollbar-width: thin;
  scrollbar-color: #2a5443 transparent;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 10px; text-decoration: none; color: #fff; }
/* The gold plate with the shop's Urdu name, beside the English name (as on the website). */
.sidebar-brand .brand-plate { flex: none; width: auto; height: 36px; filter: drop-shadow(0 5px 12px rgb(0 0 0 / 30%)); }
.sidebar-brand strong { display: block; font: 700 14px/1.2 var(--font-display); letter-spacing: -0.01em; white-space: nowrap; }
.sidebar-brand small { display: block; margin-top: 3px; color: #9fbcae; font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap; }

#mainNav { display: grid; gap: 16px; }
.nav-group { display: grid; gap: 2px; }
.nav-group-label { margin: 4px 10px 6px; color: #7fa092; font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 10px;
  color: #cfe0d6;
  font-weight: 560;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: rgb(255 255 255 / 6%); color: #fff; }
.nav-link[aria-current='page'] { background: rgb(255 255 255 / 11%); color: #fff; }
.nav-link[aria-current='page']::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 9px;
  bottom: 9px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--gold);
}
.nav-link .icon { color: #9fbcae; }
.nav-link[aria-current='page'] .icon, .nav-link:hover .icon { color: var(--gold-2); }
.nav-badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--gold); color: var(--gold-ink); font-size: 11.5px; font-weight: 800; text-align: center; }

.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding: 14px 10px 4px; border-top: 1px solid rgb(255 255 255 / 8%); font-size: 12px; color: #8fae9f; }
.sidebar-foot a { display: inline-flex; align-items: center; gap: 8px; color: #cfe0d6; text-decoration: none; font-weight: 600; }
.sidebar-foot a:hover { color: #fff; }
/* "Install the app": adds the portal to the phone's home screen or the computer's apps. */
.sidebar-foot .install-app { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 8px 12px; border: 1px solid rgb(226 173 79 / 45%); border-radius: 10px; background: rgb(226 173 79 / 12%); color: #f3dca4; font-weight: 650; }
.sidebar-foot .install-app:hover { background: rgb(226 173 79 / 20%); color: #fff; }
.sidebar-foot .android-app { display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; color: #cfe0d6; font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.sidebar-foot .android-app:hover { color: #fff; }
.android-download { justify-self: start; margin-bottom: 4px; }
/* The Android app dialog: Install with Chrome, then the APK file. */
.app-way { display: grid; gap: 8px; padding: 14px 0; border-top: 1px solid var(--line); }
.app-way:first-child { padding-top: 0; border-top: 0; }
.app-way h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: 15px; }
.app-way h3 small { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.app-way p { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.app-way > .btn { justify-self: start; }
.app-way .install-steps { margin-bottom: 4px; }
.install-apk { margin-top: 12px; }
.ios-steps li > .icon { display: inline-block; width: 18px; height: 18px; margin: 0 2px; vertical-align: -4px; color: var(--brand); }
.phone-qr { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding: 12px; border: 1px dashed var(--line); border-radius: 14px; }
.phone-qr img { flex: none; width: 132px; height: 132px; padding: 6px; border-radius: 10px; background: #fff; }
.phone-qr p { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.install-steps { display: grid; gap: 8px; margin: 0 0 14px; padding-left: 22px; }

.scrim { display: none; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--topbar-h);
  padding: 10px var(--gutter);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { min-width: 0; display: flex; flex-direction: column; }
.topbar-title small { color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.topbar-title strong { font: 650 16px/1.25 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar .menu-button { display: none; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.icon-button:hover { color: var(--ink); border-color: var(--line-strong); }

.user-menu { position: relative; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-3), var(--brand));
  color: #fff;
  font-size: 12.5px;
  font-weight: 750;
  letter-spacing: 0.02em;
}
.data-table .sub.undone-note { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
img.avatar { object-fit: cover; background: var(--surface-3); }
.avatar.avatar-lg { width: 88px; height: 88px; font-size: 28px; }
/* My profile */
.profile-card { display: flex; flex-wrap: wrap; gap: 18px 24px; align-items: center; }
.avatar.avatar-xl { width: 104px; height: 104px; font-size: 34px; }
.profile-main { flex: 1 1 320px; min-width: 0; }
.profile-main h2 { font: 700 22px/1.2 var(--font-display); }
.profile-main > p { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.profile-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 18px; margin: 14px 0 0; }
.profile-facts dt { color: var(--muted); font-size: 11.5px; font-weight: 650; }
.profile-facts dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
/* My profile → Notification popups (and the fingerprint lock). */
.push-status { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 12px; }
.push-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
/* The person's other devices, each with Remove (an old phone, the old app in Samsung Internet). */
.push-devices { margin-bottom: 16px; }
.push-devices > p { margin: 0 0 8px; font-size: 13px; }
.push-devices ul { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.push-devices li { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; padding: 8px 8px 8px 12px; border: 1px solid var(--line); border-radius: 12px; }
.push-devices li > span { display: grid; gap: 2px; min-width: 0; }
.push-devices small { color: var(--muted); font-size: 12px; }
/* "Check popups": each step a popup takes to this device, ✓ or ✗ with what to do. */
.check-steps { display: grid; gap: 10px; margin: 0 0 14px; padding: 0; list-style: none; }
.check-step { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.check-step p { margin: 3px 0 0; color: var(--ink-2); font-size: 13px; }
.check-mark { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3); color: var(--muted); }
.check-step.is-pass .check-mark { background: var(--good-bg); color: var(--good); }
.check-step.is-fail { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: var(--bad-bg); }
.check-step.is-fail .check-mark { background: var(--bad); color: #fff; }
.push-topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin: 0; padding: 0; border: 0; }
.push-topics legend { margin-bottom: 8px; padding: 0; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
/* Sign-in page: fingerprint sign-in above the username and password. */
.auth-fingerprint { display: grid; gap: 12px; margin-bottom: 20px; }
.auth-card .btn-fingerprint { min-height: 56px; border: 0; border-radius: 14px; background: linear-gradient(135deg, #f6dc9b, #e2ad4f 55%, #c98d2c); color: var(--gold-ink); font-size: 16px; font-weight: 750; box-shadow: 0 10px 24px rgb(201 141 44 / 28%), inset 0 1px 0 rgb(255 255 255 / 45%); }
.auth-card .btn-fingerprint:hover { filter: brightness(1.04); }
.btn-fingerprint .icon { width: 24px; height: 24px; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; }
.auth-or::before, .auth-or::after { flex: 1; border-top: 1px solid var(--line); content: ''; }
/* Popups page: people to send to, and the ticks in the entries table. */
.popup-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin: 0; padding: 0; border: 0; }
.popup-people legend { margin-bottom: 8px; padding: 0; color: var(--ink-2); font-size: 13px; font-weight: 620; }
.popup-people .popup-all { grid-column: 1 / -1; max-width: 220px; }
.table-check { width: 18px; height: 18px; accent-color: var(--brand-3); }
/* Popups at set times: a greeting's title and message under its name, the time, and a birthday's day and month. */
.popup-words { display: grid; justify-items: start; gap: 6px; min-width: 210px; }
.popup-words .input { width: 100%; }
.popup-try { display: inline-flex; align-items: center; gap: 4px; padding: 0; font-size: 12.5px; }
.popup-words .input { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.popup-time { width: auto; min-width: 112px; min-height: 36px; padding: 6px 10px; }
/* The days of the week a daily popup goes out on: ticked days filled, like checkboxes. */
.popup-time-cell { display: grid; gap: 8px; justify-items: start; }
.popup-time-cell .popup-time { width: 136px; }
.popup-days { display: flex; flex-wrap: wrap; gap: 4px; max-width: 136px; }
.popup-day { position: relative; display: inline-flex; }
.popup-day input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.popup-day span { display: grid; place-items: center; min-width: 30px; height: 28px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 650; }
.popup-day input:checked + span { border-color: var(--brand-3); background: var(--brand-3); color: #fff; }
.popup-day input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.popup-day input:disabled + span { opacity: 0.6; }
/* Message buttons: WhatsApp, text message (SMS) and Call side by side; the dialog's other ways. */
.message-buttons { display: inline-flex; flex-wrap: nowrap; align-items: center; gap: 4px; }
/* "Remind" on a bill still owed: the wrapper only carries the bill and customer for noting the reminder. */
.bill-reminder { display: contents; }
.wa-other { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.wa-note { margin: 10px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }

/* Sales & profit: the second row of figures, the dates form, loss-making rows. */
.kpis-small .kpi-value, .kpis-small strong.kpi-value { font-size: 22px; }
.report-dates { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; padding: 14px 16px; }
.report-dates label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.report-dates .input { width: 170px; }
.data-table tr.is-loss td { background: color-mix(in srgb, var(--bad) 7%, transparent); }

/* Website enquiries: the customer's quote list. */
.enquiry-items { display: grid; gap: 4px; margin: 0; padding: 10px 12px 10px 30px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; }
.enquiry-items li { padding-left: 2px; }
.enquiry-items li strong { margin-left: 8px; white-space: nowrap; }

/* Website list: the metals on the website. */
.website-metal-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 16px; }
.chip-button { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.chip-button small { color: var(--muted); font-weight: 600; }
.chip-button[aria-pressed="true"] { border-color: var(--brand-3); background: color-mix(in srgb, var(--brand-3) 12%, var(--surface)); }
.chip-button.is-off { opacity: 0.6; }
.chip-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot, var(--muted)); }

/* Website list: ticks, the bar for ticked rows, rows the website does not show. */
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px var(--gutter-card, 16px); border-bottom: 1px solid var(--line); }
.bulk-bar__count { color: var(--ink-2); font-size: 14px; }
.bulk-bar__hint { color: var(--muted); font-size: 13px; }
.row-tick { width: 20px; height: 20px; accent-color: var(--brand-3); cursor: pointer; }
.data-table tr.is-muted td:not(:last-child) { opacity: 0.62; }
.section-gap-sm { margin-top: 12px; }
.check-group { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.check-group legend { margin-bottom: 6px; }

/* Settings → Website details: open days and times. */
.opening-times { min-width: 0; margin: 0; padding: 0; border: 0; }
.opening-times .hint-inline { color: var(--muted); font-weight: 500; }
.opening-times__row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; margin-top: 6px; }
.open-days { max-width: none; }
.opening-times__time { display: grid; gap: 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.opening-times__time .input { width: 140px; }
.popup-when { min-width: 170px; }
.popup-when strong { white-space: nowrap; }
[data-reach] { white-space: nowrap; }
.card-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
/* Pages under long lists (components/table.js). */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.pager-buttons { display: inline-flex; align-items: center; gap: 8px; }
.pager-page { min-width: 96px; color: var(--ink-2); font-weight: 600; text-align: center; }
.pager-size { display: inline-flex; align-items: center; gap: 6px; }
.pager-size select { width: auto; min-height: 34px; padding: 4px 26px 4px 10px; border: 1px solid var(--line-strong); border-radius: 9px; background-color: var(--surface); color: var(--ink); }
@media print { .pager { display: none !important; } }
/* The fingerprint lock screen of the installed phone app (components/fingerprint.js): covers everything. */
.lock-screen { position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); border: 0; background: var(--bg); color: var(--ink); }
.lock-screen[open] { display: grid; place-items: center; }
.lock-screen::backdrop { background: var(--bg); }
.lock-panel { display: grid; justify-items: center; gap: 10px; width: min(360px, 100%); text-align: center; }
.lock-panel .brand-plate { width: auto; height: 64px; filter: drop-shadow(0 6px 14px rgb(0 0 0 / 22%)); }
.lock-panel h1 { margin: 8px 0 0; font: 700 24px/1.2 var(--font-display); letter-spacing: -0.02em; }
.lock-panel p { margin: 0; color: var(--muted); }
.lock-panel .lock-unlock { width: 100%; min-height: 54px; margin-top: 14px; font-size: 16px; }
.lock-panel .lock-unlock .icon { width: 22px; height: 22px; }
.lock-panel .lock-error { min-height: 1.4em; color: var(--bad); font-size: 13.5px; font-weight: 600; }

/* Settings: payment accounts printed on bills, and ticks for what staff may change */
.pay-slot { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px 18px; min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 14px; }
.pay-slot legend { padding: 0 6px; font-size: 13px; font-weight: 700; }
.pay-qr { display: grid; justify-items: center; align-content: start; gap: 8px; }
.pay-qr img, .pay-qr-empty { width: 120px; height: 120px; border: 1px solid var(--line); border-radius: 10px; background: #fff; object-fit: contain; }
.pay-qr-empty { display: grid; place-content: center; padding: 10px; background: var(--surface-2); color: var(--muted); font-size: 12px; text-align: center; }
.pay-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; align-content: start; }
.pay-fields .full { grid-column: 1 / -1; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 16px; }

/* Employees: who is online now */
.online-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.online-person { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.online-person > div { flex: 1; min-width: 0; }
.online-person strong { display: block; overflow-wrap: anywhere; }
.online-person small { display: block; color: var(--muted); font-size: 12px; }
.online-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }

.photo-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; }
.photo-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.photo-actions .hint { flex-basis: 100%; color: var(--muted); font-size: 12.5px; }
.user-chip-text { display: grid; line-height: 1.15; text-align: left; }
.user-chip-text strong { font-size: 13px; }
.user-chip-text small { color: var(--muted); font-size: 11.5px; text-transform: capitalize; }

.menu-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 40;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.16s ease-out;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ink);
  font-weight: 560;
  text-align: left;
  text-decoration: none;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); }
.menu-item .icon { color: var(--muted); }
.menu-divider { height: 1px; margin: 6px 4px; background: var(--line); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }

.page { width: 100%; max-width: 1480px; margin: 0 auto; padding: 26px var(--gutter) 56px; }
.page.is-refreshing { opacity: 0.6; transition: opacity 0.2s ease; }

/* ── 4. Metal selector ───────────────────────────────────────────────────── */
.metal-switcher { position: relative; }
.metal-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  max-width: 320px;
  padding: 5px 12px 5px 6px;
  border: 1px solid color-mix(in srgb, var(--metal) 45%, var(--line));
  border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--metal) 9%, var(--surface)), var(--surface));
  box-shadow: var(--shadow-sm), 0 0 0 3px color-mix(in srgb, var(--metal) 10%, transparent);
  text-align: left;
}
.metal-trigger:hover { border-color: var(--metal); }
.metal-trigger-text { display: grid; min-width: 0; line-height: 1.15; }
.metal-trigger-text small { color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.metal-trigger-text strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metal-trigger .icon { color: var(--muted); }

.metal-tile {
  --tile: #8a958f;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background:
    linear-gradient(145deg, rgb(255 255 255 / 55%), rgb(255 255 255 / 0%) 45%),
    linear-gradient(160deg, color-mix(in srgb, var(--tile) 70%, #fff), var(--tile) 55%, color-mix(in srgb, var(--tile) 70%, #000));
  color: #fff;
  font: 750 13px/1 var(--font-display);
  text-shadow: 0 1px 2px rgb(0 0 0 / 35%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 25%), 0 2px 6px color-mix(in srgb, var(--tile) 40%, transparent);
}
.metal-tile.is-all { background: linear-gradient(145deg, #2a6e55, #0f3d2e); }
.metal-tile.lg { width: 52px; height: 52px; border-radius: 14px; font-size: 19px; }
.metal-tile.sm { width: 22px; height: 22px; border-radius: 6px; font-size: 10px; }

.metal-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 40;
  width: min(340px, calc(100vw - 24px));
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.16s ease-out;
}
.metal-menu-label { padding: 8px 10px 6px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.metal-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  border: 0;
  border-radius: 11px;
  background: none;
  text-align: left;
}
.metal-option:hover, .metal-option:focus-visible { background: var(--surface-3); outline: none; }
.metal-option[aria-selected='true'] { background: color-mix(in srgb, var(--brand-3) 10%, var(--surface)); }
.metal-option-text { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.metal-option-text strong { font-size: 14px; }
.metal-option-text small { color: var(--muted); font-size: 12px; }
.metal-option .check { color: var(--brand-3); }
.metal-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 2px 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tile, #888) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--tile, #888) 30%, var(--line));
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.metal-chip .metal-tile { width: 18px; height: 18px; border-radius: 50%; font-size: 8.5px; }

/* ── 5. Page parts ───────────────────────────────────────────────────────── */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 22px; }
.page-head-text { min-width: 0; display: flex; align-items: center; gap: 16px; }
.page-head .eyebrow { display: inline-flex; align-items: center; gap: 8px; color: var(--brand-3); font-size: 11.5px; font-weight: 750; letter-spacing: 0.14em; text-transform: uppercase; }
.page-head h1 { margin-top: 4px; font: 700 clamp(22px, 2.2vw, 29px)/1.15 var(--font-display); letter-spacing: -0.025em; }
.page-head p { margin-top: 6px; max-width: 70ch; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 28%, transparent); }
.btn-primary:hover { background: var(--brand-2); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn-warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.btn-danger { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.btn-sm { min-height: 32px; padding: 5px 11px; border-radius: 9px; font-size: 13px; }
.btn-icon { padding-inline: 9px; }
.btn-sm.btn-icon { min-width: 32px; padding-inline: 7px; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ''; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor; border-color: var(--brand-ink) var(--brand-ink) transparent transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.btn-secondary.is-loading::after { border-color: var(--ink) var(--ink) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-button { border: 0; padding: 4px 2px; background: none; color: var(--brand-3); font-weight: 650; text-decoration: none; }
.link-button:hover { text-decoration: underline; }

.section-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 6px 0 14px; }
.section-title { font: 650 17px/1.3 var(--font-display); letter-spacing: -0.01em; }
.section-title .muted { font-family: var(--font-sans); font-size: 14px; font-weight: 500; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); }
.section-gap { margin-top: 18px; }

.card {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 16px; margin-bottom: 16px; }
.card-head h2 { font: 650 16px/1.3 var(--font-display); letter-spacing: -0.01em; }
.card-head p { margin-top: 3px; color: var(--muted); font-size: 13px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head { padding: 18px 20px 0; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi {
  position: relative;
  min-width: 0;
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.kpi::after {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--kpi-accent, var(--metal)), transparent 80%);
  opacity: 0.85;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-label { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.kpi-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-3); color: var(--ink-2); }
.kpi-value { margin-top: 10px; font-size: clamp(20px, 1.9vw, 26px); font-weight: 720; letter-spacing: -0.03em; line-height: 1.15; overflow-wrap: anywhere; }
.kpi-value small { font-size: 0.55em; font-weight: 650; color: var(--muted); letter-spacing: 0; }
.kpi-sub { margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.delta { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.delta.up { background: var(--good-bg); color: var(--good); }
.delta.down { background: var(--bad-bg); color: var(--bad); }
.delta.flat { background: var(--surface-3); color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--ink-2);
}
.pill .icon { width: 13px; height: 13px; stroke-width: 2.2; }
.pill-good { background: var(--good-bg); color: var(--good); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-brand { background: var(--brand-soft); color: var(--brand-3); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 240px; min-width: 0; }
/* A toolbar inside a flush card lines up with the card's own padding. */
.card-toolbar { padding: 0 20px; }
.card-toolbar.is-top { padding-top: 18px; }
.toolbar .toolbar-select, .toolbar .toolbar-date { width: auto; }
.search-box { position: relative; }
.search-box .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 38px; }

.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); gap: 2px; }
.segmented button {
  min-height: 32px;
  padding: 5px 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.segmented button[aria-pressed='true'], .segmented button[aria-selected='true'] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.segmented .count { margin-left: 4px; color: var(--muted); font-weight: 600; }

.empty { display: grid; justify-items: center; gap: 8px; padding: 36px 16px; color: var(--muted); text-align: center; }
.empty .icon { width: 30px; height: 30px; color: var(--line-strong); }
.empty strong { color: var(--ink); font-size: 15px; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-size: 13px; }
.note .icon { margin-top: 1px; color: var(--muted); }
.note.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }

.list { display: grid; gap: 2px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row-main { min-width: 0; flex: 1; }
.list-row-main strong { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row-main small { color: var(--muted); font-size: 12px; }

.progress { height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--good) 16%, var(--surface-3)); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--good); }
/* A bar that is getting full (the database in Settings): amber from the warning size, red when full. */
.progress.is-warn > span { background: var(--warn); }
.progress.is-bad > span { background: var(--bad); }
.db-usage { display: grid; gap: 8px; }
.db-usage .progress { height: 10px; }

.skeleton { border-radius: 10px; background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.metal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.metal-card { position: relative; display: grid; gap: 16px; overflow: hidden; }
.metal-card::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; background: var(--tile); }
.metal-card-head { display: flex; align-items: center; gap: 14px; }
.metal-card-head h2 { font: 700 18px/1.2 var(--font-display); }
.metal-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.metal-stats div { padding: 10px; border-radius: 12px; background: var(--surface-2); }
.metal-stats small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.metal-stats strong { display: block; margin-top: 2px; font-size: 14px; overflow-wrap: anywhere; }
.metal-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.metal-card.is-inactive { opacity: 0.72; }

.shape-icon { width: 30px; height: 30px; flex: none; }
.item-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.item-cell-text { min-width: 0; }
.item-cell-text strong { display: block; font-weight: 650; }
.item-cell-text small { display: block; color: var(--muted); font-size: 12.5px; }


/* Stock history: Field / Before / After comparison shown in a dialog. */
.compare-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.compare-table th, .compare-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.compare-table thead th { background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.compare-table tbody th { width: 30%; color: var(--ink-2); font-weight: 620; }
.compare-table tbody tr:last-child > * { border-bottom: 0; }
.compare-table tr.is-changed > * { background: color-mix(in srgb, var(--warn-bg) 70%, transparent); }
.compare-table .pill { margin-left: 4px; }
.wrap-text { white-space: normal; overflow-wrap: anywhere; }

/* Website details: three phone / WhatsApp slots. */
.contact-slots { display: grid; gap: 10px; }
.contact-slot { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.3fr) auto auto; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.contact-slot .slot-index { display: none; }
.contact-slot label.inline { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.contact-slot input[type='checkbox'], .contact-slot input[type='radio'] { width: 18px; height: 18px; accent-color: var(--brand-3); }
.contact-slots-head { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.3fr) auto auto; gap: 10px; padding: 0 12px; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.contact-slot.social-slot { grid-template-columns: 96px minmax(0, 1fr) auto; }
.social-slot .social-name { color: var(--ink-2); font-size: 13.5px; font-weight: 650; }

.enquiry-card { display: grid; gap: 12px; }
.enquiry-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; }
.enquiry-head h3 { font-size: 15.5px; }
.enquiry-meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 12.5px; }
.enquiry-message { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.enquiry-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.enquiry-wanted { color: var(--ink-2); }
.enquiry-actions .enquiry-status { width: auto; min-height: 32px; margin-left: auto; padding: 4px 10px; }
.enquiry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }

/* Calculator page: the weight card beside the keypad card when the page is wide enough for both,
   the saved calculations under them. */
.calc-layout { display: grid; gap: 18px; container-type: inline-size; }
.calc-grid { display: grid; gap: 18px; align-items: start; }
@container (min-width: 1080px) {
  .calc-grid { grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); }
}
/* Each card also lays itself out by its own width: the tape beside the keys, the result beside the form. */
.calc-keypad-card, .calc-weight { container-type: inline-size; }
@container (min-width: 600px) {
  .calc-keypad-body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
  .calc-keypad-body .calc-tape { margin-top: 0; padding: 0 0 0 20px; border-top: 0; border-left: 1px solid var(--line); }
  .calc-keypad-body .calc-tape-list { max-height: 390px; }
}
@container (min-width: 720px) {
  .calc-weight-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 0.8fr); gap: 22px; align-items: start; }
  .calc-weight-body .calc-side { margin-top: 0; }
}
.calc-screen { display: grid; justify-items: end; gap: 6px; min-height: 108px; padding: 16px 18px; border-radius: 16px; background: linear-gradient(160deg, #134a37, #0b2c21 70%); color: #eef5f0; text-align: right; box-shadow: inset 0 1px 0 rgb(255 255 255 / 8%); }
.calc-sum { max-width: 100%; min-height: 20px; color: rgb(238 245 240 / 68%); font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calc-display { max-width: 100%; font: 700 40px/1.1 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calc-display[data-size='m'] { font-size: 31px; }
.calc-display[data-size='s'] { font-size: 24px; }
.calc-display[data-size='xs'] { font-size: 18px; }
.calc-display.is-error { color: #ffb4ab; font-size: 24px; }
.calc-keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.calc-key {
  display: grid;
  place-items: center;
  min-height: 56px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink);
  font: 650 22px/1 var(--font-display);
  cursor: pointer;
  touch-action: manipulation; /* no double-tap zoom when keys are pressed quickly */
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, transform 0.08s ease;
}
.calc-key:hover { background: var(--surface-3); }
.calc-key:active, .calc-key.is-active { transform: translateY(1px) scale(0.98); background: var(--line); }
.calc-key .icon { width: 24px; height: 24px; }
.calc-key.is-clear { color: var(--bad); font-size: 18px; }
.calc-key.is-op-light { color: var(--brand-3); }
.calc-key.is-op { border-color: transparent; background: var(--brand-soft); color: var(--brand-2); font-size: 26px; }
.calc-key.is-op[aria-pressed='true'] { background: var(--brand-3); color: #fff; }
.calc-key.is-equals { border-color: transparent; background: var(--brand); color: var(--brand-ink); font-size: 26px; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 28%, transparent); }
.calc-key.is-equals:hover { background: var(--brand-2); }
.calc-tape { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.calc-tape-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.calc-tape-head h3 { font: 650 14px/1.3 var(--font-display); }
.calc-tape-list { display: grid; gap: 2px; max-height: 260px; margin: 0; padding: 0; overflow-y: auto; overscroll-behavior: contain; list-style: none; }
.calc-tape-list button { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: none; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; text-align: left; cursor: pointer; }
.calc-tape-list button:hover { background: var(--surface-2); }
.calc-tape-list button span { min-width: 0; overflow-wrap: anywhere; }
.calc-tape-list button strong { margin-left: auto; color: var(--ink); font-size: 14.5px; overflow-wrap: anywhere; }
.calc-tape-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.calc-hint { margin-top: 12px; color: var(--muted); font-size: 12px; }
@media (hover: none) { .calc-hint { display: none; } } /* phones and tablets have no keyboard to type on */
.calc-keypad-card .card-head { flex-wrap: nowrap; }
.calc-keypad-card .card-head > div { min-width: 0; }
.calc-weight .card-head { flex-wrap: wrap; }
.calc-shapes { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.calc-shape { display: grid; justify-items: center; gap: 4px; min-width: 0; padding: 9px 4px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--ink-2); font-size: 12.5px; font-weight: 650; cursor: pointer; }
.calc-shape:hover { border-color: var(--line-strong); }
.calc-shape[aria-pressed='true'] { border-color: var(--brand-3); background: var(--brand-soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--brand-3); }
.calc-dims { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-content: start; }
.calc-unit select { flex: none; width: auto; border-left: 0; border-radius: 0 11px 11px 0; background-color: var(--surface-2); }
.calc-material { display: flex; gap: 8px; }
.calc-material select { flex: 1 1 auto; min-width: 0; }
.calc-material .btn { flex: none; }
/* The sizes beside the hatched drawing of the section with its size letters (under it on a phone). */
.calc-size { display: grid; gap: 12px; align-items: start; }
@container (min-width: 520px) {
  .calc-size { grid-template-columns: minmax(0, 1fr) minmax(190px, 0.8fr); }
}
.calc-side { display: grid; gap: 14px; align-content: start; margin-top: 18px; }
.calc-figure { display: grid; gap: 6px; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.calc-drawing { display: block; width: 100%; max-width: 260px; height: auto; margin: 0 auto; color: var(--ink-2); }
.calc-drawing-fill { fill: color-mix(in srgb, var(--metal) 18%, transparent); }
.calc-drawing-letter { fill: currentColor; font: 700 13px var(--font-sans); }
.calc-figure figcaption { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 12px; color: var(--muted); font-size: 12px; }
.calc-figure figcaption strong { color: var(--ink); }
.calc-own h3 { margin-bottom: 8px; font: 650 14px/1.3 var(--font-display); }
.calc-own ul { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.calc-own li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; }
.calc-error:empty { display: none; }
.calc-result { display: grid; gap: 14px; padding: 16px; border: 1px solid color-mix(in srgb, var(--metal) 30%, var(--line)); border-radius: 16px; background: color-mix(in srgb, var(--metal) 6%, var(--surface-2)); }
.calc-total { display: grid; gap: 2px; }
.calc-total small { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.calc-total strong { font: 700 clamp(26px, 4vw, 34px)/1.15 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calc-total > span { color: var(--muted); font-size: 13px; }
.calc-total .calc-price { color: var(--ink); font-size: 18px; font-weight: 700; }
.calc-total .calc-price small { color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.calc-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 0; }
.calc-figures div { min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.calc-figures dt { color: var(--muted); font-size: 11.5px; font-weight: 650; }
.calc-figures dd { margin: 2px 0 0; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calc-formula { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.calc-result-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Sticky notes (Tools → Sticky notes, and pinned notes on the dashboard) ── */
.sticky-note.is-yellow { --note-bg: #fff3b0; --note-line: #ecd66a; --note-ink: #3b3000; }
.sticky-note.is-green { --note-bg: #d8f1dc; --note-line: #9fd5aa; --note-ink: #123b1d; }
.sticky-note.is-blue { --note-bg: #dbe9fd; --note-line: #a7c6f2; --note-ink: #0f2a4f; }
.sticky-note.is-pink { --note-bg: #fde1eb; --note-line: #f1a9c2; --note-ink: #4d0f27; }
.sticky-note.is-purple { --note-bg: #ebe2fb; --note-line: #c4adef; --note-ink: #2b1850; }
.sticky-note.is-orange { --note-bg: #fde3c8; --note-line: #f0b67d; --note-ink: #4a2706; }
.sticky-dot.is-yellow { --note-swatch: #f5d547; }
.sticky-dot.is-green { --note-swatch: #6cc983; }
.sticky-dot.is-blue { --note-swatch: #6aa6f0; }
.sticky-dot.is-pink { --note-swatch: #f08bb2; }
.sticky-dot.is-purple { --note-swatch: #ad8ae8; }
.sticky-dot.is-orange { --note-swatch: #f5a55b; }
:root[data-theme='dark'] .sticky-note.is-yellow { --note-bg: #3a3314; --note-line: #5c5120; --note-ink: #f7ecb4; }
:root[data-theme='dark'] .sticky-note.is-green { --note-bg: #17341f; --note-line: #2a5536; --note-ink: #cdeed5; }
:root[data-theme='dark'] .sticky-note.is-blue { --note-bg: #162a45; --note-line: #29466d; --note-ink: #d3e4fb; }
:root[data-theme='dark'] .sticky-note.is-pink { --note-bg: #3e1b29; --note-line: #663046; --note-ink: #f8d4e2; }
:root[data-theme='dark'] .sticky-note.is-purple { --note-bg: #2b2142; --note-line: #47376b; --note-ink: #e3d7f8; }
:root[data-theme='dark'] .sticky-note.is-orange { --note-bg: #3e2916; --note-line: #67462a; --note-ink: #f9dbbf; }

.sticky-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; align-items: start; }
.sticky-note {
  display: flex; flex-direction: column; min-width: 0;
  border: 1px solid var(--note-line); border-radius: 4px 4px 18px 4px;
  background: var(--note-bg); color: var(--note-ink);
  box-shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 8px 18px rgb(0 0 0 / 7%);
}
.sticky-note[hidden] { display: none; }
.sticky-note .sticky-title {
  display: block; width: 100%; min-height: 0; margin: 0; padding: 12px 16px 2px; border: 0; border-radius: 4px 4px 0 0; box-shadow: none;
  background: transparent; color: inherit; font: 700 16px/1.35 var(--font-display); letter-spacing: -0.01em;
}
.sticky-note .sticky-title::placeholder { color: var(--note-ink); opacity: 0.5; }
.sticky-note .sticky-title:focus { outline: none; box-shadow: none; }
.sticky-text {
  display: block; width: 100%; min-height: 96px; max-height: 420px; padding: 6px 16px 8px; resize: none; overflow-y: auto;
  border: 0; border-radius: 4px 4px 0 0; background: transparent; color: inherit;
  font: 450 15px/1.5 var(--font-sans); white-space: pre-wrap; overflow-wrap: anywhere;
}
.sticky-text::placeholder { color: var(--note-ink); opacity: 0.55; }
.sticky-text:focus { outline: none; box-shadow: none; }
.sticky-note:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.sticky-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; padding: 6px 8px 8px 12px; border-top: 1px dashed var(--note-line); }
.sticky-foot .btn-ghost { color: var(--note-ink); }
.sticky-foot .btn-ghost:hover { background: color-mix(in srgb, var(--note-ink) 10%, transparent); color: var(--note-ink); }
.sticky-pin[aria-pressed='true'] { background: color-mix(in srgb, var(--note-ink) 16%, transparent); }
.sticky-pin[aria-pressed='true'] .icon { fill: currentColor; }
.sticky-done[aria-pressed='true'] { background: color-mix(in srgb, var(--note-ink) 16%, transparent); }
/* A done note stays, faded and struck through, at the end of the list. */
.sticky-note.is-done { opacity: 0.62; }
.sticky-note.is-done .sticky-title, .sticky-note.is-done .sticky-text { text-decoration: line-through; text-decoration-thickness: 1px; }
.sticky-colors { display: flex; gap: 5px; margin-right: auto; }
.sticky-dot { width: 20px; height: 20px; padding: 0; border: 1px solid rgb(0 0 0 / 18%); border-radius: 50%; background: var(--note-swatch); cursor: pointer; }
.sticky-dot[aria-pressed='true'] { outline: 2px solid var(--note-ink); outline-offset: 1px; }
.sticky-status { flex: 1 0 100%; order: 3; font-size: 12px; opacity: 0.75; }
.sticky-hint { margin: 0 12px 8px; padding: 6px 8px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--note-ink); background: color-mix(in srgb, var(--note-ink) 12%, transparent); }
.sticky-status.is-error { color: var(--bad); opacity: 1; font-weight: 600; }

/* The pinned notes on the dashboard: read only, each opens Sticky notes. */
.sticky-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 22px; }
.sticky-mini { display: block; padding: 12px 14px; text-decoration: none; transition: transform 0.12s ease; }
.sticky-mini:hover { transform: translateY(-2px); }
.sticky-mini strong { display: block; margin-bottom: 3px; font: 700 14.5px/1.35 var(--font-display); overflow-wrap: anywhere; }
.sticky-mini span { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 5; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.45; }
.sticky-mini .icon { float: right; margin: 0 0 4px 8px; opacity: 0.7; }

/* ── 6. Tables (become cards on phones) ──────────────────────────────────── */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.data-table th {
  position: sticky;
  top: 0;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background 0.12s ease; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--surface-3) 55%, transparent); }
.data-table .num { text-align: right; white-space: nowrap; }
.data-table .actions { text-align: right; white-space: nowrap; }
/* Wide tables scroll sideways; the actions column stays pinned to the right so Edit is always in view. */
.data-table th.actions, .data-table td.actions { position: sticky; right: 0; z-index: 1; background: var(--surface); box-shadow: -14px 0 14px -14px rgb(0 0 0 / 35%); }
.data-table th.actions { z-index: 2; background: var(--surface-2); }
.data-table tbody tr:hover td.actions { background: color-mix(in srgb, var(--surface-3) 55%, var(--surface)); }
.data-table .actions > div { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.data-table .sub { display: block; color: var(--muted); font-size: 12px; }
/* In a narrow box a table scrolls sideways rather than squeezing an item or a long note into one word a line. */
.table-wrap:not(.is-cards) td.cell-main { min-width: 150px; }
.table-wrap:not(.is-cards) .wrap-text { display: block; min-width: 190px; }
.table-wrap:not(.is-cards) .item-cell { min-width: 170px; }
.card-flush .table-wrap:not(.is-cards) .data-table :is(th, td):first-child { padding-left: 20px; }
.card-flush .table-wrap:not(.is-cards) .data-table :is(th, td):last-child { padding-right: 20px; }

/* Lists as cards on phones (table.js adds .is-cards up to 760 px): the item on top, then the other
   columns two to a row (name above value; long text across the card), then the buttons, and the
   card around the list falls away. Computers and tablets keep tables. */
.table-wrap.is-cards { overflow: visible; }
.is-cards .data-table thead { display: none; }
.is-cards .data-table, .is-cards .data-table tbody { display: block; width: 100%; }
.is-cards .data-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; column-gap: 16px; margin: 0 0 12px; padding: 2px 14px 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
.is-cards .data-table tbody tr:hover { background: var(--surface); }
.is-cards .data-table td { position: static; display: block; min-width: 0; padding: 7px 0; border: 0; text-align: left; overflow-wrap: anywhere; }
.is-cards .data-table td::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--muted); font-size: 11.5px; font-weight: 650; line-height: 1.3; overflow-wrap: normal; }
.is-cards .data-table td[data-label='']::before, .is-cards .data-table td.cell-main::before, .is-cards .data-table td.actions::before, .is-cards .data-table td.empty-cell::before { display: none; }
.is-cards .data-table td.cell-main, .is-cards .data-table td.cell-wide, .is-cards .data-table td.actions, .is-cards .data-table td.empty-cell { grid-column: 1 / -1; }
.is-cards .data-table td.cell-main { order: -1; margin-bottom: 3px; padding: 11px 0 9px; border-bottom: 1px solid var(--line); font-size: 15px; }
.is-cards .data-table td.actions { order: 99; position: static; margin-top: 5px; padding: 10px 0 2px; border-top: 1px solid var(--line); box-shadow: none; background: none; }
.is-cards .data-table tbody tr:hover td.actions { background: none; }
.is-cards .data-table td.actions > div, .is-cards .data-table td.actions > div.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; }
.is-cards .data-table td.actions .btn { flex: 1 1 auto; min-height: 38px; }
.is-cards .data-table td.actions .btn-icon { flex: 0 0 auto; min-width: 42px; }
.is-cards .data-table td.actions .btn-ghost { border-color: var(--line); background: var(--surface-2); }
.is-cards .data-table td .nowrap, .is-cards .data-table td.num { white-space: normal; }
.is-single .data-table tbody tr { grid-template-columns: minmax(0, 1fr); }
.is-cards .data-table td > * { min-width: 0; }
.is-cards .data-table td.empty-cell { padding: 0; text-align: center; }
.is-cards .items-text { min-width: 0; max-width: none; }
.card.card-flush:has(.table-wrap.is-cards) { padding: 0; overflow: visible; border: 0; border-radius: 0; background: none; box-shadow: none; }
.card-flush:has(.table-wrap.is-cards) > .card-head { padding: 0; }
.card-flush:has(.table-wrap.is-cards) .card-toolbar, .card-flush:has(.table-wrap.is-cards) .card-toolbar.is-top { padding: 0; }
details.chart-table .table-wrap.is-cards { overflow: auto; }

/* ── 7. Forms, dialogs, toasts ───────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; align-content: start; gap: 6px; min-width: 0; }
.field label, .field .label { color: var(--ink-2); font-size: 13px; font-weight: 620; }
.field .hint { color: var(--muted); font-size: 12px; }
/* :where() keeps these selectors low-specificity, so small overrides (like .search-box input) win. */
.input, .field :where(input:not([type='checkbox'], [type='radio'], [type='color']), select, textarea), .toolbar :where(input:not([type='checkbox'], [type='radio']), select) {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field textarea { min-height: 84px; resize: vertical; }
.field :where(input, select, textarea):focus, .toolbar :where(input, select):focus, .input:focus {
  outline: none;
  border-color: var(--brand-3);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-3) 22%, transparent);
}
.field :where(input, textarea)::placeholder, .toolbar :where(input)::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
/* A birthday: the day and month boxes side by side (components/forms.js birthdayField). */
.birthday-boxes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px; }
.toolbar select { width: auto; }
.toolbar .check-field { padding: 9px 12px; }
.input-group { display: flex; align-items: stretch; }
.input-group input { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .addon { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 11px 11px 0; background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 650; }
.check-field { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.check-field input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand-3); }
.check-field strong { display: block; font-size: 13.5px; }
.check-field small { color: var(--muted); font-size: 12px; }
.field [aria-invalid='true'] { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }
.form-error { min-height: 0; color: var(--bad); font-size: 13px; font-weight: 600; }
.form-error:not(:empty) { padding: 10px 12px; border-radius: 10px; background: var(--bad-bg); }
.preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; padding: 12px; border-radius: 12px; background: color-mix(in srgb, var(--metal) 7%, var(--surface-2)); border: 1px dashed color-mix(in srgb, var(--metal) 35%, var(--line)); }
.preview div small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 650; }
.preview div strong { font-size: 15px; }

/* Sale bill form: one row per item, section labels between groups of fields. */
.form-grid .section-label { grid-column: 1 / -1; margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.bill-lines { display: grid; gap: 10px; }
.bill-line { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.1fr) minmax(64px, 0.55fr) minmax(0, 1.1fr) minmax(96px, 0.9fr) auto; align-items: end; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.bill-line label, .bill-line .line-amount { display: grid; gap: 5px; min-width: 0; }
.bill-line label > span, .bill-line .line-amount > span { color: var(--ink-2); font-size: 12px; font-weight: 620; }
.bill-line .line-amount strong { display: flex; align-items: center; min-height: 42px; font-size: 14px; white-space: nowrap; }
.bill-line select:disabled { opacity: 1; background: var(--surface-3); color: var(--ink); }
/* Each line comes from own stock or from another shop; a shop line types in its item and the shop's rate. */
.bill-line .line-source { grid-column: 1 / -1; justify-self: start; }
.bill-line .line-source button { display: inline-flex; gap: 6px; align-items: center; }
.bill-line.is-shop { grid-template-columns: minmax(0, 1.1fr) minmax(64px, 0.55fr) minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(96px, 0.9fr) auto; border-style: dashed; }
.bill-line .line-paper { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; margin: 0; color: var(--ink-2); font-size: 12px; }
.bill-line .line-paper .icon { flex: none; color: var(--muted); }
/* Scan to fill: a photo of a paper bill fills in a new bill. */
.scan-box { display: grid; gap: 10px; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--surface-2); }
.scan-intro { display: flex; gap: 10px; align-items: flex-start; }
.scan-intro > .icon { flex: none; margin-top: 2px; color: var(--brand-3); }
.scan-intro strong { display: block; }
.scan-intro span { color: var(--ink-2); font-size: 13px; }
.scan-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.scan-result:empty { display: none; }
.scan-done { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; align-items: start; color: var(--ink-2); font-size: 13px; }
.scan-done .scan-ok { display: flex; gap: 6px; align-items: center; color: var(--good); font-size: 14px; }
.scan-checks { margin: 6px 0 0; padding-left: 18px; color: var(--warn); }
.scan-checks li + li { margin-top: 3px; }
.scan-thumb { padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; cursor: zoom-in; }
.scan-thumb img { display: block; width: 100%; height: auto; }
.scan-done.is-zoomed, .scan-done.is-text { grid-template-columns: minmax(0, 1fr); }
.scan-paste { display: grid; gap: 10px; padding-top: 10px; border-top: 1px dashed var(--line-strong); }
.scan-steps { display: grid; gap: 10px; margin: 0; padding-left: 20px; }
.scan-step { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.scan-step > span { flex: 1 1 240px; }
.scan-step > span, .scan-answer > span { color: var(--ink-2); font-size: 13px; }
.scan-answer { display: grid; gap: 4px; }
.scan-text { width: 100%; min-height: 72px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface); color: var(--ink); font: 12.5px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; resize: vertical; }
.scan-text:focus { outline: none; border-color: var(--brand-3); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-3) 22%, transparent); }
.scan-done.is-zoomed .scan-thumb { cursor: zoom-out; }
.line-shop { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.9fr); gap: 10px; }
.line-shop label { display: grid; gap: 5px; min-width: 0; }
.line-shop label > span { color: var(--ink-2); font-size: 12px; font-weight: 620; }
/* Bulk bill items (no pieces column); a new item's name, size and unit on a row of their own. */
.bulk-line { grid-template-columns: minmax(0, 2.4fr) minmax(0, 1.15fr) minmax(0, 1.15fr) minmax(96px, 0.9fr) auto; }
.new-item-fields { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; }
.new-item-fields label, .new-item-fields .new-item-name { display: grid; gap: 5px; min-width: 0; align-content: start; }
.new-item-fields label > span, .new-item-fields .new-item-name > span { color: var(--ink-2); font-size: 12px; font-weight: 620; }
/* What a new item is: the list, and under it the name box when "Other name" is chosen. */
.item-name-pick { display: grid; gap: 6px; min-width: 0; }
.bill-actions { display: flex; flex-wrap: wrap; gap: 10px; }
/* Settings → Messages: one row per channel, then the free setup steps. */
.message-status { display: grid; gap: 8px; }
.message-status > div { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
.message-status > div > span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.message-status .hint { margin: -4px 0 4px; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.setup-steps summary { cursor: pointer; color: var(--brand-3); font-weight: 650; }
.setup-steps ol { display: grid; gap: 8px; margin: 10px 0 0; padding-left: 20px; color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }
.segmented.pay-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; overflow: visible; }
.segmented.pay-modes button { white-space: normal; line-height: 1.25; }
.btn-whatsapp { background: #1a7f4b; color: #fff; }
/* Bill lists: item names wrap between words, and row buttons stay on one line where there is room. */
.items-text { display: block; min-width: 150px; max-width: 300px; white-space: normal; overflow-wrap: break-word; }
.data-table .actions > div.row-actions { flex-wrap: nowrap; }
/* On laptop screens a row with many buttons (bills: receive, view, print, WhatsApp, SMS, call, edit,
   delete) takes two lines, so the amounts beside them stay in view. */
@media (max-width: 1600px) {
  .data-table .actions > div.row-actions { flex-wrap: wrap; width: max-content; max-width: 15.5rem; margin-left: auto; }
}
.btn-whatsapp:hover { background: #136b3e; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { width: 32px; height: 32px; border-radius: 10px; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-strong); background: var(--swatch); }
.swatch[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--ink); }
.swatches input[type='color'] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }

dialog.modal {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog.modal.lg { width: min(820px, calc(100vw - 32px)); }
dialog.modal.sm { width: min(460px, calc(100vw - 32px)); }
dialog.modal[open] { display: flex; flex-direction: column; animation: dialog-in 0.2s cubic-bezier(0.2, 0.8, 0.3, 1); }
dialog.modal::backdrop { background: rgb(6 18 13 / 55%); backdrop-filter: blur(3px); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.modal-head { display: flex; align-items: flex-start; gap: 14px; padding: 20px 22px 0; }
.modal-head h2 { font: 700 18px/1.25 var(--font-display); }
.modal-head p { margin-top: 4px; color: var(--muted); font-size: 13.5px; }
.modal-head .icon-button { margin-left: auto; flex: none; box-shadow: none; }
.modal-body { flex: 1 1 auto; min-height: 0; padding: 18px 22px; overflow-y: auto; overscroll-behavior: contain; }
/* While a dialog or the menu drawer is open the page behind it stays still, so a swipe scrolls only the dialog. */
html:has(dialog.modal[open]), html:has(.app.nav-open) { overflow: hidden; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }
/* "Send on WhatsApp": in which language (components/whatsapp.js), each with the start of its message. */
.wa-languages { display: grid; gap: 10px; }
.wa-language { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none; }
.wa-language:hover { border-color: var(--brand-3); background: var(--brand-soft); }
.wa-language:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.wa-language.is-last { border-color: var(--brand-3); }
.wa-language-name { font-size: 15px; font-weight: 700; }
/* The start of the message, a line at a time, each line reading in its own direction (as WhatsApp shows it). */
.wa-language-text { display: -webkit-box; grid-column: 1 / -1; overflow: hidden; color: var(--muted); font-size: 12.5px; line-height: 1.45; white-space: pre-line; unicode-bidi: plaintext; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
.wa-language-text[dir='rtl'] { font-size: 14px; line-height: 1.75; text-align: right; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 14px;
  background: #10241c;
  color: #eaf3ee;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.toast .icon { color: #7ee0a6; margin-top: 1px; }
.toast.error { background: #3a1311; color: #ffe8e5; }
.toast.error .icon { color: #ff9a90; }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: 0.25s ease; }
/* The portal was updated while open (components/update.js): it stays until Reload is pressed. */
.toast.is-update { align-items: center; }
.toast.is-update span { flex: 1; }
.toast.is-update .icon { margin-top: 0; }
/* A new version: the portal covers itself while it reloads (components/update.js). */
.update-cover { position: fixed; inset: 0; z-index: 2147483000; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px); }
.update-panel { display: grid; justify-items: center; gap: 14px; padding: 28px 32px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 24px 60px -24px rgb(0 0 0 / 45%); text-align: center; }
.update-panel .brand-plate { width: 120px; height: auto; }
.update-spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--brand, #1e5b4a); border-radius: 50%; animation: update-spin 0.8s linear infinite; }
@keyframes update-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .update-spinner { animation-duration: 2.4s; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* ── 8. Charts ───────────────────────────────────────────────────────────── */
.chart-box { position: relative; height: 280px; }
.chart-box.short { height: 220px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: -4px 0 12px; color: var(--ink-2); font-size: 12.5px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--swatch); }
.chart-total { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 12px; }
.chart-total div small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 650; }
.chart-total div strong { font-size: 18px; letter-spacing: -0.02em; }
.chart-empty { position: absolute; inset: 0; display: grid; place-content: center; gap: 4px; padding: 16px; color: var(--muted); text-align: center; font-size: 13px; pointer-events: none; }
.chart-controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.segmented-sm button { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.metal-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
details.chart-table { margin-top: 12px; }
details.chart-table summary { cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 650; }
details.chart-table .table-wrap { max-height: 280px; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; }

/* ── 9. Sign-in screen ───────────────────────────────────────────────────── */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); background: var(--bg); }
.auth-art {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 44px clamp(32px, 5vw, 72px);
  background:
    radial-gradient(70% 55% at 12% 8%, rgb(226 173 79 / 26%), transparent 62%),
    radial-gradient(60% 55% at 92% 92%, rgb(208 101 43 / 26%), transparent 62%),
    linear-gradient(155deg, #134a37, #0b2c21 55%, #061a13);
  color: #e7f0ea;
}
.auth-art::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgb(255 255 255 / 5%) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / 5%) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 35% 45%, #000, transparent 78%);
}
.auth-art > * { position: relative; }
.auth-brand, .auth-band { display: flex; align-items: center; gap: 14px; }
.auth-brand .brand-plate, .auth-band .brand-plate { flex: none; width: auto; height: 56px; filter: drop-shadow(0 6px 14px rgb(0 0 0 / 32%)); }
.auth-brand strong, .auth-band strong { display: block; font: 700 19px/1.2 var(--font-display); letter-spacing: -0.01em; }
.auth-brand small, .auth-band small { color: #b3cdbf; font-size: 11px; font-weight: 650; letter-spacing: 0.16em; text-transform: uppercase; }
.auth-hero { display: grid; gap: 22px; }
.auth-art h2 { max-width: 15ch; font: 700 clamp(32px, 3.5vw, 48px)/1.06 var(--font-display); letter-spacing: -0.035em; }
.auth-art h2 span { background: linear-gradient(90deg, #f6dc9b, #e2ad4f 40%, #f3b48a 70%, #d0652b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-points { display: grid; gap: 12px; max-width: 46ch; margin: 0; padding: 0; list-style: none; }
.auth-points li { display: flex; align-items: center; gap: 12px; color: #cfe0d6; font-size: 15px; }
.auth-points .icon { flex: none; width: 34px; height: 34px; padding: 8px; border: 1px solid rgb(246 220 155 / 28%); border-radius: 10px; background: rgb(255 255 255 / 6%); color: #f6dc9b; }
.auth-rods { position: relative; height: 128px; margin: 0; }
.rod { position: absolute; left: 0; height: 24px; border-radius: 12px; box-shadow: 0 10px 22px rgb(0 0 0 / 35%); animation: float 6s ease-in-out infinite; }
.rod::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 55%) 45%, transparent 60%); background-size: 250% 100%; animation: sweep 4.5s ease-in-out infinite; }
.rod.al { background: linear-gradient(180deg, #f5f8fb 0%, #c3ccd5 30%, #8d99a5 55%, #dfe5ea 78%, #a2adb8 100%); }
.rod.cu { background: linear-gradient(180deg, #ffd4b3 0%, #e39a64 30%, #b45a26 58%, #f0b48a 80%, #a5501f 100%); }
.rod:nth-child(1) { top: 8px; width: 76%; }
.rod:nth-child(2) { top: 48px; left: 12%; width: 70%; animation-delay: -1.5s; }
.rod:nth-child(3) { top: 88px; left: 4%; width: 62%; animation-delay: -3s; }
@keyframes float { 50% { transform: translateY(-7px); } }
@keyframes sweep { 0% { background-position: 150% 0; } 60%, 100% { background-position: -100% 0; } }
.auth-foot { color: #8fae9f; font-size: 12.5px; }
.auth-panel {
  display: grid;
  place-items: center;
  align-content: center;
  padding: 40px 24px;
  background:
    radial-gradient(60% 45% at 85% 5%, rgb(31 122 90 / 10%), transparent 70%),
    radial-gradient(50% 40% at 10% 100%, rgb(226 173 79 / 12%), transparent 70%),
    var(--bg);
}
/* The brand band replaces the art panel on tablets and phones. */
.auth-band { display: none; }
.auth-card { width: min(440px, 100%); padding: 34px 32px 26px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: 0 1px 2px rgb(16 40 30 / 5%), 0 24px 60px rgb(16 40 30 / 12%); }
.auth-head { margin-bottom: 24px; }
.auth-card h1 { font: 700 28px/1.15 var(--font-display); letter-spacing: -0.03em; }
.auth-head p { margin: 8px 0 0; color: var(--muted); }
.auth-card form { display: grid; gap: 16px; }
.auth-card .btn { min-height: 48px; }
.auth-card .auth-submit { min-height: 52px; border-radius: 14px; font-size: 15.5px; }
.auth-input { position: relative; display: flex; align-items: center; }
.auth-input > .icon { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.auth-card .auth-input input { min-height: 50px; padding-left: 44px; border-radius: 12px; }
.auth-card .auth-input input[type='password'], .auth-card .auth-input input[name='password'] { padding-right: 48px; }
.auth-eye { position: absolute; right: 6px; display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.auth-eye:hover, .auth-eye:focus-visible { background: var(--surface-3); color: var(--ink); }
.auth-eye .icon { width: 19px; height: 19px; }
.auth-check { align-items: center; }
.auth-check strong { display: inline-flex !important; align-items: center; gap: 7px; }
.auth-check strong .icon { width: 17px; height: 17px; color: var(--brand-3); }
.auth-card .auth-links { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.auth-card .auth-links a { color: var(--brand-3); font-weight: 650; text-decoration: none; }
.auth-card .auth-links .link-button { padding: 0; font-size: 13px; }
.auth-notice { margin: -8px 0 18px; }

/* ── 10. Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main-side { grid-template-columns: minmax(0, 1fr); }
}

/* Tablet and phone: the sidebar becomes a slide-in drawer. */
@media (max-width: 1023px) {
  :root { --gutter: 20px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 60;
    width: min(300px, 86vw);
    transform: translateX(-102%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.3, 1);
    box-shadow: var(--shadow-lg);
  }
  .app.nav-open .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 55; display: block; background: rgb(6 18 13 / 50%); opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
  .app.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .topbar .menu-button { display: inline-grid; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  /* Sign-in: a brand band on top and the card over its lower edge, like banking apps. */
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
  .auth-panel { align-content: start; place-items: start center; padding: 0 0 40px; background: var(--bg); }
  .auth-band {
    display: flex;
    justify-self: stretch;
    padding: max(28px, env(safe-area-inset-top)) clamp(20px, 6vw, 48px) 72px;
    background:
      radial-gradient(70% 90% at 10% 0%, rgb(226 173 79 / 28%), transparent 65%),
      radial-gradient(60% 80% at 100% 100%, rgb(208 101 43 / 24%), transparent 65%),
      linear-gradient(155deg, #134a37, #0b2c21 60%, #061a13);
    color: #e7f0ea;
  }
  .auth-card { width: min(520px, calc(100% - 32px)); margin-top: -48px; }
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .topbar-title { flex: 1; }
  .topbar-spacer { display: none; }
  .metal-switcher { order: 5; flex: 1 0 100%; }
  .metal-trigger { width: 100%; max-width: none; min-height: 40px; padding: 4px 10px 4px 5px; }
  .metal-trigger .metal-tile { width: 28px; height: 28px; }
  .metal-trigger-text { flex: 1; }
  .metal-trigger-text small { display: none; }
  .metal-menu { width: 100%; }
  .user-chip-text { display: none; }
  .user-chip { padding: 4px; }
  .page { padding-top: 16px; }
  .page-head .eyebrow { display: none; }
  .input, .field :where(input:not([type='checkbox'], [type='radio'], [type='color']), select, textarea), .toolbar :where(input:not([type='checkbox'], [type='radio']), select) { font-size: 16px; }

  /* Filters stack: search and lists full width, a date range side by side, choices wrap instead of scrolling away. */
  .toolbar { gap: 8px; }
  .toolbar > .grow, .toolbar > select, .toolbar > .toolbar-select, .toolbar > .segmented, .toolbar > .check-field { flex: 1 1 100%; width: 100%; }
  .toolbar > .toolbar-date { display: block; flex: 1 1 calc(50% - 4px); width: auto; min-width: 0; }
  .toolbar > .toolbar-date input { width: 100%; min-width: 0; }
  .toolbar > .btn { flex: 1 1 100%; }
  .segmented { flex-wrap: wrap; width: 100%; }
  .segmented > button { flex: 1 1 auto; }
  .segmented:has(> button:nth-child(4)) > button { flex-basis: calc(50% - 4px); }

  .card-toolbar, .card-toolbar.is-top { padding: 0; }
  .contact-slots-head { display: none; }
  .contact-slot, .contact-slot.social-slot { grid-template-columns: minmax(0, 1fr); }
  .contact-slot .slot-index { display: block; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .pay-slot, .pay-fields { grid-template-columns: minmax(0, 1fr); }
  .bill-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .bill-line .line-item { grid-column: 1 / -1; }
  .bill-line .icon-button { justify-self: end; }
  .new-item-fields { order: -1; grid-template-columns: minmax(0, 1fr); } /* right under the item choice */
  .bill-line.is-shop { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .line-shop { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .line-shop .line-shop-name, .line-shop .line-shop-item { grid-column: 1 / -1; }
  .bulk-line .line-item { order: -2; }
  .bill-actions .btn { flex: 1 1 100%; }
  .scan-actions .btn { flex: 1 1 100%; }
  .scan-step > .btn { flex: 1 1 100%; }
  .scan-text { font-size: 16px; } /* phones do not zoom in on a box with 16 px text */
  .bill-actions .btn-ghost { border-color: var(--line); background: var(--surface-2); }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .chart-box { height: 240px; }
  /* Changes: each field is a small block — its name, then the "Before" and "After" lines. */
  .compare-table thead { display: none; }
  .compare-table, .compare-table tbody, .compare-table tr { display: block; width: 100%; }
  .compare-table tbody tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .compare-table tbody tr:last-child { border-bottom: 0; }
  .compare-table tbody tr > *, .compare-table tr.is-changed > * { border-bottom: 0; background: none; }
  .compare-table tr.is-changed { background: color-mix(in srgb, var(--warn-bg) 70%, transparent); }
  .compare-table tbody th { display: block; width: auto; padding: 0 0 4px; }
  .compare-table td { position: relative; display: block; padding: 3px 0 3px 58px; }
  .compare-table td::before { content: attr(data-label); position: absolute; top: 5px; left: 0; color: var(--muted); font-size: 11.5px; font-weight: 650; }
  .compare-table td[data-label=''] { padding-left: 0; }
  .enquiry-grid { grid-template-columns: minmax(0, 1fr); }
  /* Two buttons a row (one left over takes the whole row), then the status list. */
  .enquiry-actions .btn { flex: 1 1 calc(50% - 4px); min-height: 38px; }
  .enquiry-actions .btn-ghost { border-color: var(--line); background: var(--surface-2); }
  .enquiry-actions .enquiry-status { flex: 1 1 100%; width: 100%; min-height: 40px; margin-left: 0; }

  dialog.modal, dialog.modal.lg, dialog.modal.sm {
    width: 100vw;
    max-width: 100vw;
    max-height: calc(100dvh - 24px);
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
  }
  dialog.modal[open] { animation: sheet-in 0.25s cubic-bezier(0.2, 0.8, 0.3, 1); }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: 0.4; } }
  .modal-foot .btn { flex: 1 1 140px; }
  .toasts { left: 16px; right: 16px; bottom: 16px; width: auto; }
  /* Finger-sized controls (at least 36 px tall) and labels that wrap instead of running off the screen. */
  .segmented button, .segmented-sm button { min-height: 36px; }
  .link-button { display: inline-flex; align-items: center; min-height: 36px; }
  details > summary { padding-block: 9px; }
  .contact-slot label.inline { min-height: 36px; }
  .auth-card .auth-links a, .auth-card .auth-links .link-button { min-height: 36px; padding-block: 8px; }
  .pill { max-width: 100%; white-space: normal; }

  /* Sign-in on phones: the card is a sheet over the band, the full width of the screen. */
  .auth-panel { padding-bottom: 0; }
  .auth-band { padding-bottom: 64px; }
  .auth-band .brand-plate { height: 48px; }
  .auth-band strong { font-size: 17px; }
  .auth-card { width: 100%; min-height: calc(100dvh - 120px); margin-top: -36px; padding: 28px 20px 24px; border: 0; border-radius: 26px 26px 0 0; box-shadow: 0 -8px 30px rgb(0 0 0 / 18%); }
  .auth-card h1 { font-size: 25px; }
  .auth-head { margin-bottom: 20px; }
  .auth-card input { font-size: 16px; } /* stops iPhones zooming into the field */
  .auth-card .auth-links { flex-direction: column; align-items: flex-start; gap: 10px; }
  .chart-controls { width: 100%; }
  .chart-controls .segmented { flex: 1 1 auto; }
}

@media (max-width: 480px) {
  :root { --gutter: 14px; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px 14px 12px; border-radius: 16px; }
  /* Smaller on phones, but every figure keeps its icon. */
  .kpi-icon { width: 28px; height: 28px; border-radius: 8px; flex: none; }
  .kpi-icon .icon { width: 16px; height: 16px; }
  .kpi-value { font-size: 19px; }
  .card { padding: 16px; border-radius: 18px; }
  .metal-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metal-stats > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
  /* Calculator: the weight figures as a list, name on the left and kilograms on the right. */
  .calc-figures { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .calc-figures div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 12px; }
  .calc-figures dd { margin: 0; }
  .calc-result-actions .btn { flex: 1 1 100%; }
  .calc-shape span { font-size: 11.5px; }
}

@media (max-width: 360px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .calc-keys { gap: 6px; }
  .calc-key { min-height: 52px; }
  .calc-shapes { gap: 5px; }
  .calc-shape .shape-icon { width: 26px; height: 26px; }
}

/* ── 11. Printing a page (Ctrl+P, "Save as PDF") ────────────────────────── */
/* Only the page itself, on white paper, as wide as the paper: no menu, buttons or filters, lists as
   full tables (printing.js turns cards back into tables first) and charts shrunk to fit. */
@media print {
  @page { margin: 10mm; }
  html, body { background: #fff; }
  .sidebar, .scrim, .topbar, .toasts, .page-actions, .card-toolbar, .toolbar, .chart-controls, .data-table .actions, details.chart-table:not([open]) { display: none !important; }
  .app { display: block; min-height: 0; }
  .main-col { display: block; }
  .page { max-width: none; padding: 0; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  .card-flush { overflow: visible; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .table-wrap { overflow: visible; }
  .data-table { font-size: 10px; }
  .data-table th { position: static; padding: 6px; white-space: normal; }
  .data-table td { padding: 6px; }
  .data-table .sub, .data-table .nowrap { white-space: normal; }
  .data-table .sub { font-size: 9.5px; }
  .data-table .pill { padding: 1px 6px; font-size: 9.5px; }
  .data-table .pill .icon { display: none; }
  .data-table tr { break-inside: avoid; }
  .data-table thead { display: table-header-group; }
  .items-text { min-width: 120px; max-width: none; }
  .chart-box canvas { max-width: 100% !important; }
  a { color: inherit; text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
