/* =====================================================================
   Smart E-Office Design System v2 — "Deep Teal + Indigo · Modern GovTech"
   ---------------------------------------------------------------------
   Fonts : IBM Plex Sans Thai (UI · Thai + Latin, 400/500/600/700, OFL, vendored)
           Plus Jakarta Sans (display numerals — KPI / counters)
   Icons : Phosphor (ph / ph-duotone / ph-fill / ph-bold)
   Tokens: --brand (teal) · --brand-2 (indigo) from brand_colors() · tone-* system (--tone/--tone-soft/--tone-ink)
   Rules : every v1 class kept (CONVENTIONS §14) — restyled, never renamed · docs/core/design.md = reference
   ===================================================================== */

/* ---------- Fonts (local) ---------- */
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-display: swap; font-weight: 400;
  src: url(../vendor/fonts/ibm-plex-sans-thai-thai-400-normal.woff2) format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-display: swap; font-weight: 500;
  src: url(../vendor/fonts/ibm-plex-sans-thai-thai-500-normal.woff2) format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-display: swap; font-weight: 600;
  src: url(../vendor/fonts/ibm-plex-sans-thai-thai-600-normal.woff2) format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-display: swap; font-weight: 700;
  src: url(../vendor/fonts/ibm-plex-sans-thai-thai-700-normal.woff2) format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-display: swap; font-weight: 400;
  src: url(../vendor/fonts/ibm-plex-sans-thai-latin-400-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+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-display: swap; font-weight: 500;
  src: url(../vendor/fonts/ibm-plex-sans-thai-latin-500-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+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-display: swap; font-weight: 600;
  src: url(../vendor/fonts/ibm-plex-sans-thai-latin-600-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+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-display: swap; font-weight: 700;
  src: url(../vendor/fonts/ibm-plex-sans-thai-latin-700-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+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Jakarta'; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url(../vendor/fonts/plus-jakarta-sans-latin-wght-normal.woff2) format('woff2-variations');
  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+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  /* brand (overridden per org by page_start → brand_colors()) */
  --brand: #0f766e;
  --brand-2: #4f46e5;
  --brand-deep: color-mix(in srgb, var(--brand) 70%, #021b19);
  --brand-night: #062e2b;
  --brand-mid: color-mix(in oklab, var(--brand) 52%, #0891b2);
  --brand-2-ink: color-mix(in srgb, var(--brand-2) 86%, #000);
  --brand-soft: color-mix(in srgb, var(--brand) 9%, white);
  --brand-soft-2: color-mix(in srgb, var(--brand) 16%, white);
  --brand-ink: color-mix(in srgb, var(--brand) 78%, black);
  --grad-brand: linear-gradient(135deg, var(--brand) 0%, color-mix(in oklab, var(--brand) 55%, var(--brand-2)) 100%);
  --grad-hero: linear-gradient(135deg, var(--brand) 0%, var(--brand-mid) 46%, var(--brand-2-ink) 100%);
  --grad-ai: linear-gradient(135deg, #0d9488 0%, #0891b2 38%, #6366f1 74%, #8b5cf6 100%);
  --grad-side: linear-gradient(180deg, #0b4441 0%, #072d31 44%, #0a1d3b 100%);
  --pattern: url(../img/pattern-prajam.svg);

  /* surfaces & ink */
  --bg: #f3f6f8;
  --bg-2: #eaf0f3;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --surface-3: #eef2f5;
  --glass: rgba(255, 255, 255, .74);
  --glass-strong: rgba(255, 255, 255, .92);
  --line: #e3e9ee;
  --line-2: #d4dde4;
  --line-3: #c3ced8;
  --ink: #0f1f2e;
  --text: #0f1f2e;
  --text-2: #2c3e50;
  --muted: #5d6e80;
  --muted-2: #93a2b1;
  --white: #fff;
  --overlay: rgba(6, 22, 28, .48);

  /* tones (base · soft background · ink text) */
  --indigo: #4f46e5;  --indigo-soft: #eef0fe;  --indigo-ink: #3730a3;
  --violet: #7c3aed;  --violet-soft: #f3eefe;  --violet-ink: #5b21b6;
  --purple: #9333ea;  --purple-soft: #f5edfe;  --purple-ink: #6b21a8;
  --fuchsia: #c026d3; --fuchsia-soft: #fbecfd; --fuchsia-ink: #86198f;
  --pink: #db2777;    --pink-soft: #fdedf5;    --pink-ink: #9d174d;
  --rose: #e11d48;    --rose-soft: #fff0f3;    --rose-ink: #9f1239;
  --red: #dc2626;     --red-soft: #fef0f0;     --red-ink: #991b1b;
  --orange: #ea580c;  --orange-soft: #fff3eb;  --orange-ink: #9a3412;
  --amber: #d97706;   --amber-soft: #fff6e5;   --amber-ink: #92400e;
  --yellow: #ca8a04;  --yellow-soft: #fefbe6;  --yellow-ink: #854d0e;
  --lime: #65a30d;    --lime-soft: #f3fae6;    --lime-ink: #3f6212;
  --green: #16a34a;   --green-soft: #ecfbf1;   --green-ink: #166534;
  --emerald: #059669; --emerald-soft: #e8f8f1; --emerald-ink: #065f46;
  --teal: #0d9488;    --teal-soft: #e7f6f4;    --teal-ink: #115e59;
  --cyan: #0891b2;    --cyan-soft: #e6f6fa;    --cyan-ink: #155e75;
  --sky: #0284c7;     --sky-soft: #e9f4fc;     --sky-ink: #075985;
  --blue: #2563eb;    --blue-soft: #ecf2fe;    --blue-ink: #1e40af;
  --navy: #1e3a8a;    --navy-soft: #edf1fb;    --navy-ink: #1e2f6b;
  --slate: #64748b;   --slate-soft: #eff3f6;   --slate-ink: #334155;

  --tone: var(--brand); --tone-soft: var(--brand-soft); --tone-ink: var(--brand-ink);
  --success: var(--emerald); --warning: var(--amber); --danger: var(--rose); --info: var(--sky);

  /* radius · spacing · shadows */
  --r-xs: 6px; --r-sm: 10px; --r: 14px; --r-lg: 16px; --r-xl: 22px; --r-2xl: 28px; --r-full: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 48px; --s-10: 64px;
  --sh-xs: 0 1px 2px rgba(16, 32, 48, .05);
  --sh-sm: 0 1px 2px rgba(16, 32, 48, .04), 0 2px 6px -2px rgba(16, 32, 48, .07);
  --sh: 0 1px 2px rgba(16, 32, 48, .04), 0 6px 16px -8px rgba(16, 40, 60, .10);
  --sh-md: 0 2px 4px rgba(16, 32, 48, .04), 0 12px 28px -12px rgba(16, 40, 60, .16);
  --sh-lg: 0 4px 10px -2px rgba(16, 32, 48, .06), 0 24px 48px -16px rgba(16, 40, 60, .22);
  --sh-xl: 0 32px 80px -24px rgba(8, 28, 40, .40);
  --sh-brand: 0 10px 22px -10px color-mix(in srgb, var(--brand) 70%, transparent);
  --ring: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent);
  --ring-strong: 0 0 0 2px #fff, 0 0 0 4px var(--brand);

  /* type */
  --font: 'IBM Plex Sans Thai', 'Noto Sans Thai', 'Leelawadee UI', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-num: 'Jakarta', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', 'SFMono-Regular', Consolas, monospace;

  /* motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --dur-1: .12s; --dur-2: .2s; --dur-3: .32s; --dur-4: .5s;

  /* shell */
  --sidebar-w: 268px;
  --sidebar-w-collapsed: 78px;
  --topbar-h: 66px;
  --tabbar-h: 66px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

.tone-indigo { --tone: var(--indigo); --tone-soft: var(--indigo-soft); --tone-ink: var(--indigo-ink); }
.tone-violet { --tone: var(--violet); --tone-soft: var(--violet-soft); --tone-ink: var(--violet-ink); }
.tone-purple { --tone: var(--purple); --tone-soft: var(--purple-soft); --tone-ink: var(--purple-ink); }
.tone-fuchsia { --tone: var(--fuchsia); --tone-soft: var(--fuchsia-soft); --tone-ink: var(--fuchsia-ink); }
.tone-pink { --tone: var(--pink); --tone-soft: var(--pink-soft); --tone-ink: var(--pink-ink); }
.tone-rose { --tone: var(--rose); --tone-soft: var(--rose-soft); --tone-ink: var(--rose-ink); }
.tone-red { --tone: var(--red); --tone-soft: var(--red-soft); --tone-ink: var(--red-ink); }
.tone-orange { --tone: var(--orange); --tone-soft: var(--orange-soft); --tone-ink: var(--orange-ink); }
.tone-amber { --tone: var(--amber); --tone-soft: var(--amber-soft); --tone-ink: var(--amber-ink); }
.tone-yellow { --tone: var(--yellow); --tone-soft: var(--yellow-soft); --tone-ink: var(--yellow-ink); }
.tone-lime { --tone: var(--lime); --tone-soft: var(--lime-soft); --tone-ink: var(--lime-ink); }
.tone-green { --tone: var(--green); --tone-soft: var(--green-soft); --tone-ink: var(--green-ink); }
.tone-emerald { --tone: var(--emerald); --tone-soft: var(--emerald-soft); --tone-ink: var(--emerald-ink); }
.tone-teal { --tone: var(--teal); --tone-soft: var(--teal-soft); --tone-ink: var(--teal-ink); }
.tone-cyan { --tone: var(--cyan); --tone-soft: var(--cyan-soft); --tone-ink: var(--cyan-ink); }
.tone-sky { --tone: var(--sky); --tone-soft: var(--sky-soft); --tone-ink: var(--sky-ink); }
.tone-blue { --tone: var(--blue); --tone-soft: var(--blue-soft); --tone-ink: var(--blue-ink); }
.tone-navy { --tone: var(--navy); --tone-soft: var(--navy-soft); --tone-ink: var(--navy-ink); }
.tone-slate { --tone: var(--slate); --tone-soft: var(--slate-soft); --tone-ink: var(--slate-ink); }
.tone-brand { --tone: var(--brand); --tone-soft: var(--brand-soft); --tone-ink: var(--brand-ink); }
.tone-brand2 { --tone: var(--brand-2); --tone-soft: color-mix(in srgb, var(--brand-2) 9%, white); --tone-ink: var(--brand-2-ink); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 12px); }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.62; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent; min-height: 100vh; min-height: 100dvh; font-feature-settings: 'kern';
}
img, svg, video, canvas { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; transition: color var(--dur-1); }
a:hover { color: var(--brand-ink); }
h1, h2, h3, h4, h5 { margin: 0; line-height: 1.35; letter-spacing: -.005em; color: var(--ink); font-weight: 600; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }
p { margin: 0 0 .75em; }
small { font-size: 12.5px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: color-mix(in srgb, var(--brand) 20%, transparent); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
[x-cloak] { display: none !important; }
mark { background: color-mix(in srgb, var(--amber) 26%, white); color: inherit; border-radius: 3px; padding: 0 2px; }
code, kbd, pre { font-family: var(--font-mono); }
code { font-size: .88em; background: var(--surface-3); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--text-2); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(93, 110, 128, .26); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(93, 110, 128, .44); border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: rgba(93, 110, 128, .3) transparent; }

.num, .tabular { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.ph, .ph-duotone, .ph-fill, .ph-bold { line-height: 1; vertical-align: -0.125em; }

/* ---------- Background (calm, no blobs) ---------- */
.app-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: var(--bg); }
.app-bg::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 320px; background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 5%, var(--bg)) 0%, var(--bg) 100%); }
.app-bg::after, .app-bg i { display: none; }
.app-bg .grid-dots { position: absolute; inset: 0; background-image: radial-gradient(rgba(15, 31, 46, .04) 1px, transparent 1px); background-size: 24px 24px; mask-image: linear-gradient(to bottom, #000 0%, transparent 38%); -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 38%); }

/* =====================================================================
   LAYOUT
   ===================================================================== */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: var(--sidebar-w); transition: margin-left var(--dur-3) var(--ease); }
body.sb-collapsed .app-main { margin-left: var(--sidebar-w-collapsed); }
.page { flex: 1; width: 100%; max-width: 1600px; margin: 0 auto; padding: 26px 32px 40px; }
.page.page-wide { max-width: none; }
.page.page-narrow { max-width: 980px; }
.app-footer { padding: 16px 32px 26px; color: var(--muted-2); font-size: 12.5px; display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; border-top: 1px solid transparent; }
.app-footer a { color: var(--muted); }

/* ---------- Sidebar (dark deep-teal → navy, Thai lattice texture) ---------- */
.sidebar {
  position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: var(--sidebar-w);
  display: flex; flex-direction: column; color: #fff; background: var(--grad-side);
  border-right: 1px solid rgba(255, 255, 255, .04); box-shadow: 4px 0 24px -12px rgba(4, 24, 30, .5);
  transition: width var(--dur-3) var(--ease), transform var(--dur-3) var(--ease); view-transition-name: sidebar; isolation: isolate;
}
.sidebar::before { content: ''; position: absolute; inset: 0; z-index: -1; background-image: var(--pattern); background-size: 56px 56px; opacity: .045; mask-image: linear-gradient(180deg, #000 0%, transparent 30%, transparent 70%, #000 100%); -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 30%, transparent 70%, #000 100%); pointer-events: none; }
.sidebar::after { content: ''; position: absolute; z-index: -1; left: 0; right: 0; top: 0; height: 160px; background: linear-gradient(180deg, rgba(45, 212, 191, .10), transparent); pointer-events: none; }
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 16px 18px 14px; min-height: var(--topbar-h); color: #fff; flex-shrink: 0; }
.sb-brand:hover { color: #fff; }
.sb-logo { width: 42px; height: 42px; flex-shrink: 0; object-fit: contain; border-radius: 12px; background: #fff; padding: 3px; box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255, 255, 255, .6); }
.sb-brand-text { min-width: 0; line-height: 1.3; }
.sb-brand-text b { display: block; font-size: 15.5px; font-weight: 700; color: #fff; letter-spacing: .005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-brand-text span { display: block; font-size: 12px; color: #99f6e4; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-brand-text em { display: block; font-size: 10.5px; color: rgba(255, 255, 255, .5); font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.sb-brand-text em.sb-org-type { display: flex; align-items: center; gap: 4px; color: rgba(255, 255, 255, .62); }
.sb-brand-text em.sb-org-type i { font-size: 11px; color: #5eead4; flex: none; }
/* พอร์ทัลหน่วยในสังกัด (body.portal-branch — โรงเรียน/สาขา/สำนักงานภูมิภาค): สีเน้นอำพันที่แบรนด์และเมนูที่เลือก */
body.portal-branch .sb-brand-text span { color: #fde68a; }
body.portal-branch .sb-brand-text em.sb-org-type i { color: #fbbf24; }
body.portal-branch .sb-logo { box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .5), 0 0 0 2px rgba(251, 191, 36, .85); }
.sb-search { display: none; }
.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 12px 14px; overscroll-behavior: contain; scrollbar-color: rgba(255, 255, 255, .18) transparent; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border: 3px solid transparent; background-clip: padding-box; }
.sb-section { display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 600; color: rgba(204, 251, 241, .5); padding: 18px 12px 6px; white-space: nowrap; letter-spacing: .04em; }
.sb-section::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(255, 255, 255, .1), transparent); }
.sb-section:first-child { padding-top: 6px; }
.sb-link, .sb-group-btn {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 42px; padding: 8px 12px; margin: 2px 0;
  border-radius: 12px; color: rgba(255, 255, 255, .78); font-size: 14px; font-weight: 500; border: 0; background: none; text-align: left;
  transition: background var(--dur-2), color var(--dur-2), box-shadow var(--dur-2); white-space: nowrap;
}
.sb-link:hover, .sb-group-btn:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sb-link:focus-visible, .sb-group-btn:focus-visible, .sb-sub:focus-visible { outline: 2px solid #5eead4; outline-offset: -2px; }
.sb-ico { width: 24px; height: 24px; display: grid; place-items: center; flex-shrink: 0; font-size: 21px; color: rgba(204, 251, 241, .72); transition: color var(--dur-2), transform var(--dur-2) var(--ease); }
.sb-link:hover .sb-ico, .sb-group-btn:hover .sb-ico { color: #fff; }
.sb-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sb-caret { font-size: 12px; color: rgba(255, 255, 255, .4); transition: transform var(--dur-3) var(--ease); }
.sb-group.open > .sb-group-btn .sb-caret { transform: rotate(90deg); color: #5eead4; }
.sb-group-items { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--dur-3) var(--ease); }
.sb-group.open > .sb-group-items { grid-template-rows: 1fr; }
.sb-group-items > div { overflow: hidden; }
.sb-sub {
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 10px 6px 16px; margin: 1px 0 1px 23px; position: relative;
  font-size: 13.5px; color: rgba(255, 255, 255, .64); white-space: nowrap; border-left: 1px solid rgba(255, 255, 255, .12); border-radius: 0 10px 10px 0;
  transition: background var(--dur-2), color var(--dur-2);
}
.sb-sub::before { content: ''; position: absolute; left: -3.5px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: rgba(255, 255, 255, .22); transition: var(--dur-2); }
.sb-sub:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.sb-sub.active { color: #fff; font-weight: 600; background: linear-gradient(90deg, rgba(45, 212, 191, .16), rgba(99, 102, 241, .08)); }
.sb-sub.active::before { background: #5eead4; box-shadow: 0 0 0 3px rgba(94, 234, 212, .22); }
.sb-sub i { font-size: 16px; opacity: .85; }
.sb-link.active {
  color: #fff; font-weight: 600;
  background: linear-gradient(135deg, #0d9488 0%, #0e7490 48%, #4f46e5 100%);
  box-shadow: 0 10px 22px -10px rgba(45, 212, 191, .55), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.sb-link.active .sb-ico { color: #fff; }
.sb-group.has-active > .sb-group-btn { color: #fff; font-weight: 600; background: rgba(255, 255, 255, .06); }
.sb-group.has-active > .sb-group-btn .sb-ico { color: #5eead4; }
.sb-link.sm { min-height: 38px; padding: 7px 12px; margin: 1px 0; font-size: 13.5px; color: rgba(255, 255, 255, .7); }
.sb-link.sm .sb-ico { font-size: 18px; color: rgba(255, 255, 255, .5); }
.sb-link.sm.active .sb-ico { color: #fff; }
.sb-link.sm:hover .sb-ico { color: #fff; }
.sb-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; background: #f43f5e; color: #fff; font-family: var(--font-num); box-shadow: 0 4px 10px -4px rgba(244, 63, 94, .7); line-height: 1; }
.sb-link.active .sb-count { background: #fff; color: var(--brand-ink); box-shadow: none; }
.sb-foot { position: relative; padding: 10px 12px 14px; flex-shrink: 0; }
.sb-footcard { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 14px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .86); font-size: 12px; line-height: 1.35; }
.sb-footcard .sf-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; flex-shrink: 0; color: #5eead4; background: rgba(94, 234, 212, .12); }
.sb-footcard b { display: block; font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; }
.sb-footcard span { display: flex; align-items: center; gap: 5px; color: rgba(255, 255, 255, .55); white-space: nowrap; }
.sb-footcard span::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }
.sb-footcard .sf-main { flex: 1; min-width: 0; }
.sb-collapse { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; border: 0; background: rgba(255, 255, 255, .06); color: rgba(255, 255, 255, .7); font-size: 15px; flex-shrink: 0; transition: var(--dur-2); }
.sb-collapse:hover { background: rgba(255, 255, 255, .14); color: #fff; }
body.sb-collapsed .sb-collapse i { transform: rotate(180deg); }
.sb-tagline { display: none; }
.sb-illus { display: none; }
.sb-user { display: none; }
.sb-section-sep { display: none; }

body.sb-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sb-collapsed .sb-brand-text, body.sb-collapsed .sb-label, body.sb-collapsed .sb-caret,
body.sb-collapsed .sb-group-items, body.sb-collapsed .sb-count, body.sb-collapsed .sf-main, body.sb-collapsed .sf-ico { display: none; }
body.sb-collapsed .sb-section { font-size: 0; padding: 12px 10px 4px; }
body.sb-collapsed .sb-section::after { background: rgba(255, 255, 255, .1); }
body.sb-collapsed .sb-brand { justify-content: center; padding-inline: 0; }
body.sb-collapsed .sb-nav { padding-inline: 10px; }
body.sb-collapsed .sb-link, body.sb-collapsed .sb-group-btn { justify-content: center; padding: 9px; }
body.sb-collapsed .sb-link .sb-ico, body.sb-collapsed .sb-group-btn .sb-ico { font-size: 22px; }
body.sb-collapsed .sb-link[data-badge]::after, body.sb-collapsed .sb-group-btn[data-badge]::after { content: ''; position: absolute; top: 8px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: #f43f5e; box-shadow: 0 0 0 2px #072d31; }
body.sb-collapsed .sb-footcard { justify-content: center; padding: 8px; background: none; border-color: transparent; }
body.sb-collapsed .sb-group.has-active > .sb-group-btn { background: linear-gradient(135deg, #0d9488, #4f46e5); }
body.sb-collapsed .sb-group.has-active > .sb-group-btn .sb-ico { color: #fff; }

.sb-backdrop { position: fixed; inset: 0; z-index: 55; background: var(--overlay); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity var(--dur-3); }

/* flyout menu of a collapsed group (desktop rail) */
.sb-flyout { position: fixed; z-index: 95; min-width: 230px; padding: 8px; border-radius: 14px; background: #0b2f35; color: #fff; border: 1px solid rgba(255, 255, 255, .1); box-shadow: var(--sh-xl); animation: fly-in .18s var(--ease-out); }
.sb-flyout h5 { font-size: 12px; font-weight: 600; color: rgba(204, 251, 241, .6); padding: 6px 10px 6px; }
.sb-flyout a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 9px; color: rgba(255, 255, 255, .82); font-size: 13.5px; }
.sb-flyout a:hover, .sb-flyout a.active { background: rgba(255, 255, 255, .08); color: #fff; }
.sb-flyout a.active { box-shadow: inset 3px 0 0 #5eead4; }
@keyframes fly-in { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Topbar (white: search pill · QR · ถาม AI · TH/EN · bell · user) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 24px 0 16px;
  background: rgba(255, 255, 255, .86); backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6);
  border-bottom: 1px solid var(--line); transition: box-shadow var(--dur-2); view-transition-name: topbar;
}
.topbar.scrolled { box-shadow: 0 8px 24px -18px rgba(8, 28, 40, .4); }
.topbar .tb-menu { display: inline-grid; }
.topbar .tb-back { display: none; }
.tb-title { display: none; min-width: 0; }
.tb-title .crumbs { display: none; }
.tb-mobile-title { display: none; font-weight: 600; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.tb-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.tb-search-wrap { position: relative; display: flex; align-items: center; flex: 0 1 500px; min-width: 200px; }
.tb-search {
  display: flex; align-items: center; gap: 10px; width: 100%; flex: 0 1 500px; min-width: 200px; height: 42px; padding: 0 92px 0 16px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid transparent; color: var(--muted-2); font-size: 13.5px; transition: var(--dur-2); text-align: left; cursor: text;
}
.tb-search > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-search i { font-size: 18px; color: var(--muted); }
.tb-search:hover { background: #fff; border-color: color-mix(in srgb, var(--brand) 32%, transparent); box-shadow: var(--ring); }
.tb-search kbd { position: absolute; right: 50px; top: 50%; transform: translateY(-50%); }
.tb-qr { position: absolute; right: 5px; top: 5px; width: 32px; height: 32px; border-radius: 50%; border: 0; display: grid; place-items: center; font-size: 17px; color: var(--brand-ink); background: #fff; box-shadow: var(--sh-xs), inset 0 0 0 1px var(--line); transition: var(--dur-2); }
.tb-qr:hover { background: var(--brand); color: #fff; box-shadow: var(--sh-brand); }
kbd { font-family: var(--font-num); font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 6px; background: #fff; border: 1px solid var(--line-2); border-bottom-width: 2px; color: var(--muted); line-height: 1.4; }
.icon-btn {
  position: relative; width: 42px; height: 42px; border-radius: 12px; display: inline-grid; place-items: center; font-size: 21px; flex-shrink: 0;
  background: transparent; border: 1px solid transparent; color: var(--text-2); transition: var(--dur-2) var(--ease);
}
.icon-btn:hover { color: var(--brand-ink); background: var(--brand-soft); }
.icon-btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.icon-btn.bordered { border-color: var(--line); background: #fff; box-shadow: var(--sh-xs); }
.icon-btn .dot { position: absolute; top: 3px; left: calc(50% + 1px); right: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #e11d48; color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; font-family: var(--font-num); animation: pop .4s var(--ease-spring); line-height: 1; width: auto; white-space: nowrap; letter-spacing: -.02em; }
.icon-btn.ring-anim i { animation: bell 1s var(--ease) 2; transform-origin: 50% 10%; }
.dropdown.open > .icon-btn { background: var(--brand-soft); color: var(--brand-ink); }
.tb-ai {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 15px 0 12px; border-radius: 999px; border: 0; color: #fff; font-size: 13.5px; font-weight: 600; white-space: nowrap;
  background: var(--grad-ai); background-size: 160% 160%; box-shadow: 0 8px 20px -10px rgba(79, 70, 229, .7), inset 0 1px 0 rgba(255, 255, 255, .25); transition: var(--dur-3) var(--ease); position: relative; overflow: hidden;
}
.tb-ai i { font-size: 17px; }
.tb-ai::after { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%); transform: translateX(-120%); animation: shine 5s var(--ease) infinite 2s; }
.tb-ai:hover { color: #fff; background-position: 100% 0; box-shadow: 0 12px 26px -10px rgba(79, 70, 229, .8); transform: translateY(-1px); }
@keyframes shine { 0%, 70% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
.lang-btn { display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 10px; border-radius: 10px; font-size: 12.5px; font-weight: 700; color: var(--text-2); font-family: var(--font-num); }
.lang-btn:hover { background: var(--brand-soft); color: var(--brand-ink); }
.lang-btn i { font-size: 17px; }
.lang-switch { display: inline-flex; padding: 3px; height: 36px; border-radius: 11px; background: var(--surface-3); border: 1px solid var(--line); flex-shrink: 0; }
.lang-switch a { display: grid; place-items: center; padding: 0 10px; border-radius: 8px; font-size: 12px; font-weight: 700; color: var(--muted); font-family: var(--font-num); transition: var(--dur-2); }
.lang-switch a:hover { color: var(--ink); }
.lang-switch a.active { background: #fff; color: var(--brand-ink); box-shadow: var(--sh-sm); }
.tb-user { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; height: 50px; border-radius: 14px; background: transparent; border: 0; cursor: pointer; transition: var(--dur-2); margin-left: 4px; }
.tb-user:hover, .dropdown.open > .tb-user { background: var(--surface-3); }
.tb-user .avatar { --av: 38px; box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px color-mix(in srgb, var(--brand) 35%, transparent); }
.tb-user-text { line-height: 1.3; text-align: left; min-width: 0; }
.tb-user-text b { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-user-text span { display: block; font-size: 11.5px; color: var(--muted); max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-user .ph-caret-down { color: var(--muted); font-size: 13px; margin-left: 4px; }
.tb-divider { width: 1px; height: 26px; background: var(--line-2); margin: 0 6px; }
.tb-search-m { display: none; }

/* user menu */
.user-menu { width: 300px; padding: 0; overflow: hidden; }
.user-menu .um-head { position: relative; display: flex; gap: 12px; align-items: center; padding: 18px 16px 16px; color: #fff; background: var(--grad-hero); overflow: hidden; }
.user-menu .um-head::before { content: ''; position: absolute; inset: 0; background-image: var(--pattern); background-size: 44px; opacity: .12; }
.user-menu .um-head > * { position: relative; }
.user-menu .um-head .avatar { --av: 48px; box-shadow: 0 0 0 3px rgba(255, 255, 255, .35); }
.user-menu .um-head b { display: block; font-size: 15px; font-weight: 600; line-height: 1.3; }
.user-menu .um-head span { display: block; font-size: 12px; opacity: .85; line-height: 1.4; }
.user-menu .um-head .badge { margin-top: 6px; background: rgba(255, 255, 255, .18); color: #fff; }
.user-menu .um-body { padding: 6px; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head-text { min-width: 0; }
.page-crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; flex-wrap: wrap; }
.page-crumbs a { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.page-crumbs a:hover { color: var(--brand); }
.page-crumbs i { font-size: 10px; opacity: .55; }
.page-crumbs a i { font-size: 13px; opacity: .8; }
.page-head h1 { display: flex; align-items: center; gap: 14px; color: var(--ink); font-size: 25px; font-weight: 700; letter-spacing: -.01em; }
.page-head .ph-title-ico {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; color: #fff; flex-shrink: 0;
  background: linear-gradient(145deg, color-mix(in srgb, var(--tone) 78%, #fff) 0%, var(--tone) 55%, color-mix(in srgb, var(--tone) 80%, #000) 100%);
  box-shadow: 0 10px 22px -10px var(--tone), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.page-head p { color: var(--muted); margin: 6px 0 0; font-size: 14.5px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.section-head h2, .section-head h3 { display: flex; align-items: center; gap: 10px; }
.section-head p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--tone, var(--brand)); text-transform: uppercase; }

/* ---------- Tabbar (mobile) — hidden on desktop ---------- */
.tabbar { display: none; }

/* =====================================================================
   UTILITIES
   ===================================================================== */
.grid { display: grid; gap: 20px; }
.grid > * { min-width: 0; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.g-auto-sm { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.g-sidebar { grid-template-columns: minmax(0, 1fr) 360px; }
.g-sidebar-l { grid-template-columns: 320px minmax(0, 1fr); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-9 { grid-column: span 9; } .span-12 { grid-column: 1 / -1; }
.span-full { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-sm { display: flex; align-items: center; gap: 6px; }
.row-wrap { flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.shrink-0 { flex-shrink: 0; }
.center { display: grid; place-items: center; }
.gap-0 { gap: 0 !important; } .gap-1 { gap: 4px !important; } .gap-2 { gap: 8px !important; } .gap-3 { gap: 12px !important; } .gap-4 { gap: 16px !important; } .gap-5 { gap: 24px !important; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 24px; } .mt-6 { margin-top: 32px; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-5 { margin-bottom: 24px; } .mb-6 { margin-bottom: 32px; }
.ml-auto { margin-left: auto; }
.p-0 { padding: 0 !important; } .p-2 { padding: 8px; } .p-3 { padding: 12px; } .p-4 { padding: 16px; } .p-5 { padding: 24px; }
.w-full { width: 100%; }
.text-center { text-align: center; } .text-right { text-align: right; } .text-left { text-align: left; }
.muted { color: var(--muted); } .muted-2 { color: var(--muted-2); } .text-2 { color: var(--text-2); } .text-ink { color: var(--ink); }
.fs-xs { font-size: 11.5px; } .fs-sm { font-size: 13px; } .fs-md { font-size: 15px; } .fs-lg { font-size: 17px; } .fs-xl { font-size: 20px; } .fs-2xl { font-size: 26px; } .fs-3xl { font-size: 34px; }
.fw-4 { font-weight: 400; } .fw-5 { font-weight: 500; } .fw-6 { font-weight: 600; } .fw-7 { font-weight: 700; } .fw-8 { font-weight: 800; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.upper { text-transform: uppercase; letter-spacing: .06em; }
.text-tone { color: var(--tone); } .text-success { color: var(--emerald); } .text-danger { color: var(--rose); } .text-warning { color: var(--amber-ink); } .text-info { color: var(--sky); } .text-brand { color: var(--brand); }
.bg-soft { background: var(--tone-soft); } .bg-surface-2 { background: var(--surface-2); }
.rounded { border-radius: var(--r); } .rounded-lg { border-radius: var(--r-lg); } .rounded-full { border-radius: 999px; }
.border { border: 1px solid var(--line); }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.divider-v { width: 1px; align-self: stretch; background: var(--line); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.show-mobile { display: none !important; }
.cursor-pointer { cursor: pointer; }
.pre-wrap { white-space: pre-wrap; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.gradient-text { background: var(--grad-hero); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ico-tile { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); font-size: 20px; flex-shrink: 0; }
.ico-tile.solid { background: linear-gradient(145deg, color-mix(in srgb, var(--tone) 80%, #fff), var(--tone)); color: #fff; box-shadow: 0 8px 18px -10px var(--tone); }
.ico-tile.lg { width: 52px; height: 52px; border-radius: 15px; font-size: 26px; }
.ico-tile.sm { width: 32px; height: 32px; border-radius: 10px; font-size: 17px; }

/* =====================================================================
   CARDS
   ===================================================================== */
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh);
  min-width: 0; transition: box-shadow var(--dur-3) var(--ease), transform var(--dur-3) var(--ease), border-color var(--dur-3);
}
.card-hover:hover, a.card:hover { box-shadow: var(--sh-md); transform: translateY(-2px); border-color: var(--line-2); }
a.card { color: inherit; display: block; }
a.card.stat, a.card.stat-mini { display: flex; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; flex-wrap: wrap; }
.card-head.bordered { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.card-title { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; color: var(--ink); min-width: 0; }
.card-title .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); font-size: 19px; flex-shrink: 0; }
.card-sub { font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.card-body { padding: 16px 20px 20px; }
.card-body.tight { padding: 10px 14px 14px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card-flush .card-body { padding: 0; }
.card-glass { background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.card-tone { background: linear-gradient(135deg, color-mix(in srgb, var(--tone) 90%, #000) 0%, var(--tone) 55%, color-mix(in srgb, var(--tone) 75%, #fff) 100%); color: #fff; border: 0; box-shadow: 0 18px 40px -22px var(--tone); overflow: hidden; }
.card-tone::before { content: ''; position: absolute; inset: 0; background-image: var(--pattern); background-size: 48px; opacity: .08; pointer-events: none; mask-image: linear-gradient(90deg, transparent, #000); -webkit-mask-image: linear-gradient(90deg, transparent, #000); }
.card-tone > * { position: relative; }
.card-tone h1, .card-tone h2, .card-tone h3, .card-tone .card-title { color: #fff; }
.card-tone .muted, .card-tone .card-sub { color: rgba(255, 255, 255, .8); }
.card-soft { background: var(--tone-soft); border-color: color-mix(in srgb, var(--tone) 16%, transparent); box-shadow: none; }
.card-dashed { border-style: dashed; box-shadow: none; background: var(--surface-2); }
.card-accent::before { content: ''; position: absolute; left: -1px; top: 16px; bottom: 16px; width: 4px; border-radius: 0 4px 4px 0; background: var(--tone); }
.card-elevated { box-shadow: var(--sh-md); border-color: transparent; }
.card-gradient-border { border: 1px solid transparent; background: linear-gradient(#fff, #fff) padding-box, var(--grad-hero) border-box; }

/* ---------- Stat cards / KPI tiles ---------- */
.stat { position: relative; display: flex; align-items: center; gap: 16px; padding: 18px 20px; overflow: hidden; min-height: 104px; container-type: inline-size; }
.stat::before { content: ''; position: absolute; width: 180px; height: 180px; right: -70px; top: -90px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--tone) 13%, transparent), transparent 68%); pointer-events: none; }
.stat-ico {
  position: relative; width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; font-size: 26px; color: #fff; flex-shrink: 0;
  background: linear-gradient(145deg, color-mix(in srgb, var(--tone) 74%, #fff) 0%, var(--tone) 55%, color-mix(in srgb, var(--tone) 82%, #000) 100%);
  box-shadow: 0 12px 22px -12px var(--tone), inset 0 1px 0 rgba(255, 255, 255, .32);
}
.stat-body { position: relative; flex: 1; min-width: 0; }
.stat-label { font-size: 13.5px; color: var(--text-2); font-weight: 500; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stat-value { font-family: var(--font-num); font-size: 28px; font-weight: 750; letter-spacing: -.025em; line-height: 1.15; margin-top: 4px; color: var(--ink); white-space: nowrap; }
.stat-value small { font-size: 13.5px; font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: 0; font-family: var(--font); }
.stat-foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.trend { display: inline-flex; align-items: center; gap: 3px; height: 21px; padding: 0 7px; border-radius: 999px; font-size: 12px; font-weight: 700; font-family: var(--font-num); }
.trend.up { color: var(--emerald-ink); background: var(--emerald-soft); }
.trend.down { color: var(--rose-ink); background: var(--rose-soft); }
.trend.flat { color: var(--muted); background: var(--surface-3); }
.trend i { font-size: 11px; }
.stat-deco { position: relative; flex-shrink: 0; align-self: center; font-size: 36px; color: color-mix(in srgb, var(--tone) 28%, #fff); }
.stat-deco.spark { width: 104px; height: 46px; opacity: 1; }
.stat-spark { position: relative; width: 100%; height: 100%; }
.stat.has-spark { padding-bottom: 18px; }
.stat-top { display: contents; }
.stat-mini { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 0; }
.stat-mini::before { display: none; }
.stat-mini .stat-ico { width: 42px; height: 42px; font-size: 21px; border-radius: 12px; }
.stat-mini .stat-value { font-size: 22px; margin-top: 0; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpi-row.n-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpi-row.n-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-row.n-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } .kpi-row.n-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ---------- Hero (teal → cyan → indigo · Thai lattice texture) ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: var(--r-xl); padding: 28px 30px; color: #fff; isolation: isolate;
  background: var(--grad-hero); box-shadow: 0 24px 48px -28px color-mix(in srgb, var(--brand) 85%, #000), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.hero::before { content: ''; position: absolute; inset: 0; z-index: -1; background-image: var(--pattern); background-size: 56px 56px; opacity: .13;
  mask-image: linear-gradient(100deg, transparent 18%, rgba(0, 0, 0, .55) 55%, #000 100%); -webkit-mask-image: linear-gradient(100deg, transparent 18%, rgba(0, 0, 0, .55) 55%, #000 100%); }
.hero::after { content: ''; position: absolute; inset: 0; z-index: -1; background:
  linear-gradient(115deg, rgba(255, 255, 255, .10) 0%, transparent 32%),
  repeating-linear-gradient(135deg, transparent 0 22px, rgba(255, 255, 255, .025) 22px 23px);
  pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero h1, .hero h2, .hero h3 { color: #fff; }
.hero h1 { font-size: 28px; letter-spacing: -.015em; }
.hero p { color: rgba(255, 255, 255, .88); }
.hero .muted { color: rgba(255, 255, 255, .72); }
.hero .chip { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .22); backdrop-filter: blur(6px); }
.hero .badge { background: rgba(255, 255, 255, .16); color: #fff; }
.hero-illus { position: absolute; right: 26px; bottom: 0; top: 0; display: flex; align-items: center; font-size: 150px; opacity: .16; z-index: 0; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; }
.hero-kicker { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .2); color: #fff; margin-bottom: 10px; }
.hero-kicker i { color: #a7f3d0; }
.hero-stats { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(110px, 1fr); gap: 10px; }
.hero-stat { padding: 12px 14px; border-radius: 16px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); min-width: 0; }
.hero-stat b { display: block; font-family: var(--font-num); font-size: 26px; font-weight: 750; line-height: 1.1; letter-spacing: -.02em; }
.hero-stat span { display: block; font-size: 12px; color: rgba(255, 255, 255, .8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.hero-date { text-align: right; line-height: 1.5; }
.hero-date b { display: block; font-size: 15px; }
.hero-date span { font-size: 12.5px; color: rgba(255, 255, 255, .8); }
.hero.hero-soft { background: linear-gradient(135deg, var(--brand-soft) 0%, #eef2ff 100%); color: var(--ink); box-shadow: none; border: 1px solid var(--line); }
.hero.hero-soft::before { filter: invert(1); opacity: .06; }
.hero.hero-soft h1, .hero.hero-soft h2, .hero.hero-soft h3 { color: var(--ink); }
.hero.hero-soft p { color: var(--muted); }

/* =====================================================================
   BUTTONS
   ===================================================================== */
.btn {
  --b-bg: var(--surface); --b-fg: var(--text-2); --b-bd: var(--line-2);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--b-bd); background: var(--b-bg); color: var(--b-fg); font-size: 14px; font-weight: 600; line-height: 1;
  white-space: nowrap; user-select: none; text-decoration: none; transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-2), background var(--dur-2), border-color var(--dur-2), color var(--dur-2), filter var(--dur-2);
  box-shadow: var(--sh-xs);
}
.btn i { font-size: 18px; }
.btn:hover { color: var(--b-fg); border-color: color-mix(in srgb, var(--brand) 30%, var(--line-2)); box-shadow: var(--sh-sm); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:focus-visible { outline: none; box-shadow: var(--ring-strong); }
.btn:disabled, .btn.disabled { opacity: .55; pointer-events: none; }
.btn-primary { --b-fg: #fff; --b-bd: transparent; background: var(--grad-brand); box-shadow: var(--sh-brand), inset 0 1px 0 rgba(255, 255, 255, .18); }
.btn-primary:hover { color: #fff; border-color: transparent; box-shadow: 0 14px 28px -12px color-mix(in srgb, var(--brand) 85%, transparent), inset 0 1px 0 rgba(255, 255, 255, .2); filter: brightness(1.06) saturate(1.05); }
.btn-tone { --b-fg: #fff; --b-bd: transparent; background: var(--tone); box-shadow: 0 8px 18px -10px var(--tone); }
.btn-tone:hover { color: #fff; filter: brightness(1.06); border-color: transparent; }
.btn-soft { --b-bg: var(--tone-soft); --b-fg: var(--tone-ink); --b-bd: transparent; box-shadow: none; }
.btn-soft:hover { background: color-mix(in srgb, var(--tone) 15%, white); border-color: transparent; box-shadow: none; }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; box-shadow: none; }
.btn-ghost:hover { background: rgba(15, 31, 46, .05); box-shadow: none; border-color: transparent; }
.btn-danger { --b-bg: var(--rose); --b-fg: #fff; --b-bd: transparent; box-shadow: 0 8px 18px -10px var(--rose); }
.btn-danger:hover { color: #fff; filter: brightness(1.06); border-color: transparent; }
.btn-danger-soft { --b-bg: var(--rose-soft); --b-fg: var(--rose-ink); --b-bd: transparent; box-shadow: none; }
.btn-danger-soft:hover { background: color-mix(in srgb, var(--rose) 14%, white); border-color: transparent; }
.btn-success { --b-bg: var(--emerald); --b-fg: #fff; --b-bd: transparent; box-shadow: 0 8px 18px -10px var(--emerald); }
.btn-success:hover { color: #fff; filter: brightness(1.06); border-color: transparent; }
.btn-white { --b-bg: #fff; --b-fg: var(--brand-ink); --b-bd: transparent; box-shadow: 0 8px 20px -12px rgba(0, 0, 0, .4); }
.btn-glass { --b-bg: rgba(255, 255, 255, .16); --b-fg: #fff; --b-bd: rgba(255, 255, 255, .26); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: none; }
.btn-glass:hover { color: #fff; background: rgba(255, 255, 255, .26); border-color: rgba(255, 255, 255, .4); }
.btn-ai { --b-fg: #fff; --b-bd: transparent; background: var(--grad-ai); box-shadow: 0 10px 22px -12px rgba(79, 70, 229, .75); }
.btn-ai:hover { color: #fff; filter: brightness(1.06); border-color: transparent; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; gap: 6px; }
.btn-sm i { font-size: 16px; }
.btn-xs { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; gap: 5px; }
.btn-xs i { font-size: 14px; }
.btn-lg { height: 50px; padding: 0 24px; font-size: 15.5px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 42px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }
.btn-icon.btn-xs { width: 28px; }
.btn-icon.btn-lg { width: 50px; }
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading > * { opacity: 0; }
.btn.loading::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-color: var(--b-fg) transparent var(--b-fg) transparent; animation: spin .7s linear infinite; }
.btn-primary.loading::after, .btn-tone.loading::after, .btn-danger.loading::after, .btn-success.loading::after, .btn-ai.loading::after { border-color: #fff transparent #fff transparent; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 12px 0 0 12px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 12px 12px 0; }
.link { color: var(--brand); font-weight: 600; cursor: pointer; background: none; border: 0; padding: 0; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* =====================================================================
   FORMS
   ===================================================================== */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid > .field { grid-column: span 6; }
.form-grid > .field.col-3 { grid-column: span 3; } .form-grid > .field.col-4 { grid-column: span 4; } .form-grid > .field.col-5 { grid-column: span 5; }
.form-grid > .field.col-6 { grid-column: span 6; } .form-grid > .field.col-7 { grid-column: span 7; }
.form-grid > .field.col-8 { grid-column: span 8; } .form-grid > .field.col-9 { grid-column: span 9; } .form-grid > .field.col-12, .form-grid > .col-12 { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; padding-top: 8px; color: var(--ink); }
.form-section i { color: var(--brand); font-size: 18px; }
.form-section::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.label .req { color: var(--rose); }
.hint { font-size: 12.5px; color: var(--muted); }
.field-error { font-size: 12.5px; color: var(--rose); display: flex; align-items: center; gap: 4px; }
.input, .select, .textarea {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface);
  font-size: 14.5px; color: var(--text); transition: border-color var(--dur-2), box-shadow var(--dur-2), background var(--dur-2); outline: none; appearance: none; -webkit-appearance: none;
  box-shadow: inset 0 1px 1px rgba(16, 32, 48, .03);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: var(--ring); }
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly] { background: var(--surface-2); color: var(--muted); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--rose); box-shadow: 0 0 0 4px rgba(225, 29, 72, .1); }
.textarea { height: auto; min-height: 104px; padding: 12px 14px; resize: vertical; line-height: 1.6; }
.select { padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 256 256'%3E%3Cpath fill='%235d6e80' d='M213.66 101.66l-80 80a8 8 0 0 1-11.32 0l-80-80a8 8 0 0 1 11.32-11.32L128 164.69l74.34-74.35a8 8 0 0 1 11.32 11.32z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; cursor: pointer; }
.select[multiple] { height: auto; padding: 8px; background-image: none; }
.input-sm, .select.input-sm { height: 36px; font-size: 13.5px; border-radius: 10px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > i:first-child { position: absolute; left: 14px; font-size: 18px; color: var(--muted-2); pointer-events: none; z-index: 1; transition: color var(--dur-2); }
.input-group:focus-within > i:first-child { color: var(--brand); }
.input-group > .input, .input-group > .select { padding-left: 42px; }
.input-group > .input-addon { position: absolute; right: 6px; }
.input-affix { display: flex; align-items: stretch; }
.input-affix > .input { border-radius: 12px 0 0 12px; }
.input-affix > .affix { display: grid; place-items: center; padding: 0 14px; background: var(--surface-3); border: 1px solid var(--line-2); border-left: 0; border-radius: 0 12px 12px 0; color: var(--muted); font-size: 13.5px; }
input[type=date].input, input[type=time].input, input[type=datetime-local].input, input[type=month].input { padding-right: 10px; }
input[type=color].input { padding: 4px; width: 60px; }
input[type=file].input { padding: 8px; height: auto; }
input[type=file].input::file-selector-button { border: 0; border-radius: 8px; background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; padding: 6px 12px; margin-right: 10px; cursor: pointer; }

.check, .radio { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; user-select: none; }
.check input, .radio input { appearance: none; -webkit-appearance: none; width: 20px; height: 20px; border: 1.5px solid var(--line-3); background: #fff; border-radius: 6px; display: grid; place-items: center; margin: 0; transition: var(--dur-1); flex-shrink: 0; cursor: pointer; }
.radio input { border-radius: 50%; }
.check input:checked, .radio input:checked { background: var(--brand); border-color: var(--brand); box-shadow: 0 4px 10px -4px var(--brand); }
.check input:checked::after { content: ''; width: 6px; height: 10px; border: solid #fff; border-width: 0 2.2px 2.2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.radio input:checked::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.check input:focus-visible, .radio input:focus-visible { box-shadow: var(--ring); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 14px; }
.switch input { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 13px; background: var(--line-2); position: relative; transition: var(--dur-3) var(--ease); margin: 0; cursor: pointer; flex-shrink: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .2); transition: var(--dur-3) var(--ease-spring); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { left: 21px; }
.switch input:focus-visible { box-shadow: var(--ring); }
.choice-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.choice-card { position: relative; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--surface); cursor: pointer; transition: var(--dur-2); }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card:hover { border-color: color-mix(in srgb, var(--tone) 45%, transparent); }
.choice-card:has(input:checked) { border-color: var(--tone); background: var(--tone-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 14%, transparent); }
.choice-card:has(input:checked)::after { content: ''; position: absolute; top: 8px; right: 8px; width: 16px; height: 16px; border-radius: 50%; background: var(--tone) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath fill='white' d='M232.49 80.49l-128 128a12 12 0 0 1-17 0l-56-56a12 12 0 1 1 17-17L96 183 215.51 63.51a12 12 0 0 1 17 17z'/%3E%3C/svg%3E") center / 10px no-repeat; }
.choice-card .ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); font-size: 19px; flex-shrink: 0; }
.segmented { display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface-3); gap: 2px; border: 1px solid var(--line); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented a, .segmented button, .segmented label { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 5px 14px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--muted); border: 0; background: none; cursor: pointer; white-space: nowrap; transition: var(--dur-2); }
.segmented a:hover, .segmented button:hover, .segmented label:hover { color: var(--ink); }
.segmented .active, .segmented input:checked + span { background: #fff; color: var(--ink); box-shadow: var(--sh-sm); }
.segmented label input { display: none; }
.segmented label:has(input:checked) { background: #fff; color: var(--ink); box-shadow: var(--sh-sm); }
.segmented .count { min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; font-size: 11px; display: inline-grid; place-items: center; background: var(--line); color: var(--muted); font-family: var(--font-num); }
.segmented .active .count { background: var(--brand); color: #fff; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 28px 20px; border: 2px dashed var(--line-2); border-radius: 16px; background: var(--surface-2); text-align: center; color: var(--muted); cursor: pointer; transition: var(--dur-2); }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.dropzone i { font-size: 34px; color: var(--brand); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 8px; grid-column: 1 / -1; flex-wrap: wrap; }

/* ---------- Filter bar ---------- */
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters .input-group { flex: 1; min-width: 220px; max-width: 380px; }
.filters .select, .filters .input { width: auto; min-width: 140px; }
.filters.card { padding: 12px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); }

/* =====================================================================
   TABLES (light-gray header · avatar cells · stacked cards on mobile)
   ===================================================================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th { position: sticky; top: 0; z-index: 1; background: #f5f7f9; color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; letter-spacing: .01em; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background var(--dur-1); }
.table tbody tr:hover { background: color-mix(in srgb, var(--brand) 3%, white); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr[data-href] { cursor: pointer; }
.table tr.is-unread td.primary, .table tr.is-unread .cell-user b { font-weight: 700; }
.table .num, .table td.num, .table th.num { text-align: right; }
.table td.primary { font-weight: 600; color: var(--ink); }
.table td.actions { text-align: right; white-space: nowrap; width: 1%; }
.table.compact td { padding: 9px 14px; }
.table.compact th { padding: 9px 14px; }
.table.striped tbody tr:nth-child(even) { background: var(--surface-2); }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line-2); }
.table .sort { cursor: pointer; user-select: none; }
.table .sort::after { content: '↕'; margin-left: 6px; opacity: .4; }
.table .sort.asc::after { content: '↑'; opacity: 1; color: var(--brand); }
.table .sort.desc::after { content: '↓'; opacity: 1; color: var(--brand); }
.card > .table-wrap:first-child .table th:first-child { border-top-left-radius: var(--r-lg); }
.card > .table-wrap:first-child .table th:last-child { border-top-right-radius: var(--r-lg); }
.cell-user { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-user .meta { min-width: 0; line-height: 1.35; }
.cell-user .meta b { display: block; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-user .meta span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-user .meta em { display: block; font-style: normal; font-size: 11.5px; color: var(--muted-2); }
.cell-doc { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.table .cell-doc { min-width: 220px; }
.table .cell-user { max-width: 260px; }
.table .cell-user .meta { overflow: hidden; }
.cell-doc .ico-tile { margin-top: 2px; }
.cell-doc b { display: block; font-weight: 600; color: var(--ink); line-height: 1.45; }
.cell-doc span { display: block; font-size: 12.5px; color: var(--muted); }

/* ---------- Pager ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; font-size: 13.5px; color: var(--muted); }
.pager-links { display: flex; gap: 4px; flex-wrap: wrap; }
.pager-links a, .pager-links span { min-width: 36px; height: 36px; padding: 0 10px; display: grid; place-items: center; border-radius: 10px; font-weight: 600; color: var(--text-2); font-family: var(--font-num); font-size: 13.5px; }
.pager-links a:hover { background: var(--surface-3); }
.pager-links .active { background: var(--grad-brand); color: #fff; box-shadow: var(--sh-brand); }
.pager-links .disabled { opacity: .4; }

/* =====================================================================
   BADGES / PILLS / CHIPS / AVATARS
   ===================================================================== */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--tone-soft); color: var(--tone-ink); white-space: nowrap; line-height: 1; border: 1px solid color-mix(in srgb, var(--tone) 14%, transparent); }
.badge i { font-size: 13px; }
.badge-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--tone); flex-shrink: 0; }
.badge-solid { background: var(--tone); color: #fff; border-color: transparent; box-shadow: 0 4px 10px -6px var(--tone); }
.badge-outline { background: transparent; border: 1px solid color-mix(in srgb, var(--tone) 40%, transparent); }
.badge-lg { height: 30px; padding: 0 14px; font-size: 13px; }
.badge-sm { height: 20px; padding: 0 8px; font-size: 11px; }
.badge-pulse::before { animation: pulse-dot 1.6s infinite; color: var(--tone); }
.badge-stamp { height: 26px; padding: 0 10px; border-radius: 6px; border: 1.5px solid var(--tone); background: transparent; color: var(--tone); font-weight: 700; letter-spacing: .02em; }
.status-pill { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 64px; height: 26px; padding: 0 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600; background: var(--tone-soft); color: var(--tone-ink); white-space: nowrap; }
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--tone); }
.status-pill:has(i)::before { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface); border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap; transition: var(--dur-2); }
.chip i { font-size: 16px; }
a.chip:hover, button.chip:hover { border-color: var(--brand); color: var(--brand-ink); }
.chip.active { background: var(--grad-brand); color: #fff; border-color: transparent; box-shadow: var(--sh-brand); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--tone); flex-shrink: 0; }
.avatar {
  --av: 40px; width: var(--av); height: var(--av); border-radius: 50%; flex-shrink: 0; display: inline-grid; place-items: center; overflow: hidden;
  font-size: calc(var(--av) * .36); font-weight: 600; color: #fff; background: linear-gradient(135deg, var(--av-a, #0d9488), var(--av-b, #4f46e5));
  position: relative; letter-spacing: -.01em; font-family: var(--font); line-height: 1;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sq { border-radius: 30%; }
.avatar-xs { --av: 24px; } .avatar-sm { --av: 32px; } .avatar-md { --av: 40px; } .avatar-lg { --av: 56px; } .avatar-xl { --av: 80px; } .avatar-2xl { --av: 112px; }
.avatar.ring { box-shadow: 0 0 0 3px #fff, 0 0 0 5px color-mix(in srgb, var(--brand) 35%, transparent); }
.avatar .presence { position: absolute; right: 0; bottom: 0; width: 28%; height: 28%; border-radius: 50%; background: var(--emerald); border: 2px solid #fff; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px #fff; margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-stack .more { --av: 32px; background: var(--surface-3); color: var(--muted); font-size: 11px; font-family: var(--font-num); }

/* =====================================================================
   TABS / PILLS
   ===================================================================== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; margin-bottom: 20px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 12px 14px; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; border: 0; background: none; transition: color var(--dur-2); }
.tabs a i, .tabs button i { font-size: 18px; }
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs a.active, .tabs button.active { color: var(--brand-ink); }
.tabs a.active::after, .tabs button.active::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--grad-brand); }
.tabs .count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--surface-3); font-size: 11.5px; display: inline-grid; place-items: center; color: var(--muted); font-family: var(--font-num); }
.tabs .active .count { background: var(--brand-soft); color: var(--brand-ink); }
.tabs.tabs-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 0 8px; box-shadow: var(--sh-sm); }
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.pills a, .pills button { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); white-space: nowrap; transition: var(--dur-2); }
.pills a:hover, .pills button:hover { border-color: var(--line-3); color: var(--ink); }
.pills a.active, .pills button.active { background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: 0 6px 14px -8px rgba(15, 31, 46, .6); }
.pills .count { font-family: var(--font-num); font-size: 11.5px; opacity: .75; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade-up .35s var(--ease); }

/* =====================================================================
   LISTS / TIMELINE / STEPS
   ===================================================================== */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 1px solid var(--line); transition: background var(--dur-1); color: inherit; min-width: 0; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover, .list-item.clickable:hover { background: var(--surface-2); color: inherit; }
.list-item .li-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); font-size: 20px; flex-shrink: 0; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: 14.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-end { text-align: right; flex-shrink: 0; font-size: 13px; color: var(--muted); }
.list.compact .list-item { padding: 10px 14px; }
.list.divided .list-item { border-bottom-style: dashed; }

.timeline { position: relative; padding-left: 30px; }
.timeline::before { content: ''; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: linear-gradient(var(--line-2), color-mix(in srgb, var(--line-2) 30%, transparent)); }
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: -30px; top: 1px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--tone); color: #fff; font-size: 12px; box-shadow: 0 0 0 4px var(--surface), 0 4px 10px -4px var(--tone); }
.tl-item.pending .tl-dot { background: var(--surface); color: var(--muted-2); box-shadow: 0 0 0 4px var(--surface), inset 0 0 0 2px var(--line-2); }
.tl-item.current .tl-dot { animation: pulse-ring 2s infinite; }
.tl-title { font-weight: 600; font-size: 14px; color: var(--ink); line-height: 1.45; }
.tl-meta { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.tl-body { margin-top: 8px; font-size: 13.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }

.steps { display: flex; align-items: flex-start; gap: 0; counter-reset: step; }
.step { flex: 1; position: relative; text-align: center; font-size: 12.5px; color: var(--muted); padding-top: 44px; min-width: 0; line-height: 1.4; }
.step::before { counter-increment: step; content: counter(step); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--muted); font-weight: 700; font-family: var(--font-num); font-size: 13px; z-index: 1; box-shadow: inset 0 0 0 2px var(--line-2); }
.step::after { content: ''; position: absolute; top: 16px; left: calc(50% + 22px); right: calc(-50% + 22px); height: 3px; border-radius: 3px; background: var(--line); }
.step:last-child::after { display: none; }
.step.done::before { content: '✓'; background: var(--emerald); color: #fff; box-shadow: 0 0 0 4px var(--emerald-soft); }
.step.done::after { background: linear-gradient(90deg, var(--emerald), color-mix(in srgb, var(--emerald) 60%, var(--line))); }
.step.current::before { background: var(--grad-brand); color: #fff; box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand) 16%, transparent), 0 8px 16px -6px var(--brand); }
.step.current { color: var(--ink); font-weight: 600; }
.step.rejected::before { content: '✕'; background: var(--rose); color: #fff; box-shadow: 0 0 0 4px var(--rose-soft); }
.step b { display: block; color: var(--text-2); font-size: 13px; font-weight: 600; }
.step small { display: block; color: var(--muted-2); font-size: 11.5px; }
.steps-vertical { flex-direction: column; gap: 0; }
.steps-vertical .step { display: flex; text-align: left; padding: 0 0 22px 48px; min-height: 34px; flex-direction: column; justify-content: center; }
.steps-vertical .step::before { left: 0; transform: none; }
.steps-vertical .step::after { left: 16px; right: auto; top: 38px; bottom: 2px; width: 3px; height: auto; }

/* =====================================================================
   PROGRESS / RING / SKELETON
   ===================================================================== */
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, color-mix(in srgb, var(--tone) 70%, #fff), var(--tone)); width: 0; transition: width 1.2s var(--ease); }
.progress.lg { height: 12px; }
.progress.sm { height: 5px; }
.progress-row { display: flex; align-items: center; gap: 12px; font-size: 13.5px; }
.progress-row .progress { flex: 1; }
.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-linecap: round; }
.ring .ring-bg { stroke: var(--surface-3); }
.ring .ring-fg { stroke: var(--tone); transition: stroke-dashoffset 1.4s var(--ease); }
.ring-label { position: absolute; text-align: center; line-height: 1.1; }
.ring-label b { font-family: var(--font-num); font-size: 20px; font-weight: 750; display: block; color: var(--ink); }
.ring-label span { font-size: 11px; color: var(--muted); }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, #f7f9fa 45%, var(--surface-3) 65%); background-size: 300% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; min-height: 14px; }
.skeleton.sk-text { height: 12px; border-radius: 6px; margin: 6px 0; }
.skeleton.sk-title { height: 18px; width: 55%; border-radius: 6px; }
.skeleton.sk-circle { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.skeleton.sk-tile { width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; }
.skeleton.sk-card { height: 104px; border-radius: var(--r-lg); }
.sk-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.sk-row > div:not(.skeleton) { flex: 1; }
.meter-legend { display: flex; flex-wrap: wrap; gap: 12px 18px; font-size: 13px; color: var(--muted); }
.meter-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* =====================================================================
   EMPTY STATE (SVG illustrations: assets/img/empty/*.svg) / ALERT
   ===================================================================== */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 44px 20px; gap: 6px; }
.empty-ico { width: 84px; height: 84px; border-radius: 26px; display: grid; place-items: center; font-size: 40px; color: var(--tone); background: var(--tone-soft); margin-bottom: 12px; position: relative; }
.empty-ico::after { content: ''; position: absolute; inset: -8px; border-radius: 32px; border: 2px dashed color-mix(in srgb, var(--tone) 24%, transparent); }
.empty-illus { width: 180px; max-width: 70%; height: auto; margin: 0 auto 10px; }
.empty.sm .empty-illus { width: 120px; }
.empty h3 { font-size: 17px; color: var(--ink); }
.empty p { color: var(--muted); max-width: 440px; margin: 0 auto 12px; font-size: 14px; }
.empty.sm { padding: 26px 14px; }
.empty.sm h3 { font-size: 15px; }
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--tone-soft); color: var(--tone-ink); font-size: 14px; border: 1px solid color-mix(in srgb, var(--tone) 18%, transparent); align-items: flex-start; }
.alert > i { font-size: 21px; flex-shrink: 0; margin-top: 1px; color: var(--tone); }
.alert b { display: block; }
.alert-body { flex: 1; min-width: 0; }

/* =====================================================================
   DROPDOWN / MENU / TOOLTIP
   ===================================================================== */
.dropdown { position: relative; display: inline-block; }
.menu {
  position: absolute; z-index: 80; top: calc(100% + 8px); right: 0; min-width: 230px; padding: 6px; border-radius: 16px;
  background: var(--glass-strong); backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid var(--line); box-shadow: var(--sh-lg); opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top right;
  pointer-events: none; visibility: hidden; transition: opacity .18s var(--ease), transform .2s var(--ease), visibility 0s .2s;
}
.menu.left { right: auto; left: 0; transform-origin: top left; }
.menu.up { top: auto; bottom: calc(100% + 8px); transform-origin: bottom right; }
.dropdown.open > .menu { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition: opacity .18s var(--ease), transform .2s var(--ease), visibility 0s; }
.menu:not(.notif-panel) a, .menu:not(.notif-panel) button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 10px; color: var(--text-2); font-size: 14px; border: 0; background: none; text-align: left; white-space: nowrap; }
.menu:not(.notif-panel) a:hover, .menu:not(.notif-panel) button:hover { background: rgba(15, 31, 46, .05); color: var(--ink); }
.menu:not(.notif-panel) a i, .menu:not(.notif-panel) button i { font-size: 18px; color: var(--muted); }
.menu:not(.notif-panel) a:hover i, .menu:not(.notif-panel) button:hover i { color: var(--brand); }
.menu a .kbd-hint, .menu button .kbd-hint { margin-left: auto; font-size: 11.5px; color: var(--muted-2); }
.menu .danger, .menu .danger i { color: var(--rose); }
.menu hr { margin: 6px 4px; }
.menu-head { padding: 10px 12px; }
.menu-label { padding: 8px 12px 4px; font-size: 11.5px; font-weight: 600; color: var(--muted-2); letter-spacing: .03em; }
.tooltip { position: fixed; z-index: 300; max-width: 280px; padding: 6px 10px; border-radius: 8px; background: #0f1f2e; color: #fff; font-size: 12.5px; font-weight: 500; line-height: 1.4; pointer-events: none; box-shadow: 0 8px 20px -8px rgba(0, 0, 0, .5); animation: tip-in .14s var(--ease); white-space: normal; }
.tooltip::after { content: ''; position: absolute; width: 8px; height: 8px; background: inherit; transform: rotate(45deg); left: var(--ax, 50%); margin-left: -4px; bottom: -4px; }
.tooltip.below::after { bottom: auto; top: -4px; }
.tooltip.right::after { left: -4px; top: 50%; margin: -4px 0 0; bottom: auto; }
@keyframes tip-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* =====================================================================
   MODAL / SHEET / DRAWER
   ===================================================================== */
.modal-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: var(--overlay); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); animation: fade-in .25s var(--ease); }
.modal {
  position: relative; width: 100%; max-width: 560px; max-height: calc(100dvh - 48px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-xl); animation: modal-in .35s var(--ease-out); overflow: hidden;
}
.modal.sm { max-width: 420px; } .modal.lg { max-width: 820px; } .modal.xl { max-width: 1120px; } .modal.full { max-width: none; width: calc(100vw - 48px); height: calc(100dvh - 48px); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 14px; }
.modal-head h3 { flex: 1; font-size: 18px; min-width: 0; }
.modal-head .ico { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); font-size: 22px; flex-shrink: 0; }
.modal-close { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; border: 0; background: var(--surface-3); color: var(--muted); font-size: 17px; flex-shrink: 0; transition: var(--dur-2); }
.modal-close:hover { background: var(--rose-soft); color: var(--rose); }
.modal-body { padding: 4px 22px 20px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.modal-root.closing .modal { animation: modal-out .2s var(--ease) forwards; }
.modal-root.closing .modal-backdrop { animation: fade-out .2s forwards; }
.sheet-handle { display: none; }
.confirm-ico { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; font-size: 32px; background: var(--tone-soft); color: var(--tone); margin: 6px auto 14px; }
.drawer-root { position: fixed; inset: 0; z-index: 100; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--surface); box-shadow: var(--sh-xl); display: flex; flex-direction: column; animation: drawer-in .38s var(--ease-out); }
.drawer-root.closing .drawer { animation: drawer-out .22s var(--ease) forwards; }
.drawer-root.closing .modal-backdrop { animation: fade-out .22s forwards; }

/* action sheet (FAB · App.sheet.actions) */
.action-sheet .modal-body { padding-bottom: 14px; }
.as-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
@media (min-width: 1024px) { .as-grid.apps-quick { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); } .as-grid.apps-quick .as-item { min-height: 76px; } }
.as-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; font-size: 14px; font-weight: 600; transition: var(--dur-2) var(--ease); min-height: 64px; width: 100%; }
.as-item:hover { border-color: color-mix(in srgb, var(--tone) 40%, transparent); background: var(--tone-soft); color: var(--ink); transform: translateY(-1px); }
.as-item:active { transform: scale(.97); }
.as-item .as-ico { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 22px; color: #fff; flex-shrink: 0; background: linear-gradient(145deg, color-mix(in srgb, var(--tone) 75%, #fff), var(--tone) 60%, color-mix(in srgb, var(--tone) 82%, #000)); box-shadow: 0 8px 16px -8px var(--tone); }
.as-item .as-text { min-width: 0; line-height: 1.35; }
.as-item .as-text small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); white-space: normal; }
.as-list .as-item { border: 0; border-radius: 12px; min-height: 56px; }

/* ---------- Toast ---------- */
#toasts { position: fixed; z-index: 200; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; width: min(390px, calc(100vw - 32px)); }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 14px 16px; border-radius: 16px; background: var(--glass-strong);
  backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6); border: 1px solid var(--line); box-shadow: var(--sh-lg);
  animation: toast-in .45s var(--ease-out); position: relative; overflow: hidden; color: var(--text);
}
.toast::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tone); }
.toast .t-ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--tone); color: #fff; font-size: 19px; flex-shrink: 0; box-shadow: 0 6px 14px -6px var(--tone); }
.toast .t-body { flex: 1; min-width: 0; font-size: 14px; line-height: 1.45; }
.toast .t-body b { display: block; font-size: 14px; font-weight: 600; color: var(--ink); }
.toast .t-body span { display: block; color: var(--muted); font-size: 13px; }
.toast .t-actions { display: flex; gap: 6px; margin-top: 8px; }
.toast .t-close { border: 0; background: none; color: var(--muted-2); font-size: 16px; padding: 2px; border-radius: 6px; }
.toast .t-close:hover { color: var(--ink); background: var(--surface-3); }
.toast .t-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--tone); opacity: .6; animation: toast-bar linear forwards; }
.toast:hover .t-bar { animation-play-state: paused; }
.toast.out { animation: toast-out .3s var(--ease) forwards; }
a.toast { color: inherit; }

/* =====================================================================
   NOTIFICATION CENTER (bell dropdown · full sheet on mobile · notifications.php)
   ===================================================================== */
.notif-panel { width: 430px; max-width: calc(100vw - 24px); padding: 0; right: -64px; overflow: hidden; display: flex; flex-direction: column; max-height: min(680px, calc(100dvh - 90px)); background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: var(--sh-xl); }
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 16px 10px 18px; }
.notif-head h4 { font-size: 16.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.notif-head h4 .badge { height: 22px; }
.notif-head .nh-actions { display: flex; align-items: center; gap: 2px; }
.notif-head .icon-btn { width: 36px; height: 36px; font-size: 18px; border-radius: 10px; }
.notif-tabs { display: flex; gap: 4px; padding: 0 14px 10px; border-bottom: 1px solid var(--line); }
.notif-tabs button { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; border: 0; background: none; font-size: 13px; font-weight: 600; color: var(--muted); transition: var(--dur-2); white-space: nowrap; }
.notif-tabs button:hover { color: var(--ink); background: var(--surface-3); }
.notif-tabs button.active { background: var(--ink); color: #fff; }
.notif-tabs button .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 10.5px; display: inline-grid; place-items: center; background: var(--surface-3); color: var(--muted); font-family: var(--font-num); line-height: 1; }
.notif-tabs button.active .count { background: rgba(255, 255, 255, .2); color: #fff; }
.notif-tabs button[data-tab=action] .count:not(:empty) { background: var(--rose); color: #fff; }
.notif-list { flex: 1; min-height: 120px; max-height: 470px; overflow-y: auto; padding: 4px 8px 8px; overscroll-behavior: contain; }
.notif-group { position: sticky; top: 0; z-index: 1; padding: 10px 10px 6px; font-size: 11.5px; font-weight: 600; color: var(--muted-2); letter-spacing: .03em; background: linear-gradient(#fff 70%, rgba(255, 255, 255, 0)); }
.notif-item { display: flex; gap: 12px; padding: 11px 10px; border-radius: 14px; color: inherit; position: relative; transition: background var(--dur-1); }
.notif-item:hover { background: rgba(15, 31, 46, .04); color: inherit; }
.notif-item .n-ico { position: relative; width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); font-size: 21px; flex-shrink: 0; }
.notif-item.is-action .n-ico::after { content: ''; position: absolute; right: -3px; bottom: -3px; width: 14px; height: 14px; border-radius: 50%; background: var(--rose) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath fill='white' d='M140 80v52a12 12 0 0 1-24 0V80a12 12 0 0 1 24 0zm-12 92a16 16 0 1 0 16 16 16 16 0 0 0-16-16z'/%3E%3C/svg%3E") center / 10px no-repeat; border: 2px solid #fff; }
.notif-item .n-body { flex: 1; min-width: 0; padding-right: 14px; }
.notif-item .n-title { font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--ink); }
.notif-item .n-text { font-size: 13px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.notif-item .n-time { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted-2); margin-top: 5px; flex-wrap: wrap; }
.notif-item .n-time .tag { padding: 0 6px; font-size: 11px; font-weight: 600; background: var(--tone-soft); color: var(--tone-ink); }
.notif-item .n-time .tag.act { background: var(--rose-soft); color: var(--rose-ink); }
.notif-item.unread { background: color-mix(in srgb, var(--brand) 5%, transparent); }
.notif-item.unread:hover { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.notif-item.unread::after { content: ''; position: absolute; right: 12px; top: 18px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.notif-item.unread .n-title { font-weight: 700; }
.notif-item.just-in { animation: notif-in .6s var(--ease-out); }
@keyframes notif-in { 0% { background: color-mix(in srgb, var(--amber) 22%, transparent); transform: translateY(-6px); opacity: 0; } 100% { transform: none; opacity: 1; } }
.notif-foot { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--surface-2); }
.notif-foot .btn { flex: 1; }
.notif-empty { padding: 26px 10px 30px; text-align: center; color: var(--muted); }
.notif-empty img { width: 150px; margin: 0 auto 6px; }
.notif-empty b { display: block; color: var(--ink); font-size: 15px; }
/* full page */
.notif-page .notif-item { padding: 14px 14px; }
.notif-page .notif-item .n-ico { width: 46px; height: 46px; font-size: 23px; }
/* ปุ่มอ่าน/ลบลอยทับด้านขวาของแถว (desktop) — ไม่จองพื้นที่ แถวกว้างเต็มการ์ด · มือถือใช้การปัดแทน */
.notif-page .notif-row { position: relative; }
.notif-page .notif-row .notif-item { width: 100%; }
.notif-page .notif-row .n-act { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); z-index: 2; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-md); opacity: 0; pointer-events: none; transition: opacity var(--dur-2); }
.notif-page .notif-row:hover .n-act, .notif-page .notif-row:focus-within .n-act { opacity: 1; pointer-events: auto; }
.notif-page .swipe-row .swipe-actions { display: none !important; }
.notif-day { display: flex; align-items: center; gap: 10px; padding: 14px 18px 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.notif-day::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.notif-side .list-item { border-radius: 12px; border: 0; margin: 1px 0; }
.notif-side .list-item.active { background: var(--tone-soft); }
.notif-side .list-item.active .li-title { color: var(--tone-ink); }

/* =====================================================================
   COMMAND PALETTE (Ctrl/⌘+K)
   ===================================================================== */
.cmdk-root { position: fixed; inset: 0; z-index: 150; display: flex; justify-content: center; align-items: flex-start; padding: 11vh 16px 16px; }
.cmdk { position: relative; width: 100%; max-width: 680px; max-height: 76vh; display: flex; flex-direction: column; background: var(--glass-strong); backdrop-filter: blur(24px) saturate(1.8); -webkit-backdrop-filter: blur(24px) saturate(1.8); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--sh-xl), 0 0 0 1px rgba(255, 255, 255, .6) inset; overflow: hidden; animation: modal-in .3s var(--ease-out); }
.cmdk-input { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.cmdk-input > i { font-size: 22px; color: var(--brand); }
.cmdk-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 17px; height: 36px; }
.cmdk-input input::-webkit-search-cancel-button { display: none; }
.cmdk-input .cmdk-spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--brand); animation: spin .7s linear infinite; display: none; }
.cmdk.loading .cmdk-spin { display: block; }
.cmdk-input .cmdk-x { display: none; }
.cmdk-scopes { display: flex; gap: 6px; padding: 10px 16px 0; overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.cmdk-scopes::-webkit-scrollbar { display: none; }
.cmdk-scopes button { height: 28px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.cmdk-scopes button.active { background: var(--brand-soft); border-color: transparent; color: var(--brand-ink); }
.cmdk-results { flex: 1; overflow-y: auto; padding: 6px 8px 8px; overscroll-behavior: contain; }
.cmdk-group { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--muted-2); letter-spacing: .04em; padding: 12px 12px 6px; }
.cmdk-group i { font-size: 13px; }
.cmdk-group .cg-count { margin-left: auto; font-family: var(--font-num); font-weight: 600; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; color: var(--text); cursor: pointer; scroll-margin: 8px; }
.cmdk-item:hover { color: var(--text); }
.cmdk-item .c-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); font-size: 19px; flex-shrink: 0; }
.cmdk-item .c-main { flex: 1; min-width: 0; }
.cmdk-item .c-title { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.cmdk-item .c-title .badge { height: 20px; font-size: 11px; padding: 0 8px; }
.cmdk-item .c-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-item .c-snip { font-size: 12.5px; line-height: 1.6; color: var(--text-2); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* ไฮไลต์ในบรรทัดที่ถูกตัด (บรรทัด 3+) ต้องไม่โผล่เป็นเส้นใต้บรรทัด 2 — ระบายเฉพาะกลางบรรทัด */
.cmdk-item .c-snip mark { background: linear-gradient(transparent 12%, color-mix(in srgb, var(--amber) 30%, white) 12%, color-mix(in srgb, var(--amber) 30%, white) 90%, transparent 90%); padding: 0 1px; }
.cmdk-item .c-meta { font-size: 11.5px; color: var(--muted-2); white-space: nowrap; flex-shrink: 0; }
.cmdk-item.active { background: var(--brand-soft); }
.cmdk-item.active .c-title { color: var(--brand-ink); }
.cmdk-item.active .c-arrow { opacity: 1; }
.cmdk-item .c-arrow { opacity: 0; color: var(--brand); flex-shrink: 0; }
.cmdk-item .c-del { opacity: 0; border: 0; background: none; color: var(--muted-2); font-size: 14px; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; }
.cmdk-item:hover .c-del { opacity: 1; }
.cmdk-item .c-del:hover { background: var(--rose-soft); color: var(--rose); }
.cmdk-quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; padding: 4px 4px 6px; }
.cmdk-quick .cmdk-item { gap: 10px; padding: 9px 10px; border: 1px solid var(--line); background: #fff; }
.cmdk-quick .cmdk-item .c-ico { width: 34px; height: 34px; font-size: 18px; }
.cmdk-quick .cmdk-item .c-title { font-size: 13.5px; }
.cmdk-quick .cmdk-item .c-sub { font-size: 11.5px; }
.cmdk-quick .cmdk-item .c-arrow { display: none; }
.cmdk-quick .cmdk-item.active { border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
/* มือถือ: ชื่อเรื่องเอกสารยาว → 2 บรรทัด (ไม่ตัดเหลือคำเดียว) · ซ่อนวันที่/ลูกศรคีย์บอร์ด (ไม่มีประโยชน์บนจอสัมผัส) ให้ชื่อเรื่องได้พื้นที่เต็ม */
@media (max-width: 640px) {
  .cmdk-results .cmdk-item { align-items: flex-start; gap: 11px; }
  .cmdk-results .cmdk-item .c-ico { margin-top: 1px; }
  .cmdk-results .cmdk-item .c-title { white-space: normal; align-items: flex-start; }
  .cmdk-results .cmdk-item .c-title > .truncate { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.45; flex: 1 1 auto; min-width: 0; }
  .cmdk-results .cmdk-item .c-title .badge { margin-top: 1px; flex-shrink: 0; }
  .cmdk-results .cmdk-item:has(.c-snip) .c-meta, .cmdk-results .cmdk-item .c-arrow { display: none; }
}
.cmdk-empty { padding: 30px 16px; text-align: center; color: var(--muted); }
.cmdk-empty img { width: 140px; margin: 0 auto 8px; }
.cmdk-foot { display: flex; gap: 16px; align-items: center; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); background: var(--surface-2); flex-shrink: 0; }
.cmdk-foot .cf-ai { margin-left: auto; }

/* =====================================================================
   AI DRAWER (App.ai.open — right drawer on desktop, full sheet on mobile)
   ===================================================================== */
.ai-drawer { width: min(500px, 100vw); background: #f7f9fb; }
.ai-head { position: relative; display: flex; align-items: center; gap: 12px; padding: 16px 16px 16px 18px; padding-top: calc(16px + var(--safe-t)); color: #fff; background: var(--grad-ai); overflow: hidden; flex-shrink: 0; }
.ai-head::before { content: ''; position: absolute; inset: 0; background-image: var(--pattern); background-size: 48px; opacity: .12; }
.ai-head > * { position: relative; }
.ai-head .ai-avatar { box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .16); }
.ai-head .ai-avatar::after { border-color: #4f46e5; }
.ai-head b { display: block; font-size: 16px; color: #fff; line-height: 1.3; }
.ai-head span { font-size: 12.5px; color: rgba(255, 255, 255, .85); }
.ai-head .icon-btn { color: #fff; }
.ai-head .icon-btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.ai-body { flex: 1; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.ai-welcome { text-align: center; padding: 16px 8px 4px; }
.ai-welcome img { width: 150px; margin: 0 auto 6px; }
.ai-welcome h4 { font-size: 17px; }
.ai-welcome p { color: var(--muted); font-size: 13.5px; margin: 4px auto 0; max-width: 360px; }
.ai-sugs { display: grid; gap: 8px; }
.ai-sug { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 14px; border: 1px solid var(--line); background: #fff; font-size: 13.5px; color: var(--text-2); text-align: left; transition: var(--dur-2); width: 100%; }
.ai-sug i { font-size: 18px; color: var(--indigo); flex-shrink: 0; }
.ai-sug:hover { border-color: color-mix(in srgb, var(--indigo) 40%, transparent); background: var(--indigo-soft); color: var(--indigo-ink); }
.ai-msg { display: flex; gap: 10px; align-items: flex-start; max-width: 100%; animation: fade-up .35s var(--ease); }
.ai-msg.me { justify-content: flex-end; }
.ai-msg.me .bubble { background: var(--grad-brand); color: #fff; border-radius: 18px 6px 18px 18px; max-width: 86%; padding: 10px 14px; font-size: 14px; box-shadow: var(--sh-brand); white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-msg.bot .ai-avatar { width: 32px; height: 32px; border-radius: 11px; font-size: 17px; }
.ai-msg.bot .ai-avatar::after { display: none; }
.ai-msg.bot .bubble { flex: 1; min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 6px 18px 18px 18px; padding: 12px 14px; font-size: 14px; color: var(--text-2); box-shadow: var(--sh-sm); }
.bubble .ab-title { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); margin-bottom: 6px; line-height: 1.4; }
.bubble .ab-title i { color: var(--emerald); font-size: 18px; flex-shrink: 0; }
.bubble .ab-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.bubble ul { margin: 6px 0 0; padding-left: 20px; line-height: 1.75; }
.bubble .cite-ref { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; margin: 0 1px; border-radius: 6px; background: var(--indigo-soft); color: var(--indigo-ink); font-size: 11px; font-weight: 700; font-family: var(--font-num); vertical-align: 2px; cursor: pointer; border: 0; line-height: 1; }
.bubble .cite-ref:hover { background: var(--indigo); color: #fff; }
/* อ้างอิง inline จาก ai_answer_html() (ทีม Search) — pill ตัวยกสีแบรนด์ ใช้ได้ทุกที่ (ลิงก์ไป doc.php?id=X#page=N) */
a.ai-cite { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; margin: 0 1px 0 2px; border-radius: 9px; font-size: 11px; font-weight: 700; line-height: 1; font-family: var(--font-num); font-variant-numeric: tabular-nums; vertical-align: .32em; text-decoration: none; color: var(--brand-ink); background: var(--brand-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 28%, transparent); transition: background var(--dur-1), color var(--dur-1); }
a.ai-cite:hover, a.ai-cite:focus-visible { background: var(--brand); color: #fff; outline: none; }
a.ai-cite:active { transform: translateY(.5px); }
.bubble .ab-note { margin-top: 10px; font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; }
.bubble .ab-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 11.5px; color: var(--muted-2); flex-wrap: wrap; }
.cites { display: grid; gap: 8px; margin-top: 10px; }
.cite { display: flex; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); transition: var(--dur-2); text-align: left; }
.cite:hover { border-color: color-mix(in srgb, var(--indigo) 40%, transparent); background: var(--indigo-soft); color: var(--text-2); }
.cite .cn { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; background: var(--indigo); color: #fff; font-size: 12px; font-weight: 700; font-family: var(--font-num); flex-shrink: 0; }
.cite .cm { min-width: 0; flex: 1; }
.cite b { display: block; font-size: 13px; color: var(--ink); line-height: 1.4; }
.cite small { display: block; font-size: 11.5px; color: var(--muted); }
.cite p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cite.flash { animation: flash-bg 1.2s var(--ease); }
.ai-sug-head { display: flex; align-items: center; gap: 6px; padding: 12px 2px 6px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .01em; }
.ai-sug-head i { font-size: 15px; color: var(--indigo); }
.ai-sug-head.brief i { color: var(--amber); }
.ai-sug.brief i { color: var(--amber); }
.ai-sug.brief:hover { border-color: color-mix(in srgb, var(--amber) 45%, transparent); background: var(--amber-soft); color: var(--amber-ink); }
.ai-sug span { min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.45; }
.bubble .ab-lead { line-height: 1.7; overflow-wrap: anywhere; }
.bubble .ab-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.bubble .ab-mode { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: var(--amber-soft); color: var(--amber-ink); font-weight: 600; }
.ai-sub-mode { display: inline-flex; align-items: center; gap: 4px; }
.ai-compose { padding: 10px 12px; padding-bottom: calc(12px + var(--safe-b)); border-top: 1px solid var(--line); background: #fff; flex-shrink: 0; }
.ai-compose form { display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 14px; border: 1px solid var(--line-2); border-radius: 18px; background: var(--surface-2); transition: var(--dur-2); }
.ai-compose form:focus-within { border-color: var(--indigo); box-shadow: 0 0 0 4px rgba(79, 70, 229, .12); background: #fff; }
.ai-compose textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: none; resize: none; font-size: 14.5px; line-height: 1.5; max-height: 120px; padding: 7px 0; }
.ai-compose button { width: 38px; height: 38px; border-radius: 13px; border: 0; display: grid; place-items: center; color: #fff; background: var(--grad-ai); font-size: 18px; flex-shrink: 0; box-shadow: 0 6px 14px -6px rgba(79, 70, 229, .8); }
.ai-compose button:disabled { opacity: .45; }
.ai-compose .ai-disclaimer { font-size: 11px; color: var(--muted-2); text-align: center; margin-top: 6px; }

/* =====================================================================
   APPS LAUNCHER
   ===================================================================== */
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 18px 12px; }
.app-tile { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: var(--text-2); font-size: 13px; font-weight: 600; padding: 12px 6px; border-radius: 18px; transition: var(--dur-2) var(--ease); line-height: 1.35; }
.app-tile:hover { background: #fff; color: var(--ink); transform: translateY(-3px); box-shadow: var(--sh-md); }
.app-tile:active { transform: scale(.94); }
.app-icon { position: relative; width: 62px; height: 62px; border-radius: 19px; display: grid; place-items: center; font-size: 30px; color: #fff; background: linear-gradient(145deg, color-mix(in srgb, var(--tone) 72%, #fff), var(--tone) 55%, color-mix(in srgb, var(--tone) 72%, #000)); box-shadow: 0 12px 22px -12px var(--tone), inset 0 1px 0 rgba(255, 255, 255, .35); }
.app-icon::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(180deg, rgba(255, 255, 255, .26), transparent 50%); }
.app-icon .sb-count { position: absolute; top: -6px; right: -6px; z-index: 2; border: 2px solid var(--bg); }
.apps-section { background: #fff; border: 1px solid var(--line); border-radius: var(--r-xl); padding: 18px 18px 14px; box-shadow: var(--sh); }
.apps-section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.apps-section-head h3 { font-size: 16px; }
.apps-section-head .ico-tile { width: 34px; height: 34px; border-radius: 10px; font-size: 18px; }
.apps-section-head .as-count { margin-left: auto; font-size: 12.5px; color: var(--muted); }

/* =====================================================================
   KANBAN / CALENDAR
   ===================================================================== */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(236px, 1fr); gap: 16px; overflow-x: auto; padding-bottom: 8px; align-items: start; scroll-snap-type: x proximity; }
.kanban-col { background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px; min-height: 200px; scroll-snap-align: start; }
.kanban-col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px 10px; font-weight: 600; font-size: 14px; color: var(--ink); }
.kanban-col-head .dot { width: 9px; height: 9px; }
.kanban-col-head .count { font-family: var(--font-num); font-size: 12px; color: var(--muted); background: #fff; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--line); }
.kanban-list { display: flex; flex-direction: column; gap: 10px; min-height: 80px; }
.kanban-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--sh-xs); cursor: grab; transition: var(--dur-2); color: inherit; display: block; position: relative; }
.kanban-card::before { content: ''; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--tone); opacity: .9; }
.kanban-card:hover { box-shadow: var(--sh-md); transform: translateY(-1px); color: inherit; }
.kanban-card .kc-title { font-weight: 600; font-size: 14px; color: var(--ink); line-height: 1.45; }
.kanban-card .kc-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.kanban-card.sortable-ghost { opacity: .4; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-head { padding: 10px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.cal-day { min-height: 112px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); position: relative; min-width: 0; transition: background var(--dur-1); }
.cal-day:hover { background: color-mix(in srgb, var(--brand) 2.5%, white); }
.cal-day.other { background: var(--surface-2); color: var(--muted-2); }
.cal-day.holiday { background: repeating-linear-gradient(135deg, #fff, #fff 6px, var(--rose-soft) 6px, var(--rose-soft) 7px); }
.cal-day.weekend .d { color: var(--muted-2); }
.cal-day .d { font-size: 13px; font-weight: 600; font-family: var(--font-num); width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; }
.cal-day.today .d { background: var(--grad-brand); color: #fff; box-shadow: var(--sh-brand); }
.cal-ev { display: block; margin-top: 3px; padding: 2px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: var(--tone-soft); color: var(--tone-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--tone); }

/* =====================================================================
   FILE VIEWER / SIGNATURE (viewer.js · sign.js)
   ===================================================================== */
.viewer-root { position: fixed; inset: 0; z-index: 160; display: flex; flex-direction: column; background: rgba(6, 16, 22, .94); backdrop-filter: blur(10px); animation: fade-in .25s; color: #fff; }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-top: calc(12px + var(--safe-t)); background: rgba(0, 0, 0, .25); }
.viewer-bar .v-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-bar .v-name small { display: block; font-weight: 400; color: rgba(255, 255, 255, .6); }
.viewer-bar .icon-btn { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .12); color: #fff; box-shadow: none; }
.viewer-bar .icon-btn:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.viewer-stage { flex: 1; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 18px; position: relative; }
.viewer-stage.center { align-items: center; }
.viewer-stage img.v-img { max-width: none; transition: transform .2s var(--ease); cursor: grab; border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.viewer-stage iframe, .viewer-stage .v-doc { width: min(1000px, 100%); height: 100%; min-height: 70vh; border: 0; background: #fff; border-radius: 10px; }
.viewer-stage .v-doc { color: var(--text); overflow: auto; padding: 0; }
.viewer-stage .v-pages { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.viewer-stage .v-pages canvas { background: #fff; box-shadow: 0 16px 40px rgba(0, 0, 0, .5); border-radius: 4px; max-width: 100%; height: auto; }
.viewer-stage pre.v-text { width: min(1000px, 100%); background: #0f1f2e; color: #e2e8f0; padding: 20px; border-radius: 12px; white-space: pre-wrap; font-size: 13px; }
.viewer-stage .v-sheet { background: #fff; color: #0f1f2e; border-radius: 10px; overflow: auto; width: min(1200px, 100%); max-height: 100%; }
.viewer-stage .v-sheet table { border-collapse: collapse; font-size: 13px; }
.viewer-stage .v-sheet td, .viewer-stage .v-sheet th { border: 1px solid #e2e8f0; padding: 4px 8px; white-space: nowrap; }
.viewer-empty { text-align: center; color: rgba(255, 255, 255, .8); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.viewer-empty i { font-size: 72px; opacity: .8; }
.viewer-loading { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .2); border-top-color: #fff; animation: spin .8s linear infinite; }

.sigpad-wrap { user-select: none; -webkit-user-select: none; position: relative; border-radius: 16px; border: 2px dashed var(--line-2); background: repeating-linear-gradient(0deg, #fff, #fff 39px, #f1f5f9 40px); overflow: hidden; touch-action: none; }
.sigpad-wrap canvas { width: 100%; height: 220px; cursor: crosshair; display: block; }
.sigpad-wrap .sig-line { position: absolute; left: 24px; right: 24px; bottom: 44px; border-bottom: 1.5px solid #cbd5e1; pointer-events: none; }
.sigpad-wrap .sig-x { position: absolute; left: 20px; bottom: 50px; color: #94a3b8; font-size: 20px; pointer-events: none; }
.sig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.sig-item { position: relative; border: 2px solid var(--line); border-radius: 14px; padding: 10px; background: #fff; cursor: pointer; transition: var(--dur-2); }
.sig-item img { height: 80px; width: 100%; object-fit: contain; }
.sig-item:hover { border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
.sig-item.selected { border-color: var(--brand); box-shadow: var(--ring); }
.sig-item .sig-label { font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; }
.pen-colors { display: flex; gap: 8px; }
.pen-colors button { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line-2); }
.pen-colors button.active { box-shadow: 0 0 0 2px var(--brand); }

.signer-root { position: fixed; inset: 0; z-index: 170; display: flex; flex-direction: column; background: #e6ecf0; }
.signer-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-top: calc(12px + var(--safe-t)); background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--sh-sm); flex-wrap: wrap; }
.signer-bar .grow { min-width: 160px; }
.signer-stage { flex: 1; overflow: auto; padding: 24px 12px 120px; }
.signer-pages { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.signer-page { position: relative; background: #fff; box-shadow: 0 10px 30px rgba(15, 31, 46, .18); border-radius: 4px; }
.signer-page canvas, .signer-page img { display: block; width: 100%; height: auto; border-radius: 4px; }
.signer-stamp { position: absolute; border: 2px dashed var(--brand); background: color-mix(in srgb, var(--brand) 6%, transparent); border-radius: 6px; cursor: move; touch-action: none; user-select: none; }
.signer-stamp img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.signer-stamp .st-text { width: 100%; height: 100%; display: grid; place-items: center; font-size: 14px; color: #1e3a8a; pointer-events: none; white-space: nowrap; overflow: hidden; }
.signer-stamp .st-del { position: absolute; top: -12px; right: -12px; width: 26px; height: 26px; border-radius: 50%; background: var(--rose); color: #fff; border: 2px solid #fff; display: grid; place-items: center; font-size: 13px; }
.signer-stamp .st-resize { position: absolute; right: -8px; bottom: -8px; width: 20px; height: 20px; border-radius: 6px; background: var(--brand); border: 2px solid #fff; cursor: nwse-resize; touch-action: none; }
.signer-hint { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); background: #0f1f2e; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13.5px; box-shadow: var(--sh-lg); z-index: 2; display: flex; gap: 8px; align-items: center; white-space: nowrap; }

/* ---------- User picker ---------- */
.picker-list { max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: 14px; }
.picker-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background var(--dur-1); }
.picker-item:last-child { border-bottom: 0; }
.picker-item:hover { background: var(--surface-2); }
.picker-item.selected { background: var(--brand-soft); }
.picker-item .check-ico { margin-left: auto; font-size: 22px; color: var(--line-2); }
.picker-item.selected .check-ico { color: var(--brand); }
.picker-selected { display: flex; flex-wrap: wrap; gap: 6px; min-height: 10px; }
.picker-selected .chip { height: 30px; padding: 0 6px 0 4px; }
.picker-selected .chip button { border: 0; background: none; color: var(--muted); display: grid; place-items: center; padding: 0 2px; }

/* =====================================================================
   CHARTS (ApexCharts theme — App.chart)
   ===================================================================== */
.chart { min-height: 120px; }
.chart-lg { min-height: 340px; }
.apexcharts-tooltip.apexcharts-theme-light { border: 1px solid var(--line) !important; border-radius: 12px !important; box-shadow: var(--sh-lg) !important; background: rgba(255, 255, 255, .97) !important; backdrop-filter: blur(10px); }
.apexcharts-tooltip-title { background: var(--surface-2) !important; border-bottom: 1px solid var(--line) !important; font-family: var(--font) !important; font-weight: 600 !important; }
.apexcharts-text, .apexcharts-legend-text, .apexcharts-tooltip, .apexcharts-datalabel, .apexcharts-title-text { font-family: var(--font) !important; }
.apexcharts-legend-text { color: var(--text-2) !important; font-size: 13px !important; }
.apexcharts-xaxistooltip { border-radius: 8px !important; border-color: var(--line) !important; background: #fff !important; }
.apexcharts-menu { border-radius: 12px !important; border-color: var(--line) !important; box-shadow: var(--sh) !important; }
.apexcharts-datalabel-value { font-family: var(--font-num) !important; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--emerald-ink); padding: 3px 10px 3px 8px; border-radius: 999px; background: var(--emerald-soft); }
.live-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--emerald); animation: pulse-dot 1.6s infinite; color: var(--emerald); }
.flash-update { animation: flash-bg 1.2s var(--ease); }

/* ---------- Misc widgets ---------- */
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; color: var(--ink); }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.info-grid .info label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.info-grid .info div { font-weight: 500; overflow-wrap: anywhere; color: var(--ink); }
.profile-cover { position: relative; height: 128px; border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--grad-hero); overflow: hidden; }
.profile-cover::after { content: ''; position: absolute; inset: 0; background-image: var(--pattern); background-size: 52px; opacity: .14; mask-image: linear-gradient(90deg, transparent 10%, #000 70%); -webkit-mask-image: linear-gradient(90deg, transparent 10%, #000 70%); }
.profile-head { display: flex; align-items: flex-start; gap: 18px; padding: 0 24px 20px; position: relative; z-index: 1; flex-wrap: wrap; }
.profile-head > .avatar { margin-top: -56px; }
.profile-head > .grow, .profile-head > .ph-side { padding-top: 14px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); transition: var(--dur-2); min-width: 0; }
.file-row:hover { border-color: color-mix(in srgb, var(--brand) 35%, transparent); box-shadow: var(--sh-sm); }
.file-row .f-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--tone-soft); color: var(--tone); flex-shrink: 0; }
.file-row .f-main { flex: 1; min-width: 0; }
.file-row .f-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.file-row .f-meta { font-size: 12px; color: var(--muted); }
.file-thumb { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--surface-3); cursor: zoom-in; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s var(--ease); }
.file-thumb:hover img { transform: scale(1.05); }
.rank { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-size: 13px; font-weight: 800; font-family: var(--font-num); background: var(--surface-3); color: var(--muted); flex-shrink: 0; }
.rank.r1 { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #fff; }
.rank.r2 { background: linear-gradient(135deg, #e2e8f0, #94a3b8); color: #fff; }
.rank.r3 { background: linear-gradient(135deg, #fed7aa, #f97316); color: #fff; }
.qr-box { background: #fff; padding: 14px; border-radius: 18px; box-shadow: var(--sh); display: inline-block; }
.qr-box canvas, .qr-box img, .qr-box svg { width: 220px; height: 220px; image-rendering: pixelated; }
.scanner { position: relative; border-radius: 20px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; max-height: 70vh; margin: 0 auto; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .scan-frame { position: absolute; inset: 18%; border-radius: 20px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45); }
.scanner .scan-frame::before { content: ''; position: absolute; left: 6%; right: 6%; height: 2px; top: 10%; background: linear-gradient(90deg, transparent, #2dd4bf, transparent); box-shadow: 0 0 12px #2dd4bf; animation: scanline 2.2s ease-in-out infinite; }
.scanner .scan-frame::after { content: ''; position: absolute; inset: 0; border-radius: 20px; border: 3px solid rgba(255, 255, 255, .85); clip-path: polygon(0 0, 22% 0, 22% 4%, 4% 4%, 4% 22%, 0 22%, 0 78%, 4% 78%, 4% 96%, 22% 96%, 22% 100%, 78% 100%, 78% 96%, 96% 96%, 96% 78%, 100% 78%, 100% 22%, 96% 22%, 96% 4%, 78% 4%, 78% 0, 100% 0, 100% 100%, 0 100%); }

/* ---------- Error page ---------- */
.error-page { min-height: 62vh; display: grid; place-items: center; text-align: center; padding: 20px 0; }
.error-page .err-illus { width: 280px; max-width: 80%; margin: 0 auto 8px; }
.error-code { font-family: var(--font-num); font-size: 96px; font-weight: 800; line-height: 1; letter-spacing: -.05em; }
.error-page h2 { font-size: 24px; }
.error-page .err-detail { max-width: 520px; margin: 8px auto 0; }
.error-page .err-code-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 999px; background: var(--tone-soft); color: var(--tone-ink); font-family: var(--font-num); font-size: 13px; font-weight: 700; margin-bottom: 10px; }
/* error หลังเริ่มแสดงหน้า (render_error_page กลางหน้า) — กล่องเต็มความกว้างของเนื้อหา ไม่ซ้อน shell */
.error-page.error-inline { min-height: 0; width: 100%; grid-column: 1 / -1; margin: 18px 0; padding: 28px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-sm); }
.error-page.error-inline .err-illus { width: 180px; }

/* ---------- Print ---------- */
.print-only { display: none; }
.print-head { display: flex; align-items: center; gap: 16px; border-bottom: 2px solid #0f1f2e; padding-bottom: 12px; margin-bottom: 18px; }
.print-head.print-only { display: none; }
.print-head img { width: 64px; height: 64px; object-fit: contain; }

/* =====================================================================
   DASHBOARD COMPONENTS
   ===================================================================== */
.card-title small, .card-title .sub { font-size: 12.5px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.card-link { font-size: 13px; font-weight: 600; color: var(--brand); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.card-link:hover { color: var(--brand-ink); }
.card-link i { transition: transform var(--dur-2); }
.card-link:hover i { transform: translateX(2px); }
.pill-select { height: 32px; padding: 0 30px 0 12px; border-radius: 10px; border: 1px solid var(--line-2); font-size: 12.5px; font-weight: 600; color: var(--text-2); background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 256 256'%3E%3Cpath fill='%235d6e80' d='M213.66 101.66l-80 80a8 8 0 0 1-11.32 0l-80-80a8 8 0 0 1 11.32-11.32L128 164.69l74.34-74.35a8 8 0 0 1 11.32 11.32z'/%3E%3C/svg%3E") no-repeat right 10px center; appearance: none; -webkit-appearance: none; cursor: pointer; outline: none; }
.pill-select:focus { border-color: var(--brand); box-shadow: var(--ring); }

/* welcome banner (light, office illustration) */
.welcome { position: relative; overflow: hidden; border-radius: var(--r-xl); min-height: 150px; padding: 26px 32px; display: flex; flex-direction: column; justify-content: center;
  background: #eef7f6 var(--welcome-img, url(../img/banner-office.svg)) right center / cover no-repeat; border: 1px solid #d6ebe8; box-shadow: var(--sh-sm); }
.welcome::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, #eef7f6 0%, rgba(238, 247, 246, .94) 36%, rgba(238, 247, 246, .2) 60%, transparent 72%); pointer-events: none; }
.welcome > * { position: relative; }
.welcome .w-badge { width: 30px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: var(--grad-brand); color: #fff; font-size: 13px; margin-bottom: 10px; box-shadow: var(--sh-brand); }
.welcome h1 { font-size: 26px; font-weight: 700; color: var(--brand-ink); letter-spacing: -.015em; line-height: 1.3; max-width: 60%; }
.welcome p { margin: 6px 0 0; font-size: 15.5px; color: var(--text-2); max-width: 60%; }
.welcome p b { font-weight: 700; margin-right: 12px; }
.welcome .w-quote { position: absolute; right: 30px; top: 22px; max-width: 290px; text-align: right; font-style: italic; font-weight: 600; font-size: 15.5px; line-height: 1.5; color: var(--brand-ink); text-shadow: 0 1px 10px #fff, 0 0 2px #fff; }
.welcome .w-actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }

/* right-rail list */
.rail-list { display: flex; flex-direction: column; }
.rail-item { display: flex; gap: 12px; padding: 10px 0; color: inherit; border-bottom: 1px dashed var(--line); }
.rail-item:last-child { border-bottom: 0; }
.rail-item:hover { color: inherit; }
.rail-item:hover .rail-title { color: var(--brand); }
.rail-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; font-size: 20px; background: var(--tone-soft); color: var(--tone); }
.rail-title { font-size: 13.5px; font-weight: 600; color: var(--ink); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; transition: color var(--dur-2); }
.rail-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* mini calendar */
.mini-cal .mc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.mini-cal .mc-head b { font-size: 15px; color: var(--ink); }
.mini-cal .mc-nav { width: 30px; height: 30px; border-radius: 9px; border: 0; background: none; display: grid; place-items: center; color: var(--text-2); font-size: 16px; }
.mini-cal .mc-nav:hover { background: var(--brand-soft); color: var(--brand-ink); }
.mc-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px 0; text-align: center; }
.mc-dow { font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.mc-day { width: 32px; height: 32px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 500; color: var(--text-2); position: relative; font-family: var(--font-num); cursor: default; }
.mc-day.other { color: var(--line-3); }
.mc-day.has-ev::after { content: ''; position: absolute; bottom: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--ev, var(--brand)); }
.mc-day.today { background: var(--grad-brand); color: #fff; font-weight: 700; box-shadow: var(--sh-brand); }
.mc-day.today::after { background: #fff; }
.mc-day.event { background: linear-gradient(135deg, #818cf8, #4f46e5); color: #fff; }
.mc-day.event::after { background: #fff; }
.mc-day.holiday { color: var(--rose); font-weight: 700; }
.mc-day[data-tip] { cursor: pointer; }

/* legend list */
.legend-list { display: flex; flex-direction: column; gap: 11px; }
.legend-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; font-size: 13px; color: var(--text-2); }
.legend-row .sw { width: 10px; height: 10px; border-radius: 3px; background: var(--tone); }
.legend-row .lv { font-weight: 600; font-family: var(--font-num); text-align: right; white-space: nowrap; color: var(--ink); }
.legend-row .lp { color: var(--muted); font-family: var(--font-num); text-align: right; min-width: 46px; }

/* horizontal bars */
.hbars { display: flex; flex-direction: column; gap: 13px; }
.hbar { display: grid; grid-template-columns: 104px minmax(0, 1fr) 50px; gap: 12px; align-items: center; font-size: 13px; color: var(--text-2); }
.hbar-track { position: relative; height: 10px; border-radius: 6px; background: var(--surface-3); }
.hbar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, color-mix(in srgb, var(--tone) 65%, #fff), var(--tone)); width: 0; transition: width 1.2s var(--ease); }
.hbar-target { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 2px; background: var(--navy); opacity: .45; }
.hbar .hv { text-align: right; font-weight: 600; font-family: var(--font-num); font-size: 12.5px; color: var(--ink); }
.hbar-axis { display: grid; grid-template-columns: 104px minmax(0, 1fr) 50px; gap: 12px; font-size: 11px; color: var(--muted); font-family: var(--font-num); }
.hbar-axis div { display: flex; justify-content: space-between; }

/* tiles & mini stats */
.kpi-tile { position: relative; border-radius: 16px; padding: 14px 16px; background: var(--tone-soft); border: 1px solid color-mix(in srgb, var(--tone) 14%, transparent); min-width: 0; overflow: hidden; color: inherit; display: block; transition: var(--dur-2) var(--ease); }
a.kpi-tile:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -16px var(--tone); color: inherit; }
.kpi-tile .kt-top { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-2); font-weight: 600; line-height: 1.35; }
.kpi-tile .kt-ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: #fff; color: var(--tone); font-size: 20px; flex-shrink: 0; box-shadow: var(--sh-xs); }
.kpi-tile .kt-val { font-family: var(--font-num); font-size: 24px; font-weight: 750; color: var(--ink); margin-top: 8px; white-space: nowrap; letter-spacing: -.02em; }
.kpi-tile .kt-val small { font-size: 13px; font-weight: 500; color: var(--muted); font-family: var(--font); margin-left: 4px; letter-spacing: 0; }
.kpi-tile .kt-foot { font-size: 12px; margin-top: 2px; color: var(--muted); }
.kpi-tile.solid { background: linear-gradient(145deg, color-mix(in srgb, var(--tone) 85%, #000), var(--tone) 60%, color-mix(in srgb, var(--tone) 80%, #fff)); color: #fff; border-color: transparent; box-shadow: 0 14px 28px -18px var(--tone); }
.kpi-tile.solid .kt-top, .kpi-tile.solid .kt-foot, .kpi-tile.solid .kt-val small { color: rgba(255, 255, 255, .85); }
.kpi-tile.solid .kt-val { color: #fff; }
.kpi-tile.solid .kt-ico { background: rgba(255, 255, 255, .18); color: #fff; box-shadow: none; }
.mini-stat { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; }
.mini-stat .ms-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); font-size: 20px; flex-shrink: 0; }
.mini-stat .ms-label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-stat .ms-val { font-size: 15px; font-weight: 700; color: var(--ink); font-family: var(--font-num); }
.mini-stat .ms-val small { font-weight: 500; color: var(--muted); font-family: var(--font); margin-left: 3px; }
.stat-line { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-size: 13.5px; color: var(--text-2); border-bottom: 1px dashed var(--line); }
.stat-line:last-child { border-bottom: 0; }
.stat-line i { font-size: 18px; color: var(--tone); }
.stat-line b { margin-left: auto; font-family: var(--font-num); color: var(--ink); }

/* AI assistant (inline widget + shared avatar) */
.ai-box .ai-head { display: flex; align-items: center; gap: 12px; padding: 0; background: none; color: inherit; }
.ai-box .ai-head::before { display: none; }
.ai-avatar { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; font-size: 25px; color: #fff; background: var(--grad-ai); box-shadow: 0 10px 22px -12px #4f46e5; flex-shrink: 0; position: relative; }
.ai-avatar::after { content: ''; position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; background: #22c55e; border: 2px solid #fff; }
.ai-box .ai-head b { display: block; font-size: 15px; color: var(--ink); }
.ai-box .ai-head span { font-size: 12.5px; color: var(--muted); }
.ai-thread { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; max-height: 340px; overflow-y: auto; }
.ai-q { align-self: flex-end; max-width: 92%; background: var(--brand-soft); color: var(--brand-ink); border-radius: 14px 14px 4px 14px; padding: 10px 12px; font-size: 13px; }
.ai-a { background: #fff; border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 12px 14px; font-size: 13px; color: var(--text-2); }
.ai-a .ai-a-title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 6px; color: var(--ink); }
.ai-a .ai-a-title i { color: var(--emerald); font-size: 18px; }
.ai-a ul { margin: 0; padding-left: 18px; line-height: 1.75; }
.ai-typing { display: inline-flex; gap: 5px; padding: 12px 14px; align-items: center; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--indigo); opacity: .5; animation: ai-dot 1.2s infinite; }
.ai-typing i:nth-child(2) { animation-delay: .15s; } .ai-typing i:nth-child(3) { animation-delay: .3s; }
.ai-typing span { margin-left: 6px; font-size: 12.5px; color: var(--muted); }
@keyframes ai-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ai-suggest button { border: 1px solid var(--line-2); background: #fff; border-radius: 999px; padding: 5px 10px; font-size: 12px; color: var(--text-2); }
.ai-suggest button:hover { border-color: var(--indigo); color: var(--indigo-ink); }
.ai-input { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 4px 4px 4px 14px; border: 1px solid var(--line-2); border-radius: 999px; background: #fff; }
.ai-input input { flex: 1; border: 0; outline: 0; font-size: 13px; background: none; min-width: 0; height: 36px; }
.ai-input button { width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--grad-ai); color: #fff; font-size: 17px; flex-shrink: 0; }

/* dashboard grid: main + right rail */
.dash-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.dash-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.dash-rail { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* lifecycle strip (รับ → วิเคราะห์ → ... → ค้นคืนด้วย AI) */
.lifecycle { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.lifecycle .lc-step { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; background: var(--tone-soft, var(--brand-soft)); color: var(--tone-ink, var(--brand-ink)); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.lifecycle .lc-step i { font-size: 15px; }
.lifecycle .lc-arrow { color: var(--muted-2); font-size: 12px; display: inline-flex; justify-content: center; width: 12px; flex-shrink: 0; }
.lifecycle .lc-pair { display: inline-flex; align-items: center; gap: 6px; }
/* ลูกศรต้นบรรทัดถูกซ่อน: track เลื่อนซ้าย 18px (ลูกศร 12 + gap 6) แล้ว .lifecycle ตัดส่วนเกิน */
.lifecycle:has(> .lc-track) { display: block; overflow: hidden; }
.lifecycle .lc-track { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 6px; margin-left: -18px; }
.lifecycle .lc-track > .lc-step:first-child { margin-left: 18px; }

/* swipe rows (mobile list actions) */
.swipe-row { position: relative; overflow: hidden; touch-action: pan-y; }
.swipe-row > .swipe-content { position: relative; z-index: 1; background: var(--surface); transition: transform var(--dur-3) var(--ease-out); will-change: transform; }
.swipe-row.dragging > .swipe-content { transition: none; }
.swipe-bg { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 22px; color: #fff; font-weight: 600; font-size: 13.5px; gap: 8px; }
.swipe-bg i { font-size: 22px; transition: transform var(--dur-2) var(--ease-spring); }
.swipe-bg.left { justify-content: flex-start; background: var(--tone, var(--emerald)); }
.swipe-bg.right { justify-content: flex-end; background: var(--tone, var(--indigo)); }
.swipe-row.armed .swipe-bg i { transform: scale(1.25); }
.swipe-actions { display: none; }
@media (hover: hover) and (pointer: fine) {
  .swipe-row .swipe-actions { display: flex; gap: 4px; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); z-index: 2; opacity: 0; transition: opacity var(--dur-2); }
  .swipe-row:hover .swipe-actions, .swipe-row:focus-within .swipe-actions { opacity: 1; }
}

/* pull to refresh (ปิด overscroll ของเบราว์เซอร์บนหน้าที่มี data-ptr กันรีเฟรชซ้อน) */
html:has(main[data-ptr]) { overscroll-behavior-y: contain; }
.ptr-indicator { position: fixed; z-index: 45; left: 50%; top: calc(var(--topbar-h) + var(--safe-t) - 44px); width: 40px; height: 40px; margin-left: -20px; border-radius: 50%; background: #fff; box-shadow: var(--sh-md); display: grid; place-items: center; color: var(--brand); font-size: 20px; opacity: 0; transform: translateY(0); pointer-events: none; }
.ptr-indicator.armed i { transform: rotate(180deg); }
.ptr-indicator i { transition: transform var(--dur-2); }
.ptr-indicator.loading i { animation: spin .8s linear infinite; }

/* navigation progress + skeleton overlay */
.nav-progress { position: fixed; z-index: 400; left: 0; top: 0; height: 3px; width: 0; background: linear-gradient(90deg, #2dd4bf, var(--brand-2)); box-shadow: 0 0 10px rgba(45, 212, 191, .7); opacity: 0; pointer-events: none; }
body.navigating .nav-progress { opacity: 1; width: 82%; transition: width 4s cubic-bezier(.1, .7, .2, 1), opacity .2s; }
.nav-skeleton { display: none; }

/* install banner / splash */
.install-banner { position: fixed; z-index: 90; left: 50%; bottom: 20px; transform: translate(-50%, 140%); width: min(460px, calc(100vw - 24px)); display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-radius: 20px; background: #0f1f2e; color: #fff; box-shadow: var(--sh-xl); transition: transform .5s var(--ease-out); }
.install-banner.show { transform: translate(-50%, 0); }
.install-banner img { width: 44px; height: 44px; border-radius: 12px; background: #fff; padding: 3px; flex-shrink: 0; }
.install-banner .ib-text { flex: 1; min-width: 0; line-height: 1.35; }
.install-banner b { display: block; font-size: 14px; }
.install-banner span { display: block; font-size: 12px; color: rgba(255, 255, 255, .7); }
.install-banner .btn-sm { flex-shrink: 0; }
.install-banner .ib-x { border: 0; background: none; color: rgba(255, 255, 255, .6); font-size: 18px; padding: 4px; }
.splash { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; background: var(--grad-side); color: #fff; transition: opacity .45s var(--ease), visibility 0s .45s; }
.splash.hide { opacity: 0; visibility: hidden; }
.splash::before { content: ''; position: absolute; inset: 0; background-image: var(--pattern); background-size: 56px; opacity: .06; }
.splash > div { position: relative; text-align: center; animation: fade-up .5s var(--ease-out); }
.splash img { width: 84px; height: 84px; border-radius: 24px; background: #fff; padding: 6px; margin: 0 auto 14px; box-shadow: 0 20px 40px -16px rgba(0, 0, 0, .6); }
.splash b { display: block; font-size: 20px; }
.splash span { font-size: 13px; color: rgba(204, 251, 241, .8); }


/* =====================================================================
   ANIMATIONS
   ===================================================================== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.975); } to { opacity: 1; transform: none; } }
@keyframes modal-out { to { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: none; } }
@keyframes drawer-out { to { transform: translateX(100%); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px) scale(.96); } }
@keyframes toast-bar { from { width: 100%; } to { width: 0; } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes pulse-dot { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 4px var(--surface), 0 0 0 4px color-mix(in srgb, var(--tone) 45%, transparent); } 70% { box-shadow: 0 0 0 4px var(--surface), 0 0 0 14px transparent; } 100% { box-shadow: 0 0 0 4px var(--surface), 0 0 0 4px transparent; } }
@keyframes bell { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(9deg); } 60% { transform: rotate(-6deg); } 75% { transform: rotate(3deg); } }
@keyframes flash-bg { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 40%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
@keyframes scanline { 0%, 100% { top: 10%; } 50% { top: 88%; } }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes spark-draw { to { stroke-dashoffset: 0; } }

.anim-in > * { animation: fade-up .5s var(--ease-out) both; }
.anim-in > *:nth-child(1) { animation-delay: .02s; } .anim-in > *:nth-child(2) { animation-delay: .06s; } .anim-in > *:nth-child(3) { animation-delay: .1s; }
.anim-in > *:nth-child(4) { animation-delay: .14s; } .anim-in > *:nth-child(5) { animation-delay: .18s; } .anim-in > *:nth-child(6) { animation-delay: .22s; }
.anim-in > *:nth-child(7) { animation-delay: .26s; } .anim-in > *:nth-child(8) { animation-delay: .3s; } .anim-in > *:nth-child(n+9) { animation-delay: .34s; }

@view-transition { navigation: auto; }
::view-transition-old(root) { animation: .16s var(--ease) both vt-out; }
::view-transition-new(root) { animation: .3s var(--ease-out) both vt-in; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-4px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }
::view-transition-group(sidebar), ::view-transition-group(topbar), ::view-transition-group(tabbar) { animation: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .tb-ai::after { display: none; }
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 1440px) {
  .g-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1400px) {
  .tb-user-text { display: none; }
  .tb-user .ph-caret-down { display: none; }
  .tb-search-wrap { flex-basis: 380px; }
}
@media (max-width: 1240px) {
  .tb-ai span { display: none; }
  .tb-ai { width: 38px; padding: 0; justify-content: center; }
}
@media (max-width: 1180px) {
  .kpi-row.n-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-row.n-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tb-search-wrap { flex-basis: 260px; min-width: 170px; }
  .tb-search kbd { display: none; }
  .tb-search { padding-right: 46px; }
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-sidebar { grid-template-columns: minmax(0, 1fr) 320px; }
  .page { padding: 22px 24px 36px; }
  .topbar { padding: 0 20px 0 14px; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); }
  .hero-date { text-align: left; }
}
@media (max-width: 1100px) {
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-sidebar, .g-sidebar-l { grid-template-columns: minmax(0, 1fr); }
  .g-12 > [class*='span-'] { grid-column: 1 / -1; }
  .dash-layout { grid-template-columns: minmax(0, 1fr); }
}

/* ----- Mobile / Tablet: native app mode ----- */
@media (max-width: 1023px) {
  body { font-size: 15px; }
  .app-main, body.sb-collapsed .app-main { margin-left: 0; }
  .sidebar, body.sb-collapsed .sidebar { width: min(316px, 86vw); transform: translateX(-104%); box-shadow: var(--sh-xl); padding-top: var(--safe-t); }
  body.sb-open .sidebar { transform: none; }
  body.sb-open .sb-backdrop { opacity: 1; pointer-events: auto; }
  body.sb-collapsed .sb-brand-text, body.sb-collapsed .sb-label, body.sb-collapsed .sb-caret, body.sb-collapsed .sb-count, body.sb-collapsed .sf-main, body.sb-collapsed .sf-ico { display: revert; }
  body.sb-collapsed .sb-section { font-size: 11.5px; padding: 18px 12px 6px; }
  body.sb-collapsed .sb-group-items { display: grid; }
  body.sb-collapsed .sb-link, body.sb-collapsed .sb-group-btn { justify-content: flex-start; padding: 8px 12px; }
  body.sb-collapsed .sb-brand { justify-content: flex-start; padding-inline: 18px; }
  body.sb-collapsed .sb-footcard { justify-content: flex-start; padding: 11px 12px; background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .08); }
  .sb-collapse { display: none; }
  .sb-link, .sb-group-btn { min-height: 46px; }
  .sb-sub { min-height: 42px; }

  .topbar { height: calc(58px + var(--safe-t)); padding: var(--safe-t) 10px 0; gap: 4px; background: rgba(255, 255, 255, .97); backdrop-filter: none; -webkit-backdrop-filter: none; }
  body.notif-open .topbar { z-index: 95; }
  body.notif-open .tabbar { visibility: hidden; }
  .topbar .tb-menu { display: inline-grid; }
  .topbar.has-back .tb-menu { display: none; }
  .topbar.has-back .tb-back { display: inline-grid; }
  .tb-title { display: block; flex: 1; min-width: 0; }
  .tb-mobile-title { display: block; transition: opacity var(--dur-2), transform var(--dur-2); }
  body.has-large-title:not(.title-collapsed) .tb-mobile-title { opacity: 0; transform: translateY(6px); }
  .tb-search-wrap, .tb-search, .lang-switch.hide-m, .lang-btn, .tb-user-text, .tb-hide-m, .tb-user .ph-caret-down, .tb-divider, .tb-ai, .tb-qr-d { display: none !important; }
  .tb-search-m { display: inline-grid !important; }
  .tb-user { padding: 2px; height: 42px; border-radius: 50%; margin-left: 2px; }
  .tb-user .avatar { --av: 34px; }
  .icon-btn { width: 42px; height: 42px; border-radius: 12px; font-size: 21px; }
  .icon-btn .dot { top: 2px; left: calc(50% - 1px); right: auto; }
  .topbar #notif-dd { margin-right: 6px; }
  .user-menu { position: fixed; top: calc(62px + var(--safe-t)); right: 10px; left: auto; width: min(320px, calc(100vw - 20px)); }

  .welcome { padding: 20px; min-height: 130px; background-position: 70% center; }
  .welcome h1 { font-size: 20px; max-width: 100%; }
  .welcome p { font-size: 13.5px; max-width: 100%; }
  .welcome .w-quote { display: none; }
  .welcome::before { background: linear-gradient(90deg, rgba(238, 247, 246, .97) 0%, rgba(238, 247, 246, .85) 60%, rgba(238, 247, 246, .4) 100%); }
  .stat { padding: 15px; gap: 12px; min-height: 0; }
  .stat-ico { width: 44px; height: 44px; font-size: 22px; border-radius: 13px; }
  .stat-deco { display: none; }
  .stat-label { font-size: 12.5px; -webkit-line-clamp: 2; }
  .hbar, .hbar-axis { grid-template-columns: 84px minmax(0, 1fr) 44px; }

  .page { padding: 14px 14px calc(var(--tabbar-h) + var(--safe-b) + 28px); padding-left: calc(14px + var(--safe-l)); padding-right: calc(14px + var(--safe-r)); }
  .app-footer { display: none; }
  .page-head { margin-bottom: 16px; align-items: flex-start; gap: 12px; }
  .page-head h1 { font-size: 26px; gap: 12px; letter-spacing: -.015em; }
  .page-head .ph-title-ico { width: 40px; height: 40px; font-size: 21px; border-radius: 12px; }
  .page-head p { font-size: 13.5px; }
  .page-crumbs { display: none; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }

  .tabbar {
    display: flex; position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + var(--safe-b)); padding: 6px 8px var(--safe-b);
    background: rgba(255, 255, 255, .94); backdrop-filter: blur(22px) saturate(1.8); -webkit-backdrop-filter: blur(22px) saturate(1.8);
    border-top: 1px solid var(--line); box-shadow: 0 -10px 30px -18px rgba(8, 28, 40, .35); view-transition-name: tabbar;
  }
  .tabbar a, .tabbar .tab-fab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 16px; color: var(--muted); font-size: 11px; font-weight: 600; position: relative; transition: color var(--dur-2); min-width: 0; border: 0; background: none; padding: 0; }
  .tabbar a > span:not(.tab-badge) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .tabbar a i { font-size: 24px; transition: transform var(--dur-3) var(--ease-spring); }
  .tabbar a.active { color: var(--brand-ink); }
  .tabbar a.active::before { content: ''; position: absolute; top: -6px; left: 50%; width: 28px; height: 3px; margin-left: -14px; border-radius: 0 0 3px 3px; background: var(--grad-brand); }
  .tabbar a.active i { transform: translateY(-1px) scale(1.06); color: var(--brand); }
  .tabbar a:active i { transform: scale(.86); }
  .tabbar .tab-badge { position: absolute; top: 0; left: calc(50% + 5px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--rose); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; font-family: var(--font-num); line-height: 1; }
  .tabbar .tab-fab { flex: 0 0 70px; }
  .tabbar .tab-fab span.fab { width: 56px; height: 56px; margin-top: -30px; border-radius: 20px; display: grid; place-items: center; color: #fff; background: var(--grad-hero); box-shadow: 0 12px 24px -10px color-mix(in srgb, var(--brand) 90%, #000), 0 0 0 5px var(--bg), inset 0 1px 0 rgba(255, 255, 255, .3); transition: transform var(--dur-3) var(--ease-spring); }
  .tabbar .tab-fab span.fab i { font-size: 27px; transition: transform var(--dur-3) var(--ease-spring); }
  .tabbar .tab-fab:active span.fab { transform: scale(.9); }
  .tabbar .tab-fab.open span.fab i { transform: rotate(45deg); }
  .tabbar .tab-fab > small { font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 2px; }

  #toasts { top: calc(8px + var(--safe-t)); right: 10px; left: 10px; width: auto; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(-24px) scale(.96); } to { opacity: 1; transform: none; } }
  @keyframes toast-out { to { opacity: 0; transform: translateY(-24px) scale(.96); } }

  /* Sheets instead of modals */
  .modal-root { align-items: flex-end; padding: 0; }
  .modal, .modal.sm, .modal.lg, .modal.xl { max-width: none; width: 100%; max-height: 92dvh; border-radius: 26px 26px 0 0; animation: sheet-in .4s var(--ease-out); padding-bottom: var(--safe-b); }
  .modal.full { width: 100%; height: 100dvh; border-radius: 0; }
  .modal-root.closing .modal { animation: sheet-out .25s var(--ease) forwards; }
  .sheet-handle { display: block; width: 42px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 10px auto 0; flex-shrink: 0; }
  .modal-head { padding: 12px 18px 10px; }
  .modal-body { padding: 4px 18px 18px; }
  .modal-foot { padding: 12px 18px; }
  .modal-foot .btn { flex: 1; }
  .as-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer { width: 100vw; }
  .drawer.as-sheet { top: auto; height: 100dvh; animation: sheet-in .4s var(--ease-out); }
  .drawer-root.closing .drawer.as-sheet { animation: sheet-out .25s var(--ease) forwards; }
  .cmdk-root { padding: calc(8px + var(--safe-t)) 8px 8px; align-items: stretch; }
  .cmdk { max-height: none; height: 100%; border-radius: 20px; }
  .cmdk-input .cmdk-x { display: grid; }
  .cmdk-input kbd, .cmdk-foot { display: none; }

  /* notification center → full screen sheet */
  .notif-panel { position: fixed; inset: 0; top: 0; width: auto; max-width: none; max-height: none; border-radius: 0; padding-top: var(--safe-t); background: var(--surface); transform: translateY(24px); }
  .dropdown.open > .notif-panel { transform: none; }
  .notif-list { max-height: none; }
  .notif-foot { padding-bottom: calc(10px + var(--safe-b)); }
  .notif-head { padding: 12px 10px 8px 16px; }
  .notif-head .nh-close { display: inline-grid !important; }

  .grid { gap: 12px; }
  .g-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .g-4, .g-5, .g-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2.keep-m { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2, .span-3, .span-4 { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .form-grid > .field, .form-grid > .field[class*='col-'] { grid-column: 1 / -1; }
  .form-actions { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); z-index: 5; background: var(--glass-strong); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); padding: 10px; border-radius: 18px; box-shadow: var(--sh-lg); border: 1px solid var(--line); }
  .form-actions .btn { flex: 1; }
  .card { border-radius: 18px; }
  .card-head { padding: 16px 16px 0; }
  .card-body { padding: 14px 16px 18px; }
  .card-foot { padding: 12px 16px; border-radius: 0 0 18px 18px; }
  .list-item { padding: 12px 16px; min-height: 56px; }
  .stat-value { font-size: 24px; }
  .hero { padding: 20px 18px; border-radius: 22px; }
  .hero h1 { font-size: 22px; }
  .hero-illus { display: none; }
  .hero-stats { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { gap: 8px; }
  .filters .input-group { max-width: none; min-width: 100%; }
  .filters .select, .filters .input { flex: 1; min-width: 0; }
  .toolbar { padding: 12px 14px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dt { margin-top: 10px; font-size: 12.5px; }
  .input, .select { height: 48px; font-size: 16px; }
  .textarea { font-size: 16px; }
  .btn { height: 46px; }
  .btn-sm { height: 38px; }
  .btn-xs { height: 32px; }
  .btn-icon { width: 46px; } .btn-icon.btn-sm { width: 38px; } .btn-icon.btn-xs { width: 32px; }
  .tabs a, .tabs button { padding: 12px 12px; min-height: 46px; }
  .pills a, .pills button { height: 40px; }
  .segmented a, .segmented button, .segmented label { min-height: 38px; }
  .chip { height: 36px; }
  .menu a, .menu button { min-height: 46px; }
  .hide-mobile { display: none !important; }
  .show-mobile { display: revert !important; }
  .segmented.show-mobile, .row.show-mobile, .chips.show-mobile, .row-between.show-mobile, .pills.show-mobile, .tabs.show-mobile { display: flex !important; }
  .grid.show-mobile, .kpi-row.show-mobile { display: grid !important; }
  .kpi-row, .kpi-row[class*="n-"] { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .hero-grid > * { align-items: flex-start !important; }
  .hero .hero-date { text-align: left; }
  .hero-actions { gap: 6px; }
  .hero-actions .btn { height: 40px; padding: 0 14px; font-size: 13.5px; }
  .hero .hero-kicker { margin-bottom: 6px; }
  .hero .chip { white-space: normal; height: auto; min-height: 32px; padding: 6px 12px; line-height: 1.35; }
  .profile-head { padding: 0 16px 16px; gap: 10px; }
  .profile-head { flex-direction: column; align-items: flex-start; }
  .profile-head > .avatar { --av: 88px; margin-top: -44px; }
  .profile-head > .grow { padding-top: 0; min-width: 0 !important; width: 100%; }
  .btn.show-mobile, .chip.show-mobile, .badge.show-mobile { display: inline-flex !important; }
  .cal-day { min-height: 70px; padding: 3px; }
  .cal-ev { font-size: 10px; padding: 1px 4px; }
  .apps-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 4px; }
  .app-icon { width: 56px; height: 56px; border-radius: 17px; font-size: 27px; }
  .app-tile { font-size: 11.5px; padding: 6px 0; gap: 8px; }
  .app-tile:hover { background: none; box-shadow: none; transform: none; }
  .apps-section { padding: 14px 10px 10px; border-radius: 20px; }
  .steps { overflow-x: auto; padding-bottom: 4px; }
  .step { min-width: 90px; }
  .error-code { font-size: 72px; }
  .kanban { grid-auto-columns: 84%; }

  /* Table → stacked cards */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table-stack tbody tr:hover { background: none; }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; min-height: 0; }
  .table-stack td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 500; text-align: left; flex-shrink: 0; }
  .table-stack td[data-label=''], .table-stack td:not([data-label]) { display: block; text-align: left; }
  .table-stack td[data-label='']::before, .table-stack td:not([data-label])::before { display: none; }
  .table-stack td.actions { width: 100%; justify-content: flex-end; padding-top: 10px; }
  .table-stack td.primary { font-size: 15px; padding-bottom: 6px; }
  .table-stack td .cell-user { text-align: left; }

  /* skeleton overlay while navigating (mobile) */
  body.navigating.nav-slow .page > * { opacity: 0; }
  body.navigating.nav-slow .nav-skeleton { display: block; position: fixed; z-index: 30; left: 0; right: 0; top: calc(58px + var(--safe-t)); bottom: 0; padding: 16px 14px; background: var(--bg); }
  .install-banner { bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); }
}
@media (max-width: 480px) {
  .g-4.m-1, .g-5.m-1, .g-6.m-1 { grid-template-columns: minmax(0, 1fr); }
  .stat-value { font-size: 22px; }
  .page-head h1 { font-size: 24px; }
  .hero h1, .hero h2 { font-size: 21px; }
}
@media (hover: none) {
  .btn:hover, .card-hover:hover, a.card:hover, .icon-btn:hover, a.kpi-tile:hover { transform: none; }
}
@media (display-mode: standalone) {
  .topbar { padding-top: var(--safe-t); }
}

@media print {
  body { background: #fff; font-size: 12pt; }
  .sidebar, .topbar, .tabbar, .app-footer, .page-actions, .no-print, .filters, .pager, #toasts, .app-bg, .sb-backdrop, .nav-progress, .install-banner, .ptr-indicator { display: none !important; }
  .app-main { margin: 0 !important; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .hero { color: #000; background: none; border: 1px solid #ddd; box-shadow: none; }
  .hero::before, .hero::after { display: none; }
  .hero h1, .hero h2, .hero p { color: #000; }
  .print-only { display: block; }
  .print-head.print-only { display: flex; }
  a { color: inherit; }
  @page { size: A4; margin: 14mm; }
}

/* KPI card auto-fit (container queries — วางท้ายไฟล์ให้ชนะกฎ responsive) */
@container (max-width: 340px) { .stat-deco { display: none; } }
@container (max-width: 260px) { .stat-ico { width: 44px; height: 44px; font-size: 22px; border-radius: 13px; } .stat-value { font-size: 23px; } }
@container (max-width: 215px) { .stat-ico { width: 40px; height: 40px; font-size: 20px; border-radius: 12px; } .stat-value { font-size: 22px; } .stat-value small { font-size: 12.5px; } .stat-label { font-size: 12.5px; } }
@media (max-width: 1023px) {
  .kpi-row > .stat { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
  .kpi-row > .stat .stat-value { margin-top: 2px; }
  .kpi-row > .stat::before { right: -90px; top: -110px; }
}

/* ---------- All-in-one (โปรไฟล์องค์กร — CONVENTIONS §22) ---------- */
.hero-kickers { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-kickers .hero-kicker { margin-bottom: 10px; }
.hero-kicker.hero-org { background: rgba(255, 255, 255, .2); }
.hero-kicker.hero-org i { color: #a5f3fc; }
@media (max-width: 1023px) { .hero-kickers .hero-kicker { margin-bottom: 6px; } }
