/* Modern Stickers ERP — hand-written CSS. Same palette mechanism as before (data-theme
   attribute + prefers-color-scheme), no build step. Restrained, professional enterprise
   look: solid colors over gradients, subtle shadows, a tighter radius scale, compact
   density — one primary accent, semantic colors used only for status/action. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --background: #f5f6fb;
  --surface: #ffffff;
  --surface-muted: #f1f2f8;
  --foreground: #16182a;
  --muted-foreground: #6b7089;
  --border: #e7e8f2;

  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-foreground: #ffffff;
  --primary-soft: #eef0ff;

  --accent: #0ea5a3;
  --accent-soft: #e9fbf9;

  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  --radius-sm: 0.4rem;
  --radius-md: 0.6rem;
  --radius-lg: 0.75rem;
  --radius-xl: 0.9rem;

  --shadow-sm: 0 1px 2px 0 rgb(23 24 50 / 0.05);
  --shadow-md: 0 6px 16px -6px rgb(23 24 50 / 0.12), 0 2px 5px -2px rgb(23 24 50 / 0.05);
  --shadow-lg: 0 16px 36px -10px rgb(23 24 50 / 0.16), 0 4px 10px -4px rgb(23 24 50 / 0.06);
  --shadow-glow: 0 4px 14px -3px rgb(79 70 229 / 0.28);

  --chart-series-1: #2a78d6;
  --chart-series-2: #eb6834;
  --chart-series-3: #1baf7a;
  --chart-series-4: #eda100;
  --chart-series-5: #8b5cf6;
  --chart-series-6: #0f9b8e;
  --chart-series-7: #e0507a;
  --chart-series-8: #a0662d;
  --chart-good: #0ca30c;
  --chart-warning: #fab219;
  --chart-critical: #d03b3b;
  --chart-grid: #e1e0d9;
  --chart-axis: #898781;
}

/* Light is the unconditional primary theme — dark only ever applies via an
   explicit data-theme="dark" attribute (set by the toggle), never from the
   OS's prefers-color-scheme, so there's no flash-of-dark on dark-OS machines. */
:root[data-theme="dark"] {
  --background: #0b0c14; --surface: #14151f; --surface-muted: #1b1d2b;
  --foreground: #f0f1f8; --muted-foreground: #9498b0; --border: #262841;
  --primary: #6366f1; --primary-dark: #818cf8; --primary-foreground: #ffffff; --primary-soft: #21223d;
  --accent: #2dd4bf; --accent-soft: #102a2a;
  --success: #4ade80; --success-soft: #10231a;
  --warning: #fbbf24; --warning-soft: #2a2110;
  --danger: #f87171; --danger-soft: #2a1414;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.35);
  --shadow-md: 0 6px 16px -6px rgb(0 0 0 / 0.5), 0 2px 5px -2px rgb(0 0 0 / 0.28);
  --shadow-lg: 0 16px 36px -10px rgb(0 0 0 / 0.6), 0 4px 10px -4px rgb(0 0 0 / 0.35);
  --shadow-glow: 0 4px 16px -2px rgb(99 102 241 / 0.35);
  --chart-series-1: #3987e5; --chart-series-2: #d95926; --chart-series-3: #199e70; --chart-series-4: #c98500;
  --chart-series-5: #a78bfa; --chart-series-6: #14b8a6; --chart-series-7: #f472b6; --chart-series-8: #c2884f;
  --chart-good: #0ca30c; --chart-warning: #fab219; --chart-critical: #e66767;
  --chart-grid: #2c2c2a; --chart-axis: #898781;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  background: var(--background);
  color: var(--foreground);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.015em; }
h1 { font-size: 1.375rem; }
h2 { font-size: 1rem; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--muted-foreground); font-size: 0.875rem; }
.error-text { color: var(--danger); font-size: 0.8125rem; margin: 0.25rem 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* View content fades in gently each time the router swaps it */
@keyframes viewFadeIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
.view > * { animation: viewFadeIn 0.2s ease both; }

/* Shared loading placeholder (see LOADING_HTML in app-lib.js) — a shimmer
   skeleton instead of bare "Loading…" text, used everywhere a page or
   modal is waiting on its first fetch. */
@keyframes skeletonPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.loading-skeleton { display: flex; flex-direction: column; gap: 0.65rem; padding: 0.15rem 0; }
.loading-skeleton-line {
  height: 0.8rem; width: 40%; border-radius: var(--radius-sm);
  background: var(--surface-muted); animation: skeletonPulse 1.1s ease-in-out infinite;
}
.loading-skeleton-heading { height: 1.05rem; width: 34%; }
@media (prefers-reduced-motion: reduce) { .loading-skeleton-line { animation: none; opacity: 0.7; } }

/* ---- shared building blocks -------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.input, select.input, textarea.input {
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--foreground);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  outline: none;
  width: 100%;
  margin: 0.25rem 0 0.75rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input:hover:not(:focus) { border-color: color-mix(in srgb, var(--border) 60%, var(--muted-foreground)); }
label { font-size: 0.8rem; font-weight: 600; color: var(--muted-foreground); letter-spacing: 0.01em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  border: none; border-radius: var(--radius-sm); padding: 0.5rem 0.9rem;
  font-size: 0.85rem; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: box-shadow 0.15s ease, opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 1px 2px rgb(23 24 50 / 0.06);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-primary:active { background: var(--primary-dark); box-shadow: none; transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-secondary { background: var(--surface-muted); color: var(--foreground); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-secondary:active { transform: translateY(0); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { filter: brightness(0.97); }
.btn-block { width: 100%; }
.btn-outline {
  background: var(--warning-soft); color: color-mix(in srgb, var(--warning) 70%, black); border: 1px solid var(--warning);
}
.btn-outline:hover { background: color-mix(in srgb, var(--warning) 18%, var(--warning-soft)); }
.btn-accent {
  background: var(--accent); color: var(--primary-foreground);
  box-shadow: 0 1px 2px rgb(23 24 50 / 0.06);
}
.btn-accent:hover { filter: brightness(0.94); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-accent:active { transform: translateY(0); }
.btn-lg { padding: 0.65rem 1.35rem; font-size: 0.9rem; border-radius: var(--radius-md); }
.btn-soon-badge {
  display: inline-block; font-size: 0.6rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  background: rgba(255,255,255,0.25); padding: 0.1rem 0.4rem; border-radius: 999px; margin-left: 0.35rem;
}
.btn-link { background: none; border: none; color: var(--muted-foreground); font-size: 0.85rem; cursor: pointer; padding: 0.45rem 0.65rem; border-radius: var(--radius-sm); transition: background 0.15s ease, color 0.15s ease; }
.btn-link:hover { background: var(--surface-muted); color: var(--foreground); }
.btn-whatsapp { background: color-mix(in srgb, #25d366 18%, var(--surface)); color: #1a7a43; }
.btn-whatsapp:hover { background: color-mix(in srgb, #25d366 28%, var(--surface)); }
:root[data-theme="dark"] .btn-whatsapp { color: #4ade80; }

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--surface); color: var(--muted-foreground);
  cursor: pointer; transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.icon-btn:hover { background: var(--surface-muted); color: var(--primary); border-color: var(--primary-soft); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0); }
.icon-btn.notify-active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-soft); }

.pill { display: inline-flex; align-items: center; gap: 0.3rem; border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.01em; }
.pill-primary { background: var(--primary-soft); color: var(--primary); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-secondary { background: var(--surface-muted); color: var(--muted-foreground); }

/** Small clickable pill actions (e.g. Edit/Delete on a card) — same shape as the status .pill above, but interactive. */
.pill-action { cursor: pointer; border: none; font-size: 0.7rem; padding: 0.32rem 0.8rem; transition: filter 0.15s ease, background 0.15s ease, border-color 0.15s ease; }
.pill-action:hover { filter: brightness(0.96); }
/* An unselected tab/preset pill (Pending Approval vs History, the
   Overview date-range presets, etc.) uses .pill-secondary, whose flat
   var(--surface-muted) fill is nearly the same color as the page
   background — with no border it read as plain gray text instead of a
   clickable control. A visible border fixes that without touching the
   plain (non-interactive) status pills elsewhere that also use
   .pill-secondary but aren't buttons. */
.pill-action.pill-secondary { background: var(--surface); border: 1.5px solid var(--border); }
.pill-action.pill-secondary:hover { background: var(--surface-muted); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); color: var(--foreground); }

/* Whole-card stage coloring for job cards (Process Manager board etc.) */
.stage-card-primary { background: var(--surface); border-left: 3px solid var(--primary); }
.stage-card-accent { background: var(--surface); border-left: 3px solid var(--accent); }
.stage-card-warning { background: var(--surface); border-left: 3px solid var(--warning); }
.stage-card-success { background: var(--surface); border-left: 3px solid var(--success); }
.stage-card-danger { background: var(--surface); border-left: 3px solid var(--danger); }
.job-card { cursor: pointer; transition: box-shadow 0.15s ease, transform 0.15s ease; }
.job-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.job-card .btn, .job-card select, .job-card input { cursor: auto; }
.job-card-thumb { width: 40px; height: 40px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }

.ready-banner {
  background: var(--success-soft);
  border: 1px solid var(--success); border-radius: var(--radius-md); padding: 0.75rem 1rem; margin: 0.85rem 0;
}
.ready-banner strong { color: var(--success); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 11, 20, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem;
  animation: fadeIn 0.15s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: scale(0.98) translateY(4px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-card { max-width: 480px; width: 100%; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: modalIn 0.16s ease both; }
.modal-close { float: right; background: none; border: none; font-size: 1.35rem; line-height: 1; cursor: pointer; color: var(--muted-foreground); transition: color 0.15s ease; }
.modal-close:hover { color: var(--danger); }

/* ---- Drag-and-drop reference image upload -------------------------- */
.dropzone {
  position: relative; border: 1.5px dashed var(--border); border-radius: var(--radius-md);
  padding: 0.85rem; text-align: center; cursor: pointer; min-height: 84px;
  display: flex; align-items: center; justify-content: center; background: var(--surface-muted);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone.dropzone-drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone-empty { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; color: var(--muted-foreground); font-size: 0.76rem; pointer-events: none; }
.dropzone-icon { font-size: 1.4rem; }
.dropzone-preview-wrap { position: relative; pointer-events: none; }
.dropzone-preview { max-height: 90px; max-width: 100%; border-radius: var(--radius-sm); object-fit: contain; display: block; }
.dropzone-replace-hint { font-size: 0.68rem; color: var(--muted-foreground); margin-top: 0.3rem; }
.dropzone-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.dropzone-uploading { font-size: 0.78rem; color: var(--primary); font-weight: 500; pointer-events: none; }

/* Date-range dropdown (renderDateRangeDropdown in app-lib.js) — the preset
   list inside the open menu. */
.drp-item {
  text-align: left; padding: 0.5rem 0.85rem; border: none; background: none;
  cursor: pointer; font-size: 0.85rem; color: var(--foreground); font-family: inherit;
}
.drp-item:hover { background: var(--primary-soft); }

.data-tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.85rem; }

.approval-thumb {
  width: 3.1rem; height: 3.1rem; object-fit: cover; border-radius: var(--radius-sm);
  border: 1px solid var(--border); cursor: pointer; transition: border-color 0.15s ease;
}
.approval-thumb:hover { border-color: var(--primary); }

/* Approvals card's action panel — Approve/Reject read as the one real
   decision here (equal-weight primary + a quiet outlined danger, not two
   competing filled buttons), with Edit/Delete demoted to small ghost
   actions below a soft divider instead of sharing the same visual weight.
   No boxed background anymore — the divider alone separates it from the
   card's details above, same language as .followup-actions elsewhere. */
.approval-actions { margin-top: auto; padding-top: 0.75rem; border-top: 1px dashed var(--border); }
.approval-actions-primary { display: flex; gap: 0.5rem; }
.approval-actions-primary .btn { flex: 1; padding: 0.55rem 1rem; }
.btn-danger-ghost {
  background: var(--surface); color: var(--danger);
  border: 1.5px solid color-mix(in srgb, var(--danger) 38%, var(--border));
}
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger); }
.approval-actions-secondary {
  display: flex; justify-content: center; gap: 0.35rem; margin-top: 0.55rem; padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.approval-actions-secondary .pill-action { background: transparent; box-shadow: none; color: var(--muted-foreground); }
.approval-actions-secondary .pill-action:hover { background: var(--surface-muted); color: var(--foreground); }
.approval-actions-secondary .pill-danger.pill-action:hover { background: var(--danger-soft); color: var(--danger); }

/* Public tracking page: reference images render as a CSS background (not
   an <img>) specifically so a visitor's long-press on mobile has no image
   to attach "Save image / Copy image / Search with Google Lens" to — that
   context menu is a browser feature tied to real <img> elements, so a div
   never offers it. Combined with the disabled right-click/long-press menu
   and disabled selection/drag below, this keeps a casual visitor from
   walking off with the shop's reference art via the tracking page. */
.ref-img-protected {
  width: 100%; height: 160px; margin-top: 0.5rem; border-radius: var(--radius-sm);
  background-color: var(--muted, #f4f4f5); background-size: contain; background-repeat: no-repeat; background-position: center;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none;
}

/* ---- Payment follow-up (Receptionist) ------------------------------ */
/* Grid items stretch to the tallest card in their row by default, but a
   card's own content was left top-aligned inside that extra height — so
   two cards side by side with a different number of lines above (an extra
   reference thumbnail, a longer name, "no images attached" vs an image
   row) put their action buttons at different heights instead of lining up
   across the row. Each card is a flex column now, with its action block
   pushed to the bottom via margin-top:auto, so every card's buttons sit on
   the same baseline regardless of how much it has above them. */
.followup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 0.85rem; align-items: stretch; }
.followup-card { display: flex; flex-direction: column; transition: box-shadow 0.15s ease, transform 0.15s ease; }
.followup-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.followup-avatar {
  width: 2.1rem; height: 2.1rem; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.78rem;
}
.followup-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: auto; padding-top: 0.65rem; border-top: 1px dashed var(--border); }
.followup-actions .btn { padding: 0.38rem 0.65rem; font-size: 0.76rem; }

/* ---- Notes -------------------------------------------------------- */
.note-composer { position: relative; overflow: hidden; }
.note-composer::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: var(--primary);
}
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.85rem; }
.notes-sheet th, .notes-sheet td { border-right: 1px solid var(--border); vertical-align: top; }
.notes-sheet th:last-child, .notes-sheet td:last-child { border-right: none; }
.notes-sheet tbody tr:nth-child(even) { background: var(--surface-muted); }
.notes-sheet tbody tr:hover { background: var(--primary-soft); }
.note-card {
  position: relative; padding-left: 1.05rem; transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.note-card::before {
  content: ''; position: absolute; left: 0; top: 0.85rem; bottom: 0.85rem; width: 3px; border-radius: 999px;
  background: var(--note-accent, var(--primary));
}
.note-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.note-card-body { white-space: pre-wrap; font-size: 0.875rem; line-height: 1.5; }
.note-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px dashed var(--border); }

/* A filter bar's whole point is inputs sitting next to each other, not
   stacked — but .input's base style is width:100% (correct for an
   ordinary form field), which inside this flex row makes every field
   claim the full row width and wrap onto its own line. This generic rule
   gives EVERY .input/select.input directly inside .filter-bar a sane flex
   basis instead, so any current or future filter bar lays out inline by
   default — not just the two IDs (#fbSearch/#fbFrom/#fbTo) from the one
   call site that originally had this fixed by hand. */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem; margin-bottom: 0.85rem; }
.filter-bar > .input, .filter-bar > select.input, .filter-bar > input.input { width: auto; flex: 1 1 170px; margin: 0; }
.filter-bar > .ms-details { flex: 1 1 170px; }

/* Checklist multi-select — a native <details>/<summary> disclosure (no
   popover-positioning JS, no click-outside handling needed: the browser
   already does both) styled to look like one of this app's .input fields
   until opened. Used where a filter needs to pick several values at once
   (e.g. Raw Material Intake History's Material/Category filters) instead
   of the single-value <select> used elsewhere. */
.ms-details { position: relative; }
.ms-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 0.4rem;
  cursor: pointer; user-select: none; list-style: none;
}
.ms-summary::-webkit-details-marker { display: none; }
.ms-summary::after { content: '▾'; color: var(--muted-foreground); font-size: 0.7rem; flex-shrink: 0; }
.ms-details[open] .ms-summary { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.ms-panel {
  position: absolute; z-index: 20; top: calc(100% + 0.3rem); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); padding: 0.35rem; max-height: 14rem; overflow-y: auto;
}
.ms-option {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.4rem 0.5rem;
  font-size: 0.85rem; font-weight: 400; color: var(--foreground); border-radius: var(--radius-sm);
  cursor: pointer; text-transform: none; letter-spacing: normal;
}
.ms-option:hover { background: var(--surface-muted); }
.ms-option input[type="checkbox"] { width: auto; margin: 0; flex-shrink: 0; }

/* Raw Material Intake History's multi-section filter panel — reuses
   .ms-details/.ms-panel/.ms-option (Filters button + dropdown, checkbox
   rows) but needs its own width/height since it holds several filter
   groups (Material, Category, Stock Status, ranges, Recorded By) instead
   of one flat checklist. Right-anchored + viewport-capped width so it
   never overflows off-screen on narrow phones. */
.rmi-filter-panel {
  left: auto; right: 0; width: 21rem; max-width: calc(100vw - 2rem);
  max-height: 26rem; overflow-y: auto; padding: 0.6rem;
}
.rmi-filter-section { padding: 0.5rem 0.15rem; border-bottom: 1px solid var(--border); }
.rmi-filter-section:last-of-type { border-bottom: none; }
.rmi-filter-section > label:first-child {
  display: block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted-foreground);
}
.rmi-filter-scroll { max-height: 8rem; overflow-y: auto; }
.filter-bar #fbSearch { flex: 2 1 220px; }
.filter-bar #fbFrom, .filter-bar #fbTo { flex: 1 1 140px; }
.filter-bar-sep { flex: 0 0 auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
th { text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-foreground); font-weight: 700; padding: 0.6rem 0.85rem; border-bottom: 1.5px solid var(--border); }
td { padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--surface-muted); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; margin-top: 0.85rem; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-value { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-value.danger { color: var(--danger); }
.stat-label { margin-top: 0.25rem; font-size: 0.72rem; color: var(--muted-foreground); font-weight: 500; }

/* ---- hand-rolled charts (Admin Overview) ------------------------------ */
.chart-track { flex: 1; background: var(--surface-muted); border-radius: 999px; height: 0.75rem; overflow: hidden; }
.chart-fill-h { height: 100%; border-radius: 999px; transition: width 0.5s ease; }
.chart-fill-v { border-radius: 4px 4px 0 0; transition: height 0.5s ease; margin: 0 auto; }
.donut-ring { width: 120px; height: 120px; border-radius: 50%; position: relative; flex-shrink: 0; box-shadow: var(--shadow-sm); transition: background 0.3s ease; }
.donut-center { position: absolute; inset: 18px; border-radius: 50%; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: inset 0 1px 3px rgb(0 0 0 / 0.07); padding: 0 6px; box-sizing: border-box; }
.donut-center strong { font-size: 1.1rem; letter-spacing: -0.01em; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: clip; }
.legend-dot { width: 0.6rem; height: 0.6rem; border-radius: 3px; display: inline-block; flex-shrink: 0; }

/* ---- login screen ----------------------------------------------------
   A restrained split-panel layout (the same pattern most professional
   SaaS logins use — one solid brand-color panel + one plain form panel)
   instead of the old single centered card. Below 900px the brand panel
   collapses away entirely and only the form panel shows (full-width,
   with its own compact logo) — see login-logo-lg/login-logo-mobile. */
.login-screen { min-height: 100vh; display: flex; }
.login-brand-panel {
  display: none; position: relative; overflow: hidden; flex: 1 1 42%; max-width: 34rem;
  background: var(--primary); color: #fff;
  align-items: center; justify-content: center; padding: 3rem;
}
@media (min-width: 900px) { .login-brand-panel { display: flex; } }
.login-brand-dots {
  position: absolute; inset: 0;
  background-image: radial-gradient(color-mix(in srgb, white 22%, transparent) 1.5px, transparent 1.5px);
  background-size: 22px 22px; opacity: 0.35; pointer-events: none;
  mask-image: radial-gradient(circle at 30% 30%, black, transparent 75%);
}
.login-brand-inner { position: relative; z-index: 1; max-width: 24rem; }
.login-brand-inner h1 { font-size: 1.75rem; color: #fff; margin-top: 1.25rem; }
.login-brand-inner p { color: color-mix(in srgb, white 82%, transparent); margin-top: 0.6rem; font-size: 0.95rem; line-height: 1.55; }
.login-feature-list { list-style: none; margin: 1.75rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.login-feature-list li { display: flex; align-items: center; gap: 0.6rem; font-size: 0.875rem; color: color-mix(in srgb, white 92%, transparent); }
.login-feature-check {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 1.35rem; height: 1.35rem; border-radius: 50%;
  background: color-mix(in srgb, white 18%, transparent); font-size: 0.7rem; font-weight: 800;
}
.login-form-panel {
  position: relative; flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem; background: var(--background);
}
.login-card {
  position: relative; z-index: 1; width: 100%; max-width: 380px; text-align: center;
  padding: 2rem 1.85rem; border: none; box-shadow: none; background: transparent;
}
@media (min-width: 640px) { .login-card { border: 1px solid var(--border); box-shadow: var(--shadow-sm); background: var(--surface); } }
@media (max-width: 400px) { .login-card { padding: 1.5rem 1.1rem; } }
.login-logo-lg { width: 3.5rem; height: 3.5rem; background: color-mix(in srgb, white 18%, transparent); }
.login-logo-mobile { margin-bottom: 1rem; }
@media (min-width: 900px) { .login-logo-mobile { display: none; } }
.login-track-link { margin-top: 1rem; }
.login-theme-toggle { position: absolute; top: 1.25rem; right: 1.25rem; z-index: 2; }

/* ---- customer order-tracking page ------------------------------------ */
.track-hero {
  position: relative; overflow: hidden; padding: 2.75rem 1.5rem 3.5rem;
  background:
    radial-gradient(circle at 15% 20%, color-mix(in srgb, var(--primary) 10%, transparent), transparent 45%),
    radial-gradient(circle at 85% 30%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 45%),
    var(--background);
  text-align: center;
}
.track-hero-content { position: relative; z-index: 1; max-width: 30rem; margin: 0 auto; }
.track-hero .brand-mark { margin: 0 auto 1rem; }
.track-hero h1 { font-size: 1.6rem; }
.track-page { max-width: 40rem; margin: -2.25rem auto 3rem; padding: 0 1.25rem; position: relative; z-index: 2; }
.track-form-card { text-align: left; }

.login-logo {
  width: 3rem; height: 3rem; margin: 0 auto 1rem; border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-foreground); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.05rem; overflow: hidden;
}
.login-logo img, .brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.login-logo:has(img), .brand-mark:has(img) { background: none; }
.login-card h1 { font-size: 1.4rem; margin-bottom: 0.3rem; }
.login-card form { text-align: left; margin-top: 1.35rem; }

/* ---- app shell -------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  display: flex; width: 14.5rem; flex-direction: column; border-right: 1px solid var(--border);
  background: var(--surface); padding: 1.25rem 0.85rem;
  position: fixed; inset: 0 auto 0 0; z-index: 60; transform: translateX(-100%);
  transition: transform 0.22s ease, width 0.18s ease;
  overflow-x: hidden; overflow-y: auto;
}
.sidebar.sidebar-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
@media (min-width: 640px) {
  .sidebar { position: static; transform: none; box-shadow: none; }
}
/* Desktop-only icon-rail state, toggled by #sidebarCollapseBtn (app.js's
   wireSidebarCollapse) — a per-viewer localStorage preference, unrelated to
   the mobile slide-in drawer above. */
.sidebar.sidebar-collapsed { width: 4.25rem; padding-left: 0.6rem; padding-right: 0.6rem; }
.sidebar-collapsed .sidebar-brand span,
.sidebar-collapsed .sidebar-nav-label,
.sidebar-collapsed .sidebar-user-name,
.sidebar-collapsed .sidebar-user .muted { display: none; }
.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
.sidebar-collapsed .sidebar-nav a { justify-content: center; padding: 0.55rem; }
.sidebar-collapsed .sidebar-nav a.active::before { left: -0.6rem; }
.sidebar-collapsed .sidebar-user { display: flex; justify-content: center; padding: 0.6rem; }
.sidebar-user-avatar { display: none; margin: 0 auto; }
.sidebar-collapsed .sidebar-user-avatar { display: flex; }
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(10, 11, 20, 0.5); z-index: 50;
  animation: fadeIn 0.15s ease both;
}
.sidebar-backdrop.sidebar-backdrop-open { display: block; }
@media (min-width: 640px) { .sidebar-backdrop { display: none !important; } }
.mobile-menu-toggle { display: flex; }
@media (min-width: 640px) { .mobile-menu-toggle { display: none; } }
.sidebar-collapse-btn { display: none; }
@media (min-width: 640px) { .sidebar-collapse-btn { display: flex; } }
.sidebar-brand { display: flex; align-items: center; gap: 0.55rem; padding: 0 0.4rem; margin-bottom: 1.5rem; }
.brand-mark { width: 2rem; height: 2rem; border-radius: var(--radius-md); background: var(--primary); color: var(--primary-foreground); display: flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 800; overflow: hidden; flex-shrink: 0; }
.sidebar-brand span { font-size: 0.9rem; font-weight: 700; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 0.65rem; position: relative; border-radius: var(--radius-sm); padding: 0.5rem 0.7rem;
  font-size: 0.84rem; font-weight: 500; color: var(--muted-foreground); text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-nav-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 1.125rem; height: 1.125rem; }
.sidebar-nav-icon svg { width: 100%; height: 100%; }
.sidebar-nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-nav a:hover { background: var(--surface-muted); color: var(--foreground); }
.sidebar-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar-nav a.active::before {
  content: ''; position: absolute; left: -0.85rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: var(--primary); border-radius: 0 3px 3px 0;
}
.sidebar-user { margin-top: auto; border-radius: var(--radius-md); background: var(--surface-muted); padding: 0.7rem; font-size: 0.75rem; }
.sidebar-user-name { font-weight: 600; color: var(--foreground); }

.main-column { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; border-bottom: 1px solid var(--border); background: var(--surface); padding: 0.65rem 1rem; position: relative; z-index: 5; }
@media (min-width: 640px) { .topbar { padding: 0.65rem 1.5rem; } }
.topbar-left { display: flex; align-items: center; gap: 0.6rem; min-width: 0; flex: 1; }
.topbar-title { font-size: 0.95rem; font-weight: 700; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.sync-status { display: none; align-items: center; gap: 0.4rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); padding: 0.32rem 0.7rem; font-size: 0.72rem; font-weight: 600; }
@media (min-width: 900px) { .sync-status { display: flex; } }
.sync-dot { width: 0.45rem; height: 0.45rem; border-radius: 999px; background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 20%, transparent); }
.sync-status.offline .sync-dot { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }
.sync-status.offline #syncStatusText { color: var(--danger); }

.view { flex: 1; min-width: 0; overflow-x: hidden; overflow-y: auto; padding: 1.35rem 1rem; }
@media (min-width: 640px) { .view { padding: 1.5rem 1.5rem; } }

.flex-row { display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0.85rem; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-foreground); }

/* ---------------------------------------------------------------------
   In-app toast — a push notification's twin shown inside the dashboard
   itself for whoever's already looking at it, since some browsers
   suppress the OS notification banner entirely while the tab is focused.
   ------------------------------------------------------------------- */
.toast-container {
  position: fixed; top: 1rem; right: 1rem; z-index: 1000;
  display: flex; flex-direction: column; gap: 0.55rem;
  max-width: min(360px, calc(100vw - 2rem));
  pointer-events: none;
}
@media (max-width: 640px) { .toast-container { top: auto; bottom: 1rem; right: 1rem; left: 1rem; max-width: none; } }

.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 0.6rem;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  padding: 0.75rem 0.85rem; cursor: pointer;
  opacity: 0; transform: translateX(20px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
@media (max-width: 640px) { .toast { transform: translateY(20px); } }
.toast.toast-visible { opacity: 1; transform: translateX(0); }
@media (max-width: 640px) { .toast.toast-visible { transform: translateY(0); } }

.toast-icon { font-size: 1.1rem; line-height: 1; flex-shrink: 0; margin-top: 0.1rem; }
.toast-content { flex: 1; min-width: 0; }
.toast-title { font-weight: 700; font-size: 0.82rem; color: var(--foreground); }
.toast-body { font-size: 0.78rem; color: var(--muted-foreground); margin-top: 0.15rem; word-break: break-word; }
.toast-close {
  flex-shrink: 0; background: none; border: none; cursor: pointer; color: var(--muted-foreground);
  font-size: 1.1rem; line-height: 1; padding: 0.1rem 0.2rem; border-radius: var(--radius-sm);
}
.toast-close:hover { background: var(--surface-muted); color: var(--foreground); }

/* ---------------------------------------------------------------------
   Order Journey timeline — the customer tracking page's visual stepper
   through Quote Created → Approved → Assigned → In Production → Ready →
   Delivered (or a Rejected/Cancelled dead-end). Vertical, one checkpoint
   below the next — every step is visible at once with no scrolling
   needed, unlike a cramped horizontal row would be on a phone.
   ------------------------------------------------------------------- */
.timeline { display: flex; flex-direction: column; padding: 0.25rem 0; }
.timeline-step { display: flex; align-items: flex-start; gap: 0.85rem; }
.timeline-dot-col { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.timeline-dot {
  width: 1.75rem; height: 1.75rem; border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700;
  border: 2px solid var(--border); background: var(--surface); color: var(--muted-foreground);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.timeline-step-done .timeline-dot { background: var(--success); border-color: var(--success); color: #fff; }
.timeline-step-current .timeline-dot {
  background: var(--primary-soft); border-color: var(--primary); color: var(--primary);
  animation: timeline-pulse 1.8s ease-in-out infinite;
}
.timeline-step-rejected .timeline-dot, .timeline-step-cancelled .timeline-dot { background: var(--danger); border-color: var(--danger); color: #fff; }

.timeline-connector { width: 2px; flex: 1 1 auto; min-height: 1.5rem; margin: 0.15rem 0; background: var(--border); }
.timeline-connector-done { background: var(--success); }

.timeline-label { font-size: 0.83rem; padding: 0.3rem 0 0.9rem; color: var(--muted-foreground); line-height: 1.3; }
.timeline-step-done .timeline-label, .timeline-step-current .timeline-label { color: var(--foreground); font-weight: 600; }
.timeline-step-rejected .timeline-label, .timeline-step-cancelled .timeline-label { color: var(--danger); font-weight: 600; }
.timeline-step:last-child .timeline-label { padding-bottom: 0; }

@keyframes timeline-pulse {
  0%, 100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
  50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--primary) 8%, transparent); }
}

/* ---- Week-wise Attendance ------------------------------------------- */
.attendance-grid-wrap { overflow-x: auto; }
.attendance-grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.8125rem; }
.attendance-grid th, .attendance-grid td { padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; }
.attendance-grid thead th { text-align: center; }
.attendance-grid .attendance-emp-col {
  text-align: left; position: sticky; left: 0; z-index: 2; background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
}
.attendance-grid tbody tr:hover .attendance-emp-col { background: var(--surface-muted); }
.attendance-emp-btn {
  display: flex; align-items: center; gap: 0.55rem; background: none; border: none; padding: 0.2rem 0;
  cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%;
}
.attendance-emp-btn:hover .attendance-emp-name { color: var(--primary); }
.attendance-emp-name { font-weight: 600; transition: color 0.15s ease; }
.attendance-day-head { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; padding: 0.2rem 0; }
.attendance-day-name { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-foreground); font-weight: 700; }
.attendance-day-date { font-size: 0.9rem; font-weight: 700; }
.attendance-day-today .attendance-day-name, .attendance-day-today .attendance-day-date { color: var(--primary); }
.attendance-col-today { background: color-mix(in srgb, var(--primary) 6%, transparent); }
.attendance-today-pill { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.03em; color: var(--primary); }

.attendance-cell-btn {
  width: 2.35rem; height: 2.35rem; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.66rem; font-weight: 700;
  cursor: pointer; color: var(--muted-foreground); transition: box-shadow 0.12s ease, border-color 0.12s ease;
}
.attendance-cell-btn:hover { box-shadow: var(--shadow-sm); border-color: var(--primary); }
.attendance-cell-btn.att-full { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.attendance-cell-btn.att-half { background: var(--warning-soft); border-color: var(--warning); color: var(--warning); }
.attendance-cell-btn.att-onehalf { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.attendance-cell-btn.att-two { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.attendance-cell-btn.att-absent { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.attendance-popover {
  position: fixed; z-index: 200; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); padding: 0.4rem; min-width: 180px; animation: attendance-pop-in 0.1s ease;
}
@keyframes attendance-pop-in { from { opacity: 0; transform: scale(0.97) translateY(-2px); } to { opacity: 1; transform: none; } }
.attendance-popover-title { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-foreground); font-weight: 700; padding: 0.4rem 0.6rem 0.3rem; }
.attendance-popover-option {
  display: flex; align-items: center; gap: 0.55rem; width: 100%; text-align: left; background: none; border: none;
  padding: 0.5rem 0.6rem; border-radius: var(--radius-sm); cursor: pointer; font: inherit; color: var(--foreground);
}
.attendance-popover-option:hover { background: var(--surface-muted); }
.attendance-popover-option.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.attendance-popover-swatch { width: 0.8rem; height: 0.8rem; border-radius: 50%; flex-shrink: 0; }
.attendance-popover-clear { border-top: 1px dashed var(--border); margin-top: 0.3rem; padding-top: 0.4rem; }

.attendance-progress-track { width: 100%; height: 0.55rem; border-radius: 999px; background: var(--surface-muted); overflow: hidden; }
.attendance-progress-fill { height: 100%; border-radius: 999px; background: var(--primary); transition: width 0.3s ease; }
.attendance-week-nav-label { font-weight: 700; font-size: 0.9rem; min-width: 200px; text-align: center; }

@media (max-width: 640px) {
  .attendance-cell-btn { width: 2rem; height: 2rem; font-size: 0.6rem; }
  .attendance-week-nav-label { min-width: 150px; font-size: 0.8rem; }
}

/* =====================================================================
   TOUCH-FIRST DESIGN LAYER (applies to every screen)
   One consistent system: 44px minimum touch targets, 48-56px for primary
   actions, 16px inputs (no iOS zoom-on-focus), bottom sheets on phones,
   filter chips, empty states, and the POS layout. Loaded last so it
   lifts the whole app without rewriting each page's markup.
   ===================================================================== */
:root { --touch: 44px; --touch-lg: 52px; }

.btn { min-height: var(--touch); padding: 0.55rem 1rem; font-size: 0.9rem; }
.btn-lg, .btn-touch { min-height: var(--touch-lg); padding: 0.7rem 1.3rem; font-size: 0.95rem; border-radius: var(--radius-md); }
.btn-xl { min-height: 60px; font-size: 1.05rem; font-weight: 700; border-radius: var(--radius-lg); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { filter: brightness(0.94); }
.btn:focus-visible, .chip:focus-visible, .qty-btn:focus-visible, .pos-card:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }
.btn-link { min-height: var(--touch); }
.icon-btn { width: var(--touch); height: var(--touch); }

.input, select.input, textarea.input { min-height: var(--touch); font-size: 16px; padding: 0.6rem 0.8rem; }
textarea.input { min-height: 72px; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; accent-color: var(--primary); }
.field-label { display: block; margin-top: 0.5rem; }
.req { color: var(--danger); }

.sidebar-nav a { min-height: var(--touch); }
td a, .pill-action { display: inline-flex; align-items: center; min-height: 36px; }
td a { padding: 0.25rem 0.1rem; }
.pill-action { padding: 0.4rem 0.9rem; font-size: 0.78rem; }

/* Toast variants (notify()) - the existing .toast is the base. */
.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { color: var(--success); font-weight: 800; }
.toast-warning { border-left-color: var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { color: var(--danger); }
.toast-title { font-weight: 700; font-size: 0.86rem; }
.toast-body { font-size: 0.8rem; color: var(--muted-foreground); margin-top: 0.1rem; }
.toast-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--muted-foreground); min-width: 32px; min-height: 32px; }

/* Sheets: centred modal on desktop, bottom sheet on phones. */
.sheet-card { max-width: 520px; }
.sheet-card.sheet-wide { max-width: 760px; }
.sheet-title { font-size: 1.15rem; font-weight: 700; }
.sheet-grabber { display: none; }
.sheet-actions { display: flex; gap: 0.6rem; margin-top: 1.1rem; }
.sheet-actions .btn { flex: 1; }
@keyframes sheetUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 640px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-card { max-width: none !important; width: 100%; max-height: 92vh; border-radius: 1.1rem 1.1rem 0 0; padding-bottom: calc(1.1rem + env(safe-area-inset-bottom)); animation: sheetUp 0.2s ease both; }
  .sheet-grabber { display: block; width: 44px; height: 5px; border-radius: 999px; background: var(--border); margin: -0.35rem auto 0.8rem; }
}

/* Filter chips */
.chip-row { display: flex; gap: 0.45rem; overflow-x: auto; padding: 0.15rem 0 0.35rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chip-row::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; padding: 0.45rem 1rem; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); color: var(--foreground); font-size: 0.85rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.chip-active { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.chip-count { display: inline-block; min-width: 1.4rem; padding: 0 0.35rem; margin-left: 0.25rem; border-radius: 999px; background: color-mix(in srgb, currentColor 15%, transparent); font-size: 0.72rem; }

.empty-state { text-align: center; padding: 2.5rem 1rem; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.empty-state-icon { font-size: 2.2rem; }
.empty-state-title { font-weight: 700; font-size: 1rem; }

/* Page header with a primary action on the right */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.stat-card { cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease; text-align: left; font: inherit; color: inherit; width: 100%; }
.stat-card:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); box-shadow: var(--shadow-md); }
.stat-card.is-active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }

/* Search box */
.search-box { position: relative; }
.search-box .search-icon { position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%); font-size: 0.95rem; pointer-events: none; opacity: 0.7; }
.search-box .search-input { padding-left: 2.4rem; margin: 0; min-height: var(--touch-lg); font-size: 16px; }

/* Product selector results */
.ps-results { margin-top: 0.4rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-md); max-height: 50vh; overflow-y: auto; }
.ps-row { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.7rem 0.9rem; border: none; border-bottom: 1px solid var(--border); background: none; text-align: left; font: inherit; color: inherit; min-height: 56px; }
.ps-item { cursor: pointer; }
.ps-item:hover, .ps-item:focus { background: var(--primary-soft); outline: none; }
.ps-main { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.ps-main .muted { font-size: 0.78rem; }
.ps-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; flex: none; }

/* Quantity stepper */
.qty-stepper { display: inline-flex; align-items: stretch; border: 1.5px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }
.qty-btn { width: var(--touch); min-height: var(--touch); border: none; background: var(--surface-muted); font-size: 1.25rem; font-weight: 700; cursor: pointer; color: var(--foreground); touch-action: manipulation; }
.qty-btn:active { background: var(--border); }
.qty-input { width: 3.2rem; border: none; text-align: center; font-size: 16px; font-weight: 700; background: transparent; color: var(--foreground); }
.qty-input:focus { outline: none; background: var(--primary-soft); }

/* Card list - the mobile replacement for wide tables */
.card-list { display: grid; gap: 0.6rem; }
@media (min-width: 900px) { .card-list.cols-2 { grid-template-columns: 1fr 1fr; } }
.row-card { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.9rem 1rem; }
.row-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.row-card-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.row-card-actions .btn { flex: 1 1 auto; min-height: 42px; padding: 0.45rem 0.8rem; font-size: 0.82rem; }

.offline-banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100; background: var(--danger); color: #fff; text-align: center; padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom)); font-weight: 600; font-size: 0.88rem; }

/* ---------------------------- POS ---------------------------------- */
.pos { display: grid; gap: 1rem; }
@media (min-width: 900px) { .pos { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; } }
@media (min-width: 1280px) { .pos { grid-template-columns: minmax(0, 1fr) 420px; } }
.pos-main { min-width: 0; }
.pos-toolbar { display: flex; flex-direction: column; gap: 0.6rem; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.65rem; margin-top: 0.75rem; }
@media (min-width: 1280px) { .pos-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); } }
.pos-card { display: flex; flex-direction: column; gap: 0.3rem; text-align: left; padding: 0.85rem; min-height: 132px; border: 1.5px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); cursor: pointer; font: inherit; color: inherit; touch-action: manipulation; transition: border-color 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease; position: relative; }
.pos-card:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); box-shadow: var(--shadow-md); }
.pos-card:active { transform: scale(0.98); }
.pos-card[disabled] { opacity: 0.55; cursor: not-allowed; }
.pos-card-name { font-weight: 700; font-size: 0.92rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding-right: 1.6rem; }
.pos-card-sku { font-size: 0.72rem; color: var(--muted-foreground); font-family: ui-monospace, monospace; }
.pos-card-price { font-size: 1.05rem; font-weight: 800; margin-top: auto; }
.pos-card-price small { font-weight: 500; color: var(--muted-foreground); font-size: 0.75rem; }
.pos-card-qty { position: absolute; top: 0.5rem; right: 0.5rem; min-width: 1.7rem; height: 1.7rem; border-radius: 999px; background: var(--primary); color: #fff; font-weight: 800; font-size: 0.8rem; display: flex; align-items: center; justify-content: center; padding: 0 0.4rem; }
.pos-more { margin-top: 0.75rem; text-align: center; }

.pos-cart { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
@media (min-width: 900px) { .pos-cart { position: sticky; top: 1rem; max-height: calc(100vh - 6rem); } }
.pos-cart-head { display: flex; justify-content: space-between; align-items: center; padding: 0.9rem 1rem; border-bottom: 1px solid var(--border); gap: 0.5rem; }
.pos-cart-head h2 { font-size: 1rem; margin: 0; }
.pos-customer { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.pos-customer-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; min-height: var(--touch-lg); padding: 0.5rem 0.8rem; border: 1.5px dashed var(--border); border-radius: var(--radius-md); background: var(--surface-muted); font: inherit; color: inherit; cursor: pointer; text-align: left; }
.pos-lines { overflow-y: auto; flex: 1; min-height: 120px; }
.pos-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.4rem 0.75rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.pos-line-name { font-weight: 600; font-size: 0.9rem; }
.pos-line-meta { font-size: 0.76rem; color: var(--muted-foreground); }
.pos-line-total { font-weight: 800; text-align: right; }
.pos-line-controls { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.pos-line-remove { min-width: var(--touch); min-height: var(--touch); border: none; background: none; color: var(--danger); font-size: 1.1rem; cursor: pointer; border-radius: var(--radius-sm); }
.pos-line-remove:hover { background: var(--danger-soft); }
.pos-line-warn { grid-column: 1 / -1; font-size: 0.76rem; color: var(--danger); font-weight: 600; }
.pos-price-input { width: 6.5rem; min-height: 40px !important; margin: 0 !important; text-align: right; }
.pos-totals { padding: 0.8rem 1rem; border-top: 1px solid var(--border); background: var(--surface-muted); display: grid; gap: 0.3rem; }
.pos-totals .row { display: flex; justify-content: space-between; align-items: center; font-size: 0.88rem; gap: 0.5rem; }
.pos-totals .grand { font-size: 1.35rem; font-weight: 800; padding-top: 0.3rem; }
.pos-pay { padding: 0.8rem 1rem calc(0.8rem + env(safe-area-inset-bottom)); }
.pos-kbd { font-size: 0.68rem; opacity: 0.75; font-weight: 600; margin-left: 0.35rem; }
.pos-cart-toggle { display: none; }
@media (max-width: 899px) {
  .pos-kbd { display: none; }
  .pos-cart-toggle { display: inline-flex; }
  .pos-cart { position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; border-radius: 1.1rem 1.1rem 0 0; box-shadow: 0 -10px 30px rgb(15 16 30 / 0.18); max-height: 88vh; }
  .pos-cart:not(.cart-open) .pos-customer, .pos-cart:not(.cart-open) .pos-lines, .pos-cart:not(.cart-open) .pos-totals { display: none; }
  .pos-cart .pos-cart-head { cursor: pointer; }
  .pos-main { padding-bottom: 150px; }
}
.pay-methods { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.5rem; margin-top: 0.4rem; }
.pay-method { min-height: 56px; border: 2px solid var(--border); border-radius: var(--radius-md); background: var(--surface); font: inherit; font-weight: 700; cursor: pointer; color: var(--foreground); }
.pay-method.selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.pay-amount { font-size: 1.6rem !important; font-weight: 800; text-align: right; min-height: 60px; }
.pay-quick { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.4rem; }
.pay-quick .btn { min-height: 40px; padding: 0.35rem 0.8rem; font-size: 0.82rem; }
.pay-summary { display: grid; gap: 0.35rem; margin-top: 0.8rem; padding: 0.8rem; border-radius: var(--radius-md); background: var(--surface-muted); }
.pay-summary .row { display: flex; justify-content: space-between; }
.pay-summary .big { font-size: 1.15rem; font-weight: 800; }
.sale-done { text-align: center; }
.sale-done-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--success-soft); color: var(--success); font-size: 2rem; font-weight: 800; display: flex; align-items: center; justify-content: center; margin: 0.25rem auto 0.6rem; }
.sale-done-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 1rem; }
.sale-done-actions .btn-primary { grid-column: 1 / -1; }

/* Stock / ledger */
.mv-in { color: var(--success); font-weight: 800; }
.mv-out { color: var(--danger); font-weight: 800; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; font-size: 0.88rem; margin: 0; }
.kv dt { color: var(--muted-foreground); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.table-wrap { overflow-x: auto; }
@media (max-width: 760px) { .hide-mobile { display: none !important; } }
@media (min-width: 761px) { .show-mobile { display: none !important; } }

/* The page fade-in leaves a transform on the view root, which would turn the
   mobile cart's position:fixed into position:relative-to-page. */
.pos { animation: none !important; transform: none !important; }

/* POS edit mode */
.pos-edit-banner { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.7rem 1rem; background: var(--accent-soft); border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); font-size: 0.9rem; }
