/* Sendy design system, app-wide (design-system/sendy/MASTER.md).
   Loaded on every page by base.html, last (after app.css and combo.css). Every
   class starts with sy-, every token with --sy-. Tokens live on :root; the
   page-level rules (font, colour, background, link colour, focus rings) stay on
   .sy-page, so a page without .sy-page keeps its old body look. The app shell
   (sidebar, top bar, banners) is styled here for every page: see "App shell". */

:root {
  --sy-bg: #F8FAFC;
  --sy-card: #FFFFFF;
  --sy-ink: #0F172A;
  --sy-muted: #475569;
  --sy-faint: #64748B;
  --sy-border: #E2E8F0;
  --sy-primary: #1E40AF;
  --sy-primary-soft: #EFF4FF;
  --sy-in: #15803D;
  --sy-out: #B91C1C;
  --sy-warn: #B45309;
  --sy-warn-soft: #FFF7ED;
  --sy-in-soft: #F0FDF4;
  --sy-out-soft: #FEF2F2;
  --sy-radius: 8px;
  --sy-radius-sm: 6px;
  --sy-font: 'IBM Plex Sans Thai', 'Sarabun', sans-serif;
  --sy-side-w: 240px;
  /* chart category ramp (slate/blue, dark → light) + อื่นๆ */
  --sy-chart-1: #1E3A8A;
  --sy-chart-2: #1D4ED8;
  --sy-chart-3: #3B82F6;
  --sy-chart-4: #60A5FA;
  --sy-chart-5: #475569;
  --sy-chart-6: #64748B;
  --sy-chart-7: #CBD5E1;
  --sy-chart-other: #94A3B8;
  /* AR aging buckets 0-30 · 31-60 · 61-90 · 90+ */
  --sy-age-1: #1D4ED8;
  --sy-age-2: #F59E0B;
  --sy-age-3: #C2410C;
  --sy-age-4: #B91C1C;
}

.sy-page {
  font-family: var(--sy-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--sy-ink);
  background: var(--sy-bg);
  min-width: 0;
}
.sy-page code { font-size: 12.5px; color: var(--sy-muted); }
/* :not(.btn) — a Bootstrap button inside the page (e.g. the stale-AR banner's
   btn-danger) keeps its own text colour and focus ring. */
.sy-page a:not(.btn) { color: var(--sy-primary); }
.sy-page a:not(.btn):focus-visible,
.sy-page button:not(.btn):focus-visible,
.sy-page select:focus-visible,
.sy-page input:focus-visible,
.sy-page summary:focus-visible {
  outline: 2px solid var(--sy-primary);
  outline-offset: 2px;
  box-shadow: none;
}

/* numbers */
.sy-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sy-neg { color: var(--sy-out); }
.sy-in  { color: var(--sy-in); }
.sy-out { color: var(--sy-out); }
.sy-warn { color: var(--sy-warn); }
.sy-muted { color: var(--sy-muted); }

/* 1. sy-head: title left, period control right, tabs below */
.sy-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 12px;
}
.sy-head .page-title { font-size: 22px; font-weight: 600; line-height: 1.3; margin: 0; letter-spacing: 0; }
.sy-head-sub { font-size: 12.5px; font-weight: 500; color: var(--sy-muted); margin-top: 4px; }
.sy-period { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.sy-period label { display: block; font-size: 12.5px; font-weight: 500; color: var(--sy-muted); margin-bottom: 4px; }
.sy-period .form-select,
.sy-period .form-control {
  min-height: 44px; font-size: 16px; border-color: var(--sy-border);
  border-radius: var(--sy-radius-sm);
}
.sy-period-or { font-size: 12.5px; color: var(--sy-faint); padding-bottom: 12px; }
.sy-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 16px; border-radius: var(--sy-radius-sm);
  font-weight: 500; font-size: 14px; text-decoration: none;
  border: 1px solid var(--sy-border); background: var(--sy-card); color: var(--sy-ink);
  transition: background-color 150ms, border-color 150ms;
}
.sy-btn:hover { background: var(--sy-primary-soft); }
/* a button-looking span that cannot be pressed: no hover tint, no pointer */
.sy-btn[aria-disabled="true"] { cursor: not-allowed; }
.sy-btn[aria-disabled="true"]:hover { background: var(--sy-card); }
.sy-btn-primary { background: var(--sy-primary); border-color: var(--sy-primary); color: #FFFFFF; }
.sy-btn-primary:hover { background: var(--sy-primary); filter: brightness(1.1); }
.sy-page a.sy-btn { color: var(--sy-ink); }
.sy-page a.sy-btn-warn { color: var(--sy-warn); }

.sy-page .sy-tabs {
  display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 4px;
  list-style: none; padding: 0; margin: 0 0 16px;
  border-bottom: 1px solid var(--sy-border);
}
.sy-page .sy-tabs .sy-tab {
  display: flex; align-items: center; min-height: 44px; padding: 0 12px;
  color: var(--sy-muted); font-weight: 500; font-size: 14px; white-space: nowrap;
  border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  margin-bottom: -1px; text-decoration: none;
  transition: color 150ms, border-color 150ms;
}
.sy-page .sy-tabs .sy-tab:hover { color: var(--sy-ink); }
.sy-page .sy-tabs .sy-tab.active { color: var(--sy-primary); border-bottom-color: var(--sy-primary); font-weight: 600; }

/* 2. sy-kpi */
.sy-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.sy-kpi {
  position: relative; background: var(--sy-card); border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius); padding: 16px; min-width: 0;
}
.sy-kpi-label { font-size: 12.5px; font-weight: 500; color: var(--sy-muted); padding-right: 72px; }
.sy-kpi-value {
  font-size: 26px; font-weight: 600; line-height: 1.3; margin-top: 4px;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.sy-kpi-sub { font-size: 12.5px; color: var(--sy-muted); margin-top: 8px; }
.sy-kpi .sy-pill { position: absolute; top: 12px; right: 12px; }

.sy-pill {
  display: inline-block; font-size: 12px; font-weight: 500; line-height: 1.5;
  padding: 0 8px; border-radius: 999px;
  color: var(--sy-warn); background: var(--sy-warn-soft); border: 1px solid var(--sy-warn);
  white-space: nowrap; vertical-align: middle;
}
.sy-pill-neutral { color: var(--sy-muted); background: var(--sy-bg); border-color: var(--sy-border); }

/* 3. sy-explain */
.sy-explain { font-size: 12.5px; color: var(--sy-muted); margin-top: 8px; }
.sy-explain > summary {
  cursor: pointer; font-weight: 500; color: var(--sy-primary);
  min-height: 24px; list-style-position: inside;
}
.sy-explain[open] > summary { margin-bottom: 4px; }
.sy-explain-body { line-height: 1.6; }

/* 4. sy-alert */
.sy-alert {
  background: var(--sy-warn-soft); border-left: 3px solid var(--sy-warn);
  border-radius: var(--sy-radius-sm); padding: 8px 12px; margin-bottom: 12px;
  font-size: 14px; color: var(--sy-ink);
}
.sy-alert-strong { border-left-color: var(--sy-out); }
.sy-alert ul { margin: 4px 0 0; padding-left: 24px; }
.sy-note {
  border-left: 3px solid var(--sy-border); padding: 4px 12px; margin-bottom: 12px;
  font-size: 12.5px; color: var(--sy-muted);
}

/* 5. sy-card */
.sy-card {
  background: var(--sy-card); border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius); padding: 16px; margin-bottom: 16px; min-width: 0;
}
.sy-card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 8px;
}
.sy-card-title { font-size: 15px; font-weight: 600; margin: 0; }
.sy-card-aside { font-size: 12.5px; color: var(--sy-muted); text-align: right; }
.sy-card-total { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* statement (/accounting result block) */
.sy-stmt-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-top: 1px solid var(--sy-border);
}
.sy-stmt-row:first-child { border-top: 0; }
.sy-stmt-row.sy-stmt-step { color: var(--sy-muted); padding: 4px 0; border-top: 0; }
.sy-stmt-row.sy-stmt-sub { padding: 4px 0 4px 24px; border-top: 0; color: var(--sy-muted); font-size: 12.5px; }
.sy-stmt-row.sy-stmt-result { border-top: 2px solid var(--sy-ink); }
.sy-stmt-label { font-weight: 500; }
.sy-stmt-result .sy-stmt-label { font-weight: 600; }
.sy-stmt-value { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.sy-stmt-result .sy-stmt-value { font-size: 20px; font-weight: 600; }
.sy-stmt-step .sy-stmt-label, .sy-stmt-sub .sy-stmt-label { font-weight: 400; }

/* 6. sy-table */
.sy-table-wrap { overflow-x: auto; margin: 0 -16px -16px; padding: 0 16px 8px; }
.sy-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sy-table th {
  font-size: 12.5px; font-weight: 500; color: var(--sy-faint);
  text-align: left; padding: 8px; border-bottom: 1px solid var(--sy-border); white-space: nowrap;
}
.sy-table td { padding: 8px; border-bottom: 1px solid var(--sy-border); vertical-align: top; }
.sy-table th:first-child, .sy-table td:first-child { padding-left: 0; }
.sy-table th:last-child, .sy-table td:last-child { padding-right: 0; }
.sy-table .sy-r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sy-table tbody tr { transition: background-color 150ms; }
.sy-table tbody tr:hover { background: var(--sy-primary-soft); }
.sy-table tfoot td { font-weight: 600; border-top: 2px solid var(--sy-ink); border-bottom: 0; }
.sy-table .sy-row-strong td { font-weight: 600; }
.sy-table .sy-cell-muted { color: var(--sy-faint); font-size: 12.5px; }
.sy-table-compact { max-width: 34rem; }
.sy-empty { text-align: center; color: var(--sy-muted); padding: 24px 0; }

/* sections, two-up cards, small helpers */
.sy-strong { font-weight: 600; }
.sy-section { margin-bottom: 16px; }
.sy-section-title { font-size: 15px; font-weight: 600; margin: 24px 0 12px; }
.sy-subtitle { font-size: 12.5px; font-weight: 600; color: var(--sy-muted); margin: 16px 0 4px; }
.sy-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.sy-cols > .sy-card { margin-bottom: 12px; }
.sy-notes { font-size: 12.5px; color: var(--sy-muted); margin: 12px 0 0; padding-left: 16px; }
.sy-link-text { color: var(--sy-primary); }
a.sy-kpi-link { display: block; text-decoration: none; color: inherit; transition: border-color 150ms; }
.sy-page a.sy-kpi-link { color: var(--sy-ink); }
a.sy-kpi-link:hover { border-color: var(--sy-primary); }

/* table extras */
.sy-table th.sy-group { text-align: center; font-weight: 400; }
.sy-table .sy-sep { border-left: 1px solid var(--sy-border); }
.sy-table tbody tr.sy-row-selected { background: var(--sy-primary-soft); }
.sy-table .sy-row-link { display: inline-flex; align-items: center; min-height: 32px; font-weight: 500; text-decoration: none; }
.sy-table .sy-row-link:hover { text-decoration: underline; }
.sy-table tr.sy-row-total td { font-weight: 600; font-size: 15px; border-bottom: 0; }
/* an inline edit form that opens under its row (me/leave pending request) */
.sy-table td.sy-edit-row { background: var(--sy-bg); padding: 12px; border-bottom: 1px solid var(--sy-border); }
.sy-table tbody tr.collapse:hover { background: transparent; }
@media (max-width: 991.98px) { .sy-table.sy-cards-2.table-mobile-cards td.sy-edit-row { grid-column: 1 / -1; } }
/* sy-cards-2 cells: a hidden-on-mobile cell stays hidden; a long text cell takes the whole card line */
@media (max-width: 991.98px) {
  .sy-table.sy-cards-2.table-mobile-cards td.td-hide-mobile { display: none; }
  .sy-table.sy-cards-2.table-mobile-cards tr.collapse:not(.show) { display: none; }
  .sy-table.sy-cards-2.table-mobile-cards td.sy-span-2 { grid-column: 1 / -1; }
}
.sy-table-quiet td { color: var(--sy-muted); font-size: 12.5px; padding-top: 4px; padding-bottom: 4px; }
.sy-table tbody tr[data-cb-dim], .sy-table tbody tr[data-cb-month] { cursor: pointer; }
.sy-table .sy-chev { color: var(--sy-faint); font-size: 12px; }

.sy-table-wide { min-width: 760px; }
.sy-nowrap { white-space: nowrap; }
.sy-prewrap { white-space: pre-wrap; }

/* inline cash-in bars (/cashflow legacy section) */
.sy-bars { margin-bottom: 8px; }
.sy-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sy-bar-label { width: 6rem; flex-shrink: 0; font-size: 12.5px; color: var(--sy-muted); }
.sy-bar { flex: 1 1 auto; min-width: 0; height: 16px; border-radius: 4px; background: var(--sy-bg); }
.sy-bar-fill { height: 100%; border-radius: 4px; background: var(--sy-in); }
.sy-bar-min { min-width: 2px; }
.sy-bar-value { width: 8rem; flex-shrink: 0; text-align: right; font-weight: 600; font-size: 12.5px; }
.sy-bar-count { width: 4rem; flex-shrink: 0; font-size: 12.5px; color: var(--sy-muted); }

.sy-bar-fill-out { background: var(--sy-out); }
.sy-table tfoot tr.sy-row-plain td { border-top: 0; }

/* tag bar (/cashbook/ by-tag table) */
.sy-meter { height: 4px; max-width: 240px; margin-top: 4px; border-radius: 2px; background: var(--sy-bg); }
.sy-meter > div { height: 100%; border-radius: 2px; background: var(--sy-out); }

/* list with amounts (/cashbook/ รอระบุ) */
.sy-list { list-style: none; margin: 0; padding: 0; }
.sy-list > li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 44px; padding: 4px 0; border-top: 1px solid var(--sy-border);
}
.sy-list > li:first-child { border-top: 0; }
.sy-list .sy-list-amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* small buttons + red pill */
.sy-btn-sm { min-height: 32px; padding: 0 12px; font-size: 12.5px; }
.sy-pill-out { color: var(--sy-out); background: var(--sy-card); border-color: var(--sy-out); }
.sy-explain-list { list-style: none; padding-left: 0; margin: 0; }
.sy-explain-list > li { margin-bottom: 4px; }
.sy-kpi .sy-kpi-sub + .sy-kpi-sub { margin-top: 4px; }

/* F4b (/ar, /ap, /commission) ---------------------------------------- */

/* status badge: one small label per row status (paid, partial, 90+ …).
   The word carries the meaning; the colour only repeats it. */
.sy-badge {
  display: inline-block; font-size: 12px; font-weight: 500; line-height: 1.5;
  padding: 0 8px; border-radius: 999px; white-space: nowrap; vertical-align: middle;
  color: var(--sy-muted); background: var(--sy-bg); border: 1px solid var(--sy-border);
}
.sy-badge-in   { color: var(--sy-in);   background: var(--sy-in-soft);  border-color: var(--sy-in); }
.sy-badge-warn { color: var(--sy-warn); background: var(--sy-warn-soft); border-color: var(--sy-warn); }
.sy-badge-out  { color: var(--sy-out);  background: var(--sy-out-soft); border-color: var(--sy-out); }
.sy-badge-info { color: var(--sy-primary); background: var(--sy-primary-soft); border-color: var(--sy-primary); }
/* inside a table-mobile-cards grid cell the badge keeps its own width */
.sy-table td > .sy-badge { justify-self: start; }

/* aging bar (/ar overview): one segment per bucket, widths inline, colours here */
.sy-aging-bar { display: flex; height: 28px; border-radius: var(--sy-radius-sm); overflow: hidden; margin-bottom: 12px; background: var(--sy-bg); }
.sy-aging-seg {
  display: flex; align-items: center; justify-content: center; min-width: 0; overflow: hidden;
  font-size: 12px; font-weight: 600; color: #FFFFFF; white-space: nowrap;
}
.sy-aging-1 { background: var(--sy-age-1); }
.sy-aging-2 { background: var(--sy-age-2); color: var(--sy-ink); }
.sy-aging-3 { background: var(--sy-age-3); }
.sy-aging-4 { background: var(--sy-age-4); }
.sy-aging-legend { display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 12.5px; color: var(--sy-muted); }
.sy-aging-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* the one KPI to act on first (/ar ตามได้เลย) */
.sy-kpi-hot { border-color: var(--sy-out); border-left-width: 3px; }

/* rows that need a second look */
.sy-table tbody tr.sy-row-warn { background: var(--sy-warn-soft); }
.sy-table tbody tr.sy-row-ok { background: var(--sy-in-soft); }

/* filter chips (a status filter made of links) + filter row */
.sy-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.sy-chip {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--sy-border); border-radius: 999px; background: var(--sy-card);
  font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background-color 150ms, border-color 150ms;
}
.sy-page a.sy-chip { color: var(--sy-muted); }
.sy-chip:hover { background: var(--sy-primary-soft); }
.sy-page a.sy-chip.active { color: var(--sy-primary); background: var(--sy-primary-soft); border-color: var(--sy-primary); font-weight: 600; }
.sy-filter { align-items: flex-end; }
.sy-filter .sy-grow { flex: 1 1 200px; }

/* a row of page actions (links styled as sy-btn) */
.sy-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* commission payout amount column */
.sy-table .sy-col-amount { width: 120px; }
.sy-table td input.form-control { min-width: 110px; }

/* pager */
.sy-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; }

/* chart boxes */
.sy-chart { position: relative; height: 260px; }
/* U4a: a time-series bar chart with many labels (12 weeks / a year of weeks) needs more height */
.sy-chart.sy-chart-lg { height: 360px; }

/* U1a (dashboard) ------------------------------------------------------ */

/* sy-alert with a one-line text + an action button (button drops under the text on narrow widths) */
.sy-alert-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.sy-alert-row .sy-alert-text { flex: 1 1 240px; min-width: 0; }
.sy-alert-row .sy-btn { margin-left: auto; }

/* KPI footer: sub-line left, "go to the list" link right */
.sy-kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 -12px; }
.sy-kpi-foot .sy-kpi-sub { margin-top: 0; }

/* quiet "go" link with a 44px hit area (KPI footer, card header) */
.sy-page a.sy-go {
  display: inline-flex; align-items: center; min-height: 44px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap; text-decoration: none;
}
.sy-page a.sy-go:hover { text-decoration: underline; }
.sy-card-head.sy-card-head-center { align-items: center; }

/* a right-aligned number cell reads left inside a mobile card, like its sibling label/value rows */
@media (max-width: 991.98px) {
  .sy-table.table-mobile-cards td.sy-r { text-align: left; }
}

/* App shell (U0b): sidebar, top bar, page-wide banners, flash messages.
   base.html renders it on every page. Some old class names stay in the markup
   as hooks that tests, app.js and print CSS read (nav.sidebar-nav,
   a.sidebar-link, .sidebar-section, span.badge-count, header.topbar, #sidebar,
   #today-date, aside.sidebar + div.main-wrap: the @media print rules in
   labels/print.html and hr/payslip.html select them);
   the styling hangs off the sy- classes and their scope, never off those hooks. */
.sy-side, .sy-main > header, .sy-banner, .sy-bookbar, .sy-flash { font-family: var(--sy-font); }
.sy-side .btn, .sy-banner .btn, .sy-bookbar .btn, .sy-flash .btn { font-family: inherit; }

/* sidebar: light rail, one accent (--sy-primary) for "you are here" */
.sy-side {
  width: var(--sy-side-w); height: 100vh;
  position: fixed; top: 0; left: 0; z-index: 100;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--sy-card); border-right: 1px solid var(--sy-border);
  color: var(--sy-ink);
}
.sy-side-brand {
  display: flex; align-items: center; gap: 8px;
  padding: 12px; border-bottom: 1px solid var(--sy-border);
}
.sy-side-logo { display: flex; align-items: center; gap: 12px; flex-shrink: 0; text-decoration: none; color: var(--sy-ink); border-radius: var(--sy-radius-sm); }
.sy-side-mark {
  width: 40px; height: 40px; flex-shrink: 0; padding: 3px;
  display: flex; align-items: center; justify-content: center;
  background: var(--sy-card); border: 1px solid var(--sy-border); border-radius: 50%;
}
.sy-side-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sy-side-name { font-size: 15px; font-weight: 600; line-height: 1.2; color: var(--sy-ink); }
.sy-side-tag { font-size: 12px; font-weight: 500; line-height: 1.3; color: var(--sy-muted); }
.sy-side-switch {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 40px; min-height: 40px; padding: 0 8px;
  border: 1px solid var(--sy-border); border-radius: var(--sy-radius-sm);
  background: var(--sy-card); color: var(--sy-muted); font-size: 14px; line-height: 1;
  transition: background-color 150ms, color 150ms;
}
.sy-side-switch:hover, .sy-side-switch[aria-expanded="true"] { background: var(--sy-primary-soft); color: var(--sy-primary); border-color: var(--sy-border); }
.sy-side-switch::after { margin-left: 0; }
.sy-side-menu {
  min-width: 220px; padding: 4px; font-size: 14px;
  border: 1px solid var(--sy-border); border-radius: var(--sy-radius);
  box-shadow: 0 4px 12px rgba(15, 23, 42, .08);
}
.sy-side-menu .dropdown-item {
  display: flex; align-items: center; min-height: 40px; padding: 0 12px;
  border-radius: var(--sy-radius-sm); color: var(--sy-ink);
}
.sy-side-menu .dropdown-item i { color: var(--sy-faint); }
.sy-side-menu .dropdown-item:hover { background: var(--sy-bg); }
.sy-side-menu .dropdown-item.active,
.sy-side-menu .dropdown-item:active { background: var(--sy-primary-soft); color: var(--sy-primary); font-weight: 600; }
.sy-side-menu .dropdown-item.active i { color: var(--sy-primary); }
.sy-side-module {
  display: flex; align-items: center; gap: 4px;
  padding: 12px 16px 0; font-size: 12.5px; font-weight: 600; color: var(--sy-ink);
}
.sy-side-module i { color: var(--sy-primary); }
.sy-side > nav { flex: 1; padding: 4px 8px 16px; overflow-y: auto; }
.sy-side-section {
  font-size: 12px; font-weight: 600; color: var(--sy-faint);
  padding: 16px 12px 4px;
}
.sy-side-link {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 40px; padding: 8px 12px; margin-bottom: 2px;
  border-radius: var(--sy-radius-sm); text-decoration: none;
  font-size: 14px; font-weight: 500; line-height: 1.35; color: var(--sy-muted);
  transition: background-color 150ms, color 150ms;
}
.sy-side-link i { font-size: 16px; flex-shrink: 0; color: var(--sy-faint); transition: color 150ms; }
.sy-side-link:hover { background: var(--sy-bg); color: var(--sy-ink); }
.sy-side-link:hover i { color: var(--sy-ink); }
.sy-side-link.active { background: var(--sy-primary-soft); color: var(--sy-primary); font-weight: 600; }
.sy-side-link.active i { color: var(--sy-primary); }
.sy-side-link.active::before {
  content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--sy-primary);
}
/* nav badges: the span classes come from nav.py ("badge-count", or
   "badge bg-danger ms-auto" for the mapping queue); restyled here */
.sy-side-link .badge-count,
.sy-side-link .badge {
  margin-left: auto; min-width: 20px; padding: 0 6px;
  font-size: 12px; font-weight: 600; line-height: 20px; text-align: center;
  border-radius: 999px; font-variant-numeric: tabular-nums;
  color: var(--sy-ink); background: var(--sy-bg); border: 1px solid var(--sy-border);
}
.sy-side-link .badge.bg-danger { color: #FFFFFF; background: var(--sy-out) !important; border-color: var(--sy-out); }
.sy-side-link.active .badge-count { color: var(--sy-primary); background: var(--sy-card); border-color: var(--sy-primary); }
.sy-side-form { display: grid; padding: 4px 8px 8px; }
.sy-side-form .sy-btn { gap: 4px; }
.sy-btn-warn { background: var(--sy-warn-soft); border-color: var(--sy-warn); color: var(--sy-warn); }
.sy-btn-warn:hover { background: var(--sy-warn-soft); filter: brightness(.97); }
/* focus inside the rail: offset inward, the nav's overflow would clip an outer ring */
.sy-side a:focus-visible, .sy-side button:focus-visible {
  outline: 2px solid var(--sy-primary); outline-offset: -2px; box-shadow: none;
}

/* main column + top bar (header.topbar: the class is a test hook) */
.sy-main {
  margin-left: var(--sy-side-w); flex: 1;
  display: flex; flex-direction: column; min-height: 100vh;
  /* a flex child defaults to min-width:auto; 0 lets a wide table scroll
     inside its own wrapper instead of scrolling the page body on mobile */
  min-width: 0;
}
.sy-main > header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  height: 60px; padding: 0 24px;
  background: var(--sy-card); border-bottom: 1px solid var(--sy-border);
  font-size: 14px; color: var(--sy-ink);
}
.sy-top-crumb { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; color: var(--sy-muted); white-space: nowrap; }
.sy-top-crumb i { color: var(--sy-primary); }
.sy-top-spacer { flex: 1; }
.sy-top-actions { display: flex; align-items: center; gap: 8px; }
.sy-top-meta { font-size: 12.5px; font-weight: 500; color: var(--sy-muted); white-space: nowrap; }
/* buttons in the top bar (.btn) keep app.css's look, font included, until
   each page's own round (Put, 2026-10-30) */
.sy-main > header a:focus-visible, .sy-main > header button:focus-visible {
  outline: 2px solid var(--sy-primary); outline-offset: 2px; box-shadow: none;
}

/* page-wide banners (base.html): one line, full width, under the top bar */
.sy-banner {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
  padding: 8px 24px; font-size: 14px; font-weight: 600; line-height: 1.5;
}
.sy-banner form { margin: 0 0 0 auto; }
.sy-banner-meta { font-weight: 500; }
.sy-banner-out { background: var(--sy-out); color: #FFFFFF; }       /* viewing another book, read-only */
.sy-banner-warn { background: var(--sy-warn); color: #FFFFFF; }     /* admin simulating another user */
.sy-banner-btn {
  display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 12px;
  border: 0; border-radius: var(--sy-radius-sm); background: var(--sy-card);
  font-size: 12.5px; font-weight: 600; transition: filter 150ms;
}
.sy-banner-out .sy-banner-btn { color: var(--sy-out); }
.sy-banner-warn .sy-banner-btn { color: var(--sy-warn); }
.sy-banner-btn:hover { filter: brightness(.95); }
.sy-banner-btn:focus-visible { outline: 2px solid #FFFFFF; outline-offset: 2px; }
/* book switcher strip (other books available, not viewing one) */
.sy-bookbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
  padding: 4px 24px; font-size: 12.5px; font-weight: 500;
  background: var(--sy-bg); color: var(--sy-muted); border-bottom: 1px solid var(--sy-border);
}
.sy-bookbar form { margin: 0; }
.sy-bookbar form:first-of-type { margin-left: auto; }
.sy-bookbar .sy-btn:focus-visible { outline: 2px solid var(--sy-primary); outline-offset: 2px; }

/* flash messages: Bootstrap alerts (app.js auto-dismisses success/info)
   re-pointed to the token pairs (over app.css's .alert-* colours, which page
   bodies keep), 3px left rule like sy-alert */
.sy-flash .alert {
  border: 1px solid var(--sy-border); border-left: 3px solid currentColor;
  border-radius: var(--sy-radius-sm); font-size: 14px;
}
.sy-flash .alert-success { color: var(--sy-in);      background: var(--sy-in-soft); }
.sy-flash .alert-danger  { color: var(--sy-out);     background: var(--sy-out-soft); }
.sy-flash .alert-warning { color: var(--sy-warn);    background: var(--sy-warn-soft); }
.sy-flash .alert-info    { color: var(--sy-primary); background: var(--sy-primary-soft); }

/* below 992px the rail is off-screen; the bottom nav + drawer take over */
@media (max-width: 991.98px) {
  .sy-side { transform: translateX(-100%); height: 100dvh; }
  .sy-main { margin-left: 0; }
  .sy-main > header { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .sy-side *, .sy-main > header *, .sy-banner * { transition: none !important; }
}

@media (max-width: 991.98px) {
  /* iOS zooms on focus below 16px (the commission amount inputs) */
  .sy-page .sy-table input.form-control, .sy-page .sy-table select.form-select { font-size: 16px; }
}
@media (max-width: 767.98px) {
  .sy-head { flex-direction: column; align-items: stretch; }
  .sy-cols { grid-template-columns: 1fr; gap: 0; }
  .sy-bar-row { flex-wrap: wrap; row-gap: 4px; }
  .sy-bar { flex-basis: 100%; order: 5; }
  .sy-bar-value { width: auto; margin-left: auto; }
  .sy-period > div { flex: 1 1 140px; }
  .sy-period-or { flex-basis: 100%; padding-bottom: 0; }
}
@media (max-width: 575.98px) {
  .sy-card, .sy-kpi { padding: 12px; }
  .sy-table-wrap { margin: 0 -12px -12px; padding: 0 12px 8px; }
  .sy-kpi-value { font-size: 22px; }
}
@media (max-width: 479.98px) {
  .sy-kpis { grid-template-columns: 1fr; }
}
@media (min-width: 480px) and (max-width: 991.98px) {
  .sy-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 992px) {
  .sy-kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sy-kpis-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sy-kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sy-kpis-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1400px) {
  .sy-kpis-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .sy-page * { transition: none !important; }
}

/* U1b (/alerts, /review) --------------------------------------------- */

/* a list-item card with a severity left rule: the word in its badge carries the meaning */
.sy-card-flag { padding: 8px 12px; margin-bottom: 8px; border-left-width: 3px; }
.sy-flag-out  { border-left-color: var(--sy-out); }
.sy-flag-warn { border-left-color: var(--sy-warn); }
.sy-flag-info { border-left-color: var(--sy-primary); }
/* /review is a scan-many-bills page: dense rows (Put 2026-10-30), hit area grown by padding-free ::after */
.sy-doc-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-bottom: 4px; }
.sy-doc-head .sy-badge { margin-left: auto; }
.sy-page a.sy-doc-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; text-decoration: none; }
.sy-page a.sy-doc-link:hover { text-decoration: underline; }
.sy-doc-meta { font-size: 12.5px; color: var(--sy-muted); }
.sy-flags { list-style: none; margin: 0; padding: 0; font-size: 14px; line-height: 1.4; }
.sy-flags > li { display: flex; align-items: flex-start; gap: 4px; margin-bottom: 4px; }
.sy-flags > li:last-child { margin-bottom: 0; }
.sy-flags .sy-badge { flex-shrink: 0; line-height: 1.3; margin-top: 1px; }
.sy-page .sy-flags a.sy-go { min-height: 0; display: inline; }

/* long machine text (JSON context) wraps instead of widening the page */
.sy-break { display: block; overflow-wrap: anywhere; white-space: normal; }

/* row-action buttons in a mobile card are touch targets */
@media (max-width: 991.98px) {
  .sy-table.table-mobile-cards .sy-btn-sm { min-height: 44px; }
  .sy-table.sy-actions-left.table-mobile-cards td.td-actions { justify-content: flex-start; }
}

/* U2a (products pages) ------------------------------------------------ */

/* "Back to the list" / breadcrumb row: 44px links, current page is plain text */
.sy-crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; font-size: 12.5px; color: var(--sy-muted); }
.sy-crumb [aria-current] { font-weight: 600; color: var(--sy-ink); }
.sy-crumb-sep { color: var(--sy-faint); }

/* monospaced id / code */
.sy-mono { font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sy-tag { color: var(--sy-faint); font-size: 12px; }

/* a headline quantity inside a card (list rows, stock card) */
.sy-qty { font-size: 22px; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; }
.sy-qty-lg { font-size: 40px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sy-center { text-align: center; }
.sy-card-head .sy-actions { gap: 4px; }

/* small stat tiles side by side (Shopee / Lazada stock) */
.sy-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 16px; text-align: left; }
.sy-tile { border: 1px solid var(--sy-border); border-radius: var(--sy-radius-sm); padding: 8px 12px; }
.sy-tile-label { font-size: 12.5px; font-weight: 500; color: var(--sy-muted); }
.sy-tile-value { font-size: 22px; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; }
.sy-tile-unit { font-size: 12px; color: var(--sy-faint); }

/* label / value table (product info card): quiet, no hover */
.sy-table-dl td { padding: 8px 0; }
/* label cell: <td class="text-subtle"> (tests read that markup) */
.sy-table-dl td.text-subtle { width: 45%; padding-right: 8px; color: var(--sy-muted); }
.sy-card-title .text-accent { color: var(--sy-primary); }
.sy-table-dl tbody tr:hover { background: transparent; }
.sy-table-dl tbody tr:last-child td { border-bottom: 0; }
.sy-table-flush { margin: 0 -16px; padding: 0 16px; }

/* a pencil / small icon button that opens an edit modal (44px hit area on touch) */
.sy-icon-btn {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  min-width: 32px; min-height: 32px; padding: 0; border: 0; background: none;
  color: var(--sy-primary); border-radius: var(--sy-radius-sm); text-decoration: none;
}
.sy-icon-btn:hover { background: var(--sy-primary-soft); }
.sy-page a.sy-icon-btn { color: var(--sy-primary); }
/* 44px hit area, 32px of layout: the negative margin gives the rest back */
@media (max-width: 991.98px) { .sy-icon-btn { min-width: 44px; min-height: 44px; margin: -6px; } }

/* destructive action */
.sy-btn-danger { background: var(--sy-out-soft); border-color: var(--sy-out); color: var(--sy-out); }
.sy-btn-danger:hover { background: var(--sy-out-soft); filter: brightness(.97); }
.sy-page a.sy-btn-primary { color: #FFFFFF; }
.sy-page a.sy-btn-danger { color: var(--sy-out); }
.sy-btn-block { display: flex; width: 100%; }

/* a form on the system: labels, 16px controls (no iOS zoom), token borders */
.sy-form .form-label { font-size: 12.5px; font-weight: 500; color: var(--sy-muted); margin-bottom: 4px; }
.sy-form .form-control,
.sy-form .form-select {
  min-height: 40px; font-size: 16px; color: var(--sy-ink);
  border-color: var(--sy-border); border-radius: var(--sy-radius-sm);
}
.sy-form .form-control[readonly] { background: var(--sy-bg); }
.sy-form .form-control:focus,
.sy-form .form-select:focus { border-color: var(--sy-primary); box-shadow: none; }
.sy-form .input-group-text {
  font-size: 14px; color: var(--sy-muted); background: var(--sy-bg);
  border-color: var(--sy-border); border-radius: var(--sy-radius-sm);
}
.sy-form .form-text { font-size: 12.5px; color: var(--sy-muted); }
.sy-form hr { border-color: var(--sy-border); opacity: 1; }
.sy-form .input-group > .sy-btn { border-radius: 0 var(--sy-radius-sm) var(--sy-radius-sm) 0; }
.sy-form .form-check-input:checked { background-color: var(--sy-primary); border-color: var(--sy-primary); }
@media (max-width: 991.98px) { .sy-form .form-control, .sy-form .form-select { min-height: 44px; } }

/* a row of checkboxes with 44px hit areas (list filters) */
.sy-checks { display: flex; flex-wrap: wrap; gap: 0 16px; }
.sy-checks .form-check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin: 0; padding: 0; }
.sy-checks .form-check-input { float: none; margin: 0; width: 18px; height: 18px; }
.sy-checks .form-check-label { font-size: 14px; color: var(--sy-ink); }

/* numbered pager (Bootstrap pagination markup kept) */
.sy-pagination { padding-top: 12px; }
.sy-pagination .pagination { --bs-pagination-color: var(--sy-primary); --bs-pagination-hover-color: var(--sy-primary);
  --bs-pagination-active-bg: var(--sy-primary); --bs-pagination-active-border-color: var(--sy-primary);
  --bs-pagination-border-color: var(--sy-border); --bs-pagination-focus-box-shadow: none; --bs-pagination-hover-bg: var(--sy-primary-soft);
  --bs-pagination-padding-x: 12px; --bs-pagination-padding-y: 0; --bs-pagination-font-size: 14px; --bs-pagination-border-radius: var(--sy-radius-sm); }
.sy-pagination .page-link { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; justify-content: center; font-variant-numeric: tabular-nums; }

/* Bridge: the shared macro macros.html vat_badge still prints Bootstrap .badge, because other,
   unconverted pages use it. Inside .sy-bridge it takes the system's badge shape; its colours stay. */
.sy-bridge .badge { font-size: 12px; font-weight: 500; line-height: 1.5; padding: 0 8px; border-radius: 999px; }

/* low-stock row in a sy-table: red rule + soft red, as the Sendy cards do */
.sy-table tbody tr.row-low-stock td { background: var(--sy-out-soft) !important; }
.sy-table tbody tr.row-low-stock td:first-child { box-shadow: inset 3px 0 0 var(--sy-out); padding-left: 8px; }
.sy-table th.sy-col-id { width: 200px; }

/* inline stack of badges/codes under a name */
.sy-stack > * + * { margin-top: 4px; }
.sy-inline-gap > * + * { margin-left: 4px; }
.sy-scroll-y { max-height: 420px; overflow-y: auto; }
.sy-btn.disabled { opacity: .5; pointer-events: none; }
.sy-kpi-value-sm { font-size: 15px; line-height: 1.5; }
.sy-list > li.sy-list-top { align-items: flex-start; }
.sy-page .sy-tabs button.sy-tab { background: none; }
.sy-tab-pane-gap { margin-top: 0; }
@media (max-width: 991.98px) { .sy-btn-touch { min-height: 44px; } }
.sy-pagination .page-link { color: var(--sy-primary); border-color: var(--sy-border); background: var(--sy-card); box-shadow: none; }
.sy-pagination .page-item.active .page-link { background: var(--sy-primary); border-color: var(--sy-primary); color: #FFFFFF; }
.sy-pagination .page-item.disabled .page-link { color: var(--sy-faint); background: var(--sy-bg); }


/* a scan-many-rows table (stock history): 6px cell padding, the row link keeps its 32px hit area */
.sy-table-dense td { padding-top: 6px; padding-bottom: 6px; }

/* U3a (conversions pages) -------------------------------------------- */

/* type-ahead product picker (a text input + a hidden id + a floating result list) */
.sy-combo { position: relative; }
.sy-combo-results {
  display: none; position: absolute; z-index: 1056; left: 0; right: 0; top: 100%;
  margin-top: 2px; max-height: 320px; overflow-y: auto;
  background: var(--sy-card); border: 1px solid var(--sy-border); border-radius: var(--sy-radius);
}
.sy-combo-results.open { display: block; }
.sy-combo-item {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px;
  cursor: pointer; border-bottom: 1px solid var(--sy-border);
}
.sy-combo-item:last-child { border-bottom: 0; }
.sy-combo-item:hover, .sy-combo-item.active { background: var(--sy-primary-soft); }
.sy-combo-item .name { flex: 1 1 auto; min-width: 0; }
.sy-combo-chip {
  flex: 0 0 auto; font-size: 12.5px; color: var(--sy-muted); background: var(--sy-bg);
  border: 1px solid var(--sy-border); border-radius: 999px; padding: 0 8px; white-space: nowrap;
}
.sy-combo-empty { padding: 8px 12px; color: var(--sy-muted); font-size: 12.5px; }

/* an optional repeating row inside a form (e.g. extra pack items) */
.sy-extra-row { border: 1px solid var(--sy-border); border-radius: var(--sy-radius); padding: 8px; }
.sy-extra-row .form-control[type=number] { max-width: 6rem; }

/* a read-only value shown in a form control's shape */
.sy-form .sy-static { background: var(--sy-bg); }

/* an optional group of fields inside a form that Put should notice (e.g. ของเสีย) */
.sy-panel-warn {
  background: var(--sy-warn-soft); border: 1px solid var(--sy-border);
  border-left: 3px solid var(--sy-warn); border-radius: var(--sy-radius-sm); padding: 12px;
}

/* a whole card that is one link (choose-a-formula list) */
.sy-page a.sy-card-link { display: block; color: var(--sy-ink); text-decoration: none; }
.sy-page a.sy-card-link:hover { background: var(--sy-primary-soft); }

.sy-btn:disabled { opacity: .5; cursor: not-allowed; }

/* a right-aligned cell whose text may wrap (long product names), and a filter box that stays short */
.sy-table .sy-r.sy-wrap { white-space: normal; }
.sy-filter .sy-grow.sy-narrow { max-width: 28rem; }
/* a free-text note cell in a wide scrolling table: wraps, but never squeezed to one word per line */
/* a very wide numeric table (payroll items, 16-17 columns) that must fit a 1440 desktop without sideways scroll */
.sy-table.sy-table-tight { font-size: 12.5px; }
.sy-table.sy-table-tight th { font-size: 12px; padding: 6px 3px; white-space: normal; vertical-align: bottom; }
.sy-table.sy-table-tight td { padding: 6px 3px; }
.sy-table.sy-table-tight td.sy-cell-note { min-width: 4.5rem; max-width: 7rem; }
.sy-table td.sy-cell-note { min-width: 9rem; max-width: 12rem; }

/* U3b (label pages) -------------------------------------------------- */

/* a segmented toggle: a row of sy-btn where `.active` marks the chosen one (the page script toggles it) */
.sy-seg { display: flex; gap: 8px; flex-wrap: wrap; }
.sy-seg > .sy-btn { flex: 1 1 0; }
.sy-btn.active { background: var(--sy-primary-soft); border-color: var(--sy-primary); color: var(--sy-primary); }

/* a form card that should not stretch across a wide screen */
.sy-card-narrow { max-width: 720px; }

/* U5a (customer + supplier pages) ------------------------------------ */

/* a table row that is one link (onclick navigates); the row hover tint is the affordance */
.sy-table tr.sy-row-click { cursor: pointer; }
.sy-table tr.sy-row-click:hover { background: var(--sy-primary-soft); }

/* a totals row inside tbody (a tfoot is not flattened by table-mobile-cards) */
.sy-table tr.sy-total-row td { font-weight: 600; border-top: 2px solid var(--sy-ink); border-bottom: 0; }

/* a row of label/value groups with room between them (supplier info card) */
.sy-actions.sy-actions-wide { gap: 24px; align-items: flex-start; }

/* U5b (call list + call card) ---------------------------------------- */

/* two columns, narrow summary side + wide main side; stacks under 992px */
.sy-cols-aside { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); gap: 12px; align-items: start; }
.sy-cols-aside > div > .sy-card:last-child { margin-bottom: 0; }
@media (max-width: 991.98px) { .sy-cols-aside { grid-template-columns: minmax(0, 1fr); gap: 0; } .sy-cols-aside > div > .sy-card:last-child { margin-bottom: 16px; } }

/* label over value pairs (customer summary): `.k` label, `.v` value, `[data-sm]` a smaller value */
.sy-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.sy-stats .k { font-size: 12.5px; font-weight: 500; color: var(--sy-muted); }
.sy-stats .v { font-size: 17px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.sy-stats .v[data-sm] { font-size: 14px; }
.sy-stats .v small { font-size: 12px; font-weight: 400; color: var(--sy-muted); }

/* a label + control (+ button) row inside a form card; wraps on narrow widths */
.sy-field-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.sy-field-row:first-child { margin-top: 0; }
.sy-field-row > label { flex: 0 0 96px; font-size: 12.5px; font-weight: 500; color: var(--sy-muted); margin: 0; }
.sy-field-row > .form-control { flex: 1 1 200px; min-width: 0; }

/* a row of label/value on one line (AR totals) */
.sy-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0; }
.sy-line .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* a clickable table cell that opens a modal */
.sy-table td.sy-cell-click { cursor: pointer; }
.sy-table td.sy-cell-click:hover { background: var(--sy-primary-soft); }
.sy-cell-hint { font-size: 12px; color: var(--sy-primary); margin-top: 2px; }

/* an entry list (call log): one block per entry, meta line under it */
.sy-log { list-style: none; margin: 0; padding: 0; }
.sy-log > li { padding: 8px 0; border-top: 1px solid var(--sy-border); font-size: 14px; }
.sy-log > li:first-child { border-top: 0; }
.sy-log .meta { font-size: 12.5px; color: var(--sy-muted); margin-top: 2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* a quiet text button (delete inside a log entry, mini flag) */
.sy-link-btn { background: none; border: 0; padding: 0 8px; min-height: 32px; font: inherit; font-size: 12.5px; color: var(--sy-muted); cursor: pointer; }
.sy-link-btn:hover { color: var(--sy-out); }

/* small select that sits inside a table header */
.sy-th-select { font: inherit; font-size: 12.5px; min-height: 32px; margin-left: 4px; border: 1px solid var(--sy-border); border-radius: var(--sy-radius-sm); background: var(--sy-card); color: var(--sy-ink); }

/* phone buttons of the call card header: a stack of 44px buttons */
.sy-hdr .callstack { display: flex; flex-direction: column; gap: 8px; }
.sy-hdr .callstack .sy-btn small { font-size: 12px; font-weight: 400; margin-left: 8px; color: inherit; opacity: .85; }
.sy-hdr .callstack .sy-btn.sy-off { opacity: .7; cursor: default; background: var(--sy-bg); }
.sy-hdr { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px 24px; }
.sy-hdr-right { margin-left: auto; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.sy-hdr .page-title { margin: 0; font-size: 22px; font-weight: 600; }
@media (max-width: 991.98px) { .sy-hdr-right { margin-left: 0; align-items: stretch; width: 100%; } }

/* U5c: caption-size text inside a table cell or line, a 3px severity rule on a full card, a wide info cell, a collapse toggle that is a whole head */
.sy-small { font-size: 12.5px; }
.sy-card-rule { border-left-width: 3px; }
.sy-actions-wide > .sy-info-wide { min-width: 200px; max-width: 320px; }
.sy-page a.sy-audit-toggle { display: inline-flex; align-items: center; min-height: 44px; flex: 1; color: var(--sy-ink); }
.sy-bank-acct { padding: 12px 0; border-top: 1px solid var(--sy-border); }
.sy-bank-acct:first-of-type { border-top: 0; }
.sy-bank-form { border: 1px solid var(--sy-border); border-radius: var(--sy-radius-sm); padding: 12px; margin-top: 8px; }

/* U6a (VAT sub pages) ------------------------------------------- */
/* label / value list: label left, figure right, 1px dividers */
.sy-dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; margin: 0; font-size: 14px; }
.sy-dl dt, .sy-dl dd { margin: 0; padding: 8px 0; border-top: 1px solid var(--sy-border); }
.sy-dl dt { font-weight: 400; color: var(--sy-muted); padding-right: 12px; }
.sy-dl dd { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.sy-dl dt:first-of-type, .sy-dl dt:first-of-type + dd { border-top: 0; }

/* U6b-1 (ecommerce overview + product page) ----------------------------------------*/
/* a row of read-only status pills (data freshness per source) */
.sy-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.sy-pills > span {
  font-size: 12.5px; color: var(--sy-muted); padding: 6px 12px;
  background: var(--sy-card); border: 1px solid var(--sy-border); border-radius: var(--sy-radius-sm);
}
.sy-pills > span strong { color: var(--sy-ink); font-weight: 600; }

/* count inside a filter chip */
.sy-chip-n { margin-left: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sy-chip-gap { margin-top: 12px; }

/* row tints: out of stock on a channel (red), faded (dead) */
.sy-table tbody tr.sy-row-out { background: var(--sy-out-soft); }
.sy-table tbody tr.sy-row-dim td { opacity: .6; }

/* per-channel blocks on a product page: a header, item sub-headers, listing rows */
.sy-plats { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 768px) { .sy-plats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1360px) { .sy-plats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.sy-plats > .sy-card { margin-bottom: 0; padding: 0; overflow: hidden; }
.sy-plat-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--sy-border); font-size: 15px; font-weight: 600;
}
.sy-plat-head .sy-small { margin-left: auto; font-weight: 400; color: var(--sy-muted); text-align: right; }
.sy-subhead {
  padding: 8px 16px; background: var(--sy-bg); border-bottom: 1px solid var(--sy-border);
  font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere;
}
.sy-listing { padding: 12px 16px; border-bottom: 1px solid var(--sy-border); overflow-wrap: anywhere; }
.sy-listing:last-child { border-bottom: 0; }
.sy-kv { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 12.5px; color: var(--sy-muted); }
.sy-kv b { color: var(--sy-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.sy-strike { text-decoration: line-through; }
.sy-badge-wrap { white-space: normal; border-radius: var(--sy-radius-sm); }

/* U6b-2 (marketplace orders, review, unmapped, order + IV modals) --------------------*/
/* an id that opens a modal: a real button that reads as a link (keyboard reachable) */
.sy-id-btn {
  background: none; border: 0; padding: 0; min-height: 32px; font: inherit; font-size: 12.5px;
  color: var(--sy-primary); text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.sy-id-btn:hover { text-decoration-thickness: 2px; }
.sy-id-btn:focus-visible { outline: 2px solid var(--sy-primary); outline-offset: 2px; }
.sy-page code.js-order-detail { color: inherit; }
@media (max-width: 991.98px) { .sy-id-btn { min-height: 44px; } }

/* label / text list for a modal: label above value under 576px (a long address must not squeeze its label) */
.sy-dl-text { grid-template-columns: minmax(7rem, 30%) minmax(0, 1fr); font-size: 14px; }
.sy-dl-text dd { text-align: left; font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
  .sy-dl-text { grid-template-columns: minmax(0, 1fr); }
  .sy-dl-text dt { padding-bottom: 0; font-size: 12.5px; }
  .sy-dl-text dd { border-top: 0; padding-top: 0; }
}

/* /vat-links: Claude's suggestion box inside a table-mobile-cards cell. A grid item keeps its content's
   width (nowrap doc lines, amounts) and ran past a 390px card; it may shrink and wrap, and under 576px
   its cell stacks label over value so the box gets the whole card width. */
.sy-suggest { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 991.98px) { .sy-suggest .sy-nowrap { white-space: normal; } }
@media (max-width: 575.98px) {
  .sy-table.table-mobile-cards td.sy-suggest-cell { grid-template-columns: minmax(0, 1fr); }
}

/* quiet bordered box (modal timeline, margin, adjustments); the warn variant is sy-panel-warn */
.sy-box { background: var(--sy-bg); border: 1px solid var(--sy-border); border-radius: var(--sy-radius-sm); padding: 8px 12px; font-size: 12.5px; }
.sy-box-title { font-weight: 600; color: var(--sy-ink); }
.sy-steps { display: flex; align-items: flex-start; justify-content: space-between; gap: 4px; }
.sy-step { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; min-width: 0; }
.sy-step-label { font-size: 12px; color: var(--sy-muted); }
.sy-step-arrow { color: var(--sy-faint); padding-top: 2px; }
.sy-help { cursor: help; border-bottom: 1px dotted var(--sy-faint); }

/* IV picker rows: the whole row is the label, 44px high */
.sy-pick { display: flex; flex-direction: column; border: 1px solid var(--sy-border); border-radius: var(--sy-radius-sm); overflow: hidden; margin-bottom: 12px; font-size: 12.5px; }
.sy-pick-item { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; margin: 0; border-top: 1px solid var(--sy-border); cursor: pointer; transition: background-color 150ms; }
.sy-pick-item:first-child { border-top: 0; }
.sy-pick-item:hover { background: var(--sy-primary-soft); }
.sy-pick-item:has(input:checked) { background: var(--sy-primary-soft); }
.sy-pick-item input { flex-shrink: 0; margin: 0; }
.sy-pick-note { padding: 8px 12px; color: var(--sy-muted); }

/* a long list as cards (/marketplace has up to 500 rows): two label-over-value cells per line under 992px */
@media (max-width: 991.98px) {
  .sy-table.sy-cards-2.table-mobile-cards tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; padding: 10px 12px; }
  .sy-table.sy-cards-2.table-mobile-cards td { display: block; padding: 0; min-width: 0; overflow-wrap: anywhere; font-size: 14px; line-height: 1.3; }
  .sy-table.sy-cards-2.table-mobile-cards td::before { display: block; font-size: 12px; line-height: 1.3; }
  .sy-table.sy-cards-2.table-mobile-cards td.td-primary { grid-column: 1 / -1; margin: 0; padding-bottom: 2px; }
  .sy-table.sy-cards-2.table-mobile-cards td.td-actions { grid-column: 1 / -1; }
}

/* U6b-3 (marketplace settlement + returns) -------------------------------------------*/
/* a caption that sits at the start of a chip row (ปี:) */
.sy-chips-label { display: inline-flex; align-items: center; padding: 0 4px; font-size: 12.5px; font-weight: 500; color: var(--sy-muted); }
/* a two-tab bar whose tabs share the row and may wrap their text (long Thai tab names at 390px) */
.sy-page .sy-tabs.sy-tabs-fill .sy-tab { flex: 1 1 0; justify-content: center; text-align: center; white-space: normal; line-height: 1.3; padding: 6px 8px; }
.sy-tabs-fill > li { flex: 1 1 0; display: flex; }
/* an expandable card (payout block): the header is one real button, the body lazy-loads on expand */
.sy-dep { padding-top: 4px; padding-bottom: 0; }
.sy-dep-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px;
  width: 100%; min-height: 44px; padding: 0; background: none; border: 0; text-align: left;
  font: inherit; color: inherit; cursor: pointer;
}
.sy-dep-title { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sy-dep-title::before {
  content: '\203A'; display: inline-block; font-size: 20px; line-height: 1; color: var(--sy-faint);
  transition: transform 150ms;
}
.sy-dep-head[aria-expanded="true"] .sy-dep-title::before { transform: rotate(90deg); }
.sy-dep-figs { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0 12px; font-variant-numeric: tabular-nums; }
.sy-dep .sy-dep-body { margin: 0 -16px; padding: 0 16px 8px; border-top: 1px solid var(--sy-border); overflow-x: auto; }
.sy-dep-foot { margin: 0 -16px; padding: 8px 16px; border-top: 1px solid var(--sy-border); font-size: 12.5px; color: var(--sy-muted); }
@media (max-width: 575.98px) {
  .sy-dep .sy-dep-body, .sy-dep-foot { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
}
/* a cell with no content (the ตรวจ cell of a row that needs no review) takes no room inside a mobile card */
@media (max-width: 991.98px) { .sy-table.table-mobile-cards td.td-actions:empty { display: none; } }
/* a table whose warn rows need more than a faint tint (reconcile): a 3px rule on the row's leading edge (the row-low-stock pattern) */
.sy-table-flag tbody tr.sy-row-warn td:first-child { box-shadow: inset 3px 0 0 var(--sy-warn); padding-left: 8px; }
@media (max-width: 991.98px) {
  .sy-table-flag.table-mobile-cards tbody tr.sy-row-warn td:first-child { box-shadow: none; padding-left: 0; }
  .sy-table-flag.table-mobile-cards tbody tr.sy-row-warn { box-shadow: inset 3px 0 0 var(--sy-warn); }
}
/* a whole-banner link (alert / note that is one anchor): body text keeps its own colour, only the label reads as the link */
.sy-page a.sy-alert { color: var(--sy-ink); text-decoration: none; }
.sy-page a.sy-note { color: var(--sy-muted); text-decoration: none; }
.sy-page a.sy-alert .sy-alert-text, .sy-page a.sy-note .sy-alert-text { color: var(--sy-primary); }
.sy-link-btn:disabled, .sy-link-btn:disabled:hover { color: var(--sy-faint); cursor: not-allowed; }

/* U7a-1 (commission drill-downs, payouts, overrides) ------------------- */

/* toolbar above a table-mobile-cards list: its select-all and sort live here under 992px (the thead is hidden) */
.sy-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 12px; }
.sy-bulk .form-select { flex: 1 1 200px; width: auto; min-height: 44px; font-size: 16px; }

/* a checkbox with a visible, touch-sized label (select a row, select all) */
.sy-tick { display: inline-flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; }
.sy-tick input[type="checkbox"] { width: 20px; height: 20px; margin: 0; flex-shrink: 0; }
@media (max-width: 991.98px) { .sy-tick { min-height: 44px; } }

/* a sortable column header link */
.sy-table th a.sy-sort { color: inherit; text-decoration: none; white-space: nowrap; }
.sy-table th a.sy-sort:hover { color: var(--sy-ink); }
.sy-table th a.sy-sort.active { color: var(--sy-ink); font-weight: 600; }
.sy-table th a.sy-sort .bi { font-size: 11px; margin-left: 2px; }

/* radio pair rendered as a segmented control (Bootstrap .btn-check + label.sy-btn) */
.sy-seg > .btn-check:checked + .sy-btn { background: var(--sy-primary-soft); border-color: var(--sy-primary); color: var(--sy-primary); }
.sy-seg > .btn-check:focus-visible + .sy-btn { outline: 2px solid var(--sy-primary); outline-offset: 2px; }
.sy-seg.sy-seg-auto > .sy-btn { flex: 0 0 auto; min-width: 120px; }

/* U14a (payslip, account ledger, statement upload, VAT detail) ------------------*/
/* two columns that stack on a phone, on screen only: the printed payslip keeps its column pairs */
@media screen and (max-width: 575.98px) { .sy-stack-xs > [class*="col-"] { flex: 0 0 100%; max-width: 100%; } }
/* a card cell with no content (an empty note / user tag) takes no room */
@media (max-width: 991.98px) { .sy-table.sy-cards-2.table-mobile-cards td:empty { display: none; } }

/* U9a (statement reconcile) ------------------------------------------- */
/* a group heading row inside a table body (one per proposal group): full width in a mobile card too */
.sy-table tr.sy-row-head th { background: var(--sy-bg); color: var(--sy-ink); font-size: 12.5px; font-weight: 600; white-space: normal; }
.sy-table tbody tr.sy-row-head:hover { background: transparent; }
/* one option stacked in a cell (a receipt that can be linked to this credit), divided from the next */
.sy-cand { padding: 4px 0; border-bottom: 1px solid var(--sy-border); }
.sy-rule-top { border-top: 1px solid var(--sy-border); }
@media (max-width: 991.98px) {
  .sy-table.sy-cards-2.table-mobile-cards tr.sy-row-head { display: block; padding: 8px 12px; }
  .sy-table.sy-cards-2.table-mobile-cards tr.sy-row-head th { display: block; padding: 0; background: none; border: 0; }
  /* touch-sized controls inside a mobile card: inputs, selects, and a <summary> that opens a row form */
  .sy-table.table-mobile-cards .form-control, .sy-table.table-mobile-cards .form-select { min-height: 44px; }
  .sy-table.table-mobile-cards td summary { min-height: 44px; padding: 12px 0; }
  /* a row form in a card wraps its controls instead of squeezing the button to one letter per line */
  .sy-table.table-mobile-cards td .d-flex { flex-wrap: wrap; }
  .sy-table.table-mobile-cards td .sy-btn { flex-shrink: 0; white-space: nowrap; }
}

/* U10a (import pages, unit conversions) ------------------------------------- */
/* Status colours on a page whose markup keeps Bootstrap text-* classes (tests read them): the same words, token colours.
   Scoped to the .sy-tone wrapper, so no other page moves. Bootstrap's text-warning (#ffc107) is 1.6:1 on white. */
.sy-tone .text-success { color: var(--sy-in) !important; }
.sy-tone .text-danger { color: var(--sy-out) !important; }
.sy-tone .text-warning { color: var(--sy-warn) !important; }
.sy-tone .text-muted, .sy-tone .text-subtle, .sy-tone .text-secondary { color: var(--sy-muted) !important; }
/* a single-column page body that should not stretch across a wide screen */
.sy-measure { max-width: 60rem; }
/* a status line: 14px text, a quiet divider between groups */
.sy-status p { margin: 0 0 8px; }
.sy-status ul { margin: 0; padding-left: 20px; }
.sy-status li { margin-bottom: 4px; }
.sy-status hr { border-color: var(--sy-border); opacity: 1; margin: 12px 0; }
/* a "1 unit = ratio unit" input group that stays short and centres in its column (left in a mobile card) */
.sy-ratio { max-width: 230px; margin: 0 auto; }
.sy-table td .sy-ratio input.form-control { min-width: 0; }
@media (max-width: 991.98px) { .sy-ratio { margin: 0; max-width: none; } }
.sy-table th.sy-col-ratio { width: 260px; }
.sy-table th.sy-col-count { width: 90px; }
.sy-table th.sy-col-act { min-width: 112px; }
.sy-table th.sy-col-desc { min-width: 160px; }
.sy-table th.sy-col-note { min-width: 140px; }
/* a script-built result list under a search box (list-group buttons): 44px rows, token border */
.sy-results { max-height: 320px; overflow-y: auto; border-radius: var(--sy-radius); }
.sy-results:empty { display: none; }
.sy-results .list-group-item { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-height: 44px; font-size: 14px; border-color: var(--sy-border); }
/* a form control sized for a row cell in a mobile card (checkbox + long label stays one tap target) */
.sy-tick-text { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-size: 14px; cursor: pointer; }
.sy-tick-text input[type="checkbox"] { width: 20px; height: 20px; margin: 2px 0 0; flex-shrink: 0; }
@media (max-width: 991.98px) { .sy-tick-text { min-height: 44px; align-items: center; } }
/* a stat trio inside a preview card (new / unchanged / changed) */
.sy-kpis-trio .sy-kpi-label { padding-right: 0; }
.sy-tone .border-warning { border-color: var(--sy-warn) !important; }
/* unit-conversions rows as cards: the ratio and its edit button share one line; while the row is being edited (or a code rule
   makes the cell long) the ratio takes the whole line and the button wraps under it */
@media (max-width: 991.98px) {
  .sy-table.sy-uc-table.sy-cards-2.table-mobile-cards td.td-actions { grid-column: auto; align-self: end; justify-self: end; }
  .sy-table.sy-uc-table.sy-cards-2.table-mobile-cards tr:has(.ratio-form:not(.d-none)) td.td-actions { grid-column: 1 / -1; }
  .sy-table.sy-uc-table.sy-cards-2.table-mobile-cards td.sy-ratio-cell:has(.ratio-form:not(.d-none)),
  .sy-table.sy-uc-table.sy-cards-2.table-mobile-cards td.sy-ratio-cell:has([data-code-rule]) { grid-column: 1 / -1; }
}
/* U10b-1: a card row whose last cell is a single action keeps it on the line of the cell before it (a short list of
   label/value rows, e.g. the naming colour dictionary: count + "ดูตัวอย่าง"). New class, so no other page moves. */
@media (max-width: 991.98px) {
  .sy-table.sy-cards-inline-actions.sy-cards-2.table-mobile-cards td.td-actions { grid-column: auto; align-self: end; justify-self: end; }
}

/* U11a (/mapping): empty-state emoji, a Bootstrap accordion on tokens, a card nested in a modal, and an alert whose
   tone the page script flips between .alert-info and .alert-warning. All four are new classes, so nothing shared moves. */
.sy-empty-icon { font-size: 2rem; line-height: 1.2; }
.sy-accordion { --bs-accordion-border-color: var(--sy-border); --bs-accordion-border-radius: var(--sy-radius);
  --bs-accordion-inner-border-radius: calc(var(--sy-radius) - 1px); --bs-accordion-btn-focus-box-shadow: none;
  --bs-accordion-active-bg: var(--sy-primary-soft); --bs-accordion-active-color: var(--sy-ink); margin-bottom: 16px; }
.sy-accordion .accordion-item { background: var(--sy-card); }
.sy-accordion .accordion-button { font-size: 14px; color: var(--sy-ink); }
.sy-accordion .accordion-button:focus-visible { outline: 2px solid var(--sy-primary); outline-offset: -2px; }
@media (max-width: 991.98px) { .sy-accordion .accordion-button { min-height: 44px; } }
.sy-card-nested { background: var(--sy-bg); }
.sy-alert-toggle { border: 0; border-left: 3px solid var(--sy-primary); border-radius: var(--sy-radius-sm); padding: 8px 12px;
  margin-bottom: 12px; font-size: 14px; color: var(--sy-ink); }
.sy-alert-toggle.alert-info { background: var(--sy-primary-soft); border-left-color: var(--sy-primary); }
.sy-alert-toggle.alert-warning { background: var(--sy-warn-soft); border-left-color: var(--sy-warn); }

/* U12a (system + settings pages) ------------------------------------------------------*/
/* a small centred card (login) */
.sy-card-sm { max-width: 440px; margin-left: auto; margin-right: auto; }
/* disk-usage bar (/admin/backups, /admin/upload-db): Bootstrap progress markup kept (a test reads
   `progress-bar bg-*`), look from the tokens */
.sy-disk-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-bottom: 8px; font-size: 12.5px; }
.sy-disk .progress { --bs-progress-height: 8px; --bs-progress-bg: var(--sy-bg); --bs-progress-border-radius: 4px; }
.sy-disk .progress-bar.bg-success { background-color: var(--sy-in) !important; }
.sy-disk .progress-bar.bg-warning { background-color: var(--sy-warn) !important; }
.sy-disk .progress-bar.bg-danger { background-color: var(--sy-out) !important; }
/* /users list: a test pins the employee cell as a bare <td>, so its card label comes from here */
@media (max-width: 991.98px) {
  .sy-table.sy-users-table.table-mobile-cards td:nth-child(3)::before { content: 'พนักงาน'; }
}
/* install steps: readable numbered list on a phone */
.sy-steps-list { margin: 0; padding-left: 24px; line-height: 2; }

/* U13a (mobile pages /m/*) ----------------------------------------------------------
   Every rule is scoped to a wrapper class (.sy-stock, .sy-mcust, .sy-trip) on those 3 templates, so no other
   page moves. The class names the two inline scripts and the tests read (stock-result*, is-low, low, trip-cust*,
   region-chip, data-row) are kept and styled here. */
/* /m/stock: sticky search under the top bar; results are built by JS with the classes below */
.sy-stock .stock-search-wrap {
  position: sticky; top: 60px; z-index: 40; background: var(--sy-bg);
  padding: 8px 12px 12px; margin: -12px -12px 8px; border-bottom: 1px solid var(--sy-border);
}
.sy-stock .stock-search-wrap .form-control,
.sy-stock .stock-search-wrap .input-group-text { height: 48px; font-size: 16px; border-color: var(--sy-border); }
.sy-stock .stock-search-wrap .form-control:focus { border-color: var(--sy-primary); box-shadow: none; }
.sy-stock .stock-result {
  display: block; background: var(--sy-card); border: 1px solid var(--sy-border); border-radius: var(--sy-radius);
  padding: 12px 14px; margin-bottom: 8px; text-decoration: none; color: var(--sy-ink);
}
.sy-page.sy-stock a.stock-result { color: var(--sy-ink); }  /* beats .sy-page a:not(.btn) */
.sy-stock .stock-result:hover { background: var(--sy-primary-soft); }
.sy-stock .stock-result.is-low { border-left: 4px solid var(--sy-out); padding-left: 10px; background: var(--sy-out-soft); }
.sy-stock .stock-result-name { font-size: 16px; font-weight: 600; line-height: 1.3; }
.sy-stock .stock-result-meta { display: flex; gap: 6px 12px; align-items: center; margin-top: 4px; flex-wrap: wrap; font-size: 14px; }
.sy-stock .stock-result-qty { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sy-stock .stock-result-qty.low { color: var(--sy-out); }
.sy-stock .stock-result-sku { font-size: 12.5px; color: var(--sy-muted); background: var(--sy-bg); border: 1px solid var(--sy-border); padding: 0 6px; border-radius: 4px; }
.sy-stock .stock-result .badge { font-size: 12px; font-weight: 500; line-height: 1.5; padding: 0 8px; border-radius: 999px; border: 1px solid var(--sy-border); }
.sy-stock .stock-result .badge-warning { color: var(--sy-warn); background: var(--sy-warn-soft); border-color: var(--sy-warn); }
.sy-stock .stock-result .badge-gray { color: var(--sy-muted); background: var(--sy-bg); }
.sy-stock .stock-result .badge.bg-danger-subtle { color: var(--sy-out) !important; background-color: var(--sy-out-soft) !important; border-color: var(--sy-out); }
.sy-stock .stock-empty { text-align: center; color: var(--sy-muted); font-size: 14px; padding: 40px 12px; }

/* /m/customer: header, contact buttons, bill rows */
.sy-mcust .sy-mname { font-size: 20px; font-weight: 600; line-height: 1.3; }
.sy-mcust .sy-badge-wrap { white-space: normal; }
.sy-mcust .sy-actions { margin-top: 12px; }
.sy-mcust .sy-actions .btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px;
  border-radius: var(--sy-radius-sm); font-size: 14px; font-weight: 500; text-decoration: none;
  border: 1px solid var(--sy-border); background: var(--sy-card); color: var(--sy-ink);
}
.sy-mcust .sy-actions .btn.btn-success { background: var(--sy-in); border-color: var(--sy-in); color: #FFFFFF; }
.sy-mcust .sy-btn-call { background: var(--sy-in); border-color: var(--sy-in); color: #FFFFFF; }
.sy-page.sy-mcust a.sy-btn-call { color: #FFFFFF; }
.sy-mcust .sy-btn-call:hover { background: var(--sy-in); filter: brightness(1.1); }
.sy-mcust .sy-btn-off { color: var(--sy-muted); background: var(--sy-bg); cursor: default; }
.sy-mcust .sy-btn-off:hover { background: var(--sy-bg); }
.sy-mcust .sy-card-due { border-left: 3px solid var(--sy-out); }
.sy-mcust .sy-mrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px;
  padding: 8px 0; border-top: 1px solid var(--sy-border); text-decoration: none; color: var(--sy-ink);
}
.sy-mcust .sy-mrow:first-child { border-top: 0; }
.sy-page.sy-mcust a.sy-mrow { color: var(--sy-ink); }
.sy-mcust a.sy-mrow:hover { background: var(--sy-primary-soft); }
.sy-mcust .sy-mamt { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sy-mcust .sy-mstat { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sy-mcust .sy-mstats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.sy-mcust .sy-mstats .sy-card { margin-bottom: 0; text-align: center; padding: 8px 12px; }
.sy-mcust .sy-note strong { color: var(--sy-ink); }
.sy-mcust .sy-mmore { text-align: center; margin-bottom: 16px; }

/* /m/sales-trip: region filter, grouped customer rows (long list: rows add no DOM) */
.sy-trip .region-section {
  background: var(--sy-bg); margin: 16px -12px 8px; padding: 6px 14px; font-size: 14px; font-weight: 600;
  color: var(--sy-muted); border-bottom: 1px solid var(--sy-border); position: sticky; top: 60px; z-index: 30;
}
.sy-trip .trip-cust {
  display: block; background: var(--sy-card); border: 1px solid var(--sy-border); border-radius: var(--sy-radius);
  padding: 12px 14px; margin-bottom: 8px; text-decoration: none; color: var(--sy-ink);
}
.sy-page.sy-trip a.trip-cust { color: var(--sy-ink); }
.sy-trip .trip-cust:hover { background: var(--sy-primary-soft); }
.sy-trip .trip-cust.has-due { border-left: 4px solid var(--sy-out); padding-left: 10px; }
.sy-trip .trip-cust-name { font-size: 16px; font-weight: 600; line-height: 1.3; }
.sy-trip .trip-cust-meta { display: flex; gap: 4px 12px; align-items: center; margin-top: 4px; flex-wrap: wrap; font-size: 13px; color: var(--sy-muted); }
.sy-trip .trip-cust-due { color: var(--sy-out); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin-left: auto; }

/* U17 (การค้า document pages) ---------------------------------------- */

/* totals under a document's line table (a tfoot is not flattened by table-mobile-cards) */
.sy-doc-totals { max-width: 420px; margin: 8px 0 0 auto; }

/* a card whose whole head row toggles a Bootstrap collapse (audit history) */
.sy-page a.sy-collapse-toggle {
  display: flex; align-items: center; gap: 8px; min-height: 44px;
  color: var(--sy-ink); text-decoration: none;
}
.sy-collapse-toggle .sy-card-title { margin: 0; }
.sy-collapse-toggle[aria-expanded="true"] .bi-chevron-down { transform: rotate(180deg); }

/* a radio option as a whole 44px+ row (choose how the stock moves) */
.sy-choice.form-check {
  position: relative; padding: 0; margin: 0 0 8px;
  border: 1px solid var(--sy-border); border-radius: var(--sy-radius-sm);
}
.sy-choice.form-check .form-check-input { position: absolute; left: 12px; top: 14px; float: none; margin: 0; width: 18px; height: 18px; }
.sy-choice.form-check .form-check-label { display: block; padding: 10px 12px 10px 40px; font-size: 14px; cursor: pointer; }
.sy-choice.form-check:has(.form-check-input:checked) { background: var(--sy-primary-soft); border-color: var(--sy-primary); }

/* U19: photo reviewer image stage, its result list, and the stock-adjust reason rows (_adjust_fields) */
.sy-photo-stage { background: var(--sy-ink); text-align: center; padding: 8px; }
.sy-photo-stage img { max-width: 100%; max-height: 70vh; object-fit: contain; }
.sy-pick-list { max-height: 30vh; overflow: auto; }
.sy-choice-row { cursor: pointer; min-height: 44px; border-color: var(--sy-border) !important; font-size: 14px; }
.sy-choice-row.border-warning { border-color: var(--sy-primary) !important; }
.sy-choice-row.bg-warning-subtle { background-color: var(--sy-primary-soft) !important; }

/* U20 (shared partials) ---------------------------------------------- */

/* popue_badge: popue.badge() hands the template a Bootstrap-era class string. Map the grey one here;
   the muted "ไม่ใช่ของโป๊ว" variant (border text-subtle fw-normal) already reads right on .sy-badge. */
.sy-badge.badge-gray { color: var(--sy-muted); background: var(--sy-bg); border-color: var(--sy-border); }

/* hr/_bank_select: the free-text bank name under the select (the 4px Bootstrap mt-1 was) */
.sy-bank-other { margin-top: 4px; }

/* catalogue_table inside a sy-card-flag (/products/catalogue-check): the card pads 8px 12px, not 16px */
.sy-card-flag > .sy-cat-wrap { margin: 0 -12px -8px; padding: 0 12px 4px; }

/* Mobile chrome (U21): bottom bar + "เพิ่มเติม" drawer, below 992px only.
   .bottom-nav and .bottom-nav-item stay on the markup as test hooks (tests/test_pwa_nav_phase3_render.py), never styled by name.
   The drawer reuses sy-side-link / sy-side-section from the desktop rail, so both read as one nav.
   Bar height and the body clearance gain env(safe-area-inset-bottom): 0 everywhere but a notched iPhone. */
.sy-bnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  display: flex; height: calc(60px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--sy-card); border-top: 1px solid var(--sy-border);
  font-family: var(--sy-font);
}
.sy-bnav-item {
  position: relative; flex: 1; min-width: 0; min-height: 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 6px 2px; border: 0; background: transparent; text-decoration: none;
  font: inherit; font-size: 11px; font-weight: 500; line-height: 1.2; color: var(--sy-muted);
  transition: color 150ms, background-color 150ms;
}
.sy-bnav-item i { font-size: 22px; line-height: 1; }
.sy-bnav-item span:not(.badge-count) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sy-bnav-item.active { color: var(--sy-primary); font-weight: 600; background: var(--sy-primary-soft); }
/* "you are here" is also a bar on top edge, not colour alone */
.sy-bnav-item.active::before {
  content: ""; position: absolute; top: 0; left: 20%; right: 20%; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--sy-primary);
}
.sy-bnav-item .badge-count {
  position: absolute; top: 4px; right: calc(50% - 22px);
  min-width: 18px; padding: 0 5px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
  font-variant-numeric: tabular-nums; color: #FFFFFF; background: var(--sy-out);
}
.sy-bnav-item:focus-visible { outline: 2px solid var(--sy-primary); outline-offset: -3px; }

.sy-drawer { --bs-offcanvas-width: min(320px, 86vw); --bs-offcanvas-bg: var(--sy-card); font-family: var(--sy-font); }
.sy-drawer-head { padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--sy-border); }
.sy-drawer-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--sy-ink); }
.sy-drawer-title i { color: var(--sy-primary); }
.sy-drawer .btn-close { width: 44px; height: 44px; padding: 0; margin: 0; background-size: 14px; }
.sy-drawer-body { padding: 4px 8px calc(16px + env(safe-area-inset-bottom, 0px)); }
.sy-drawer-form { margin: 0; }
.sy-drawer .sy-side-link { min-height: 48px; font-size: 15px; }
.sy-drawer .sy-side-link i { font-size: 18px; }
.sy-drawer button.sy-side-link { width: 100%; border: 0; background: transparent; font-family: inherit; text-align: left; cursor: pointer; }
.sy-drawer a:focus-visible, .sy-drawer button:focus-visible { outline: 2px solid var(--sy-primary); outline-offset: -2px; box-shadow: none; }
@media (max-width: 991.98px) {
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) { .sy-bnav-item { transition: none; } }
@media print { .sy-bnav, .sy-drawer { display: none !important; } }
