/* nuansa.css — starter MECHANICS + one example SKIN.
 * Mechanics (keep): app shell with mobile drawer, page header, buttons, chips, cards, stat
 * tiles, badges, responsive table (stacks on mobile, scrolls on tablet), forms, search,
 * progress, empty state, [hidden] fix, long-content and contrast hardening.
 * Skin (replace per project): the token blocks below (fonts, colors, tints, radius,
 * shadows) and a few accents. Derive the project's own identity with
 * references/design-direction.md; see ../examples/skins.css for three very different
 * skins on the same markup. Don't ship this skin unchanged unless the user wants it.
 * Pair with ../ui-controls.css, ../ui-feedback.css, ../ui-feedback.js and ../ui-scroll.js (scroller edges).
 */

/* ============ Tokens ============ */
:root {
  /* Brand (change these to re-theme) */
  --color-primary: #6d5efc;          /* accent: active states, focus, charts, highlights */
  --color-primary-hover: #5b4be8;
  --color-primary-soft: #efedff;
  --color-on-primary: #ffffff;
  --color-primary-text: #5443e6;     /* accent as text on white (≥ 4.5:1) */
  --color-ink: #111214;              /* primary buttons, active nav, selected chips */
  --color-on-ink: #ffffff;
  --color-action: var(--color-ink);  /* set to var(--color-primary) for colored primary buttons */
  --color-on-action: var(--color-on-ink);

  /* Pastel tints for categories / stat tiles (one family: same lightness) */
  --tint-lime: #e9f8b8;   --tint-violet: #ebe8ff; --tint-orange: #ffe9d6;
  --tint-sky: #e1f0ff;    --tint-pink: #fde6f1;   --tint-mint: #daf5e8;

  /* Neutrals */
  --color-bg: #f2f3f5;
  --color-surface: #ffffff;
  --color-surface-muted: #f5f6f8;
  --color-border: #eceef1;
  --color-border-strong: #dfe2e7;
  --color-text: #111214;
  --color-text-muted: #6a6f78;       /* 4.9:1 on white */
  --color-text-subtle: #9aa0a9;      /* decorative / non-essential only */

  /* Semantic */
  --color-success: #116b33; --color-success-soft: #e3f6e9;
  --color-warning: #b45309; --color-warning-soft: #fdf0dc;
  --color-danger:  #c81e1e; --color-danger-soft:  #fde8e8;
  --color-info:    #0369a1; --color-info-soft:    #e2f1fb;

  /* Type */
  --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: .75rem; --text-sm: .875rem; --text-base: 1rem; --text-lg: 1.125rem;
  --text-xl: 1.25rem; --text-2xl: 1.625rem; --text-3xl: 2rem; --text-4xl: clamp(2.25rem, 1.6rem + 2.6vw, 3.5rem);
  --weight-normal: 400; --weight-medium: 500; --weight-semibold: 600; --weight-bold: 700;
  --leading-tight: 1.15; --leading-normal: 1.55;
  --tracking-tight: -0.025em;

  /* Space (4px base) */
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem; --space-5: 1.25rem;
  --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem; --space-16: 4rem;

  /* Shape & depth */
  --radius-sm: 10px; --radius-md: 18px; --radius-lg: 24px; --radius-full: 9999px;
  --radius-control: 9999px;
  --shadow-sm: 0 1px 2px rgb(17 18 20 / .05);
  --shadow-md: 0 8px 24px rgb(17 18 20 / .08);
  --shadow-lg: 0 18px 48px rgb(17 18 20 / .14);
  --ring: 0 0 0 3px rgb(109 94 252 / .3);

  /* Layout */
  --container-max: 1200px; --sidebar-width: 248px; --topbar-height: 68px;
  --control-height: 40px; --control-height-sm: 32px; --gutter: 16px;

  /* Motion & layers */
  --ease: cubic-bezier(.2, 0, 0, 1); --duration: 160ms;
  --z-dropdown: 1000; --z-sticky: 1100; --z-overlay: 1200; --z-modal: 1300; --z-toast: 1400;
}
@media (prefers-reduced-motion: reduce) { :root { --duration: 0ms; } }
:root[data-theme="dark"] {
  --color-bg: #0c0d10; --color-surface: #16181c; --color-surface-muted: #1d2025;
  --color-border: #23262c; --color-border-strong: #2e323a;
  --color-text: #eef0f3; --color-text-muted: #a3a9b3; --color-text-subtle: #6f7682;
  --color-ink: #f4f5f7; --color-on-ink: #111214;
  --color-primary-soft: rgb(109 94 252 / .18); --color-primary-text: #a99fff;
  --tint-lime: #2b3410; --tint-violet: #25213f; --tint-orange: #3a2717; --tint-sky: #142b40; --tint-pink: #3a1a2b; --tint-mint: #12301f;
  --color-success: #4ade80; --color-success-soft: rgb(74 222 128 / .14);
  --color-warning: #fbbf24; --color-warning-soft: rgb(251 191 36 / .14);
  --color-danger: #f87171;  --color-danger-soft: rgb(248 113 113 / .14);
  --color-info: #38bdf8;    --color-info-soft: rgb(56 189 248 / .14);
  --shadow-md: 0 8px 24px rgb(0 0 0 / .4); --shadow-lg: 0 18px 48px rgb(0 0 0 / .5);
  color-scheme: dark;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-sans); font-size: var(--text-base); line-height: var(--leading-normal);
  color: var(--color-text); background: var(--color-bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: var(--leading-tight); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); overflow-wrap: anywhere; }
p, label, td, .field__label { overflow-wrap: anywhere; }  /* real content contains long emails, URLs and names */
p { margin: 0; }
img, svg { display: block; max-width: 100%; }
a { color: var(--color-primary-text); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
/* Icons: one set, three sizes, one stroke (components.md → Icons) */
:root { --icon-sm: 16px; --icon-md: 20px; --icon-lg: 24px; --icon-stroke: 1.75; }
.icon { width: var(--icon-md); height: var(--icon-md); flex: none; stroke: currentColor; fill: none; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
.icon--sm, .btn--sm .icon, .badge .icon { width: var(--icon-sm); height: var(--icon-sm); }
.icon--lg { width: var(--icon-lg); height: var(--icon-lg); }
[hidden] { display: none !important; }  /* components set display; hidden must still win */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--color-text-muted); }
.num { font-variant-numeric: tabular-nums; }
.skip-link { position: absolute; left: var(--space-4); top: -60px; z-index: var(--z-toast); background: var(--color-ink); color: var(--color-on-ink); padding: var(--space-2) var(--space-4); border-radius: var(--radius-full); }
.skip-link:focus { top: var(--space-4); }

/* ============ App shell (admin / dashboard) ============ */
.app { display: grid; grid-template-columns: 1fr; min-height: 100dvh; }
@media (min-width: 1024px) { .app { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); } }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: var(--z-overlay); width: min(var(--sidebar-width), 86vw);
  display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-5) var(--space-4);
  background: var(--color-surface); transform: translateX(-102%); transition: transform var(--duration) var(--ease); overflow-y: auto; }
.sidebar.is-open { transform: none; box-shadow: var(--shadow-lg); }
@media (min-width: 1024px) { .sidebar { position: sticky; top: 0; height: 100dvh; transform: none; width: auto; } }
.scrim { position: fixed; inset: 0; z-index: calc(var(--z-overlay) - 1); background: rgb(17 18 20 / .4); opacity: 0; pointer-events: none; transition: opacity var(--duration); }
.scrim.is-open { opacity: 1; pointer-events: auto; }
.brand { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-2) var(--space-4); font-weight: var(--weight-bold); letter-spacing: var(--tracking-tight); color: var(--color-text); }
.brand__mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--color-ink); color: var(--color-on-ink); }
.nav-group { display: grid; gap: 2px; margin-top: var(--space-3); }
.nav-group__label { padding: 0 var(--space-3) var(--space-1); font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--color-text-muted); }
.nav-item { display: flex; align-items: center; gap: var(--space-3); height: 42px; min-width: 0; padding: 0 var(--space-3); border-radius: var(--radius-full);
  color: var(--color-text-muted); font-size: var(--text-sm); font-weight: var(--weight-medium); transition: background var(--duration), color var(--duration); }
.nav-item > span:not(.count) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: var(--color-surface-muted); color: var(--color-text); }
.nav-item[aria-current="page"] { background: var(--color-ink); color: var(--color-on-ink); }
.nav-item .count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center; border-radius: var(--radius-full); background: var(--color-primary); color: var(--color-on-primary); font-size: 11px; font-weight: var(--weight-semibold); }
.sidebar__foot { margin-top: auto; padding: var(--space-4); border-radius: var(--radius-md); background: var(--tint-lime); }
.sidebar__foot p { font-size: var(--text-sm); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; gap: var(--space-3);
  height: var(--topbar-height); padding: 0 var(--space-4); background: color-mix(in srgb, var(--color-bg) 82%, transparent); backdrop-filter: blur(12px); }
@media (min-width: 768px) { .topbar { padding: 0 var(--space-8); } }
.topbar .search { max-width: 380px; }
.topbar__end { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--tint-violet); color: var(--color-text); font-weight: var(--weight-semibold); font-size: var(--text-sm); } /* ink text: readable on any tint a palette produces */
.content { width: 100%; max-width: 1360px; margin: 0 auto; padding: var(--space-2) var(--space-4) var(--space-16); display: grid; grid-template-columns: minmax(0, 1fr); /* an implicit auto column would grow to the widest content */ gap: var(--gutter); }
@media (min-width: 768px) { .content { padding: var(--space-2) var(--space-8) var(--space-16); } }
.hide-desktop { } @media (min-width: 1024px) { .hide-desktop { display: none !important; } }
.hide-mobile { display: none !important; } @media (min-width: 768px) { .hide-mobile { display: revert !important; } }

/* ============ Page header ============ */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) 0 var(--space-2); }
.page-header__eyebrow { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: var(--space-1); }
.page-header__title { font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.5rem); font-weight: var(--weight-semibold); }
.page-header__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ============ Buttons ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: var(--control-height); padding: 0 var(--space-5);
  border: 1px solid transparent; border-radius: var(--radius-control); font-size: var(--text-sm); font-weight: var(--weight-semibold); line-height: 1;
  white-space: nowrap; cursor: pointer; text-decoration: none; transition: background var(--duration) var(--ease), border-color var(--duration), transform var(--duration); }
.btn:active { transform: scale(.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn--primary { background: var(--color-action); color: var(--color-on-action); }
.btn--primary:hover { background: color-mix(in srgb, var(--color-action) 86%, var(--color-surface)); }
.btn--secondary { background: var(--color-surface); border-color: var(--color-border-strong); color: var(--color-text); }
.btn--secondary:hover { background: var(--color-surface-muted); }
.btn--ghost { background: transparent; color: var(--color-text-muted); }
.btn--ghost:hover { background: var(--color-surface-muted); color: var(--color-text); }
.btn--accent { background: var(--color-primary); color: var(--color-on-primary); }
.btn--danger { background: var(--color-danger); color: #fff; }
.btn--sm { height: var(--control-height-sm); padding: 0 var(--space-4); font-size: var(--text-xs); }
.btn--block { width: 100%; }
/* Action pair (card footer, dialog, sticky bar): same height, equal widths, label never touches the edge.
 * In a narrow card (< 260px, e.g. 2-column product grid on phones) a secondary button with an icon
 * collapses to an icon button; its .btn__label stays for screen readers. */
.actions { display: flex; gap: var(--space-2); }
.actions > .btn { flex: 1 1 0; min-width: 0; overflow: hidden; }
.btn__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; } /* long labels truncate instead of spilling out */
.actions > .icon-btn, .actions > .btn--icon { flex: none; }
.card--actions { display: flex; flex-direction: column; container-type: inline-size; }
.card--actions > .actions { margin-top: auto; padding-top: var(--space-3); }
@container (max-width: 259px) {
  .actions > .btn--secondary:has(.icon) { flex: none; width: var(--control-height); padding: 0; }
  .actions > .btn--secondary:has(.icon) .btn__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.icon-btn { display: inline-grid; place-items: center; width: var(--control-height); height: var(--control-height); flex: none; border-radius: 50%;
  border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-text); cursor: pointer; position: relative; transition: background var(--duration); }
.icon-btn:hover { background: var(--color-surface-muted); }
.icon-btn--sm { width: var(--control-height-sm); height: var(--control-height-sm); }
.icon-btn--plain { border-color: transparent; background: transparent; }
.icon-btn--danger:hover { background: var(--color-danger-soft); color: var(--color-danger); border-color: transparent; }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--color-danger); border: 2px solid var(--color-surface); }

/* ============ Chips / segmented ============ */
/* Horizontal scroller: snap so items never stop half-cut, fade only the side that hides content
 * (data-overflow is set by ui-scroll.js), and 4px of room so focus rings aren't clipped. */
.chips { --fade: 24px; display: flex; gap: var(--space-2); overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  scroll-snap-type: x proximity; scroll-padding-inline: var(--fade); padding: 4px; margin: -4px;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fade-start, 0px), #000 calc(100% - var(--fade-end, 0px)), transparent);
          mask-image: linear-gradient(to right, transparent, #000 var(--fade-start, 0px), #000 calc(100% - var(--fade-end, 0px)), transparent); }
.chips::-webkit-scrollbar { display: none; }
.chips > * { scroll-snap-align: start; }
.chips[data-overflow~="start"] { --fade-start: var(--fade); }
.chips[data-overflow~="end"] { --fade-end: var(--fade); }
[dir="rtl"] .chips { -webkit-mask-image: linear-gradient(to left, transparent, #000 var(--fade-start, 0px), #000 calc(100% - var(--fade-end, 0px)), transparent);
          mask-image: linear-gradient(to left, transparent, #000 var(--fade-start, 0px), #000 calc(100% - var(--fade-end, 0px)), transparent); }
/* Full-bleed on phones: the row runs to the screen edge, items still start on the page gutter. */
@media (max-width: 767px) { .chips--bleed { --fade: var(--space-4); margin-inline: calc(-1 * var(--space-4)); padding-inline: var(--space-4); } }
.chip { flex: none; display: inline-flex; align-items: center; gap: var(--space-2); height: 38px; padding: 0 var(--space-4); border-radius: var(--radius-full);
  border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-text); font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer; white-space: nowrap; }
.chip:hover { background: var(--color-surface-muted); }
.chip[aria-selected="true"], .chip[aria-pressed="true"] { background: var(--color-ink); border-color: var(--color-ink); color: var(--color-on-ink); }
.chip .count { min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center; border-radius: var(--radius-full); background: var(--color-surface-muted); color: var(--color-text-muted); font-size: 11px; font-weight: var(--weight-semibold); }
.chip[aria-selected="true"] .count { background: rgb(255 255 255 / .18); color: inherit; }

/* ============ Cards, stats, bento ============ */
.card { background: var(--color-surface); border-radius: var(--radius-lg); padding: var(--space-6); min-width: 0; }
.card--flush { padding: 0; overflow: hidden; position: relative; }
.table-scroll { overflow-x: auto; position: relative; } /* wide tables scroll inside the card instead of hiding columns */
.card__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); }
.card__head > * { min-width: 0; }
.card--flush .card__head { padding: var(--space-6) var(--space-6) 0; }
.card__title { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.card__sub { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: 2px; }
.bento > *, .grid-2 > *, .page-header > * { min-width: 0; }
.bento { display: grid; gap: var(--gutter); grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* ≥1100px: a 12-column grid shared with .grid-main-side, so every card edge sits on the same column lines. */
@media (min-width: 1100px) { .bento { grid-template-columns: repeat(12, minmax(0, 1fr)); } .bento > * { grid-column: span 3; } }
.stat { display: flex; flex-direction: column; gap: var(--space-4); min-height: 148px; }
.stat__top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.stat__label { min-width: 0; overflow-wrap: anywhere; font-size: var(--text-sm); color: var(--color-text-muted); font-weight: var(--weight-medium); }
.stat__value { overflow-wrap: anywhere; margin-top: auto; font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.25rem); font-weight: var(--weight-semibold); letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat__value small { font-size: .45em; font-weight: var(--weight-medium); color: var(--color-text-muted); letter-spacing: 0; margin-left: 2px; }
.stat--tint { background: var(--tint, var(--tint-lime)); }
.stat--tint .stat__label, .stat--tint .stat__value small { color: color-mix(in srgb, var(--color-text) 82%, transparent); }
.stat__icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--color-surface); color: var(--color-text); }
.stat:not(.stat--tint) .stat__icon { background: var(--color-surface-muted); }
@media (max-width: 479px) { .stat { min-height: 120px; padding: var(--space-5); } .stat__top > :not(.stat__label) { display: none; } }

/* ============ Badges, deltas, avatars ============ */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; padding: 0 10px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-semibold); white-space: nowrap; background: var(--color-surface-muted); color: var(--color-text-muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--success { background: var(--color-success-soft); color: var(--color-success); }
.badge--warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge--danger  { background: var(--color-danger-soft);  color: var(--color-danger); }
.badge--info    { background: var(--color-info-soft);    color: var(--color-info); }
.delta { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-semibold); background: var(--color-surface); }
.delta--up { color: var(--color-success); } .delta--down { color: var(--color-danger); }
.thumb, .avatar { overflow: hidden; white-space: nowrap; } /* initials/images never spill out */
.thumb { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; font-weight: var(--weight-semibold); font-size: var(--text-sm); background: var(--tint, var(--tint-violet)); color: var(--color-text); }

/* ============ Table (→ stacked rows on mobile) ============ */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; padding: var(--space-3) var(--space-6); font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--color-text-muted); white-space: nowrap; border-bottom: 1px solid var(--color-border); }
.table td { padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--duration); }
.table tbody tr:hover { background: var(--color-surface-muted); }
.table .num { text-align: right; white-space: nowrap; font-weight: var(--weight-semibold); }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table .actions > * { display: inline-grid; vertical-align: middle; }
.cell-product { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.cell-product__name { font-weight: var(--weight-semibold); overflow-wrap: anywhere; }
.cell-product__meta { font-size: var(--text-xs); color: var(--color-text-muted); }
@media (max-width: 767px) {
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { position: relative; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); }
  .table--stack tbody tr:last-child { border-bottom: 0; }
  .table--stack td { padding: 0; border: 0; }
  .table--stack td + td { margin-top: var(--space-2); }
  .table--stack td[data-label] { display: flex; justify-content: space-between; gap: var(--space-4); text-align: right; }
  .table--stack td[data-label]::before { content: attr(data-label); color: var(--color-text-muted); font-weight: var(--weight-normal); text-align: left; }
  .table--stack td.actions { position: absolute; top: var(--space-4); right: var(--space-4); width: auto; }
  .table--stack .cell-product { padding-right: 88px; }
}

/* ============ Forms ============ */
.field { display: grid; gap: 6px; min-width: 0; }
.field__label { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.field__hint { font-size: var(--text-xs); color: var(--color-text-muted); }
.field__error { font-size: var(--text-xs); color: var(--color-danger); margin: 0; }
.input, .select, .textarea { width: 100%; min-height: var(--control-height); padding: 0 var(--space-4); background: var(--color-surface-muted);
  border: 1px solid transparent; border-radius: var(--radius-sm); font-size: max(16px, var(--text-sm)); transition: border-color var(--duration), box-shadow var(--duration), background var(--duration); }
@media (min-width: 768px) { .input, .select, .textarea { font-size: var(--text-sm); } }
.textarea { padding: var(--space-3) var(--space-4); min-height: 96px; resize: vertical; }
.input:hover, .select:hover { border-color: var(--color-border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; background: var(--color-surface); border-color: var(--color-primary); box-shadow: var(--ring); }
.input::placeholder { color: var(--color-text-subtle); }
.input-affix { position: relative; } .input-affix .input { padding-right: 2.75rem; }
.input-affix__end { max-width: 40%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; position: absolute; right: var(--space-4); top: 50%; transform: translateY(-50%); color: var(--color-text-muted); font-size: var(--text-sm); pointer-events: none; }
.form-row { display: grid; gap: var(--space-4); }
@media (min-width: 640px) { .form-row { grid-template-columns: 1fr 1fr auto; align-items: end; } }
.search { display: flex; align-items: center; gap: var(--space-2); flex: 1; min-width: 0; height: var(--control-height); padding: 0 var(--space-4);
  background: var(--color-surface); border: 1px solid transparent; border-radius: var(--radius-full); color: var(--color-text-muted); }
.search:focus-within { border-color: var(--color-primary); box-shadow: var(--ring); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; color: var(--color-text); font-size: max(16px, var(--text-sm)); }
@media (min-width: 768px) { .search input { font-size: var(--text-sm); } }

/* ============ Progress, empty state, toolbar ============ */
.progress { height: 10px; border-radius: var(--radius-full); overflow: hidden; background: repeating-linear-gradient(135deg, transparent 0 5px, rgb(17 18 20 / .07) 5px 6px), var(--color-surface-muted); }
.progress__fill { height: 100%; width: var(--value); border-radius: inherit; background: var(--color-ink); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-6); }
.empty { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-12) var(--space-6); text-align: center; }
.empty__icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: var(--color-surface-muted); color: var(--color-text-muted); margin-bottom: var(--space-2); }

/* ============ Grid helpers ============ */
.grid-2 { display: grid; gap: var(--gutter); }
@media (min-width: 1100px) { .grid-2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; } }
.stack { display: grid; gap: var(--space-4); }

/* ============ Aliases for class names used in references/components.md ============ */
.card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); }
.card__body { min-width: 0; }
.table-wrap { background: var(--color-surface); border-radius: var(--radius-lg); overflow-x: auto; }
.switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.switch__track { display: none; } /* ui-controls.css already turns input[role=switch] into a toggle */
.progress__fill:not(:empty) { font-size: 0; } /* label text stays available to screen readers via aria */

/* ============ Data & charts (pair with ../charts.js) ============ */
:root { --chart-accent: var(--color-primary); --chart-muted: var(--color-border-strong); }
.chart { position: relative; width: 100%; min-width: 0; }
.card--chart { display: flex; flex-direction: column; }
.card--chart .chart { flex: 1; min-height: 200px; } /* chart grows to fill a card stretched by its row */
.chart__svg { display: block; width: 100%; height: auto; overflow: visible; outline: none; border-radius: var(--radius-sm); }
.chart__svg:focus-visible { box-shadow: var(--ring); }
.chart__axis { font-size: 11px; fill: var(--color-text-muted); font-variant-numeric: tabular-nums; font-family: var(--font-sans); }
.chart__bar { transition: fill var(--duration); }
.chart__tip { position: absolute; transform: translate(-50%, -100%); pointer-events: none; display: grid; gap: 1px; padding: 6px 10px; border-radius: 10px;
  background: var(--color-ink); color: var(--color-on-ink); font-size: var(--text-xs); max-width: min(260px, 70vw); overflow-wrap: anywhere; box-shadow: var(--shadow-md); transition: left var(--duration) var(--ease), top var(--duration) var(--ease); }
.chart__tip::after { content: ""; position: absolute; left: 50%; bottom: -4px; width: 8px; height: 8px; background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 2px; }
.chart__tip-label { opacity: .7; } .chart__tip strong { font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.delta { gap: 3px; }
.delta--good { background: var(--color-success-soft); color: var(--color-success); }
.delta--bad { background: var(--color-danger-soft); color: var(--color-danger); }
.delta--neutral { background: var(--color-surface-muted); color: var(--color-text-muted); }
.stat--tint .kpi-foot { color: color-mix(in srgb, var(--color-text) 82%, transparent); }
.kpi-foot { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-size: var(--text-xs); color: var(--color-text-muted); }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-control); background: var(--color-surface); max-width: 100%; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding-inline: 3px; }
.seg > * { scroll-snap-align: start; }
.card .seg { background: var(--color-surface-muted); }
.seg button { flex: none; height: 34px; padding: 0 var(--space-4); border: 0; border-radius: var(--radius-control); background: transparent; color: var(--color-text-muted); font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer; white-space: nowrap; }
.seg button:hover:not([aria-selected="true"]) { color: var(--color-text); background: color-mix(in srgb, var(--color-text) 6%, transparent); }
.seg button[aria-selected="true"] { background: var(--color-ink); color: var(--color-on-ink); }
.headline { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-1); }
.headline__value { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); font-weight: var(--weight-semibold); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.legend { min-width: 0; overflow-wrap: anywhere; display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--color-text-muted); }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--color-primary)); }
.list { display: grid; }
.list-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--color-border); min-width: 0; }
.list-row:last-child { border-bottom: 0; }
.list-row__main { flex: 1 1 0; min-width: 0; } /* shrinks first (title ellipsis); the row wraps only if thumb + value alone don't fit */
.list-row__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row__meta { font-size: var(--text-xs); color: var(--color-text-muted); }
.list-row__value { font-size: var(--text-sm); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-inline { display: flex; align-items: center; gap: var(--space-3); min-width: 120px; }
.bar-inline .progress { flex: 1; height: 8px; }
.bar-inline .progress__fill { background: var(--color-primary); }
.bar-inline span { font-size: var(--text-xs); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.date-pill > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.date-pill:hover { background: var(--color-surface-muted); }
.date-pill { max-width: 100%; display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control-height); padding: 0 var(--space-4); border-radius: var(--radius-control); border: 1px solid var(--color-border-strong); background: var(--color-surface); font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer; color: var(--color-text); white-space: nowrap; }
/* Main (8) + side (4) on the same 12-column grid and gutter as .bento: edges land on shared column lines. */
.grid-main-side { display: grid; gap: var(--gutter); }
@media (min-width: 1100px) { .grid-main-side { grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: stretch; } .grid-main-side > :first-child { grid-column: span 8; } .grid-main-side > :last-child { grid-column: span 4; } }
.grid-main-side > * { min-width: 0; }

/* ============ Popover (e.g. the "Tampilan" theme picker) ============ */
.popover-anchor { position: relative; }
.popover { position: absolute; top: calc(100% + 10px); right: 0; z-index: var(--z-dropdown); width: min(380px, calc(100vw - 32px));
  padding: var(--space-5); border-radius: var(--radius-lg); background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-lg); border: 1px solid var(--color-border); }
.popover__title { font-size: var(--text-base); font-weight: var(--weight-semibold); margin-bottom: var(--space-4); }
/* Phones: the anchor isn't at the screen edge, so pin the panel to the viewport instead of the button. */
@media (max-width: 640px) {
  .popover { position: fixed; top: calc(var(--topbar-height, 64px) + 8px); left: var(--space-4); right: var(--space-4); width: auto;
    max-height: calc(100dvh - var(--topbar-height, 64px) - 24px); overflow-y: auto; overscroll-behavior: contain; }
}
