/* GENERATED จาก TaoKae-RestaurantOS@78708c5076 src/styles/ui.css + คลาส ui-* ใน src/styles/theme.css โดย web/scripts/design-sync.mjs — ห้ามแก้มือ */
/*
 * Shared UI classes (#445 step 2 · #442 slice 1) — the layer that turns tokens
 * into controls. Until now every screen drew its own button, field, badge, tab and
 * row inline (~3,900 `style={{…}}` app-wide), so a token change never reached the
 * screen. A screen that adopts these gets the CI by using the class, and the next
 * change to a token lands everywhere at once.
 *
 * The contract, checked by src/styles/ui-classes.test.ts:
 *  - Every selector names a `ui-*` class that did not exist before this file. No
 *    bare element selector, so a page that does not use these classes cannot move.
 *  - Colours come from theme.css only. Words in a status colour use the *-text twin
 *    (DESIGN.md The Semantic Text Rule); every badge tone reads >= 4.5:1 in both
 *    modes on its own tint.
 *  - Shapes per DESIGN.md: controls 10px, cards 16px, the capsule only for a status
 *    badge (The Pill-Means-State Rule); controls at least 44px.
 *  - Responsive keys off `.shell[data-layout]`, never a width query of its own
 *    (src/lib/device/breakpointBudget.test.ts). A Modal renders outside `.shell`
 *    (overlay.css), so nothing a dialog uses may depend on data-layout.
 *  - No text is clipped: every line wraps. A clipped line needs headroom for stacked
 *    marks — Thai tone marks (ที่ ปี๊บ สุกี้) and, with the staff languages of #451,
 *    Burmese / Khmer / Lao stacks up to three deep; Khmer in Noto Sans Khmer outgrew
 *    the Thai headroom — so the classes wrap instead of cutting.
 *
 * Loaded by an @import at the top of theme.css, so every entry that has the tokens
 * (owner app, staff apps, public pages) has these too. It therefore sits BEFORE
 * mobile.css and every page stylesheet in the cascade: a page's own layout rule of
 * equal weight wins, which is what a page wants.
 */

/* ---- Buttons ----------------------------------------------------------------
 * The base IS the ghost button, DESIGN.md's default secondary: `ui-btn` alone.
 * `--primary` is เขียวหยก, the one control that changes something (save, add);
 * `--brand` is แดงชาด for the rare control that means "this one is chosen";
 * `--danger` is never a solid red block; `--icon` is the 44px square. */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--ui-control-height);
  padding: 9px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    filter var(--dur-fast) var(--ease-out);
}
/* :active twins every :hover — a finger never hovers (DESIGN.md § Motion). */
.ui-btn:not(:disabled):hover,
.ui-btn:not(:disabled):active {
  background: var(--color-surface-2);
}
.ui-btn--primary {
  border-color: transparent;
  background: var(--color-action);
  color: var(--color-action-fg);
  font-weight: 700;
}
.ui-btn--brand {
  border-color: transparent;
  background: var(--color-brand);
  color: var(--color-brand-fg);
  font-weight: 700;
}
.ui-btn--primary:not(:disabled):hover,
.ui-btn--primary:not(:disabled):active {
  background-color: var(--color-action);
  filter: brightness(1.05);
}
.ui-btn--brand:not(:disabled):hover,
.ui-btn--brand:not(:disabled):active {
  background-color: var(--color-brand);
  filter: brightness(1.05);
}
/* Solid buttons take the design system's top light (btn-lit-solid / btn-rim-solid). */
.ui-btn--primary,
.ui-btn--brand {
  background-image: linear-gradient(var(--btn-lit-solid), transparent 70%);
  box-shadow: inset 0 1px 0 var(--btn-rim-solid);
}
/* Danger (design system v25): the danger tint, no border, the same top rim as the soft
 * secondary. danger-text is the readable twin of danger in both modes. */
.ui-btn--danger {
  border-color: transparent;
  background-color: var(--color-danger-soft);
  box-shadow: inset 0 1px 0 var(--btn-rim);
  color: var(--color-danger-text);
  font-weight: 700;
}
.ui-btn--danger:not(:disabled):hover,
.ui-btn--danger:not(:disabled):active {
  background-color: color-mix(in srgb, var(--color-danger) 16%, var(--color-surface));
}
/* Secondary on a card or a dialog, design system v25 option "ข": a soft fill with no
 * border and a light on top. Outside them the button may sit straight on the grey page
 * tray, where surface-2 against the tray differs by ~1.03:1, so it keeps its fill and
 * border from the base rule. */
.ui-card .ui-btn:not(.ui-btn--primary, .ui-btn--brand, .ui-btn--danger),
.ui-overlay__panel .ui-btn:not(.ui-btn--primary, .ui-btn--brand, .ui-btn--danger) {
  border-color: transparent;
  background-color: var(--color-surface-2);
  background-image: linear-gradient(var(--btn-lit), transparent 70%);
  box-shadow:
    inset 0 1px 0 var(--btn-rim),
    inset 0 -1px 0 var(--btn-floor);
}
.ui-card .ui-btn:not(.ui-btn--primary, .ui-btn--brand, .ui-btn--danger):not(:disabled):hover,
.ui-overlay__panel .ui-btn:not(.ui-btn--primary, .ui-btn--brand, .ui-btn--danger):not(:disabled):hover,
.ui-card .ui-btn:not(.ui-btn--primary, .ui-btn--brand, .ui-btn--danger):not(:disabled):active,
.ui-overlay__panel .ui-btn:not(.ui-btn--primary, .ui-btn--brand, .ui-btn--danger):not(:disabled):active {
  background-color: var(--color-border);
}
/* Always with an aria-label (mobile.css keys touch width off it too). */
.ui-btn--icon {
  width: var(--ui-control-height);
  min-width: var(--ui-control-height);
  padding: 0;
  border-radius: var(--radius-control);
}
/* mobile.css gives every `.ui-card a` 6px block padding on touch screens, one class
 * heavier than .ui-btn; a link drawn as a button keeps the button's padding. */
.ui-card .ui-btn:not(.ui-btn--icon) {
  padding-block: 9px;
}
.ui-btn:disabled,
.ui-btn[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Fields ------------------------------------------------------------------
 * input / select / textarea. 16px because iOS zooms the page into anything
 * smaller when it takes focus; font: inherit so a textarea is not monospace. */
.ui-field {
  width: 100%;
  min-width: 0;
  min-height: var(--ui-control-height);
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  box-sizing: border-box;
}
/* Chrome draws a select 2px taller than an input with the same padding, so the two
   side by side (quantity + unit) did not line up. */
.ui-field:is(select) {
  height: var(--ui-control-height);
}
/* iOS WebKit draws a native date/time control at its own width and ignores
 * min-width: 0 while the control keeps its native appearance, so two dates side by
 * side push past their grid track and the card scrolls sideways (#401 · #434, the
 * same fix as Modal's dateFieldStyle). Our border, background and 16px still apply. */
.ui-field[type='date'],
.ui-field[type='time'],
.ui-field[type='datetime-local'] {
  -webkit-appearance: none;
  appearance: none;
}
/* …and iOS centres the date inside the box; the other fields read from the left. */
.ui-field::-webkit-date-and-time-value {
  text-align: left;
}
.ui-field::placeholder {
  color: var(--color-text-muted);
}
.ui-field:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
/* The border only backs up the message a page shows beside the field — an error
 * is never told by colour alone (DESIGN.md § Inputs). */
.ui-field[aria-invalid='true'] {
  border-color: var(--color-danger);
}

/* A field with a magnifier inside it (Figma คลัง 01). Markup:
 * <label class="ui-search"><span class="ui-search__icon"><Icon/></span><input class="ui-field"/></label> */
.ui-search {
  position: relative;
  display: block;
  min-width: 0;
}
.ui-search__icon {
  display: grid;
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}
.ui-search .ui-field {
  padding-left: 40px;
}

/* ---- Status badge --------------------------------------------------------------
 * Capsule = status. Faint tint + 1px edge + the tone's TEXT colour, never the fill
 * colour as words. 8% keeps every tone >= 4.5:1 in both modes (info light is the
 * tightest at 4.6:1). Gold is not a tone: it reads 3.9:1 on its tint, and in the CI
 * gold is the colour of KPI numbers, not of a state. data-tone: neutral (default)
 * · success · warning · danger · info. Pair it with a word; an icon is optional. */
.ui-badge {
  --tone: var(--color-text-muted);
  --tone-text: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 10px;
  border: 1px solid color-mix(in srgb, var(--tone) 35%, var(--color-surface));
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--tone) 8%, var(--color-surface));
  color: var(--tone-text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}
.ui-badge[data-tone='success'] {
  --tone: var(--color-success);
  --tone-text: var(--color-success-text);
}
.ui-badge[data-tone='warning'] {
  --tone: var(--color-warning);
  --tone-text: var(--color-warning-text);
}
.ui-badge[data-tone='danger'] {
  --tone: var(--color-danger);
  --tone-text: var(--color-danger);
}
.ui-badge[data-tone='info'] {
  --tone: var(--color-info);
  --tone-text: var(--color-info);
}
:root[data-theme='dark'] .ui-badge[data-tone='danger'] {
  --tone-text: var(--color-danger-on-dark);
}

/* ---- Segmented switch -------------------------------------------------------------
 * A small set of views or filters; the chosen one is แดงชาด (brand = what is
 * selected). Each option is a <button aria-pressed>. Scrolls sideways rather than
 * wrapping when a phone runs out of room. */
.ui-seg {
  display: inline-flex;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.ui-seg__btn {
  flex: none;
  min-height: var(--ui-control-height);
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.ui-seg__btn + .ui-seg__btn {
  border-left: 1px solid var(--color-border);
}
.ui-seg__btn[aria-pressed='true'] {
  background: var(--color-brand);
  color: var(--color-brand-fg);
  font-weight: 700;
}
/* The container clips, so the focus ring goes inside the option. */
.ui-seg__btn:focus-visible {
  outline-offset: -3px;
}
.shell[data-layout='phone'] .ui-seg {
  display: flex;
  width: 100%;
}
.shell[data-layout='phone'] .ui-seg__btn {
  flex: 1 0 auto;
}
/* The rows / photo-tiles switch (ListLayoutSwitch). A phone always gets the row
 * cards, so there is nothing to switch. */
.ui-seg--layout {
  flex: none;
}
.shell[data-layout='phone'] .ui-seg--layout {
  display: none;
}

/* ---- Row card ------------------------------------------------------------------------
 * One thing in a list: optional lead (photo, icon) · title + meta · end (a number,
 * a badge, a button). A row that opens something is an <a> or <button> with
 * `ui-row--press`, and lifts under a mouse or a finger (The Two-Step Depth Rule).
 *
 * `.ui-card .ui-row` is listed on purpose: mobile.css turns every `.ui-card a` into
 * inline-flex with 6px padding on touch screens, one class heavier than `.ui-row`,
 * which would collapse a row link inside a card to the width of its text. */
.ui-row,
.ui-card .ui-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}
.ui-row {
  width: 100%;
  min-width: 0;
  min-height: 56px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-rest);
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  box-sizing: border-box;
}
.ui-row--press {
  cursor: pointer;
  transition:
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.ui-row--press:hover,
.ui-row--press:active {
  box-shadow: var(--shadow-lift);
  transform: translateY(-2px);
}
.ui-row__lead,
.ui-row__end {
  flex: none;
}
.ui-row__end {
  display: grid;
  justify-items: end;
  gap: 2px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ui-row__main {
  flex: 1;
  min-width: 0;
  display: grid;
}
/* Names wrap rather than cut: a Thai name clipped to one line loses the part that
 * tells two items apart (owner decision on #442 — the Figma's one-line names are
 * not copied), and nothing clipped means no tone mark is ever cut. */
.ui-row__title,
.ui-row__meta {
  overflow-wrap: anywhere;
}
.ui-row__title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}
.ui-row__meta {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--color-text-muted);
}
/* The number the row is about — money or a quantity — in the display face with
 * even digits (DESIGN.md The Two-Face Rule). */
.ui-row__value {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* A dense list of rows in ONE card, split by hairlines — lots, movements, recent
 * transfers: long histories read as a list, not a stack of cards. Markup:
 * <div class="ui-list"><div class="ui-row">…</div>…</div> */
.ui-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* A list with a height cap scrolls; its rows keep their own height. With the
     default auto rows and the rows' min-height 0, a capped grid squeezed every row
     and a two-line Thai name spilled over its neighbour (import dialog, slice 5). */
  grid-auto-rows: max-content;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-rest);
}
.ui-list > .ui-row {
  min-height: 0;
  padding: 8px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 13px;
}
.ui-list > .ui-row + .ui-row {
  border-top: 1px solid var(--color-border);
}
.ui-list .ui-row__title {
  font-size: 14px;
}
/* Inside a card the card is the frame: the list keeps only its dividers. */
.ui-card .ui-list {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.ui-card .ui-list > .ui-row {
  padding-inline: 0;
}

/* A 40px tile at the head of a row: a photo, an icon, or the name's first letter.
 * data-tone='brand' tints it แดงชาด. */
.ui-thumb {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-weight: 700;
}
.ui-thumb[data-tone='brand'] {
  background: color-mix(in srgb, var(--color-brand) 10%, var(--color-surface));
  color: var(--color-brand-text);
}
/* A state or a kind of movement (dashboard rows): the tone's text colour on its tint. */
.ui-thumb[data-tone='success'] {
  background: color-mix(in srgb, var(--color-success) 12%, var(--color-surface));
  color: var(--color-success-text);
}
.ui-thumb[data-tone='warning'] {
  background: color-mix(in srgb, var(--color-warning) 12%, var(--color-surface));
  color: var(--color-warning-text);
}
.ui-thumb[data-tone='danger'] {
  background: color-mix(in srgb, var(--color-danger) 10%, var(--color-surface));
  color: var(--color-danger);
}
.ui-thumb[data-tone='info'] {
  background: color-mix(in srgb, var(--color-info) 8%, var(--color-surface));
  color: var(--color-info);
}
:root[data-theme='dark'] .ui-thumb[data-tone='danger'] {
  color: var(--color-danger-on-dark);
}

/* ---- A list read as rows or as photo tiles (the BOM list's two views) ------------------
 * Markup: <div class="ui-rows" data-mode="rows|tiles"> ui-row … </div>, one per group,
 * with a ListLayoutSwitch in the tools. A phone always gets the row cards. On a wide
 * column:
 *  - rows: one card per group split by hairlines, like ui-list. The row's end cells
 *    stand side by side in the tracks the page names in --ui-row-cols, so every
 *    number lands on the same x down the group. A row renders the same number of end
 *    cells every time (an empty span holds a missing one's place).
 *  - tiles: the lead thumb grows into the photo on top and the end cells sit at the
 *    tile's foot. */
.ui-rows {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
}
.shell:not([data-layout='phone']) .ui-rows[data-mode='rows'] {
  gap: 0;
  grid-auto-rows: max-content;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-rest);
}
/* A pressable line, not a card: it tints on press and never lifts. */
.shell:not([data-layout='phone']) .ui-rows[data-mode='rows'] > .ui-row {
  min-height: 52px;
  padding: 6px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
  transition: background var(--dur-fast) var(--ease-out);
}
.shell:not([data-layout='phone']) .ui-rows[data-mode='rows'] > .ui-row + .ui-row {
  border-top: 1px solid var(--color-border);
}
/* the card does not clip, so its end rows round their own corners for the press tint */
.shell:not([data-layout='phone']) .ui-rows[data-mode='rows'] > .ui-row:first-child {
  border-top-left-radius: calc(var(--radius-md) - 1px);
  border-top-right-radius: calc(var(--radius-md) - 1px);
}
.shell:not([data-layout='phone']) .ui-rows[data-mode='rows'] > .ui-row:last-child {
  border-bottom-left-radius: calc(var(--radius-md) - 1px);
  border-bottom-right-radius: calc(var(--radius-md) - 1px);
}
.shell:not([data-layout='phone']) .ui-rows[data-mode='rows'] > .ui-row--press:hover,
.shell:not([data-layout='phone']) .ui-rows[data-mode='rows'] > .ui-row--press:active {
  background: var(--color-surface-2);
  box-shadow: none;
  transform: none;
}
.shell:not([data-layout='phone']) .ui-rows[data-mode='rows'] > .ui-row:focus-visible {
  outline-offset: -2px;
}
.shell:not([data-layout='phone']) .ui-rows[data-mode='rows'] .ui-row__end {
  grid-template-columns: var(--ui-row-cols, auto);
  column-gap: var(--space-3);
  align-items: center;
}
/* A fixed track holds the number; a long one wraps inside it rather than spill. */
.shell:not([data-layout='phone']) .ui-rows[data-mode='rows'] .ui-row__value {
  white-space: normal;
  overflow-wrap: break-word;
}
.shell:not([data-layout='phone']) .ui-rows[data-mode='tiles'] {
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: var(--space-3);
}
.shell:not([data-layout='phone']) .ui-rows[data-mode='tiles'] > .ui-row {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 10px;
}
.shell:not([data-layout='phone']) .ui-rows[data-mode='tiles'] .ui-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  font-size: 28px;
}
.shell:not([data-layout='phone']) .ui-rows[data-mode='tiles'] .ui-row__main {
  align-content: start;
  gap: 2px;
}
.shell:not([data-layout='phone']) .ui-rows[data-mode='tiles'] .ui-row__end {
  justify-items: start;
  padding-top: 6px;
  border-top: 1px solid var(--color-border);
  text-align: left;
}

/* ---- Group bar (Figma คลัง 01: "วัตถุดิบ · ติดตามสต็อก") -----------------------------------
 * The label over a run of rows — tinted, not a card. data-tone brand (แดงชาด) or
 * kpi (ทองเหลือง; words stay ink, gold words on a gold tint read too faintly). */
.ui-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 700;
}
.ui-group[data-tone='brand'] {
  background: color-mix(in srgb, var(--color-brand) 10%, var(--color-surface));
  color: var(--color-brand-text);
}
.ui-group[data-tone='kpi'] {
  background: color-mix(in srgb, var(--color-kpi) 14%, var(--color-surface));
  color: var(--color-text);
}
.ui-group__n {
  font-weight: 600;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

/* ---- KPI boxes (Figma คลัง 01) ------------------------------------------------------------
 * A coloured edge, the number in Kanit with even digits. A box that filters the
 * list below it is a <button aria-pressed> and fills faintly when on — the boxes
 * replace a separate filter bar, as on the BOM list. Gold by default; data-tone
 * success · warning · danger · muted for a count that means a state. */
.ui-kpi {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}
.shell:not([data-layout='phone']) .ui-kpi {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
}
.ui-kpi__box {
  --kpi: var(--color-kpi);
  --kpi-text: var(--color-kpi-text);
  display: grid;
  align-content: start;
  gap: 2px;
  min-width: 0;
  min-height: var(--ui-control-height);
  padding: 12px 14px;
  border: 1.5px solid var(--kpi);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: inherit;
  font: inherit;
  text-align: left;
  transition: background var(--dur-fast) var(--ease-out);
}
.ui-kpi__box[aria-pressed] {
  cursor: pointer;
}
.ui-kpi__box[aria-pressed='true'] {
  background: color-mix(in srgb, var(--kpi) 9%, var(--color-surface));
  box-shadow: inset 0 0 0 1px var(--kpi);
}
.ui-kpi__box[data-tone='success'] {
  --kpi: var(--color-success);
  --kpi-text: var(--color-success-text);
}
.ui-kpi__box[data-tone='warning'] {
  --kpi: var(--color-warning);
  --kpi-text: var(--color-warning-text);
}
.ui-kpi__box[data-tone='danger'] {
  --kpi: var(--color-danger);
  --kpi-text: var(--color-danger);
}
.ui-kpi__box[data-tone='action'] {
  --kpi: var(--color-action);
  --kpi-text: var(--color-action-text);
}
.ui-kpi__box[data-tone='muted'] {
  --kpi: var(--color-border);
  --kpi-text: var(--color-text-muted);
}
:root[data-theme='dark'] .ui-kpi__box[data-tone='danger'] {
  --kpi-text: var(--color-danger-on-dark);
}
.ui-kpi__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
}
.ui-kpi__value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--kpi-text);
  font-variant-numeric: tabular-nums;
  /* a ฿ figure in a narrow dashboard column breaks rather than spill out of its box */
  overflow-wrap: anywhere;
}
.ui-kpi__sub {
  overflow-wrap: anywhere;
  font-size: var(--ui-helper-size);
  line-height: 1.45;
  color: var(--color-text-muted);
}

/* ---- Meter: one bar of a chart (dashboard funnel, branch values, level) -------------------
 * The track is the quiet surface; `.ui-meter__fill`'s width is the data (inline, a percentage).
 * Bar caps use the chart radius, not the capsule (DESIGN.md: the capsule means a
 * status). The number the bar stands for is always printed beside it. */
.ui-meter {
  display: block;
  height: 8px;
  border-radius: var(--radius-chart);
  background: var(--color-surface-2);
  /* a bar is data: keep its colour on paper (browsers drop backgrounds by default) */
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.ui-meter__fill {
  display: block;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  max-width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--color-action-text);
}
.ui-meter[data-tone='kpi'] .ui-meter__fill {
  background: var(--color-kpi);
}
.ui-meter[data-tone='success'] .ui-meter__fill {
  background: var(--color-success);
}
.ui-meter[data-tone='warning'] .ui-meter__fill {
  background: var(--color-warning);
}
.ui-meter[data-tone='danger'] .ui-meter__fill {
  background: var(--color-danger);
}
.ui-meter[data-tone='info'] .ui-meter__fill {
  background: var(--color-info);
}

/* ---- Text link: "ดูทั้งหมด ›" at the head of a card. A way to another page, in the
 * action colour's text twin; the one filled jade control stays the page's button. */
.ui-link {
  color: var(--color-action-text);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.ui-link:hover {
  text-decoration: underline;
}

/* ---- Checkbox and radio --------------------------------------------------------------------
 * Ticked in the brand red, as on the BOM list and the chosen tab (it was the browser's
 * blue). 20px so a finger finds it; the <label> around it carries the 44px. */
.ui-check {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--color-brand);
}

/* ---- Small text, and words in a status colour -------------------------------------------
 * `ui-note` is the small grey line (a hint, a date, "printed 2×"). `ui-text` with
 * data-tone colours words with the tone's TEXT colour; it can sit on a ui-note or
 * a ui-row__value. */
.ui-note {
  font-size: var(--ui-helper-size);
  line-height: 1.45;
  color: var(--color-text-muted);
}
.ui-text[data-tone='muted'] {
  color: var(--color-text-muted);
}
.ui-text[data-tone='success'] {
  color: var(--color-success-text);
}
.ui-text[data-tone='warning'] {
  color: var(--color-warning-text);
}
.ui-text[data-tone='danger'] {
  color: var(--color-danger);
}
.ui-text[data-tone='info'] {
  color: var(--color-info);
}
:root[data-theme='dark'] .ui-text[data-tone='danger'] {
  color: var(--color-danger-on-dark);
}

/* ---- Empty list and inline alert ------------------------------------------------------------
 * Empty: nothing to show yet — a dashed box (DESIGN.md: dashed = "add / explain"),
 * the reason, and at most one way forward. Alert: a message about what just
 * happened, words on a faint tint of the tone; danger by default, data-tone
 * warning or success. */
.ui-empty {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-muted);
  text-align: center;
}
.ui-alert {
  --tone: var(--color-danger);
  --tone-text: var(--color-danger);
  margin: 0;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--tone) 35%, var(--color-surface));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--tone) 8%, var(--color-surface));
  color: var(--tone-text);
  font-size: 13px;
  font-weight: 600;
}
.ui-alert[data-tone='warning'] {
  --tone: var(--color-warning);
  --tone-text: var(--color-warning-text);
}
.ui-alert[data-tone='success'] {
  --tone: var(--color-success);
  --tone-text: var(--color-success-text);
}
:root[data-theme='dark'] .ui-alert:not([data-tone]) {
  --tone-text: var(--color-danger-on-dark);
}

/* ---- Page head and action row --------------------------------------------------------------
 * Head: the title block, then the page's one primary action, wrapping under it on a
 * narrow column. Actions: the buttons that finish a form or a dialog, right-aligned. */
.ui-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.ui-head__titles {
  flex: 1;
  min-width: 180px;
  display: grid;
  gap: 2px;
}
.ui-head__sub {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-muted);
}
.ui-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}
.ui-actions > .ui-btn {
  min-width: 96px;
}

/* ---- ui-* จาก src/styles/theme.css ---- */
.ui-card {
  min-width: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-rest);
  padding: var(--ui-card-padding);
}
.ui-card[data-density='compact'] {
  padding: var(--ui-card-padding-compact);
}
.ui-card[data-density='roomy'] {
  padding: var(--ui-card-padding-roomy);
}
.ui-page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--ui-page-title-size);
  font-weight: 800;
  line-height: 1.2;
}
.ui-section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--ui-section-title-size);
  font-weight: 800;
  line-height: 1.35;
}
.ui-card table {
  width: 100%;
  border-collapse: collapse;
}
.ui-card th {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
}
.ui-card td {
  font-size: var(--ui-body-size);
}
.ui-card tbody tr:last-child > td {
  border-bottom: 0;
}
@keyframes ui-page-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.ui-page {
  animation: ui-page-in var(--dur-base) var(--ease-out) backwards;
}
@keyframes ui-rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
.ui-stagger > * {
  animation: ui-rise-in var(--dur-base) var(--ease-out) backwards;
}
.ui-stagger > *:nth-child(1) { animation-delay: 0ms; }
.ui-stagger > *:nth-child(2) { animation-delay: 40ms; }
.ui-stagger > *:nth-child(3) { animation-delay: 80ms; }
.ui-stagger > *:nth-child(4) { animation-delay: 120ms; }
.ui-stagger > *:nth-child(5) { animation-delay: 160ms; }
.ui-stagger > *:nth-child(n + 6) { animation-delay: 200ms; }
@keyframes ui-skeleton-sweep {
  to {
    background-position: -200% 0;
  }
}
.ui-skeleton {
  border-radius: var(--radius-sm);
  background-image: linear-gradient(
    90deg,
    var(--color-surface-2) 0%,
    color-mix(in srgb, var(--color-border) 55%, var(--color-surface-2)) 50%,
    var(--color-surface-2) 100%
  );
  background-size: 200% 100%;
  animation: ui-skeleton-sweep 1.4s linear infinite;
}
.ui-skeleton--text {
  height: 1em;
  border-radius: var(--radius-xs);
}
.ui-skeleton--title {
  height: 1.4em;
  border-radius: var(--radius-xs);
}
