/* ==========================================================================
   Agri ERP design system v0.1.3 · Bootstrap 5.3 + jQuery, no build step
   --------------------------------------------------------------------------
   1. Fonts            5. Layout (sidebar, topbar)   9. Forms
   2. Tokens           6. Page head, cards, KPI     10. Auth / portal chooser
   3. Colour themes    7. Tables, pills, badges     11. Utilities
   4. Bootstrap bridge 8. Theme picker, toasts
   Rules: use tokens (var(--…)) only, never raw hex in components.
   Themes switch with <html data-theme="green|blue|indigo|teal|earth">,
   light/dark with <html data-bs-theme="light|dark">. See docs/DESIGN.md.
   ========================================================================== */

/* 1. Fonts ----------------------------------------------------------------- */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../lib/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+20B9, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../lib/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* 2. Tokens ---------------------------------------------------------------- */
:root {
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;

  /* type scale (base 14px) */
  --fs-xs: .75rem; --fs-sm: .8125rem; --fs-base: .875rem; --fs-md: 1rem; --fs-lg: 1.125rem; --fs-xl: 1.375rem; --fs-2xl: 1.75rem;
  /* spacing (4px grid) */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem; --sp-5: 1.25rem; --sp-6: 1.5rem; --sp-8: 2rem;
  /* radius */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-pill: 999px;
  /* elevation */
  --shadow-sm: 0 1px 2px rgba(15, 23, 20, .06);
  --shadow-md: 0 1px 3px rgba(15, 23, 20, .08), 0 1px 2px rgba(15, 23, 20, .04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 20, .12);
  --ring: 0 0 0 3px rgba(var(--brand-rgb), .22);
  --ring-danger: 0 0 0 3px rgba(220, 38, 38, .18);
  /* sizes */
  --sidebar-w: 276px; --sidebar-w-collapsed: 76px; --topbar-h: 60px; --control-h: 38px;
  --ease: cubic-bezier(.2, .7, .3, 1);

  /* neutrals (light) */
  --bg: #f5f7f6; --surface: #ffffff; --surface-2: #f8faf9; --surface-3: #eef2f0;
  --border: #e3e8e5; --border-strong: #cdd5d0;
  --text: #16211b; --text-2: #3b4a42; --text-muted: #66756d; --text-subtle: #8a978f;

  /* semantic (theme independent) */
  --success: #16a34a; --success-soft: #e8f7ee; --warning: #d97706; --warning-soft: #fdf3e2;
  --danger: #dc2626;  --danger-soft: #fdecec;  --info: #0284c7;    --info-soft: #e6f4fb;
}

/* 3. Colour themes ---------------------------------------------------------- */
:root, [data-theme="green"] {
  --brand: #15803d; --brand-rgb: 21, 128, 61; --brand-hover: #166534; --brand-active: #14532d;
  --brand-soft: #ecfdf3; --brand-soft-2: #d1fadf; --accent: #a3e635; --on-brand: #ffffff;
  --sidebar-bg: #0f241a; --sidebar-fg: #b8cbbf; --sidebar-fg-strong: #ffffff; --sidebar-muted: rgba(184, 203, 191, .6);
  --sidebar-hover: rgba(255, 255, 255, .06); --sidebar-active: rgba(163, 230, 53, .14); --sidebar-accent: #a3e635;
  --chart-from: #4ade80; --chart-to: #15803d;
}
[data-theme="blue"] {
  --brand: #2563eb; --brand-rgb: 37, 99, 235; --brand-hover: #1d4ed8; --brand-active: #1e40af;
  --brand-soft: #eff6ff; --brand-soft-2: #dbeafe; --accent: #38bdf8; --on-brand: #ffffff;
  --sidebar-bg: #0f1b2e; --sidebar-fg: #b6c3d6; --sidebar-fg-strong: #ffffff; --sidebar-muted: rgba(182, 195, 214, .6);
  --sidebar-hover: rgba(255, 255, 255, .06); --sidebar-active: rgba(56, 189, 248, .16); --sidebar-accent: #38bdf8;
  --chart-from: #60a5fa; --chart-to: #2563eb;
}
[data-theme="indigo"] {
  --brand: #4f46e5; --brand-rgb: 79, 70, 229; --brand-hover: #4338ca; --brand-active: #3730a3;
  --brand-soft: #eef2ff; --brand-soft-2: #e0e7ff; --accent: #a78bfa; --on-brand: #ffffff;
  --sidebar-bg: #17152e; --sidebar-fg: #c1bfdc; --sidebar-fg-strong: #ffffff; --sidebar-muted: rgba(193, 191, 220, .6);
  --sidebar-hover: rgba(255, 255, 255, .06); --sidebar-active: rgba(167, 139, 250, .18); --sidebar-accent: #c4b5fd;
  --chart-from: #818cf8; --chart-to: #4f46e5;
}
[data-theme="teal"] {
  --brand: #0f766e; --brand-rgb: 15, 118, 110; --brand-hover: #115e59; --brand-active: #134e4a;
  --brand-soft: #effcfa; --brand-soft-2: #ccfbf1; --accent: #5eead4; --on-brand: #ffffff;
  --sidebar-bg: #0c2321; --sidebar-fg: #b3cbc8; --sidebar-fg-strong: #ffffff; --sidebar-muted: rgba(179, 203, 200, .6);
  --sidebar-hover: rgba(255, 255, 255, .06); --sidebar-active: rgba(94, 234, 212, .15); --sidebar-accent: #5eead4;
  --chart-from: #2dd4bf; --chart-to: #0f766e;
}
[data-theme="earth"] {
  --brand: #a16207; --brand-rgb: 161, 98, 7; --brand-hover: #854d0e; --brand-active: #713f12;
  --brand-soft: #fefbe8; --brand-soft-2: #fef3c7; --accent: #facc15; --on-brand: #ffffff;
  --sidebar-bg: #261c10; --sidebar-fg: #d6c8b2; --sidebar-fg-strong: #ffffff; --sidebar-muted: rgba(214, 200, 178, .6);
  --sidebar-hover: rgba(255, 255, 255, .06); --sidebar-active: rgba(250, 204, 21, .15); --sidebar-accent: #facc15;
  --chart-from: #eab308; --chart-to: #a16207;
}

/* dark mode: neutrals + softened brand tints (works with every theme) */
[data-bs-theme="dark"] {
  --bg: #0c1210; --surface: #131b17; --surface-2: #17211c; --surface-3: #1d2923;
  --border: #25332c; --border-strong: #34453c;
  --text: #e6ede9; --text-2: #c3cfc8; --text-muted: #93a39a; --text-subtle: #6f7f76;
  --brand-soft: rgba(var(--brand-rgb), .16); --brand-soft-2: rgba(var(--brand-rgb), .26);
  --success-soft: rgba(22, 163, 74, .16); --warning-soft: rgba(217, 119, 6, .16); --danger-soft: rgba(220, 38, 38, .16); --info-soft: rgba(2, 132, 199, .16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow-md: 0 1px 3px rgba(0, 0, 0, .35); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  --sidebar-bg: #0a100e;
}
[data-bs-theme="dark"] .text-brand, [data-bs-theme="dark"] a:not(.btn):not(.nav-link):not(.kpi):not(.quick):not(.gsearch-item):not(.dropdown-item):not(.portal-card) { --bs-link-color-rgb: var(--brand-rgb); }

/* 4. Bootstrap bridge ------------------------------------------------------- */
:root, [data-bs-theme] {
  --bs-body-font-family: var(--font-sans); --bs-body-font-size: var(--fs-base);
  --bs-body-bg: var(--bg); --bs-body-color: var(--text); --bs-emphasis-color: var(--text);
  --bs-secondary-color: var(--text-muted); --bs-tertiary-bg: var(--surface-2);
  --bs-border-color: var(--border); --bs-border-radius: var(--r-md); --bs-border-radius-lg: var(--r-lg);
  --bs-primary: var(--brand); --bs-primary-rgb: var(--brand-rgb);
  --bs-link-color: var(--brand); --bs-link-color-rgb: var(--brand-rgb);
  --bs-link-hover-color: var(--brand-hover); --bs-link-hover-color-rgb: var(--brand-rgb);
  --bs-focus-ring-color: rgba(var(--brand-rgb), .22);
  --bs-form-invalid-color: var(--danger); --bs-form-invalid-border-color: var(--danger);
  --bs-form-valid-color: var(--success); --bs-form-valid-border-color: var(--success);
}
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font-sans); font-size: var(--fs-base); line-height: 1.5;
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
body.preload *, body.preload *::before, body.preload *::after { transition: none !important; }
h1, h2, h3, h4, h5, h6 { color: var(--text); letter-spacing: -.01em; }
.text-muted, .form-text { color: var(--text-muted) !important; }
.text-brand { color: var(--brand) !important; }
.bg-brand-soft { background: var(--brand-soft) !important; }
::selection { background: rgba(var(--brand-rgb), .2); }
:focus-visible { outline: 2px solid rgba(var(--brand-rgb), .6); outline-offset: 2px; }

/* buttons: one height, one radius, brand-aware */
.btn { --bs-btn-font-size: var(--fs-base); --bs-btn-font-weight: 500; --bs-btn-padding-y: .45rem; --bs-btn-padding-x: .95rem;
  --bs-btn-border-radius: var(--r-md); --bs-btn-focus-box-shadow: var(--ring);
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease); }
.btn .bi { font-size: 1.05em; line-height: 1; }
.btn > .me-1, .btn > .me-2 { margin-right: 0 !important; }
.btn-sm { --bs-btn-font-size: var(--fs-sm); --bs-btn-padding-y: .3rem; --bs-btn-padding-x: .7rem; --bs-btn-border-radius: var(--r-sm); }
.btn-lg { --bs-btn-font-size: var(--fs-md); --bs-btn-padding-y: .6rem; --bs-btn-padding-x: 1.25rem; }
.btn-primary { --bs-btn-color: var(--on-brand); --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-color: var(--on-brand); --bs-btn-hover-bg: var(--brand-hover); --bs-btn-hover-border-color: var(--brand-hover);
  --bs-btn-active-color: var(--on-brand); --bs-btn-active-bg: var(--brand-active); --bs-btn-active-border-color: var(--brand-active);
  --bs-btn-disabled-color: var(--on-brand); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
  box-shadow: 0 1px 2px rgba(var(--brand-rgb), .25); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: rgba(var(--brand-rgb), .5);
  --bs-btn-hover-color: var(--on-brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-color: var(--on-brand); --bs-btn-active-bg: var(--brand-hover); --bs-btn-active-border-color: var(--brand-hover); }
.btn-outline-secondary, .btn-light, .btn-secondary-soft { --bs-btn-color: var(--text-2); --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--border-strong);
  --bs-btn-hover-color: var(--text); --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-border-color: var(--border-strong);
  --bs-btn-active-color: var(--text); --bs-btn-active-bg: var(--surface-3); --bs-btn-active-border-color: var(--border-strong); }
.btn-ghost { --bs-btn-color: var(--text-2); --bs-btn-bg: transparent; --bs-btn-border-color: transparent;
  --bs-btn-hover-color: var(--brand); --bs-btn-hover-bg: var(--brand-soft); --bs-btn-hover-border-color: transparent;
  --bs-btn-active-color: var(--brand); --bs-btn-active-bg: var(--brand-soft-2); --bs-btn-active-border-color: transparent; }
.btn-danger { --bs-btn-bg: var(--danger); --bs-btn-border-color: var(--danger); }

/* 5. Layout ----------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1040; width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-fg);
  display: flex; flex-direction: column; transition: width .2s var(--ease), transform .2s var(--ease); }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; transition: margin-left .2s var(--ease); display: flex; flex-direction: column; }

.logo-mark, .sidebar-brand .logo { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center; font-size: 1.15rem;
  background: linear-gradient(135deg, var(--accent), var(--brand)); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15); }
.logo-mark.lg { width: 44px; height: 44px; border-radius: 12px; font-size: 1.35rem; }
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; color: #fff; text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, .06); flex-shrink: 0; }
.sidebar-brand:hover { color: #fff; }
.sidebar-brand .name { font-weight: 700; letter-spacing: .01em; line-height: 1.1; white-space: nowrap; }
.sidebar-brand .name small { display: block; font-weight: 500; font-size: .68rem; color: var(--sidebar-fg); letter-spacing: .06em; text-transform: uppercase; margin-top: 2px; }

.sidebar-nav { list-style: none; margin: 0; padding: .75rem .75rem 1rem; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .15) transparent; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: .75rem; padding: .5rem .75rem; border-radius: var(--r-md); color: var(--sidebar-fg);
  font-weight: 500; white-space: nowrap; cursor: pointer; user-select: none; transition: background-color .12s, color .12s; }
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-fg-strong); }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: var(--sidebar-fg-strong); }
.sidebar-nav .nav-link.active .bi { color: var(--sidebar-accent); }
.sidebar-nav .nav-link .bi { font-size: 1.1rem; width: 1.25rem; text-align: center; flex-shrink: 0; }
.sidebar-nav .nav-link .label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav .chev { display: inline-block; font-size: .75rem !important; transition: transform .2s var(--ease); width: auto !important; opacity: .7; }
.sidebar-nav .nav-group.open > .nav-link .chev { transform: rotate(90deg); }
.sidebar-nav .nav-group.has-active > .nav-link { color: var(--sidebar-fg-strong); }
.sidebar-nav .submenu { list-style: none; padding: .15rem 0 .35rem 1.75rem; margin: 0; display: none; position: relative; }
.sidebar-nav .submenu::before { content: ""; position: absolute; left: 1.2rem; top: .25rem; bottom: .5rem; width: 1px; background: rgba(255, 255, 255, .08); }
.sidebar-nav .nav-group.open > .submenu { display: block; }
.sidebar-nav .submenu .nav-link { gap: .6rem; padding: .38rem .6rem; font-weight: 400; font-size: var(--fs-sm); }
.sidebar-nav .submenu .nav-link .bi { font-size: .95rem; }
.sidebar-foot { padding: .75rem 1.25rem; font-size: var(--fs-xs); color: var(--sidebar-muted); border-top: 1px solid rgba(255, 255, 255, .06); white-space: nowrap; flex-shrink: 0; }

body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .sidebar .name, body.sidebar-collapsed .sidebar .label, body.sidebar-collapsed .sidebar .chev,
body.sidebar-collapsed .sidebar .ext { display: none; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
body.sidebar-collapsed .sidebar-nav { overflow: visible; padding: .75rem .6rem; }
body.sidebar-collapsed .sidebar-nav > li > .nav-link { justify-content: center; padding: .65rem 0; }
body.sidebar-collapsed .sidebar-nav .nav-group { position: relative; }
body.sidebar-collapsed .sidebar-nav .nav-group > .submenu, body.sidebar-collapsed .sidebar-nav .nav-group.open > .submenu { display: none; }
body.sidebar-collapsed .sidebar-nav .nav-group:hover > .submenu { display: block; position: absolute; left: calc(100% + 6px); top: 0; min-width: 230px; padding: .4rem;
  background: var(--sidebar-bg); border-radius: var(--r-lg); box-shadow: 0 10px 30px rgba(0, 0, 0, .35); z-index: 1060; }
body.sidebar-collapsed .sidebar-nav .nav-group:hover > .submenu::before { content: attr(data-title); position: static; width: auto; background: none; display: block;
  padding: .35rem .65rem .45rem; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-muted); }
body.sidebar-collapsed .sidebar-nav .nav-group:hover > .submenu .label { display: inline; }

.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  .main { margin-left: 0 !important; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 1035; }
  body.sidebar-collapsed .sidebar .name, body.sidebar-collapsed .sidebar .label, body.sidebar-collapsed .sidebar .chev, body.sidebar-collapsed .sidebar .ext { display: revert; }
}

/* topbar */
.topbar { position: sticky; top: 0; z-index: 1020; height: var(--topbar-h); display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border); }
.icon-btn { width: var(--control-h); height: var(--control-h); border-radius: var(--r-md); border: 1px solid transparent; background: transparent; color: var(--text-muted);
  display: inline-grid; place-items: center; font-size: 1.15rem; transition: background-color .12s, color .12s; }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--brand-soft); color: var(--brand); }
.topbar .page-title { font-weight: 600; font-size: var(--fs-md); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.gsearch { position: relative; flex: 1; max-width: 560px; margin-left: auto; }
.gsearch .form-control { padding-left: 2.4rem; padding-right: 3.5rem; height: var(--control-h); border-radius: var(--r-md); background: var(--surface-2); border-color: var(--border); }
.gsearch .form-control:focus { background: var(--surface); }
.gsearch > .bi-search { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.gsearch > kbd { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); }
.gsearch input:not(:placeholder-shown) ~ kbd { display: none; }
kbd, .gsearch-foot kbd { font-family: var(--font-sans); font-size: .68rem; font-weight: 500; background: var(--surface); color: var(--text-muted); border: 1px solid var(--border);
  border-bottom-width: 2px; padding: .08rem .35rem; border-radius: 5px; box-shadow: none; }
.gsearch-panel { position: absolute; top: calc(100% + 8px); left: 0; right: 0; max-height: min(70vh, 560px); overflow-y: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: .4rem; display: none; z-index: 1050; }
.gsearch.open .gsearch-panel { display: block; }
.gsearch-group { padding: .5rem .6rem .25rem; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); display: flex; align-items: center; gap: .4rem; }
.gsearch-item { display: flex; align-items: center; gap: .75rem; padding: .5rem .6rem; border-radius: var(--r-md); color: var(--text); text-decoration: none; }
.gsearch-item .ico { width: 32px; height: 32px; border-radius: var(--r-md); background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex-shrink: 0; }
.gsearch-item .t { font-weight: 500; line-height: 1.2; }
.gsearch-item .s { font-size: var(--fs-xs); color: var(--text-muted); }
.gsearch-item .ext { margin-left: auto; color: var(--text-muted); font-size: .8rem; }
.gsearch-item.active, .gsearch-item:hover { background: var(--brand-soft); color: var(--text); }
.gsearch-item mark { padding: 0; background: rgba(var(--brand-rgb), .2); color: inherit; border-radius: 2px; }
.gsearch-empty { padding: 1.25rem; text-align: center; color: var(--text-muted); font-size: var(--fs-sm); }
.gsearch-foot { display: flex; gap: 1rem; padding: .5rem .6rem .25rem; border-top: 1px solid var(--border); margin-top: .35rem; font-size: var(--fs-xs); color: var(--text-muted); }
@media (max-width: 767.98px) { .gsearch > kbd, .topbar .page-title { display: none; } .topbar { padding: 0 .75rem; gap: .4rem; } }

.user-chip { display: flex; align-items: center; gap: .6rem; padding: .2rem .5rem .2rem .2rem; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.user-chip:hover { border-color: var(--border-strong); }
.user-chip .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font-weight: 600; font-size: .8rem; }
.user-chip .who { line-height: 1.15; text-align: left; font-weight: 500; }
.user-chip .who small { display: block; color: var(--text-muted); font-size: .7rem; font-weight: 400; }

.dropdown-menu { --bs-dropdown-bg: var(--surface); --bs-dropdown-border-color: var(--border); --bs-dropdown-border-radius: var(--r-lg);
  --bs-dropdown-link-hover-bg: var(--brand-soft); --bs-dropdown-link-hover-color: var(--text); --bs-dropdown-link-active-bg: var(--brand); --bs-dropdown-font-size: var(--fs-base);
  box-shadow: var(--shadow-lg); padding: .35rem; }
.dropdown-item { border-radius: var(--r-sm); padding: .45rem .7rem; }

.content { padding: var(--sp-6); flex: 1; width: 100%; max-width: 1600px; }
@media (max-width: 767.98px) { .content { padding: var(--sp-4); } }
.app-footer { padding: 1rem 1.5rem; font-size: var(--fs-xs); color: var(--text-muted); border-top: 1px solid var(--border); display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }

/* 6. Page head, cards, KPI ---------------------------------------------------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-head .ph-main { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.page-head .ph-icon { width: 44px; height: 44px; border-radius: var(--r-lg); background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0; }
.page-head h1 { font-size: var(--fs-xl); font-weight: 700; margin: 0; line-height: 1.25; }
.page-head .sub { color: var(--text-muted); font-size: var(--fs-sm); margin-top: .15rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.page-head .ph-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.breadcrumb-back { display: inline-flex; align-items: center; gap: .3rem; font-size: var(--fs-sm); color: var(--text-muted); text-decoration: none; font-weight: 500; margin-bottom: .35rem; }
.breadcrumb-back:hover { color: var(--brand); }

.card { --bs-card-bg: var(--surface); --bs-card-border-color: var(--border); --bs-card-border-radius: var(--r-lg); --bs-card-inner-border-radius: calc(var(--r-lg) - 1px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); padding: .9rem 1.25rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.card-footer { background: var(--surface-2); border-top: 1px solid var(--border); }

.kpi { --kpi: var(--brand); display: block; position: relative; height: 100%; padding: 1.1rem 1.2rem; border-radius: var(--r-lg); text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); color: var(--text);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), border-color .15s var(--ease); cursor: pointer; overflow: hidden; }
.kpi:hover, .kpi:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--kpi) 45%, var(--border)); color: var(--text); outline: none; }
.kpi .kpi-ico { width: 42px; height: 42px; border-radius: var(--r-lg); display: grid; place-items: center; font-size: 1.25rem; background: color-mix(in srgb, var(--kpi) 14%, transparent); color: var(--kpi); }
.kpi .kpi-label { color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500; margin-top: .9rem; }
.kpi .kpi-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .kpi-meta { font-size: var(--fs-xs); color: var(--text-muted); margin-top: .2rem; }
.kpi .kpi-go { position: absolute; top: 1.1rem; right: 1.1rem; color: var(--text-muted); opacity: 0; transform: translateX(-4px); transition: all .15s var(--ease); }
.kpi:hover .kpi-go { opacity: 1; transform: none; color: var(--kpi); }
.kpi .kpi-old { position: absolute; top: 1.1rem; right: 1.1rem; font-size: .64rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-pill); padding: .15rem .5rem; transition: all .15s var(--ease); }
.kpi:hover .kpi-old { color: var(--kpi); border-color: color-mix(in srgb, var(--kpi) 40%, var(--border)); }
@media (max-width: 575.98px) {
  .kpi { padding: .9rem; } .kpi .kpi-ico { width: 36px; height: 36px; font-size: 1.05rem; }
  .kpi .kpi-value { font-size: 1.25rem; } .kpi .kpi-label { margin-top: .7rem; } .kpi .kpi-old { top: .9rem; right: .9rem; padding: .1rem .4rem; }
  .page-head h1 { font-size: var(--fs-lg); } .page-head .ph-icon { width: 38px; height: 38px; font-size: 1.1rem; }
}
/* KPI palette: brand follows the theme; the rest are fixed semantic hues */
.kpi-brand, .kpi-green { --kpi: var(--brand); }
.kpi-blue { --kpi: #2563eb; } .kpi-amber { --kpi: #d97706; } .kpi-rose { --kpi: #e11d48; }
.kpi-violet { --kpi: #7c3aed; } .kpi-teal { --kpi: #0d9488; } .kpi-slate { --kpi: #64748b; } .kpi-lime { --kpi: #65a30d; }

.quick { display: flex; align-items: center; gap: .75rem; padding: .8rem 1rem; border: 1px solid var(--border); border-radius: var(--r-lg); text-decoration: none; color: var(--text);
  background: var(--surface); font-weight: 500; transition: all .15s var(--ease); }
.quick:hover { border-color: rgba(var(--brand-rgb), .5); background: var(--brand-soft); color: var(--text); }
.quick .bi { font-size: 1.2rem; color: var(--brand); }

.chart-body { display: flex; flex-direction: column; }
.chart { display: flex; align-items: flex-end; gap: 6px; flex: 1; min-height: 200px; padding-top: .5rem; }
.chart .bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.chart .bar { width: 100%; max-width: 34px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, var(--chart-from), var(--chart-to)); min-height: 3px; position: relative; transition: opacity .15s; }
.chart .bar.today { background: linear-gradient(180deg, var(--accent), var(--brand)); }
.chart .bar-wrap:hover .bar { opacity: .8; }
.chart .x { font-size: .65rem; color: var(--text-muted); margin-top: .35rem; white-space: nowrap; }
.chart .tip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); font-size: .72rem;
  padding: .2rem .45rem; border-radius: 5px; white-space: nowrap; display: none; }
.chart .bar-wrap:hover .tip { display: block; }
@media (max-width: 575.98px) { .chart .x { display: none; } }

/* 7. Tables, pills, badges -------------------------------------------------- */
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--border); margin: 0; }
.table > :not(caption) > * > * { padding: .7rem 1rem; border-bottom-color: var(--border); }
.table thead th { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.table thead th a { color: inherit; text-decoration: none; }
.table thead th a:hover { color: var(--brand); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr.row-link { cursor: pointer; }
.table tbody tr.row-link:hover > * { background: var(--brand-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: .92em; }

/* segmented filter (All / Active / Inactive) */
.filter-pills { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: var(--r-md); }
.filter-pills .btn { --bs-btn-padding-y: .28rem; --bs-btn-padding-x: .8rem; --bs-btn-font-size: var(--fs-sm); --bs-btn-color: var(--text-muted); --bs-btn-bg: transparent;
  --bs-btn-border-color: transparent; --bs-btn-hover-color: var(--text); --bs-btn-hover-bg: transparent; --bs-btn-hover-border-color: transparent;
  --bs-btn-active-color: var(--text); --bs-btn-active-bg: var(--surface); --bs-btn-active-border-color: transparent; border-radius: var(--r-sm) !important; box-shadow: none; }
.filter-pills .btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); }
.filter-pills .btn .count { font-size: .72rem; color: var(--text-muted); background: var(--surface-3); border-radius: var(--r-pill); padding: 0 .4rem; margin-left: .15rem; }
.filter-pills .btn.active .count { background: var(--brand-soft); color: var(--brand); }

.badge { font-weight: 600; font-size: .7rem; letter-spacing: .02em; padding: .3em .6em; border-radius: var(--r-pill); }
.badge-soft-brand { background: var(--brand-soft); color: var(--brand); }
.badge-soft-success { background: var(--success-soft); color: var(--success); }
.badge-soft-secondary { background: var(--surface-3); color: var(--text-muted); }
.badge-soft-warning { background: var(--warning-soft); color: var(--warning); }
.badge-soft-danger { background: var(--danger-soft); color: var(--danger); }
.badge-soft-info { background: var(--info-soft); color: var(--info); }
.badge-dot::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: .4em; vertical-align: .1em; }

.status-switch { cursor: pointer; }
.form-switch .form-check-input { cursor: pointer; }
.empty { padding: 3rem 1rem; text-align: center; color: var(--text-muted); }
.empty .bi { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .5; }

.pagination { --bs-pagination-color: var(--text-2); --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--border); --bs-pagination-hover-bg: var(--brand-soft);
  --bs-pagination-hover-color: var(--brand); --bs-pagination-hover-border-color: var(--border); --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand);
  --bs-pagination-active-color: var(--on-brand); --bs-pagination-disabled-bg: var(--surface-2); --bs-pagination-focus-box-shadow: var(--ring); --bs-pagination-font-size: var(--fs-sm); margin: 0; }

.alert { border-radius: var(--r-lg); font-size: var(--fs-base); border-width: 1px; }
.alert-danger { --bs-alert-bg: var(--danger-soft); --bs-alert-color: var(--danger); --bs-alert-border-color: rgba(220, 38, 38, .25); }
.alert-success { --bs-alert-bg: var(--success-soft); --bs-alert-color: var(--success); --bs-alert-border-color: rgba(22, 163, 74, .25); }
.alert-warning { --bs-alert-bg: var(--warning-soft); --bs-alert-color: var(--warning); --bs-alert-border-color: rgba(217, 119, 6, .25); }
.alert-info { --bs-alert-bg: var(--info-soft); --bs-alert-color: var(--info); --bs-alert-border-color: rgba(2, 132, 199, .25); }

/* 8. Theme picker, toasts ---------------------------------------------------- */
.theme-menu { width: 260px; padding: .75rem !important; }
.theme-menu h6 { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; margin: 0 0 .5rem; }
.theme-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; margin-bottom: .9rem; }
.theme-swatch { aspect-ratio: 1; border-radius: var(--r-md); border: 2px solid transparent; padding: 0; position: relative; cursor: pointer;
  background: linear-gradient(135deg, var(--sw-a) 0 50%, var(--sw-b) 50% 100%); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); transition: transform .12s var(--ease); }
.theme-swatch:hover { transform: scale(1.06); }
.theme-swatch.active { border-color: var(--text); }
.theme-swatch.active::after { content: "\F26E"; font-family: "bootstrap-icons"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1rem; text-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.theme-swatch[data-theme-set="green"] { --sw-a: #15803d; --sw-b: #0f241a; }
.theme-swatch[data-theme-set="blue"] { --sw-a: #2563eb; --sw-b: #0f1b2e; }
.theme-swatch[data-theme-set="indigo"] { --sw-a: #4f46e5; --sw-b: #17152e; }
.theme-swatch[data-theme-set="teal"] { --sw-a: #0f766e; --sw-b: #0c2321; }
.theme-swatch[data-theme-set="earth"] { --sw-a: #a16207; --sw-b: #261c10; }
.theme-name { font-size: var(--fs-xs); color: var(--text-muted); margin: -.5rem 0 .8rem; }
.mode-toggle { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; background: var(--surface-3); border-radius: var(--r-md); }
.mode-toggle button { border: 0; background: transparent; color: var(--text-muted); border-radius: var(--r-sm); padding: .35rem .25rem; font-size: var(--fs-sm); font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: .3rem; }
.mode-toggle button:hover { color: var(--text); }
.mode-toggle button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); }

.toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 1090; display: flex; flex-direction: column; gap: .5rem; }
.toast-msg { background: var(--text); color: var(--surface); padding: .7rem 1rem; border-radius: var(--r-lg); box-shadow: var(--shadow-lg); display: flex; align-items: center;
  gap: .6rem; font-size: var(--fs-base); animation: toastIn .2s var(--ease); max-width: 380px; }
.toast-msg.error { background: var(--danger); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 9. Forms ------------------------------------------------------------------ */
.form-label { font-weight: 500; font-size: var(--fs-sm); color: var(--text-2); margin-bottom: .35rem; display: flex; align-items: baseline; gap: .3rem; }
.form-label .req { color: var(--danger); font-weight: 600; }
.form-label .opt { color: var(--text-subtle); font-weight: 400; font-size: var(--fs-xs); margin-left: auto; }
.form-control, .form-select { font-size: var(--fs-base); min-height: var(--control-h); border-radius: var(--r-md); border-color: var(--border-strong); background-color: var(--surface);
  color: var(--text); transition: border-color .12s, box-shadow .12s; }
.form-control::placeholder { color: var(--text-subtle); }
.form-control:hover:not(:focus):not(:disabled):not([readonly]), .form-select:hover:not(:focus):not(:disabled) { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text-muted)); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: var(--ring); background-color: var(--surface); }
.form-control:disabled, .form-control[readonly], .form-select:disabled { background-color: var(--surface-2); color: var(--text-muted); }
.form-control-sm, .form-select-sm { min-height: 32px; font-size: var(--fs-sm); }
.form-control.text-upper { text-transform: uppercase; }
.form-control.text-upper::placeholder { text-transform: none; }
.form-check-input { border-color: var(--border-strong); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { border-color: var(--brand); box-shadow: var(--ring); }
.form-text { font-size: var(--fs-xs); margin-top: .3rem; }
.input-group-text { background: var(--surface-2); border-color: var(--border-strong); color: var(--text-muted); font-size: var(--fs-sm); min-width: 2.5rem; justify-content: center; }
.input-group > .form-control:focus { z-index: 5; }
.input-group:focus-within .input-group-text { border-color: var(--brand); color: var(--brand); }
.input-group.is-invalid-group .input-group-text, .input-group:has(.is-invalid) .input-group-text { border-color: var(--danger); }

/* validation (server + live jQuery) */
.form-control.is-invalid, .form-select.is-invalid, .was-validated .form-control:invalid { border-color: var(--danger); background-image: none; padding-right: .75rem; }
.form-control.is-invalid:focus, .form-select.is-invalid:focus { box-shadow: var(--ring-danger); border-color: var(--danger); }
.form-control.is-valid, .form-select.is-valid { border-color: var(--border-strong); background-image: none; padding-right: .75rem; }
.form-control.is-valid:focus { border-color: var(--brand); box-shadow: var(--ring); }
.field.valid .form-label::after { content: "\F26E"; font-family: "bootstrap-icons"; color: var(--success); font-size: .9rem; line-height: 1; }
.invalid-feedback { font-size: var(--fs-xs); color: var(--danger); margin-top: .3rem; align-items: flex-start; gap: .3rem; }
.invalid-feedback::before { content: "\F33A"; font-family: "bootstrap-icons"; }
.invalid-feedback.d-block, .is-invalid ~ .invalid-feedback, .field.has-error .invalid-feedback { display: flex !important; }
.field .meta { display: flex; justify-content: space-between; gap: .5rem; }
.field .meta > :only-child { flex: 1; }
.char-count { font-size: var(--fs-xs); color: var(--text-subtle); margin-top: .3rem; margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.char-count.near { color: var(--warning); } .char-count.over { color: var(--danger); }

.error-summary { display: flex; gap: .8rem; padding: .9rem 1.1rem; border: 1px solid rgba(220, 38, 38, .3); background: var(--danger-soft); color: var(--text);
  border-radius: var(--r-lg); margin-bottom: var(--sp-5); }
.error-summary > .bi { color: var(--danger); font-size: 1.2rem; line-height: 1.3; }
.error-summary strong { color: var(--danger); }
.error-summary ul { margin: .35rem 0 0; padding-left: 1.1rem; font-size: var(--fs-sm); }
.error-summary a { color: var(--text); text-decoration: underline; text-decoration-color: rgba(220, 38, 38, .4); text-underline-offset: 2px; }
.error-summary a:hover { color: var(--danger); }

/* sectioned form: label column + fields column */
.form-card { padding: 0; }
.form-section { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: var(--sp-8); padding: var(--sp-6); border-bottom: 1px solid var(--border); scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.form-section:last-of-type { border-bottom: 0; }
.fs-head { display: flex; gap: .75rem; align-items: flex-start; }
.fs-head .fs-icon { width: 36px; height: 36px; border-radius: var(--r-md); background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 1.05rem; flex-shrink: 0; }
.fs-head h2 { font-size: var(--fs-md); font-weight: 600; margin: .35rem 0 .2rem; }
.fs-head p { font-size: var(--fs-sm); color: var(--text-muted); margin: 0; }
.fs-head .fs-err { display: none; margin-top: .4rem; }
.form-section.has-error .fs-head .fs-err { display: inline-flex; }
.fs-body { min-width: 0; }
@media (max-width: 991.98px) { .form-section { grid-template-columns: 1fr; gap: var(--sp-4); padding: var(--sp-5); } }
@media (max-width: 575.98px) { .form-section { padding: var(--sp-4); } }

/* segmented control (status, yes/no) */
.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: var(--r-md); border: 1px solid var(--border); }
.segmented .btn-check + label { margin: 0; padding: .35rem 1rem; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 500; color: var(--text-muted);
  cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; transition: all .12s var(--ease); user-select: none; }
.segmented .btn-check + label:hover { color: var(--text); }
.segmented .btn-check:checked + label { background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); }
.segmented .btn-check:checked + label.on { color: var(--success); }
.segmented .btn-check:checked + label.off { color: var(--text-2); }
.segmented .btn-check:focus-visible + label { box-shadow: var(--ring); }
fieldset:disabled .segmented { opacity: .7; }

/* sticky actions bar */
.form-actions { position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; gap: .5rem; justify-content: flex-end; padding: .85rem var(--sp-6);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--border);
  border-radius: 0 0 var(--r-lg) var(--r-lg); }
.form-actions .status-note { margin-right: auto; font-size: var(--fs-sm); color: var(--text-muted); display: flex; align-items: center; gap: .45rem; }
.form-actions .dirty-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); display: none; }
form.is-dirty .form-actions .dirty-dot { display: inline-block; }
form.is-dirty .form-actions .note-clean, form:not(.is-dirty) .form-actions .note-dirty { display: none; }
@media (max-width: 575.98px) { .form-actions { padding: .75rem var(--sp-4); } .form-actions .status-note { display: none; } .form-actions .btn { flex: 1; } }

/* Tom Select, themed */
.ts-wrapper.form-select, .ts-wrapper.form-control { padding: 0 !important; background-image: none; min-height: var(--control-h); border: 0; box-shadow: none !important; }
.ts-wrapper .ts-control, .ts-wrapper.form-select .ts-control, .ts-wrapper.form-control .ts-control { min-height: var(--control-h); border-radius: var(--r-md); border: 1px solid var(--border-strong) !important; background: var(--surface) !important; color: var(--text);
  font-size: var(--fs-base); padding: .35rem 2rem .35rem .75rem; box-shadow: none; }
.ts-wrapper.single .ts-control { background-image: var(--bs-form-select-bg-img) !important; background-repeat: no-repeat !important; background-position: right .75rem center !important; background-size: 16px 12px !important; }
.ts-wrapper.focus .ts-control { border-color: var(--brand) !important; box-shadow: var(--ring); }
.ts-wrapper.is-invalid .ts-control { border-color: var(--danger) !important; }
.ts-wrapper .ts-control input { color: var(--text); font-size: var(--fs-base); }
.ts-wrapper .ts-control input::placeholder { color: var(--text-subtle); }
.ts-wrapper.multi .ts-control > .item { background: var(--brand-soft) !important; color: var(--brand) !important; border: 1px solid rgba(var(--brand-rgb), .25) !important;
  border-radius: var(--r-sm); padding: .05rem .45rem; font-size: var(--fs-sm); font-weight: 500; }
.ts-wrapper.multi .ts-control > .item .remove { border-left-color: rgba(var(--brand-rgb), .25) !important; color: inherit; }
.ts-wrapper.disabled .ts-control { background: var(--surface-2) !important; opacity: 1; }
.ts-dropdown { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); margin-top: 4px; z-index: 1060; }
.ts-dropdown .option, .ts-dropdown .no-results, .ts-dropdown .optgroup-header { padding: .45rem .75rem; font-size: var(--fs-base); }
.ts-dropdown .active { background: var(--brand-soft); color: var(--text); }
.ts-dropdown .option.selected:not(.active) { color: var(--brand); font-weight: 500; }
.ts-dropdown .dropdown-header, .ts-dropdown .ts-dropdown-content .dropdown-header { padding: .45rem .75rem; }
.ts-wrapper .clear-button { color: var(--text-muted); right: 2rem !important; }
.ts-wrapper .dropdown-input { border-color: var(--border); background: var(--surface-2); }
.plugin-checkbox_options .option input { margin-right: .5rem; accent-color: var(--brand); }
.ts-count { font-size: var(--fs-xs); color: var(--text-muted); margin-top: .3rem; }

/* legacy checklist (fallback without JS) */
.checklist { border: 1px solid var(--border-strong); border-radius: var(--r-md); max-height: 230px; overflow-y: auto; padding: .25rem .75rem; background: var(--surface); }
.checklist .form-check { padding: .3rem 0 .3rem 1.75rem; margin: 0; border-bottom: 1px dashed var(--border); }
.checklist .form-check:last-child { border-bottom: 0; }

/* 10. Auth / portal chooser ------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: radial-gradient(1200px 600px at 10% 10%, color-mix(in srgb, var(--brand) 55%, var(--sidebar-bg)), var(--sidebar-bg)); color: var(--sidebar-fg);
  padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 35%, transparent), transparent 70%); }
.auth-art h2 { font-weight: 700; font-size: var(--fs-2xl); color: #fff; max-width: 26ch; letter-spacing: -.02em; }
.auth-form { display: grid; place-items: center; padding: 2rem; background: var(--surface); }
.auth-form .box { width: 100%; max-width: 380px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-art { display: none; } }

.portal-card { --kpi: var(--brand); display: block; text-decoration: none; color: var(--text); padding: 1.75rem; border-radius: var(--r-xl); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm); transition: all .15s var(--ease); height: 100%; }
.portal-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); color: var(--text); border-color: var(--kpi); }
.portal-card .kpi-ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.5rem; background: color-mix(in srgb, var(--kpi) 14%, transparent); color: var(--kpi); }

/* 11. Utilities -------------------------------------------------------------- */
.min-w-0 { min-width: 0; }
.fw-medium { font-weight: 500 !important; }
.text-xs { font-size: var(--fs-xs) !important; } .text-sm { font-size: var(--fs-sm) !important; }
.gap-row > * + * { border-top: 1px solid var(--border); }
.error-summary:focus, .error-summary:focus-visible { outline: none; }

/* 12. Lists: toolbar, table, pager (v0.1.4) ---------------------------------- */
.btn-icon { --bs-btn-padding-x: 0; width: var(--control-h); height: var(--control-h); }
.btn-icon.btn-sm { width: 30px; height: 30px; }
.list-card { overflow: visible; }
.list-toolbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
.list-filter { position: relative; flex: 1 1 260px; max-width: 420px; margin-left: auto; }
.list-filter > .bi-search { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--text-subtle); pointer-events: none; }
.list-filter .form-control { padding-left: 2.25rem; padding-right: 2.25rem; background: var(--surface-2); }
.list-filter .form-control:focus { background: var(--surface); }
.list-filter .form-control::-webkit-search-cancel-button { display: none; }
.list-filter-clear { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--text-subtle); padding: .25rem .4rem; line-height: 1; }
.list-filter-clear:hover { color: var(--text-muted); }
.list-tools { display: flex; gap: .15rem; }
.list-tools .btn.active { --bs-btn-active-bg: var(--brand-soft); color: var(--brand); }
.col-menu { min-width: 220px; max-height: 60vh; overflow-y: auto; }
.col-menu h6 { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; padding: .35rem .7rem .25rem; margin: 0; }
.col-menu .dropdown-item.form-check { display: flex; align-items: center; gap: .55rem; padding-left: .7rem; cursor: pointer; }
.col-menu .form-check-input { margin: 0; float: none; flex-shrink: 0; }

.list-root { position: relative; }
.list-root::before { content: ""; position: absolute; left: 0; top: 0; height: 2px; width: 0; background: var(--brand); z-index: 6; opacity: 0; transition: width .6s var(--ease), opacity .2s; }
.list-root.is-loading::before { width: 80%; opacity: 1; }
.list-root.is-loading .table-wrap { opacity: .55; pointer-events: none; transition: opacity .15s .1s; }

/* table: one line per row, sticky header, typed alignment */
.table-wrap { overflow: auto; max-height: calc(100vh - var(--topbar-h) - 250px); min-height: 220px; overscroll-behavior: contain; }
@media (max-height: 640px) { .table-wrap { max-height: none; } }
.table-list { --row-py: .62rem; border-collapse: separate; border-spacing: 0; }
.table-list > :not(caption) > * > * { padding: var(--row-py) .9rem; white-space: nowrap; vertical-align: middle; }
.list-card.is-compact .table-list { --row-py: .32rem; }
.list-card.is-compact .table-list td { font-size: var(--fs-sm); }
.table-list thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); border-bottom: 1px solid var(--border); padding-top: .55rem; padding-bottom: .55rem; }
.table-list thead th:first-child { border-top-left-radius: 0; }
.th-sort { display: inline-flex; align-items: center; gap: .35rem; color: inherit; text-decoration: none; }
.th-sort .bi { font-size: .8rem; opacity: 0; transition: opacity .12s; }
.th-sort:hover .bi, .th-sort:focus-visible .bi { opacity: .6; }
.th-sort.is-sorted { color: var(--brand); }
.th-sort.is-sorted .bi { opacity: 1; }
.num .th-sort { flex-direction: row-reverse; }
.table-list tbody tr { transition: background-color .1s; }
.table-list tbody tr.row-link:hover > * { background: var(--brand-soft); }
.table-list tbody tr.is-inactive td:not(.col-status):not(.col-actions) { color: var(--text-muted); }
.table-list tbody tr.is-inactive .cell-link { color: var(--text-muted); }
.table-list tbody tr:focus-visible { outline: 2px solid rgba(var(--brand-rgb), .5); outline-offset: -2px; }
.table-list tbody tr.is-cursor > * { background: var(--brand-soft); }
.table-list tbody tr.is-cursor > td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
@keyframes rowFlash { 0%, 30% { background: rgba(var(--brand-rgb), .22); } 100% { background: transparent; } }
.table-list tbody tr.row-flash > * { animation: rowFlash 2.4s var(--ease); }

.col-id { width: 1%; color: var(--text-subtle); font-variant-numeric: tabular-nums; font-size: var(--fs-sm); }
.col-primary { min-width: 180px; max-width: 320px; }
.col-trunc { max-width: 220px; }
.col-email { max-width: 220px; }
.col-primary, .col-trunc { overflow: hidden; text-overflow: ellipsis; }
.col-primary > *, .col-trunc > .cell-text { display: block; overflow: hidden; text-overflow: ellipsis; }
.col-center { text-align: center; }
.col-center .th-sort { justify-content: center; }
.col-status { width: 1%; }
/* Status + actions stay pinned on the right when a wide table scrolls sideways */
.table-list > :not(caption) > tr > .col-status { position: sticky; right: 46px; z-index: 2; --bs-table-bg: var(--surface); --bs-table-bg-state: none; background: var(--surface); box-shadow: none; }
.table-list > thead > tr > .col-status { --bs-table-bg: var(--surface-2); background: var(--surface-2); z-index: 4; }
.table-list > tbody > tr.row-link:hover > .col-status, .table-list > tbody > tr.is-cursor > .col-status { background: linear-gradient(var(--brand-soft), var(--brand-soft)), var(--surface); }
.table-wrap.is-scrolled-x .table-list > :not(caption) > tr > .col-status { box-shadow: -10px 0 10px -10px rgba(0, 0, 0, .25); }
.table-list > :not(caption) > tr > .col-actions { width: 46px; min-width: 46px; max-width: 46px; text-align: right; padding-left: .35rem; position: sticky; right: 0; z-index: 2; --bs-table-bg: var(--surface); --bs-table-bg-state: none; background: var(--surface); box-shadow: none; }
.table-list > thead > tr > .col-actions { --bs-table-bg: var(--surface-2); background: var(--surface-2); z-index: 4; }
.table-list > tbody > tr.row-link:hover > .col-actions, .table-list > tbody > tr.is-cursor > .col-actions { background: linear-gradient(var(--brand-soft), var(--brand-soft)), var(--surface); }
.table-list > tbody > tr.row-flash > .col-actions { animation: none; }
.col-actions .btn { opacity: .55; }
tr:hover .col-actions .btn, .col-actions .btn:focus-visible { opacity: 1; }
.cell-link { color: var(--text); font-weight: 600; text-decoration: none; }
.cell-link:hover { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.cell-code { font-family: var(--font-mono); font-size: .86em; letter-spacing: .01em; color: var(--text-2); }
.cell-empty { color: var(--text-subtle); }
.cell-tags { display: inline-flex; gap: .25rem; }
.tag { display: inline-block; padding: .08rem .45rem; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-2); font-size: var(--fs-xs); font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.tag-more { background: var(--brand-soft); color: var(--brand); }
.status-switch { display: inline-flex; align-items: center; gap: .4rem; padding-left: 0; }
.status-switch .form-check-input { margin: 0; float: none; width: 2.1em; height: 1.15em; }
.status-switch .state { font-size: var(--fs-sm); color: var(--text-muted); min-width: 4.2em; }
.status-switch input:checked ~ .state { color: var(--success); font-weight: 500; }
mark.hl { padding: 0; background: rgba(var(--brand-rgb), .18); color: inherit; border-radius: 2px; }
.row-empty td { white-space: normal !important; }
.row-empty:hover > * { background: transparent !important; }

/* pager */
.pager { display: flex; align-items: center; gap: .75rem 1.25rem; flex-wrap: wrap; padding: .7rem 1rem; border-top: 1px solid var(--border); background: var(--surface); border-radius: 0 0 var(--r-lg) var(--r-lg); font-size: var(--fs-sm); }
.pager-info { color: var(--text-muted); margin-right: auto; font-variant-numeric: tabular-nums; }
.pager-info strong { color: var(--text); font-weight: 600; }
.pager-size, .pager-jump { display: flex; align-items: center; gap: .45rem; margin: 0; }
.pager-size .form-select { width: auto; min-height: 30px; padding-top: .15rem; padding-bottom: .15rem; }
.pager-jump .form-control { width: 70px; min-height: 30px; text-align: center; }
.pagination-sm { --bs-pagination-padding-x: .6rem; --bs-pagination-padding-y: .22rem; --bs-pagination-border-radius: var(--r-sm); gap: 3px; }
.pagination-sm .page-link { border-radius: var(--r-sm) !important; min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; border-color: transparent; }
.pagination-sm .page-item:not(.active):not(.disabled) .page-link:hover { border-color: var(--border); }
.pagination-sm .page-item.gap .page-link { background: transparent; border-color: transparent; padding-left: .2rem; padding-right: .2rem; min-width: 0; }
.pagination-sm .page-item.disabled .page-link { background: transparent; color: var(--text-subtle); }

/* phones: each row becomes a card */
@media (max-width: 767.98px) {
  .list-toolbar { padding: .75rem; }
  .list-filter { max-width: none; flex-basis: 100%; order: 3; margin-left: 0; }
  .list-tools { margin-left: auto; }
  .table-wrap { max-height: none; overflow: visible; }
  .table-list thead { display: none; }
  .table-list, .table-list tbody { display: block; }
  .table-list tbody tr { display: grid; grid-template-columns: 1fr auto; gap: .15rem .75rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
  .table-list tbody tr > td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; width: auto !important; padding: 0 !important; border: 0; white-space: normal; max-width: none; grid-column: 1 / -1; font-size: var(--fs-sm); text-align: right; }
  .table-list tbody tr.row-flash { animation: rowFlash 2.4s var(--ease); }
  .table-list tbody tr.row-flash > * { animation: none; }
  .list-tools [data-density] { display: none; }
  .filter-pills .btn { --bs-btn-padding-x: .6rem; }
  .table-list tbody tr > td::before { content: attr(data-label); color: var(--text-muted); font-size: var(--fs-xs); text-align: left; flex-shrink: 0; }
  .table-list tbody tr > td.col-primary { grid-column: 1; grid-row: 1; font-size: var(--fs-md); text-align: left; margin-bottom: .2rem; }
  .table-list tbody tr > td.col-primary::before, .table-list tbody tr > td.col-actions::before, .table-list tbody tr > td.col-id::before { content: none; }
  .table-list tbody tr > td.col-id { display: none; }
  .table-list tbody tr > td.col-actions { grid-column: 2; grid-row: 1; position: static; background: none; }
  .table-list tbody tr > td.col-status { margin-top: .35rem; }
  .table-list tbody tr > td > *:not(.status-switch) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .table-list > tbody > tr > .col-actions, .table-list > tbody > tr > .col-status { position: static; background: none !important; box-shadow: none !important; max-width: none; }
  .table-list tbody tr.row-flash > td { background: transparent !important; }
  .row-empty { display: block !important; }
  .row-empty td { display: block !important; text-align: center !important; }
  .row-empty td::before { content: none !important; }
  .pager { justify-content: center; }
  .pager-info { flex-basis: 100%; text-align: center; margin: 0; }
  .pager-jump { display: none; }
}

/* 13. Forms: alignment, section nav (v0.1.4) --------------------------------- */
.fs-body .field { display: flex; flex-direction: column; }
.fs-body .field > .segmented { align-self: flex-start; }
.fs-body .form-label { white-space: nowrap; min-width: 0; }
.fs-body .form-label .lbl { overflow: hidden; text-overflow: ellipsis; }
.fs-body .form-control[type="number"], .fs-body .form-control.text-end { text-align: right; }
textarea.form-control[data-autosize] { resize: vertical; overflow: hidden; min-height: 80px; }

.form-nav { position: sticky; top: var(--topbar-h); z-index: 15; display: flex; gap: .35rem; align-items: center; overflow-x: auto; scrollbar-width: none;
  padding: .55rem 1rem; margin: 0 0 var(--sp-4); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: var(--r-lg); }
.form-nav::-webkit-scrollbar { display: none; }
.form-nav a { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; padding: .3rem .7rem; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 500; color: var(--text-muted); text-decoration: none; }
.form-nav a:hover { color: var(--text); background: var(--surface-3); }
.form-nav a.active { color: var(--brand); background: var(--brand-soft); }
.form-nav a .n { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .68rem; background: var(--surface-3); color: var(--text-muted); }
.form-nav a.active .n { background: var(--brand); color: var(--on-brand); }
.form-nav a.has-error .n { background: var(--danger); color: #fff; }
.form-nav a.is-done .n { background: var(--success-soft); color: var(--success); }
.form-nav .kbd-hint { margin-left: auto; font-size: var(--fs-xs); color: var(--text-subtle); white-space: nowrap; padding-left: 1rem; }
@media (max-width: 991.98px) { .form-nav .kbd-hint { display: none; } }
.form-section.is-current .fs-head .fs-icon { background: var(--brand); color: var(--on-brand); }
.form-actions .btn-another { white-space: nowrap; }

/* 14. Sidebar menu: headings, finder, accordion, collapse button (v0.1.5) ------ */
.sidebar-find { position: relative; padding: .75rem .75rem .15rem; flex-shrink: 0; }
.sidebar-find .bi { position: absolute; left: 1.45rem; top: calc(50% + .3rem); transform: translateY(-50%); color: var(--sidebar-muted); font-size: .85rem; pointer-events: none; }
.sidebar-find input { width: 100%; height: 34px; border-radius: var(--r-md); border: 1px solid rgba(255, 255, 255, .08); background: rgba(255, 255, 255, .05);
  color: var(--sidebar-fg-strong); padding: 0 .75rem 0 2.1rem; font-size: var(--fs-sm); outline: none; transition: border-color .12s, background-color .12s; }
.sidebar-find input::placeholder { color: var(--sidebar-muted); }
.sidebar-find input:focus { border-color: var(--sidebar-accent); background: rgba(255, 255, 255, .08); }
.sidebar-find input::-webkit-search-cancel-button { filter: invert(1); opacity: .5; }

.sidebar-nav { padding-top: .35rem; }
.sidebar-nav .nav-heading { padding: 1rem .75rem .35rem; font-size: .66rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--sidebar-muted); white-space: nowrap; user-select: none; }
.sidebar-nav .nav-heading:first-child { padding-top: .35rem; }
.sidebar-nav .nav-group > .nav-link .count { font-size: .66rem; font-weight: 600; min-width: 1.35rem; text-align: center; padding: .05rem .3rem; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .06); color: var(--sidebar-muted); transition: opacity .15s; }
.sidebar-nav .nav-group.open > .nav-link .count { opacity: 0; }
.sidebar-nav .nav-group > .nav-link:hover .count { opacity: 1; }
.sidebar-nav .nav-link .ext { font-size: .68rem !important; width: auto !important; opacity: .4; margin-left: auto; }
.sidebar-nav .nav-link:hover .ext { opacity: .8; }
.sidebar-nav .submenu .nav-link.active { font-weight: 500; }
.sidebar-nav .submenu .nav-link.active::before { content: ""; position: absolute; left: -.57rem; top: 50%; width: 5px; height: 5px; border-radius: 50%; background: var(--sidebar-accent); transform: translateY(-50%); }
.sidebar-nav .submenu .nav-link { position: relative; }
/* smooth accordion */
.sidebar-nav .submenu { display: block; max-height: 0; overflow: hidden; padding-top: 0; padding-bottom: 0; transition: max-height .22s var(--ease), padding .22s var(--ease); }
.sidebar-nav .nav-group.open > .submenu { max-height: 900px; padding-top: .15rem; padding-bottom: .35rem; }
body.preload .sidebar-nav .submenu { transition: none; }
.sidebar-nav mark { padding: 0; background: rgba(255, 255, 255, .18); color: var(--sidebar-fg-strong); border-radius: 2px; }
.sidebar-nav .nav-empty { padding: .75rem; font-size: var(--fs-sm); color: var(--sidebar-muted); }
.sidebar.is-finding .nav-group > .nav-link .count { opacity: 1; }

.sidebar-foot { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem .5rem 1.25rem; }
.sidebar-foot .legend { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .legend .bi { font-size: .7rem; margin-right: .2rem; }
.collapse-btn { width: 30px; height: 30px; border-radius: var(--r-md); border: 1px solid rgba(255, 255, 255, .08); background: transparent; color: var(--sidebar-fg);
  display: grid; place-items: center; flex-shrink: 0; transition: background-color .12s, color .12s; }
.collapse-btn:hover { background: var(--sidebar-hover); color: var(--sidebar-fg-strong); }
.collapse-btn .bi { transition: transform .2s var(--ease); }

/* collapsed (icons only) */
body.sidebar-collapsed .sidebar-find, body.sidebar-collapsed .sidebar-nav .count, body.sidebar-collapsed .sidebar-nav > li > .nav-link .ext, body.sidebar-collapsed .sidebar-foot .legend { display: none; }
body.sidebar-collapsed .sidebar-nav .nav-heading { padding: .6rem .5rem; font-size: 0; }
body.sidebar-collapsed .sidebar-nav .nav-heading::after { content: ""; display: block; height: 1px; background: rgba(255, 255, 255, .1); }
body.sidebar-collapsed .sidebar-nav .nav-heading:first-child { display: none; }
body.sidebar-collapsed .sidebar-foot { display: flex; justify-content: center; padding: .5rem 0; }
body.sidebar-collapsed .collapse-btn .bi { transform: rotate(180deg); }
body.sidebar-collapsed .sidebar-nav .nav-group > .submenu { max-height: none; overflow: visible; transition: none; }
body.sidebar-collapsed .sidebar-nav .nav-group:hover > .submenu { max-height: 70vh; overflow-y: auto; padding: .4rem; }
body.sidebar-collapsed .sidebar-nav .nav-group:hover > .submenu .ext { display: inline; }
body.sidebar-collapsed .sidebar-nav .submenu .nav-link.active::before { display: none; }
body.sidebar-collapsed .sidebar-nav .nav-group.has-active > .nav-link { background: var(--sidebar-active); }
body.sidebar-collapsed .sidebar-nav .nav-group.has-active > .nav-link .bi { color: var(--sidebar-accent); }
@media (max-width: 991.98px) {
  .collapse-btn { display: none; }
  body.sidebar-collapsed .sidebar-find, body.sidebar-collapsed .sidebar-foot .legend, body.sidebar-collapsed .sidebar-nav .count { display: revert; }
  body.sidebar-collapsed .sidebar-nav .nav-heading { padding: 1rem .75rem .35rem; font-size: .66rem; }
  body.sidebar-collapsed .sidebar-nav .nav-heading::after { content: none; }
  body.sidebar-collapsed .sidebar-nav .nav-group > .submenu { max-height: 0; overflow: hidden; }
  body.sidebar-collapsed .sidebar-nav .nav-group.open > .submenu { max-height: 900px; }
}

/* 15. Sales: Book Sale (POS), invoice, register (v0.2.0) --------------------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--sp-5); align-items: start; }
.pos-main { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.pos-side { display: flex; flex-direction: column; gap: var(--sp-4); position: sticky; top: calc(var(--topbar-h) + 1rem); }
@media (max-width: 1199.98px) { .pos { grid-template-columns: 1fr; } .pos-side { position: static; } }
.pos-entry { padding: var(--sp-4) var(--sp-5); }
/* entry row: two rows (item · batch / qty · crop · add) — one row on very wide screens */
.pos-entry-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .75rem; align-items: end; }
.pos-entry-grid .form-label { white-space: nowrap; }
.pe-item { grid-column: span 7; } .pe-batch { grid-column: span 5; }
.pe-qty { grid-column: span 4; } .pe-crop { grid-column: span 5; } .pe-add { grid-column: span 3; }
@media (min-width: 1800px) { .pe-item { grid-column: span 4; } .pe-batch { grid-column: span 3; } .pe-qty { grid-column: span 2; } .pe-crop { grid-column: span 2; } .pe-add { grid-column: span 1; } }
@media (max-width: 575.98px) { .pe-item, .pe-batch, .pe-crop, .pe-add { grid-column: 1 / -1; } .pe-qty { grid-column: 1 / -1; } }
.pe-item .ts-dropdown { width: max(100%, 480px); }
@media (max-width: 575.98px) { .pe-item .ts-dropdown { width: 100%; } }
.pos-item-info { display: flex; flex-wrap: wrap; gap: .35rem 1.25rem; margin-top: .75rem; padding: .5rem .75rem; border-radius: var(--r-md); background: var(--brand-soft); font-size: var(--fs-sm); color: var(--text-2); }
.pos-entry-err { margin-top: .6rem; color: var(--danger); font-size: var(--fs-sm); }
.pos-entry-err::before { content: "\F33A"; font-family: "bootstrap-icons"; margin-right: .35rem; }
.pos-opt .t { font-weight: 500; }
.pos-opt .s { display: flex; gap: .5rem; font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }
.pos-opt .stk { min-width: 70px; text-align: right; font-variant-numeric: tabular-nums; }
.pos-cart-card .card-header { gap: .5rem; }
.pos-cart-card .table-wrap { max-height: none; min-height: 0; }
.pos-cart td.col-primary { max-width: 260px; }
.pos-cart tr.is-error > td { background: var(--danger-soft) !important; }
.pos-qty-edit { display: inline-flex; align-items: center; gap: .35rem; }
.pos-qty-edit input { width: 76px; }
.pos-qty-edit span { font-size: var(--fs-xs); color: var(--text-muted); min-width: 2rem; text-align: left; }
.pos-farmer-note { margin-top: .45rem; font-size: var(--fs-sm); color: var(--text-muted); }
.pos-farmer-note.is-ok { color: var(--success); }
.pos-farmer-note.is-bad { color: var(--danger); }
.pos-farmer-note .pos-due { margin-top: .3rem; padding: .35rem .6rem; border-radius: var(--r-sm); background: var(--warning-soft); color: var(--warning); font-weight: 500; }
.pos-more summary { cursor: pointer; font-size: var(--fs-sm); color: var(--brand); font-weight: 500; list-style: none; }
.pos-more summary::-webkit-details-marker { display: none; }
.pos-more summary::before { content: "\F285"; font-family: "bootstrap-icons"; font-size: .7rem; margin-right: .4rem; display: inline-block; transition: transform .15s; }
.pos-more[open] summary::before { transform: rotate(90deg); }
.pos-sum { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; margin: 0; font-size: var(--fs-sm); }
.pos-sum dt { font-weight: 400; color: var(--text-muted); }
.pos-sum dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.pos-net { display: flex; justify-content: space-between; align-items: baseline; margin-top: .75rem; padding-top: .75rem; border-top: 1px dashed var(--border-strong); }
.pos-net span { font-weight: 600; }
.pos-net strong { font-size: 1.6rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--brand); }
.pos-pay { display: grid; grid-template-columns: repeat(3, 1fr); }
.pos-pay .btn-check + label { justify-content: center; padding: .45rem .5rem; }
.pos-lookup { background: var(--surface); }

/* invoice page */
.inv-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-5); align-items: start; }
@media (max-width: 1199.98px) { .inv-grid { grid-template-columns: 1fr; } }
.inv-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem 1.5rem; }
.inv-meta .k { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.inv-meta .v { font-weight: 500; margin-top: .15rem; }
.inv-totals { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; font-size: var(--fs-sm); margin: 0; }
.inv-totals dt { font-weight: 400; color: var(--text-muted); }
.inv-totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.inv-totals .grand { font-size: var(--fs-lg); font-weight: 700; color: var(--text); padding-top: .5rem; border-top: 1px solid var(--border); }
.inv-words { font-size: var(--fs-sm); color: var(--text-muted); font-style: italic; margin-top: .5rem; }
.stamp { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .7rem; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600; }
.stamp-paid { background: var(--success-soft); color: var(--success); }
.stamp-due { background: var(--warning-soft); color: var(--warning); }
.stamp-void { background: var(--danger-soft); color: var(--danger); }
.pay-list { list-style: none; margin: 0; padding: 0; }
.pay-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px dashed var(--border); font-size: var(--fs-sm); }
.pay-list li:last-child { border-bottom: 0; }
.list-filter-extra { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.list-filter-extra .form-control, .list-filter-extra .form-select { width: auto; min-height: 34px; font-size: var(--fs-sm); }
.list-filter-extra input[type=date] { width: 150px; }
.list-summary { display: flex; flex-wrap: wrap; gap: .5rem 2rem; padding: .7rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-sm); }
.list-summary b { font-variant-numeric: tabular-nums; }
.age-old { color: var(--danger); font-weight: 600; }
.age-mid { color: var(--warning); font-weight: 600; }

.pos-line-meta { display: flex; flex-wrap: wrap; gap: .1rem .75rem; font-size: var(--fs-xs); color: var(--text-muted); margin-top: .1rem; white-space: normal; }
.pos-line-meta .bi { font-size: .75rem; }
.pos-cart td.col-primary, .inv-grid td.col-primary { max-width: none; white-space: normal; }
.pos-cart td, .inv-grid .table-list td { vertical-align: top; }

/* 16. Stock adjustment form (v0.3.0) --------------------------------------- */
.adj-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.adj-type { display: flex; flex-direction: column; gap: .15rem; padding: .7rem .8rem; border: 1px solid var(--border-strong); border-radius: var(--r-md); cursor: pointer; background: var(--surface); transition: all .12s var(--ease); }
.adj-type .bi { font-size: 1.2rem; }
.adj-type span { font-weight: 600; font-size: var(--fs-sm); }
.adj-type small { color: var(--text-muted); font-size: var(--fs-xs); }
.adj-type.is-in .bi { color: var(--success); } .adj-type.is-out .bi { color: var(--danger); } .adj-type.is-fix .bi { color: var(--info); }
.btn-check:checked + .adj-type { border-color: var(--brand); background: var(--brand-soft); box-shadow: var(--ring); }
.btn-check:focus-visible + .adj-type { box-shadow: var(--ring); }
.adj-entry { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .75rem; align-items: end; }
.ae-item { grid-column: span 6; } .ae-batch { grid-column: span 6; } .ae-exp, .ae-newb, .ae-newe { grid-column: span 4; }
.ae-qty { grid-column: span 3; } .ae-cost { grid-column: span 3; } .ae-add { grid-column: span 2; }
.adj-entry [hidden] { display: none !important; }
@media (max-width: 767.98px) { .adj-entry > div { grid-column: 1 / -1 !important; } }
.ae-item .ts-dropdown { width: max(100%, 440px); }

/* 17. Reports: view tabs, KPI strip, chart, report tables (v0.3.0) ---------- */
.report-views { display: flex; gap: .25rem; padding: .6rem .75rem 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; }
.report-views .rv-tab { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .8rem; font-size: var(--fs-sm); font-weight: 500; color: var(--text-muted);
  text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; border-radius: var(--r) var(--r) 0 0; }
.report-views .rv-tab:hover { color: var(--text); background: var(--surface-2); }
.report-views .rv-tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.period-dates { display: inline-flex; align-items: center; gap: .4rem; }
.period-dates[hidden] { display: none; }
.report-kpis { display: flex; flex-wrap: wrap; overflow: hidden; border-bottom: 1px solid var(--border); background: var(--surface); }
.report-kpis .rk { flex: 1 1 140px; background: var(--surface); padding: .75rem 1rem; display: flex; flex-direction: column; min-width: 0; box-shadow: 1px 0 0 var(--border), 0 1px 0 var(--border); }
.report-kpis .rk-main { flex: 1.6 1 200px; background: color-mix(in srgb, var(--brand) 4%, var(--surface)); }
.report-kpis .rk span { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.report-kpis .rk b { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report-kpis .rk small { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report-kpis .rk-main b { color: var(--brand); font-size: 1.35rem; }
.report-chart { padding: .75rem 1rem .5rem; border-bottom: 1px solid var(--border); }
.report-chart .chart { gap: 3px; height: 170px; min-height: 0 !important; }
.table-report td.num, .table-report th.num { white-space: nowrap; }
.table-report tfoot th { background: var(--surface-2); font-weight: 700; border-top: 2px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-report .col-net { min-width: 130px; }
.net-cell { display: flex; align-items: baseline; justify-content: flex-end; gap: .4rem; }
.net-cell .share { font-size: .68rem; color: var(--text-muted); min-width: 2.6rem; text-align: right; }
.net-bar { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: .3rem; overflow: hidden; }
.net-bar span { display: block; height: 100%; margin-left: auto; background: linear-gradient(90deg, var(--chart-to), var(--chart-from)); border-radius: 2px; }
.report-note { font-size: var(--fs-xs); color: var(--text-muted); padding: .5rem 1rem .9rem; margin: 0; }
.mv-in { color: var(--bs-success); font-weight: 600; } .mv-out { color: var(--bs-danger); font-weight: 600; }
.badge-mv { font-size: .68rem; font-weight: 600; letter-spacing: .02em; }
.exp-bucket { display: inline-flex; align-items: center; gap: .35rem; }
.audit-data { font-size: .72rem; max-height: 220px; overflow: auto; background: var(--surface-2); border-radius: var(--r); padding: .5rem .6rem; margin: .4rem 0 0; white-space: pre-wrap; word-break: break-word; }
@media (max-width: 767.98px) {
  .report-kpis .rk, .report-kpis .rk-main { flex: 1 1 45%; }
  .table-report tfoot { display: none; }
  .net-bar { display: none; }
}
@media print {
  .sidebar, .topbar, .ph-actions, .list-toolbar, .report-views, .pager, .list-tools, .report-note, .app-footer { display: none !important; }
  .report-card, .card { box-shadow: none !important; border: 0 !important; }
  .table-wrap { overflow: visible !important; }
  .table-report { font-size: 10px; }
  .net-bar { display: none; }
}
.table-report tfoot th { position: sticky; bottom: 0; z-index: 2; }
.table-report thead tr.th-group th { position: static; font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding-top: .35rem; padding-bottom: .1rem; border-bottom: 0; }
.table-report th.grp-in, .table-report td.grp-in { background-color: color-mix(in srgb, var(--bs-success) 5%, var(--surface-2)); }
.table-report th.grp-out { background-color: color-mix(in srgb, var(--bs-danger) 5%, var(--surface-2)); }
.table-report tr.is-negative td { background: color-mix(in srgb, var(--bs-danger) 6%, transparent); }
.health-ok { display: flex; align-items: center; gap: .75rem; padding: 1.25rem; }
.health-ok .bi { font-size: 1.8rem; color: var(--bs-success); }
.table-report > :not(caption) > * > * { padding-left: .65rem; padding-right: .65rem; }
.table-report td.col-primary { white-space: normal; min-width: 180px; max-width: 280px; }
.table-report td.col-primary .cell-link, .table-report td.col-primary .cell-text { white-space: normal; }
.table-report td.col-note { white-space: normal; min-width: 160px; max-width: 240px; font-size: var(--fs-sm); color: var(--text-muted); }
