/* ============================================================
   Techelev8 POS — component system
   Depends on tokens.css. Every value here comes from a token.
   ============================================================ */

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4, h5 {
  margin: 0;
  font-weight: var(--weight-semi);
  line-height: var(--leading-tight);
  letter-spacing: -.014em;
  color: var(--text);
}
h1 { font-size: var(--text-h1); }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); }
p  { margin: 0 0 var(--s-3); }
a  { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-4) 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--r-xs); }
[hidden] { display: none !important; }
::selection { background: var(--brand-100); color: var(--brand-800); }

/* Money and quantities line up in columns. */
.num, .money, td.num, th.num { font-variant-numeric: tabular-nums; }

/* ---------- typography helpers ---------- */
.display  { font-size: var(--text-display); font-weight: var(--weight-bold); letter-spacing: -.03em; line-height: 1.1; }
.h1 { font-size: var(--text-h1); font-weight: var(--weight-semi); }
.h2 { font-size: var(--text-h2); font-weight: var(--weight-semi); }
.h3 { font-size: var(--text-h3); font-weight: var(--weight-semi); }
.body { font-size: var(--text-body); }
.small { font-size: var(--text-sm); }
.xs    { font-size: var(--text-xs); }
.cap {
  font-size: var(--text-cap); font-weight: var(--weight-semi);
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-3);
}
.muted  { color: var(--text-2); }
.dim    { color: var(--text-3); }
.strong { font-weight: var(--weight-semi); }
.bold   { font-weight: var(--weight-bold); }
.center { text-align: center; }
.right  { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-brand   { color: var(--brand); }

/* ---------- layout primitives ---------- */
.stack    { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s-6); }
.row      { display: flex; align-items: center; gap: var(--s-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.row-end  { display: flex; align-items: center; justify-content: flex-end; gap: var(--s-2); }
.wrap     { flex-wrap: wrap; }
.grow     { flex: 1 1 auto; min-width: 0; }
.grid     { display: grid; gap: var(--s-4); }
.grid-2   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3   { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4   { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto{ grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.divider  { height: 1px; background: var(--border); border: 0; margin: 0; }
.spacer   { flex: 1 1 auto; }

.container { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 0 var(--s-4); }
.page      { padding: var(--s-5) 0 var(--s-12); }
/* Visibility utilities have to beat whatever display a component sets — a
   ".list.only-mobile" was showing at every width because ".list { display:
   flex }" is declared later in this file. */
.only-mobile  { display: revert !important; }
.only-desktop { display: none !important; }
@media (min-width: 900px) {
  .only-mobile  { display: none !important; }
  .only-desktop { display: revert !important; }
  .container { padding: 0 var(--s-6); }
}
@media (max-width: 720px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Pages set bespoke two-column templates inline for desktop; on a phone
     every one of them becomes a single stack, so nothing scrolls sideways. */
  .grid[style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ---------- brand lockup ---------- */
/* One typeface, for the name only.
   The interface itself stays on the system stack: it renders on the first
   frame with no download, which matters on a till running over mobile data.
   The wordmark is the one place a real face earns its 12KB — it goes on
   receipts, emails and the sign-in screen, and the system font was too light
   to stand next to the mark. Self-hosted rather than pulled from Google so
   there is no third-party request and it still works offline in the app. */
@font-face {
  font-family: "Jakarta Brand";
  src: url("../fonts/plus-jakarta-sans-800.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;   /* the name shows immediately in the fallback, then swaps */
}
/* The 8 in "Techelev8" is the mark's own 8, drawn rather than typed, so the
   logo and the name share a letter. Sized from the surrounding type so it
   tracks whatever the wordmark is set at. */
.brand-eight {
  /* This one sits inside a word, so it opts out of the blanket `svg{display:
     block}` reset above — as a block it broke the line either side of itself.
     Width is stated rather than auto because an inline SVG given only a height
     falls back to the 300px default width. 0.573em is the 12:18 viewBox ratio. */
  display: inline-block;
  height: 0.86em; width: 0.573em;
  vertical-align: -0.085em;
  margin-left: 0.015em;
}
.brand-badge {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  background: var(--brand-gradient); color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 34%, transparent);
}
.brand-lockup { display: inline-flex; align-items: center; gap: var(--s-3); }
.brand-words  { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name {
  font-family: "Jakarta Brand", var(--font);
  font-size: 1.0625rem; font-weight: 800;
  letter-spacing: -.02em; color: var(--text); white-space: nowrap;
}
.brand-name-accent { color: var(--brand); font-weight: var(--weight-semi); }
.brand-sub { font-size: var(--text-xs); color: var(--text-3); white-space: nowrap; }
/* On a brand-coloured ground the badge would vanish into it, so it becomes
   a translucent white tile instead of a gradient one. */
.brand-lockup--invert .brand-badge {
  background: rgba(255, 255, 255, .18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
  color: #fff;
}
.brand-lockup--invert .brand-name { color: #fff; }
.brand-lockup--invert .brand-name-accent { color: rgba(255,255,255,.72); }
.brand-lockup--invert .brand-sub { color: rgba(255,255,255,.6); }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-flat  { box-shadow: none; }
.card-hover { transition: box-shadow var(--normal) var(--ease), transform var(--normal) var(--ease); }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card-pad  { padding: var(--s-5); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { font-size: var(--text-h3); }
.card-head .cap { margin: 0; }
.card-body { padding: var(--s-5); }
.card-body--tight { padding: var(--s-3) var(--s-5); }
.card-foot {
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* ---------- stat / KPI tiles ---------- */
.kpi {
  position: relative;
  display: flex; flex-direction: column; gap: var(--s-1);
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--normal) var(--ease), transform var(--normal) var(--ease);
}
.kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.kpi-icon {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  display: grid; place-items: center; flex: 0 0 auto;
  background: var(--brand-soft); color: var(--brand);
}
.kpi-icon--accent  { background: var(--accent-soft);  color: var(--accent); }
.kpi-icon--success { background: var(--success-soft); color: var(--success); }
.kpi-icon--warning { background: var(--warning-soft); color: var(--warning); }
.kpi-icon--danger  { background: var(--danger-soft);  color: var(--danger); }
.kpi-icon--info    { background: var(--info-soft);    color: var(--info); }
.kpi-label { font-size: var(--text-cap); font-weight: var(--weight-semi); letter-spacing: .05em;
             text-transform: uppercase; color: var(--text-3); }
.kpi-value { font-size: 1.6rem; font-weight: var(--weight-bold); letter-spacing: -.028em;
             font-variant-numeric: tabular-nums; line-height: 1.15; color: var(--text); }
.kpi-meta  { font-size: var(--text-sm); color: var(--text-2); display: flex; align-items: center; gap: var(--s-1); }

/* the one hero tile per dashboard */
.kpi--hero {
  background: var(--brand-gradient); border-color: transparent; color: #fff;
  box-shadow: 0 8px 28px color-mix(in srgb, var(--brand) 32%, transparent);
}
.kpi--hero .kpi-label { color: rgba(255,255,255,.76); }
.kpi--hero .kpi-value { color: #fff; }
.kpi--hero .kpi-meta  { color: rgba(255,255,255,.82); }
.kpi--hero .kpi-icon  { background: rgba(255,255,255,.16); color: #fff; }

.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: var(--weight-semi); }
.trend--up   { color: var(--success); }
.trend--down { color: var(--danger); }
.trend--flat { color: var(--text-3); }
.kpi--hero .trend--up, .kpi--hero .trend--down, .kpi--hero .trend--flat { color: #fff; }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 42px; padding: 0 var(--s-4);
  border: 1px solid var(--btn-bd); border-radius: var(--r-sm);
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: var(--text-body); font-weight: var(--weight-semi);
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
              box-shadow var(--fast) var(--ease), transform .06s var(--ease), opacity var(--fast);
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: scale(.985); }
.btn:disabled, .btn.is-disabled { opacity: .5; pointer-events: none; }

.btn-primary { --btn-bg: var(--brand); --btn-fg: var(--brand-ink); --btn-bd: var(--brand);
               box-shadow: 0 1px 2px color-mix(in srgb, var(--brand) 40%, transparent); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover);
                     box-shadow: 0 3px 10px color-mix(in srgb, var(--brand) 38%, transparent); }
.btn-accent  { --btn-bg: var(--accent); --btn-fg: #fff; --btn-bd: var(--accent); }
.btn-accent:hover { background: var(--accent-700); border-color: var(--accent-700); }
.btn-danger  { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: var(--danger); }
.btn-danger:hover { filter: brightness(.94); background: var(--danger); }
.btn-soft    { --btn-bg: var(--brand-soft); --btn-fg: var(--brand); --btn-bd: transparent; }
.btn-soft:hover { background: color-mix(in srgb, var(--brand) 14%, var(--surface)); }
.btn-ghost   { --btn-bg: transparent; --btn-bd: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }

.btn-block { width: 100%; }
.btn-lg { min-height: 50px; padding: 0 var(--s-6); font-size: 1rem; border-radius: var(--r); }
.btn-sm { min-height: 34px; padding: 0 var(--s-3); font-size: var(--text-sm); }
.btn-icon { width: 42px; padding: 0; flex: 0 0 auto; }
.btn-icon.btn-sm { width: 34px; }
.btn .ico { flex: 0 0 auto; }

/* ---------- inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-4); }
.field:last-child { margin-bottom: 0; }
.label { font-size: var(--text-sm); font-weight: var(--weight-semi); color: var(--text-2); }
.label .req { color: var(--danger); }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); }

.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px var(--s-3);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: var(--text-body);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast);
  appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { min-height: 96px; resize: vertical; line-height: var(--leading-body); }
.select {
  padding-right: var(--s-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A93A3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--s-3) center;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring); background: var(--surface);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
.input.has-error, .select.has-error, .textarea.has-error { border-color: var(--danger); }
.input.has-error:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }
.hint { font-size: var(--text-xs); color: var(--text-3); }
.error-text { font-size: var(--text-xs); color: var(--danger); display: flex; align-items: center; gap: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

/* input with a leading affix (currency, dial code) */
.input-group { display: flex; align-items: stretch; }
.input-group .affix {
  display: flex; align-items: center; padding: 0 var(--s-3);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-right: 0;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  font-size: var(--text-sm); font-weight: var(--weight-semi); color: var(--text-2);
  white-space: nowrap;
}
.input-group .input { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.input-group:focus-within .affix { border-color: var(--brand); }

/* search box */
.searchbar { position: relative; }
.searchbar .input { padding-left: var(--s-10); }
.searchbar > .ico {
  position: absolute; left: var(--s-3); top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}

/* toggle */
.switch { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) 0; }
.switch + .switch { border-top: 1px solid var(--border); }
.switch-label { font-weight: var(--weight-medium); color: var(--text); }
.switch-sub { font-size: var(--text-sm); color: var(--text-2); margin-top: 1px; }
.toggle { position: relative; width: 44px; height: 26px; flex: 0 0 auto; }
.toggle input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle .track {
  position: absolute; inset: 0; background: var(--border-strong);
  border-radius: var(--r-pill); transition: background var(--normal) var(--ease);
}
.toggle .thumb {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--normal) var(--ease-out);
}
.toggle input:checked ~ .track { background: var(--brand); }
.toggle input:checked ~ .thumb { transform: translateX(18px); }
.toggle input:focus-visible ~ .track { box-shadow: var(--ring); }

/* segmented control */
.segmented {
  display: inline-flex; background: var(--surface-3); border-radius: var(--r-sm);
  padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented a, .segmented button {
  border: 0; background: transparent; color: var(--text-2);
  padding: 7px var(--s-3); border-radius: var(--r-xs);
  font-size: var(--text-sm); font-weight: var(--weight-semi);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.segmented a:hover, .segmented button:hover { color: var(--text); text-decoration: none; }
.segmented .is-active {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs);
}

/* filter chips */
.chips { display: flex; gap: var(--s-2); overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px var(--s-3); border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface);
  font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-2);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: all var(--fast) var(--ease);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-count { font-variant-numeric: tabular-nums; opacity: .7; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px var(--s-2); border-radius: var(--r-pill);
  font-size: var(--text-xs); font-weight: var(--weight-semi); letter-spacing: .01em;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.badge-success { background: var(--success-soft); color: var(--success-ink); }
.badge-warning { background: var(--warning-soft); color: var(--warning-ink); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger-ink); }
.badge-info    { background: var(--info-soft);    color: var(--info-ink); }
.badge-brand   { background: var(--brand-soft);   color: var(--brand-700); }
.badge-muted   { background: var(--surface-3);    color: var(--text-3); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }
.badge-lg { padding: 5px var(--s-3); font-size: var(--text-sm); }
[data-theme="dark"] .badge-success, [data-theme="dark"] .badge-warning,
[data-theme="dark"] .badge-danger, [data-theme="dark"] .badge-info { color: var(--text); }

/* ---------- avatars ---------- */
.avatar {
  width: 38px; height: 38px; border-radius: var(--r-pill); flex: 0 0 auto;
  display: grid; place-items: center; overflow: hidden;
  font-weight: var(--weight-semi); font-size: var(--text-sm);
  background: var(--brand-soft); color: var(--brand-700);
}
.avatar-sm { width: 30px; height: 30px; font-size: var(--text-xs); }
.avatar-lg { width: 52px; height: 52px; font-size: 1.0625rem; }
.avatar-square { border-radius: var(--r-sm); }
.avatar-neutral { background: var(--surface-3); color: var(--text-2); }

.thumb {
  width: 44px; height: 44px; border-radius: var(--r-sm); flex: 0 0 auto;
  object-fit: cover; background: var(--surface-3);
  display: grid; place-items: center; color: var(--text-3);
}

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-5); min-height: 60px;
  border-bottom: 1px solid var(--border);
  color: inherit; text-decoration: none; background: transparent;
  transition: background var(--fast) var(--ease);
}
.list-row:last-child { border-bottom: 0; }
a.list-row:hover, button.list-row:hover { background: var(--surface-2); text-decoration: none; }
/* Rows are built from spans, so the two lines have to be made block-level. */
.list-row .title {
  display: block; font-weight: var(--weight-semi); font-size: var(--text-body);
  overflow: hidden; text-overflow: ellipsis;
}
.list-row .sub {
  display: block; font-size: var(--text-sm); color: var(--text-2); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis;
}
.list-row .end { margin-left: auto; text-align: right; flex: 0 0 auto; }
.list-row .end .strong { display: block; }
.list--compact .list-row { min-height: 52px; padding: var(--s-2) var(--s-4); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
table.table th {
  text-align: left; font-size: var(--text-cap); text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); font-weight: var(--weight-semi);
  padding: var(--s-3) var(--s-4); white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
}
table.table td {
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); vertical-align: middle;
}
table.table tbody tr:last-child td { border-bottom: 0; }
table.table tbody tr { transition: background var(--fast) var(--ease); }
table.table tbody tr:hover { background: var(--surface-2); }
table.table tr.is-clickable { cursor: pointer; }
table.table .right { text-align: right; }

/* ---------- empty states ---------- */
.empty { text-align: center; padding: var(--s-12) var(--s-5); }
.empty-art {
  width: 72px; height: 72px; margin: 0 auto var(--s-4);
  border-radius: var(--r-lg); display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
}
.empty-art--neutral { background: var(--surface-3); color: var(--text-3); }
.empty h3 { font-size: var(--text-h3); margin-bottom: 6px; }
.empty p { color: var(--text-2); font-size: var(--text-sm); max-width: 38ch; margin: 0 auto var(--s-5); }
.empty-actions { display: flex; gap: var(--s-2); justify-content: center; flex-wrap: wrap; }

/* ---------- skeletons ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-xs);
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.sk-line  { height: 12px; margin-bottom: var(--s-2); }
.sk-line.w-40 { width: 40%; } .sk-line.w-60 { width: 60%; } .sk-line.w-80 { width: 80%; }
.sk-title { height: 18px; width: 45%; margin-bottom: var(--s-3); }
.sk-kpi   { height: 108px; border-radius: var(--r-lg); }
.sk-row   { height: 60px; border-radius: var(--r-sm); margin-bottom: var(--s-2); }
.sk-tile  { height: 120px; border-radius: var(--r); }
.sk-chart { height: 200px; border-radius: var(--r); }
.sk-circle{ width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; }

.spinner {
  width: 18px; height: 18px; border: 2px solid color-mix(in srgb, currentColor 22%, transparent);
  border-top-color: currentColor; border-radius: 50%;
  animation: spin .7s linear infinite; flex: 0 0 auto;
}
.spinner-lg { width: 30px; height: 30px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- alerts / banners ---------- */
.alert {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r);
  font-size: var(--text-sm); border: 1px solid transparent;
}
.alert .ico { flex: 0 0 auto; margin-top: 1px; }
.alert-info    { background: var(--info-soft);    color: var(--info-ink);    border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.alert-success { background: var(--success-soft); color: var(--success-ink); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning-ink); border-color: color-mix(in srgb, var(--warning) 26%, transparent); }
.alert-danger  { background: var(--danger-soft);  color: var(--danger-ink);  border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.alert a { color: inherit; text-decoration: underline; font-weight: var(--weight-semi); }
a.alert:hover { text-decoration: none; filter: brightness(.98); }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + var(--s-3)); z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--s-2);
  width: min(460px, calc(100vw - var(--s-6))); pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: var(--text-sm); font-weight: var(--weight-medium);
  animation: toast-in var(--slow) var(--ease-out); pointer-events: auto; cursor: pointer;
}
.toast.is-out { animation: toast-out var(--normal) var(--ease) forwards; }
.toast-ico { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; }
.toast-success .toast-ico { background: var(--success-soft); color: var(--success); }
.toast-error   .toast-ico { background: var(--danger-soft);  color: var(--danger); }
.toast-info    .toast-ico { background: var(--info-soft);    color: var(--info); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(-14px) scale(.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(-10px) scale(.97); } }

/* ---------- overlay, sheets, modals ---------- */
.scrim {
  position: fixed; inset: 0; z-index: var(--z-overlay);
  background: var(--overlay); backdrop-filter: blur(2px);
  animation: fade-in var(--normal) var(--ease);
}
@keyframes fade-in { from { opacity: 0; } }

.sheet {
  position: fixed; inset: auto 0 0 0; z-index: var(--z-modal);
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-xl); max-height: 90vh;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  animation: sheet-up var(--slow) var(--ease-out);
}
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet-grab { width: 40px; height: 4px; border-radius: 3px; background: var(--border-strong); margin: var(--s-2) auto 0; flex: 0 0 auto; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.sheet-head h2 { font-size: var(--text-h2); }
.sheet-body { padding: var(--s-5); overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1 1 auto; }
.sheet-body--flush { padding: 0; }
.sheet-foot { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); flex: 0 0 auto; }

@media (min-width: 640px) {
  .sheet {
    inset: 50% auto auto 50%; transform: translate(-50%, -50%);
    width: min(560px, calc(100vw - var(--s-8))); border-radius: var(--r-xl);
    max-height: min(88vh, 780px);
    animation: dialog-in var(--normal) var(--ease-out);
  }
  @keyframes dialog-in { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } }
  .sheet-grab { display: none; }
  .sheet--wide { width: min(880px, calc(100vw - var(--s-8))); }
}

/* ---------- dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: var(--z-sticky);
  min-width: 200px; padding: var(--s-1);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  animation: pop-in var(--fast) var(--ease-out);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.dropdown-item {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; padding: var(--s-2) var(--s-3); border: 0; border-radius: var(--r-xs);
  background: transparent; color: var(--text); font-size: var(--text-sm);
  text-align: left; text-decoration: none; cursor: pointer;
}
.dropdown-item:hover { background: var(--surface-3); text-decoration: none; }
.dropdown-item--danger { color: var(--danger); }
.dropdown-sep { height: 1px; background: var(--border); margin: var(--s-1) 0; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: var(--s-5); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: var(--s-3) 0; border: 0; background: none; cursor: pointer;
  font-size: var(--text-body); font-weight: var(--weight-medium); color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  text-decoration: none; white-space: nowrap;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); font-weight: var(--weight-semi); }

/* ---------- pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--s-1); padding: var(--s-5) 0; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 38px; height: 38px; padding: 0 var(--s-3); border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); font-size: var(--text-sm); color: var(--text-2);
  text-decoration: none; background: var(--surface);
  transition: all var(--fast) var(--ease);
}
.pagination a:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.pagination .is-active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: var(--weight-semi); }

/* ---------- progress ---------- */
.progress { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress-bar { height: 100%; border-radius: var(--r-pill); background: var(--brand); transition: width var(--slow) var(--ease-out); }
.progress-bar--success { background: var(--success); }
.progress-bar--warning { background: var(--warning); }
.progress-bar--danger  { background: var(--danger); }

/* ---------- charts ---------- */
/* The chart grows to fill its card so a tall neighbour does not leave a gap. */
/* A chart card is a flex column: the head keeps its height, the plot takes the
   rest, and the axis under it never gets clipped by the card's overflow. */
.card--chart { display: flex; flex-direction: column; }
.card--chart .card-head { flex: 0 0 auto; }
.card-body--chart { display: flex; flex-direction: column; justify-content: flex-end; flex: 1 1 auto; min-height: 0; }
.chart-axis { flex: 0 0 auto; }
.chart { display: flex; align-items: flex-end; gap: 5px; height: 180px; flex: 1 1 auto; min-height: 180px; }
.chart-col { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; border-radius: 5px; }
.chart-col:hover { background: var(--surface-2); }
.chart-bar {
  width: 100%; border-radius: 5px 5px 3px 3px;
  background: linear-gradient(180deg, var(--brand-500) 0%, var(--brand-600) 100%);
  transition: opacity var(--fast) var(--ease);
  animation: bar-grow var(--slow) var(--ease-out) backwards;
  min-height: 3px;
}
.chart-col:hover .chart-bar { opacity: .82; }
@keyframes bar-grow { from { height: 0 !important; } }
.chart-axis { display: flex; justify-content: space-between; margin-top: var(--s-2); }
.chart-tip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--surface); padding: 4px 8px; border-radius: var(--r-xs);
  font-size: var(--text-xs); font-weight: var(--weight-semi); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity var(--fast) var(--ease);
}
.chart-col:hover .chart-tip { opacity: 1; }
/* Keep the tooltip inside the card at both ends so it never widens the page. */
.chart-col:first-child .chart-tip { left: 0; transform: none; }
.chart-col:last-child  .chart-tip { left: auto; right: 0; transform: none; }

/* horizontal ranked bars (top products) */
.rank-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; }
.rank-num {
  width: 22px; height: 22px; border-radius: var(--r-xs); flex: 0 0 auto;
  display: grid; place-items: center; font-size: var(--text-xs); font-weight: var(--weight-bold);
  background: var(--surface-3); color: var(--text-2);
}
.rank-row:nth-child(1) .rank-num { background: var(--brand-soft); color: var(--brand); }
.rank-track { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; margin-top: 5px; }
.rank-fill { height: 100%; border-radius: var(--r-pill); background: var(--brand); animation: bar-grow-x var(--slow) var(--ease-out) backwards; }
@keyframes bar-grow-x { from { width: 0 !important; } }

/* ---------- page header ---------- */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-4); margin-bottom: var(--s-5); flex-wrap: wrap;
}
.page-head .title-block { min-width: 0; }
.page-head h1 { font-size: var(--text-h1); }
.page-head .subtitle { font-size: var(--text-sm); color: var(--text-2); margin-top: 2px; }
.page-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ---------- misc ---------- */
.mono { font-family: var(--font-num); }
.code-chip {
  font-family: var(--font-num); font-weight: var(--weight-semi); letter-spacing: .06em;
  background: var(--surface-2); border: 1px dashed var(--border-strong);
  padding: 5px var(--s-3); border-radius: var(--r-sm); display: inline-block; font-size: var(--text-sm);
}
.section-title { font-size: var(--text-cap); font-weight: var(--weight-semi); letter-spacing: .06em;
                 text-transform: uppercase; color: var(--text-3); }
.dot-sep::before { content: "·"; margin: 0 6px; color: var(--text-3); }

.fade-in { animation: fade-up var(--slow) var(--ease-out) backwards; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } }
.stagger > * { animation: fade-up var(--slow) var(--ease-out) backwards; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .10s; }
.stagger > *:nth-child(4) { animation-delay: .14s; }
.stagger > *:nth-child(5) { animation-delay: .18s; }
.stagger > *:nth-child(6) { animation-delay: .22s; }

/* A stack stretches its children; these controls should hug their content. */
.stack > .segmented,
.stack > .chips,
.stack-sm > .segmented,
.stack-lg > .segmented { align-self: flex-start; max-width: 100%; }

/* ---------- stock intake tabs (quick add vs full invoice) ---------- */
.intake-tabs { display: flex; gap: var(--s-2); margin-bottom: var(--s-5); }
.intake-tab {
  flex: 1 1 0; display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4); border-radius: var(--r); text-decoration: none;
  border: 1.5px solid var(--border); background: var(--surface); color: inherit;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.intake-tab:hover { border-color: var(--border-strong); text-decoration: none; }
.intake-tab.is-active { border-color: var(--brand); background: var(--brand-soft); }
.intake-tab.is-active .intake-ico { background: var(--brand); color: #fff; }
.intake-ico {
  width: 36px; height: 36px; border-radius: var(--r-sm); flex: 0 0 auto;
  display: grid; place-items: center; background: var(--surface-3); color: var(--text-2);
}
.intake-title { font-weight: var(--weight-semi); }
.intake-sub { font-size: var(--text-sm); color: var(--text-2); margin-top: 1px; }
@media (max-width: 640px) { .intake-tabs { flex-direction: column; } }

/* ---------- table map ---------- */
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-3); }
.table-card {
  display: flex; flex-direction: column; gap: 3px; min-height: 108px;
  padding: var(--s-4); border-radius: var(--r);
  border: 1.5px solid var(--border); background: var(--surface);
  text-decoration: none; color: inherit; box-shadow: var(--shadow-xs);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), transform .07s var(--ease);
}
.table-card:hover { text-decoration: none; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.table-card:active { transform: scale(.985); }
.table-name { font-weight: var(--weight-bold); font-size: 1.0625rem; }
.table-status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--text-xs); font-weight: var(--weight-semi);
  text-transform: uppercase; letter-spacing: .04em;
}
.table-total { font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; margin-top: auto; }
.table-time { font-size: var(--text-xs); color: var(--text-3); }

.table-card.is-available .table-status { color: var(--text-3); }
.table-card.is-occupied  { border-color: var(--brand);   background: var(--brand-soft); }
.table-card.is-occupied  .table-status { color: var(--brand-700); }
.table-card.is-ready     { border-color: var(--success); background: var(--success-soft); }
.table-card.is-ready     .table-status { color: var(--success-ink); }
.table-card.is-bill      { border-color: var(--warning); background: var(--warning-soft); }
.table-card.is-bill      .table-status { color: var(--warning-ink); }
[data-theme="dark"] .table-card.is-occupied .table-status,
[data-theme="dark"] .table-card.is-ready .table-status,
[data-theme="dark"] .table-card.is-bill .table-status { color: var(--text); }

/* ---------- customer cards ---------- */
.customer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-3); }
.customer-card {
  display: block; padding: var(--s-4); border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface);
  text-decoration: none; color: inherit; box-shadow: var(--shadow-xs);
  transition: box-shadow var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.customer-card:hover { text-decoration: none; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.customer-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3);
  margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--border);
}

/* A short list of checkboxes that should read as one block — branch access on
   the team sheet, and anywhere else a handful of options are picked together. */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-2); }
.check { display: flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); }
.check input { flex: 0 0 auto; }

/* Filter bars above a table: as many columns as fit, each wide enough for a
   date input or a select without the label wrapping. */
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s-3); }

/* Inline guidance that has become a caution — a form field whose meaning has
   just changed under the person filling it in. */
.warn-text { color: var(--warning-ink); }
