/* =====================================================================
   EduNexus Design System — Modern SaaS, light theme, colorful
   Fonts: Anuphan (Thai/Latin) + Plus Jakarta Sans (numbers/display)
   Icons: Phosphor (ph / ph-duotone / ph-fill / ph-bold)
   ===================================================================== */

/* ---------- Fonts (local, variable) ---------- */
@font-face { font-family: 'Anuphan'; font-style: normal; font-display: swap; font-weight: 100 700;
  src: url(../vendor/fonts/anuphan-thai-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Anuphan'; font-style: normal; font-display: swap; font-weight: 100 700;
  src: url(../vendor/fonts/anuphan-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Anuphan'; font-style: normal; font-display: swap; font-weight: 100 700;
  src: url(../vendor/fonts/anuphan-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; }
@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: #2563eb;
  --brand-2: #3b82f6;
  --brand-soft: color-mix(in srgb, var(--brand) 10%, white);
  --brand-ink: color-mix(in srgb, var(--brand) 80%, black);
  --grad-brand: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);

  --bg: #f4f7fc;
  --bg-2: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --glass: rgba(255, 255, 255, .72);
  --glass-strong: rgba(255, 255, 255, .88);
  --line: #e8edf5;
  --line-2: #dbe3ee;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --white: #fff;

  /* tones */
  --indigo: #4f46e5;  --indigo-soft: #eef0ff;  --indigo-ink: #3730a3;
  --violet: #7c3aed;  --violet-soft: #f3edff;  --violet-ink: #5b21b6;
  --purple: #9333ea;  --purple-soft: #f6edff;  --purple-ink: #6b21a8;
  --fuchsia: #c026d3; --fuchsia-soft: #fbeafe; --fuchsia-ink: #86198f;
  --pink: #ec4899;    --pink-soft: #fdebf4;    --pink-ink: #9d174d;
  --rose: #f43f5e;    --rose-soft: #ffe9ec;    --rose-ink: #9f1239;
  --red: #ef4444;     --red-soft: #fee9e9;     --red-ink: #991b1b;
  --orange: #f97316;  --orange-soft: #fff0e5;  --orange-ink: #9a3412;
  --amber: #f59e0b;   --amber-soft: #fff5dc;   --amber-ink: #92400e;
  --yellow: #eab308;  --yellow-soft: #fef9d7;  --yellow-ink: #854d0e;
  --lime: #65a30d;    --lime-soft: #f0f9dc;    --lime-ink: #3f6212;
  --green: #22c55e;   --green-soft: #e5f9ec;   --green-ink: #166534;
  --emerald: #10b981; --emerald-soft: #e2f8f0; --emerald-ink: #065f46;
  --teal: #14b8a6;    --teal-soft: #e0f7f4;    --teal-ink: #115e59;
  --cyan: #06b6d4;    --cyan-soft: #e0f7fb;    --cyan-ink: #155e75;
  --sky: #0ea5e9;     --sky-soft: #e3f4fd;     --sky-ink: #075985;
  --blue: #3b82f6;    --blue-soft: #e8f0fe;    --blue-ink: #1e40af;
  --slate: #64748b;   --slate-soft: #eef2f6;   --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);

  --r-xs: 6px; --r-sm: 10px; --r: 14px; --r-lg: 20px; --r-xl: 26px; --r-2xl: 32px; --r-full: 999px;
  --sh-xs: 0 1px 2px rgba(15, 23, 42, .06);
  --sh-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 2px 8px -2px rgba(15, 23, 42, .06);
  --sh: 0 1px 2px rgba(15, 23, 42, .03), 0 6px 20px -12px rgba(30, 64, 120, .14);
  --sh-lg: 0 2px 6px rgba(15, 23, 42, .05), 0 22px 48px -18px rgba(15, 23, 42, .22);
  --sh-xl: 0 30px 80px -20px rgba(15, 23, 42, .35);
  --sh-brand: 0 10px 24px -10px color-mix(in srgb, var(--brand) 70%, transparent);
  --ring: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);

  --font: 'Anuphan', 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-num: 'Jakarta', 'Anuphan', system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  --sidebar-w: 244px;
  --sidebar-w-collapsed: 84px;
  --topbar-h: 68px;
  --tabbar-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 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-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); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.6; 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;
}
img, svg, video, canvas { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-ink); }
h1, h2, h3, h4, h5 { margin: 0; line-height: 1.3; letter-spacing: -.01em; color: var(--text); }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 650; }
h3 { font-size: 17px; font-weight: 650; }
h4 { font-size: 15px; font-weight: 650; }
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) 22%, transparent); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
[x-cloak] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, .28); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, .45); border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: rgba(100, 116, 139, .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; }

/* ---------- Aurora background ---------- */
.app-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: var(--bg); }
.app-bg::before, .app-bg::after, .app-bg i {
  display: none; content: ''; position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55;
}
.app-bg::before { width: 620px; height: 620px; top: -220px; right: -120px; background: radial-gradient(circle, color-mix(in srgb, var(--brand) 38%, transparent), transparent 65%); }
.app-bg::after { width: 520px; height: 520px; bottom: -200px; left: 12%; background: radial-gradient(circle, rgba(236, 72, 153, .20), transparent 65%); }
.app-bg i { width: 460px; height: 460px; top: 30%; left: -160px; background: radial-gradient(circle, rgba(6, 182, 212, .22), transparent 65%); }
.app-bg .grid-dots { display: none; position: absolute; inset: 0; background-image: radial-gradient(rgba(15, 23, 42, .045) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(to bottom, #000 0%, transparent 60%); }

/* =====================================================================
   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 .35s 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: 18px 32px 26px; color: var(--muted-2); font-size: 12.5px; display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; }

/* ---------- Sidebar (official style: white, flat list, blue active pill) ---------- */
.sidebar {
  position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: var(--sidebar-w);
  display: flex; flex-direction: column; background: #fff;
  border-right: 1px solid var(--line); transition: width .35s var(--ease), transform .35s var(--ease);
  view-transition-name: sidebar;
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px; min-height: var(--topbar-h); color: inherit; }
.sb-brand:hover { color: inherit; }
.sb-logo { width: 46px; height: 50px; flex-shrink: 0; object-fit: contain; }
.sb-brand-text { min-width: 0; line-height: 1.25; }
.sb-brand-text b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14.5px; font-weight: 700; color: #0f2a5f; line-height: 1.3; }
.sb-brand-text span { display: block; font-size: 11.5px; color: var(--brand-ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-brand-text em { display: block; font-size: 10.5px; color: var(--muted); font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.sb-search { display: none; }
.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 12px 12px; overscroll-behavior: contain; }
.sb-section { font-size: 12px; font-weight: 600; color: var(--muted); padding: 18px 12px 6px; white-space: nowrap; border-top: 1px solid var(--line); margin-top: 10px; }
.sb-link, .sb-group-btn {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; margin: 3px 0;
  border-radius: 11px; color: #1f2d4d; font-size: 14px; font-weight: 500; border: 0; background: none; text-align: left;
  transition: background .2s, color .2s; white-space: nowrap;
}
.sb-link:hover, .sb-group-btn:hover { background: #f1f5fd; color: var(--brand-ink); }
.sb-ico { width: 24px; height: 24px; display: grid; place-items: center; flex-shrink: 0; font-size: 21px; color: var(--brand); background: none; transition: .2s; }
.sb-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sb-caret { font-size: 13px; color: #94a3b8; transition: transform .25s var(--ease); }
.sb-group.open > .sb-group-btn .sb-caret { transform: rotate(90deg); color: var(--brand); }
.sb-group-items { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s 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; padding: 7px 10px 7px 16px; margin: 1px 0 1px 23px; border-radius: 9px;
  font-size: 13.5px; color: #475569; position: relative; white-space: nowrap; border-left: 1.5px solid #e2e8f0; border-radius: 0 9px 9px 0;
}
.sb-sub::before { content: ''; position: absolute; left: -4.5px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: #cbd5e1; transition: .2s; }
.sb-sub:hover { color: var(--brand-ink); background: #f5f8fe; }
.sb-sub.active { color: var(--brand); font-weight: 600; background: var(--brand-soft); }
.sb-sub.active::before { background: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.sb-sub i { font-size: 16px; opacity: .85; }
.sb-link.active { background: var(--grad-brand); color: #fff; box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--brand) 80%, transparent); }
.sb-link.active .sb-ico { color: #fff; }
.sb-group.has-active > .sb-group-btn { color: var(--brand-ink); font-weight: 600; background: #f3f7ff; }
.sb-link.sm { padding: 8px 12px; margin: 1px 0; font-size: 13.5px; color: #334155; }
.sb-link.sm .sb-ico { font-size: 18px; color: #64748b; }
.sb-link.sm.active .sb-ico { color: #fff; }
.sb-link.sm:hover .sb-ico { color: var(--brand); }
.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: #ef4444; color: #fff; font-family: var(--font-num); }
.sb-link.active .sb-count { background: #fff; color: var(--brand); }
.sb-foot { position: relative; padding: 0; overflow: hidden; flex-shrink: 0; }
.sb-tagline { padding: 10px 22px 0; line-height: 1.25; position: relative; z-index: 1; }
.sb-tagline b { display: block; font-size: 13px; font-weight: 700; color: var(--brand); letter-spacing: .01em; }
.sb-tagline span { display: block; font-size: 14.5px; font-weight: 700; color: var(--brand-ink); }
.sb-illus { display: block; width: 100%; height: auto; margin-top: -6px; pointer-events: none; }
.sb-user, .sb-collapse { display: none; }
@media (max-height: 760px) { .sb-illus { 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-section,
body.sb-collapsed .sb-group-items, body.sb-collapsed .sb-count, body.sb-collapsed .sb-foot { display: none; }
body.sb-collapsed .sb-brand { justify-content: center; padding-inline: 0; }
body.sb-collapsed .sb-link, body.sb-collapsed .sb-group-btn { justify-content: center; padding: 10px; }
body.sb-collapsed .sb-section-sep { display: block; height: 1px; background: var(--line); margin: 10px 14px; }
.sb-section-sep { display: none; }

.sb-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(15, 23, 42, .38); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .3s; }

/* ---------- Topbar (white, search pill, term selector, icons, user) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center; gap: 14px; padding: 0 26px 0 18px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--line); transition: box-shadow .2s; view-transition-name: topbar;
}
.topbar.scrolled { box-shadow: 0 6px 20px -16px rgba(15, 23, 42, .35); }
.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: 700; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.tb-search { display: flex; align-items: center; gap: 10px; flex: 0 1 460px; min-width: 200px; height: 42px; padding: 0 16px; border-radius: 999px; background: #f2f5fa; border: 1px solid transparent; color: #8a97ab; font-size: 13.5px; transition: .2s; text-align: left; }
.tb-search i { font-size: 18px; color: #64748b; }
.tb-search:hover { background: #fff; border-color: color-mix(in srgb, var(--brand) 35%, transparent); box-shadow: var(--ring); }
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); color: var(--muted); }
.icon-btn {
  position: relative; width: 42px; height: 42px; border-radius: 12px; display: inline-grid; place-items: center; font-size: 22px;
  background: transparent; border: 1px solid transparent; color: #334155; transition: .2s var(--ease);
}
.icon-btn:hover { color: var(--brand); background: #f1f5fd; }
.icon-btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.icon-btn .dot { position: absolute; top: 2px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #ef4444; 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); }
.icon-btn.ring-anim i { animation: bell 1s var(--ease) 2; transform-origin: 50% 10%; }
.term-chip { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px 0 14px; border-radius: 12px; background: #fff; border: 1px solid var(--line-2); font-size: 13.5px; font-weight: 600; color: #1f2d4d; white-space: nowrap; cursor: pointer; transition: .2s; margin-right: 6px; }
.term-chip:hover { border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.term-chip > i:first-child { color: var(--brand); font-size: 18px; }
.term-chip .ph-caret-down { color: var(--muted); font-size: 13px; margin-left: 4px; }
.term-menu a.cur { color: var(--brand); font-weight: 600; }
.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: #475569; font-family: var(--font-num); }
.lang-btn:hover { background: #f1f5fd; color: var(--brand); }
.lang-btn i { font-size: 17px; }
.lang-switch { display: inline-flex; padding: 4px; height: 40px; border-radius: 12px; background: #fff; border: 1px solid var(--line-2); }
.lang-switch a { display: grid; place-items: center; padding: 0 10px; border-radius: 8px; font-size: 12.5px; font-weight: 700; color: var(--muted); font-family: var(--font-num); }
.lang-switch a.active { background: var(--grad-brand); color: #fff; }
.tb-user { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; height: 50px; border-radius: 14px; background: transparent; border: 0; cursor: pointer; transition: .2s; margin-left: 6px; }
.tb-user:hover { background: #f1f5fd; }
.tb-user .avatar { --av: 40px; }
.tb-user-text { line-height: 1.25; text-align: left; }
.tb-user-text b { display: block; font-size: 14px; color: #0f2a5f; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-user-text span { font-size: 12px; color: var(--muted); }
.tb-user .ph-caret-down { color: var(--muted); font-size: 14px; margin-left: 8px; }
.child-switch { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 10px 0 5px; border-radius: 12px; background: #fff; border: 1px solid var(--line-2); cursor: pointer; font-size: 13px; font-weight: 600; }
.tb-divider { width: 1px; height: 28px; background: var(--line-2); margin: 0 6px; }

.tb-search-m { display: none; }
/* ---------- 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); }
.page-crumbs a:hover { color: var(--brand); }
.page-crumbs i { font-size: 10px; opacity: .6; }
.page-head h1 { display: flex; align-items: center; gap: 12px; color: #0f2a5f; font-size: 24px; }
.page-head .ph-title-ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; color: #fff; background: linear-gradient(145deg, color-mix(in srgb, var(--tone) 72%, #fff), var(--tone)); box-shadow: 0 10px 22px -10px var(--tone); flex-shrink: 0; }
.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; }

/* ---------- Tabbar (mobile) ---------- */
.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); }
.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-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* =====================================================================
   CARDS
   ===================================================================== */
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh);
  min-width: 0; transition: box-shadow .25s var(--ease), transform .25s var(--ease), border-color .25s;
}
.card-hover:hover, a.card:hover { box-shadow: var(--sh-lg); 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: 700; color: #0f2a5f; 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: 12px 16px 16px; }
.card-foot { padding: 14px 22px; 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); }
.card-tone { background: linear-gradient(135deg, var(--tone), color-mix(in srgb, var(--tone) 70%, #fff)); color: #fff; border: 0; box-shadow: 0 18px 40px -20px var(--tone); }
.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) 18%, transparent); box-shadow: none; }
.card-dashed { border-style: dashed; box-shadow: none; background: var(--surface-2); }
.card-accent::before { content: ''; position: absolute; left: 0; top: 18px; bottom: 18px; width: 4px; border-radius: 0 4px 4px 0; background: var(--tone); }

/* ---------- Stat cards (KPI: gradient icon tile left · big number · trend · faint icon right) ---------- */
.stat { position: relative; display: flex; align-items: center; gap: 16px; padding: 20px 20px; overflow: hidden; min-height: 108px; container-type: inline-size; }
.stat-ico { width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; font-size: 30px; color: #fff; flex-shrink: 0;
  background: linear-gradient(145deg, color-mix(in srgb, var(--tone) 72%, #fff) 0%, var(--tone) 60%, color-mix(in srgb, var(--tone) 85%, #000) 100%);
  box-shadow: 0 12px 22px -12px var(--tone), inset 0 1px 0 rgba(255, 255, 255, .35); }
.stat-body { flex: 1; min-width: 0; }
.stat-label { font-size: 14px; color: #1f2d4d; font-weight: 600; line-height: 1.35; 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: -.02em; line-height: 1.2; margin-top: 4px; color: #0f2a5f; white-space: nowrap; }
.stat-value small { font-size: 14.5px; font-weight: 600; color: #334155; 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; font-size: 12.5px; font-weight: 700; font-family: var(--font-num); }
.trend.up { color: #16a34a; }
.trend.down { color: #ef4444; }
.trend.flat { color: var(--muted); }
.trend i { font-size: 12px; }
.stat-deco { flex-shrink: 0; align-self: center; font-size: 34px; color: color-mix(in srgb, var(--tone) 40%, #fff); opacity: .75; }
.stat-deco.spark { width: 96px; height: 44px; opacity: 1; }
.stat-spark { position: relative; width: 100%; height: 100%; }
.stat.has-spark { padding-bottom: 20px; }
.stat-top { display: contents; }
.stat-mini { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 0; }
.stat-mini .stat-ico { width: 44px; height: 44px; font-size: 22px; border-radius: 13px; }
.stat-mini .stat-value { font-size: 22px; margin-top: 0; }

/* ---------- Hero / Welcome ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: var(--r-xl); padding: 28px 30px; color: #fff;
  background: radial-gradient(1200px 400px at 110% -40%, rgba(255, 255, 255, .28), transparent 60%), var(--grad-brand);
  box-shadow: 0 24px 50px -24px var(--brand);
}
.hero::before { content: ''; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, .16) 1px, transparent 1px); background-size: 18px 18px; mask-image: linear-gradient(90deg, transparent 40%, #000); }
.hero::after { content: ''; position: absolute; width: 380px; height: 380px; right: -90px; bottom: -200px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .25), transparent 65%); }
.hero > * { position: relative; z-index: 1; }
.hero h1, .hero h2 { color: #fff; }
.hero p { color: rgba(255, 255, 255, .88); }
.hero .chip { background: rgba(255, 255, 255, .18); color: #fff; border-color: rgba(255, 255, 255, .25); }
.hero-illus { position: absolute; right: 26px; bottom: 0; top: 0; display: flex; align-items: center; font-size: 150px; opacity: .22; z-index: 0; }

/* =====================================================================
   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;
  white-space: nowrap; user-select: none; text-decoration: none; transition: transform .15s var(--ease), box-shadow .2s, background .2s, border-color .2s, color .2s;
  box-shadow: var(--sh-xs);
}
.btn i { font-size: 18px; }
.btn:hover { color: var(--b-fg); border-color: color-mix(in srgb, var(--b-fg) 30%, transparent); box-shadow: var(--sh-sm); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled, .btn.disabled { opacity: .55; pointer-events: none; }
.btn-primary { --b-bg: var(--grad-brand); --b-fg: #fff; --b-bd: transparent; background: var(--grad-brand); box-shadow: var(--sh-brand); }
.btn-primary:hover { color: #fff; box-shadow: 0 14px 28px -10px color-mix(in srgb, var(--brand) 80%, transparent); filter: brightness(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); }
.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) 16%, white); }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; box-shadow: none; }
.btn-ghost:hover { background: rgba(15, 23, 42, .05); box-shadow: none; }
.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.05); }
.btn-danger-soft { --b-bg: var(--rose-soft); --b-fg: var(--rose-ink); --b-bd: transparent; box-shadow: none; }
.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.05); }
.btn-white { --b-bg: #fff; --b-fg: var(--brand-ink); --b-bd: transparent; }
.btn-glass { --b-bg: rgba(255, 255, 255, .18); --b-fg: #fff; --b-bd: rgba(255, 255, 255, .28); backdrop-filter: blur(8px); box-shadow: none; }
.btn-glass:hover { color: #fff; background: rgba(255, 255, 255, .28); }
.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-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.loading { color: transparent !important; pointer-events: none; }
.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 { 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; }

/* =====================================================================
   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-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: 650; font-size: 15px; padding-top: 8px; }
.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 .2s, box-shadow .2s, background .2s; outline: none; appearance: none; -webkit-appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--brand) 30%, var(--line-2)); }
.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(244, 63, 94, .12); }
.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='%2364748b' 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; }
.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; }

.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-2); background: #fff; border-radius: 6px; display: grid; place-items: center; margin: 0; transition: .15s; 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: .25s 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: .25s var(--ease-spring); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { left: 21px; }
.choice-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 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: .2s; }
.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) 15%, transparent); }
.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; }
.segmented { display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface-3); gap: 2px; border: 1px solid var(--line); }
.segmented a, .segmented button, .segmented label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--muted); border: 0; background: none; cursor: pointer; white-space: nowrap; transition: .2s; }
.segmented a:hover, .segmented button:hover, .segmented label:hover { color: var(--text); }
.segmented .active, .segmented input:checked + span { background: #fff; color: var(--text); box-shadow: var(--sh-sm); }
.segmented label input { display: none; }
.segmented label:has(input:checked) { background: #fff; color: var(--text); box-shadow: var(--sh-sm); }
.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: .2s; }
.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; }
.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
   ===================================================================== */
.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: #f7f9fc; color: #64748b; font-size: 12.5px; font-weight: 600; text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--brand) 3.5%, white); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr[data-href] { cursor: pointer; }
.table .num, .table td.num, .table th.num { text-align: right; }
.table td.actions { text-align: right; white-space: nowrap; width: 1%; }
.table.compact td { padding: 9px 14px; }
.table.compact th { padding: 9px 14px; }
.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; }
.table .sort.desc::after { content: '↓'; opacity: 1; }
.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; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-user .meta span { 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; }
.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 / CHIPS / AVATARS
   ===================================================================== */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--tone-soft); color: var(--tone-ink); white-space: nowrap; line-height: 1; }
.badge i { font-size: 13px; }
.badge-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--tone); }
.badge-solid { background: var(--tone); color: #fff; }
.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-pulse::before { animation: pulse-dot 1.6s infinite; }
.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; }
.chip i { font-size: 16px; }
a.chip:hover, button.chip:hover { border-color: var(--brand); color: var(--brand); }
.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) * .38); font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--av-a, #6366f1), var(--av-b, #a855f7));
  position: relative; letter-spacing: -.02em; font-family: var(--font);
}
.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; }

/* =====================================================================
   TABS
   ===================================================================== */
.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 .2s; }
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs a.active, .tabs button.active { color: var(--brand); }
.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); }
.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; }
.pills a.active, .pills button.active { background: var(--text); color: #fff; border-color: var(--text); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade-up .35s var(--ease); }

/* =====================================================================
   LISTS / TIMELINE / STEPS / FEED
   ===================================================================== */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 12px 22px; border-bottom: 1px solid var(--line); transition: background .15s; 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; 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 16px; }
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 10px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--line-2), transparent); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: -28px; top: 2px; width: 22px; height: 22px; 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-title { font-weight: 600; font-size: 14px; }
.tl-meta { font-size: 12.5px; color: var(--muted); }
.tl-body { margin-top: 6px; font-size: 13.5px; color: var(--text-2); background: var(--surface-2); 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: 42px; min-width: 0; }
.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-3); color: var(--muted); font-weight: 700; font-family: var(--font-num); border: 2px solid var(--surface); z-index: 1; box-shadow: 0 0 0 2px var(--line); }
.step::after { content: ''; position: absolute; top: 16px; left: calc(50% + 20px); right: calc(-50% + 20px); 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 2px var(--emerald-soft); }
.step.done::after { background: var(--emerald); }
.step.current::before { background: var(--grad-brand); color: #fff; box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand) 18%, transparent); }
.step.current { color: var(--text); font-weight: 600; }
.step.rejected::before { content: '✕'; background: var(--rose); color: #fff; }
.step b { display: block; color: var(--text-2); font-size: 13px; }

/* =====================================================================
   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, var(--tone), color-mix(in srgb, var(--tone) 60%, #fff)); 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; }
.ring-label span { font-size: 11px; color: var(--muted); }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, #f8fafc 45%, var(--surface-3) 65%); background-size: 300% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; min-height: 14px; }
.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 / ALERT / CALLOUT
   ===================================================================== */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 48px 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: 10px; position: relative; }
.empty-ico::after { content: ''; position: absolute; inset: -8px; border-radius: 32px; border: 2px dashed color-mix(in srgb, var(--tone) 25%, transparent); }
.empty h3 { font-size: 17px; }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto 10px; font-size: 14px; }
.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; }
.alert b { display: block; }
.alert-body { flex: 1; min-width: 0; }

/* =====================================================================
   DROPDOWN / MENU / POPOVER / TOOLTIP
   ===================================================================== */
.dropdown { position: relative; display: inline-block; }
.menu {
  position: absolute; z-index: 80; top: calc(100% + 8px); right: 0; min-width: 220px; 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; transition: opacity .18s var(--ease), transform .2s var(--ease);
}
.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; }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 10px; color: var(--text-2); font-size: 14px; border: 0; background: none; text-align: left; white-space: nowrap; }
.menu a:hover, .menu button:hover { background: rgba(15, 23, 42, .05); color: var(--text); }
.menu a i, .menu button i { font-size: 18px; color: var(--muted); }
.menu .danger, .menu .danger i { color: var(--rose); }
.menu hr { margin: 6px 4px; }
.menu-head { padding: 10px 12px; }
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 90; white-space: nowrap;
  padding: 6px 10px; border-radius: 8px; background: #0f172a; color: #fff; font-size: 12px; font-weight: 500; pointer-events: none; animation: fade-in .15s;
}

/* =====================================================================
   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: rgba(15, 23, 42, .45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); 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-spring); 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: 18px; flex-shrink: 0; }
.modal-close:hover { background: var(--rose-soft); color: var(--rose); }
.modal-body { padding: 4px 22px 20px; overflow-y: auto; flex: 1; }
.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 .35s var(--ease); }
.drawer-root.closing .drawer { animation: drawer-out .22s var(--ease) forwards; }

/* ---------- Toast ---------- */
#toasts { position: fixed; z-index: 200; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; width: min(380px, calc(100vw - 32px)); }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 12px; padding: 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-spring); position: relative; overflow: hidden;
}
.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; }
.toast .t-body b { display: block; font-size: 14px; }
.toast .t-body span { color: var(--muted); font-size: 13px; }
.toast .t-close { border: 0; background: none; color: var(--muted-2); font-size: 16px; padding: 2px; }
.toast .t-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--tone); animation: toast-bar linear forwards; }
.toast.out { animation: toast-out .3s var(--ease) forwards; }
a.toast { color: inherit; }

/* =====================================================================
   NOTIFICATION PANEL
   ===================================================================== */
.notif-panel { width: 400px; max-width: calc(100vw - 24px); padding: 0; right: -60px; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; }
.notif-head h4 { font-size: 16px; }
.notif-list { max-height: 440px; overflow-y: auto; padding: 0 8px 8px; }
.notif-item { display: flex; gap: 12px; padding: 12px 10px; border-radius: 14px; color: inherit; position: relative; transition: background .15s; }
.notif-item:hover { background: rgba(15, 23, 42, .04); color: inherit; }
.notif-item .n-ico { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); font-size: 20px; flex-shrink: 0; }
.notif-item .n-body { flex: 1; min-width: 0; }
.notif-item .n-title { font-size: 14px; font-weight: 600; line-height: 1.4; }
.notif-item .n-text { font-size: 13px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.notif-item .n-time { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }
.notif-item.unread { background: color-mix(in srgb, var(--brand) 5%, 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) 20%, transparent); }
.notif-foot { padding: 10px; border-top: 1px solid var(--line); text-align: center; }

/* =====================================================================
   COMMAND PALETTE
   ===================================================================== */
.cmdk-root { position: fixed; inset: 0; z-index: 150; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.cmdk { position: relative; width: 100%; max-width: 640px; 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); overflow: hidden; animation: modal-in .3s var(--ease-spring); }
.cmdk-input { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.cmdk-input i { font-size: 22px; color: var(--brand); }
.cmdk-input input { flex: 1; border: 0; outline: 0; background: none; font-size: 17px; }
.cmdk-results { max-height: 56vh; overflow-y: auto; padding: 8px; }
.cmdk-group { font-size: 11.5px; font-weight: 700; color: var(--muted-2); text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px 6px; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--text); cursor: pointer; }
.cmdk-item .c-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; }
.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; }
.cmdk-item .c-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-item.active { background: var(--brand-soft); color: var(--brand-ink); }
.cmdk-item.active .c-arrow { opacity: 1; }
.cmdk-item .c-arrow { opacity: 0; color: var(--brand); }
.cmdk-foot { display: flex; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); background: var(--surface-2); }

/* =====================================================================
   APPS LAUNCHER
   ===================================================================== */
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 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: 10px 4px; border-radius: 18px; transition: .2s var(--ease); line-height: 1.35; }
.app-tile:hover { background: rgba(255, 255, 255, .7); color: var(--text); transform: translateY(-3px); }
.app-tile:active { transform: scale(.94); }
.app-icon { position: relative; width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; font-size: 32px; color: #fff; background: linear-gradient(145deg, color-mix(in srgb, var(--tone) 70%, #fff), var(--tone) 55%, color-mix(in srgb, var(--tone) 70%, #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, .28), transparent 50%); }
.app-icon .sb-count { position: absolute; top: -6px; right: -6px; z-index: 2; border: 2px solid var(--bg); }

/* =====================================================================
   KANBAN / CALENDAR
   ===================================================================== */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(280px, 1fr); gap: 16px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px; min-height: 200px; }
.kanban-col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 12px; font-weight: 650; font-size: 14px; }
.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: .2s; color: inherit; display: block; }
.kanban-card:hover { box-shadow: var(--sh); transform: translateY(-1px); color: inherit; }
.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: 700; color: var(--muted); text-align: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-2); text-transform: uppercase; }
.cal-day { min-height: 112px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); position: relative; min-width: 0; }
.cal-day.other { background: var(--surface-2); 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-root { position: fixed; inset: 0; z-index: 160; display: flex; flex-direction: column; background: rgba(10, 12, 24, .92); 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: #0f172a; color: #e2e8f0; padding: 20px; border-radius: 12px; white-space: pre-wrap; font-size: 13px; }
.viewer-stage .v-sheet { background: #fff; color: #0f172a; 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(170px, 1fr)); gap: 12px; }
.sig-item { position: relative; border: 2px solid var(--line); border-radius: 14px; padding: 10px; background: #fff; cursor: pointer; transition: .2s; }
.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: #e9edf5; }
.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, 23, 42, .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: #0f172a; 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; }
.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
   ===================================================================== */
.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, .96) !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; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; 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; }
.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; }
.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: 550; overflow-wrap: anywhere; }
.profile-cover { height: 150px; border-radius: var(--r-xl) var(--r-xl) 0 0; background: var(--grad-brand); position: relative; overflow: hidden; }
.profile-cover::after { content: ''; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, .18) 1px, transparent 1px); background-size: 16px 16px; }
.profile-head { display: flex; align-items: flex-end; gap: 18px; padding: 0 24px 20px; margin-top: -48px; position: relative; z-index: 1; flex-wrap: wrap; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); transition: .2s; 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; }
.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, #22d3ee, transparent); box-shadow: 0 0 12px #22d3ee; 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: 60vh; display: grid; place-items: center; text-align: center; }
.error-code { font-family: var(--font-num); font-size: 120px; font-weight: 800; line-height: 1; letter-spacing: -.05em; }

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

/* =====================================================================
   OFFICIAL DASHBOARD COMPONENTS (ดูแบบอ้างอิง docs/design/dashboard-reference.webp)
   ===================================================================== */
/* card header helpers */
.card-title small, .card-title .sub { font-size: 12.5px; font-weight: 500; 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); text-decoration: underline; }
.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: #334155; 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='%2364748b' 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 with school photo/illustration */
.welcome { position: relative; overflow: hidden; border-radius: 18px; min-height: 150px; padding: 26px 32px; display: flex; flex-direction: column; justify-content: center;
  background: #eef5ff var(--welcome-img, url(../img/banner-school.svg)) right center / cover no-repeat; border: 1px solid #dbe7fb; box-shadow: var(--sh-sm); }
.welcome::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, #eef5ff 0%, rgba(238, 245, 255, .92) 34%, rgba(238, 245, 255, .15) 58%, transparent 70%); 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: 27px; font-weight: 750; color: var(--brand); letter-spacing: -.02em; line-height: 1.25; max-width: 60%; }
.welcome p { margin: 6px 0 0; font-size: 16px; color: #1f2d4d; 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: 16px; line-height: 1.5; color: #0f2a5f; 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 (news/items with round colored icons) */
.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: #1f2d4d; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; transition: color .2s; }
.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: #0f2a5f; }
.mini-cal .mc-nav { width: 30px; height: 30px; border-radius: 9px; border: 0; background: none; display: grid; place-items: center; color: #475569; font-size: 16px; }
.mini-cal .mc-nav:hover { background: #f1f5fd; color: var(--brand); }
.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: #1f2d4d; position: relative; font-family: var(--font-num); cursor: default; }
.mc-day.other { color: #cbd5e1; }
.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, #a78bfa, #7c3aed); color: #fff; }
.mc-day.event::after { background: #fff; }
.mc-day[data-tip] { cursor: pointer; }

/* legend list (chart legends with values) */
.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: #1f2d4d; }
.legend-row .sw { width: 10px; height: 10px; border-radius: 50%; background: var(--tone); }
.legend-row .lv { font-weight: 600; font-family: var(--font-num); text-align: right; white-space: nowrap; }
.legend-row .lp { color: var(--muted); font-family: var(--font-num); text-align: right; min-width: 46px; }

/* horizontal bars with target marker */
.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: #1f2d4d; }
.hbar-track { position: relative; height: 10px; border-radius: 6px; background: #eef2f7; }
.hbar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, color-mix(in srgb, var(--tone) 70%, #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: #1e3a8a; opacity: .45; }
.hbar .hv { text-align: right; font-weight: 600; font-family: var(--font-num); font-size: 12.5px; color: #334155; }
.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 { border-radius: 14px; padding: 14px 16px; background: var(--tone-soft); border: 1px solid color-mix(in srgb, var(--tone) 16%, transparent); min-width: 0; }
.kpi-tile .kt-top { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: #334155; font-weight: 600; }
.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: 22px; font-weight: 750; color: #0f2a5f; margin-top: 8px; white-space: nowrap; }
.kpi-tile .kt-val small { font-size: 13px; font-weight: 600; color: #334155; font-family: var(--font); margin-left: 4px; }
.kpi-tile .kt-foot { font-size: 12px; margin-top: 2px; }
.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: 14px; font-weight: 700; color: #0f2a5f; 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: #1f2d4d; 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); }

/* AI assistant widget */
.ai-box .ai-head { display: flex; align-items: center; gap: 12px; }
.ai-avatar { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; font-size: 26px; color: #fff; background: linear-gradient(135deg, #60a5fa, #2563eb 55%, #7c3aed); box-shadow: 0 10px 22px -12px #2563eb; 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-head b { display: block; font-size: 15px; color: #0f2a5f; }
.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: #eef4ff; color: #1e3a8a; 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: #1f2d4d; }
.ai-a .ai-a-title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 6px; }
.ai-a .ai-a-title i { color: #16a34a; font-size: 18px; }
.ai-a ul { margin: 0; padding-left: 18px; line-height: 1.75; }
.ai-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; animation: ai-dot 1.2s infinite; }
.ai-typing i:nth-child(2) { animation-delay: .15s; } .ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 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: #334155; }
.ai-suggest button:hover { border-color: var(--brand); color: var(--brand); }
.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-brand); color: #fff; font-size: 17px; flex-shrink: 0; }

/* dashboard grid: main + right rail */
.dash-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; 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; }
.status-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 64px; height: 26px; padding: 0 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; background: var(--tone-soft); color: var(--tone-ink); }

/* KPI card auto-fit: ซ่อนไอคอนจาง/กราฟเล็กเมื่อการ์ดแคบ แล้วย่อขนาด */
@container (max-width: 340px) { .stat-deco { display: none; } }
@container (max-width: 250px) { .stat-ico { width: 46px; height: 46px; font-size: 23px; border-radius: 13px; } .stat-value { font-size: 22px; } .stat { gap: 12px; } }
@container (max-width: 215px) { .stat-ico { width: 38px; height: 38px; font-size: 20px; border-radius: 11px; } .stat-value { font-size: 20px; } .stat-value small { font-size: 12.5px; } }

/* =====================================================================
   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(14px); } 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(18px) scale(.97); } 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(.95); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px) scale(.95); } }
@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 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); } }

.anim-in > * { animation: fade-up .55s var(--ease) both; }
.anim-in > *:nth-child(1) { animation-delay: .02s; } .anim-in > *:nth-child(2) { animation-delay: .07s; } .anim-in > *:nth-child(3) { animation-delay: .12s; }
.anim-in > *:nth-child(4) { animation-delay: .17s; } .anim-in > *:nth-child(5) { animation-delay: .22s; } .anim-in > *:nth-child(6) { animation-delay: .27s; }
.anim-in > *:nth-child(7) { animation-delay: .32s; } .anim-in > *:nth-child(8) { animation-delay: .37s; } .anim-in > *:nth-child(n+9) { animation-delay: .42s; }

@view-transition { navigation: auto; }
::view-transition-old(root) { animation: .18s var(--ease) both vt-out; }
::view-transition-new(root) { animation: .32s var(--ease) both vt-in; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }
::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; }
}

/* =====================================================================
   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: 1360px) {
  .tb-user-text { display: none; }
  .tb-search { flex-basis: 300px; }
}
@media (max-width: 1180px) {
  .term-chip span { display: none; }
  .tb-search { flex-basis: 220px; min-width: 150px; }
  .lang-btn { padding: 0 6px; }
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-sidebar { grid-template-columns: minmax(0, 1fr) 320px; }
  .tb-search { width: 220px; }
  .page { padding: 22px 24px 36px; }
  .topbar { padding: 0 22px; }
}
@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; }
  .term-chip span.full { display: none; }
}

/* ----- Mobile / Tablet: 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(310px, 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-section,
  body.sb-collapsed .sb-user-text, body.sb-collapsed .sb-search span, body.sb-collapsed .sb-count { display: revert; }
  body.sb-collapsed .sb-group-items { display: grid; }
  .sb-collapse { display: none; }

  .topbar { height: calc(60px + var(--safe-t)); padding: var(--safe-t) 12px 0; gap: 6px; }
  .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; }
  .tb-mobile-title { display: block; }
  .tb-search, .term-chip, .lang-switch.hide-m, .lang-btn, .tb-user-text, .tb-hide-m, .tb-user .ph-caret-down, .tb-divider { display: none !important; }
  .tb-search-m { display: inline-grid !important; }
  .tb-actions .dropdown:has(> .term-chip) { display: none; }
  .tb-user { padding: 2px; height: 42px; border-radius: 50%; margin-left: 2px; }
  .tb-user .avatar { --av: 36px; }
  .dash-layout { grid-template-columns: minmax(0, 1fr); }
  .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,245,255,.97) 0%, rgba(238,245,255,.85) 60%, rgba(238,245,255,.4) 100%); }
  .stat { padding: 16px; gap: 12px; min-height: 0; }
  .stat-ico { width: 48px; height: 48px; font-size: 24px; border-radius: 14px; }
  .stat-deco { display: none; }
  .stat-label { font-size: 13px; -webkit-line-clamp: 3; }
  .hbar, .hbar-axis { grid-template-columns: 84px minmax(0, 1fr) 44px; }
  .icon-btn { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; }

  .page { padding: 16px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px); }
  .app-footer { display: none; }
  .page-head { margin-bottom: 16px; align-items: flex-start; }
  .page-head h1 { font-size: 22px; }
  .page-head .ph-title-ico { width: 40px; height: 40px; font-size: 21px; border-radius: 12px; }
  .page-head p { font-size: 13.5px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }

  .tabbar {
    display: flex; position: fixed; z-index: 50; left: 10px; right: 10px; bottom: calc(10px + var(--safe-b)); height: var(--tabbar-h);
    background: var(--glass-strong); backdrop-filter: blur(22px) saturate(1.8); -webkit-backdrop-filter: blur(22px) saturate(1.8);
    border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 16px 40px -14px rgba(15, 23, 42, .35); padding: 6px; view-transition-name: tabbar;
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 18px; color: var(--muted); font-size: 11px; font-weight: 600; position: relative; transition: color .2s, background .25s var(--ease); }
  .tabbar a i { font-size: 24px; transition: transform .3s var(--ease-spring); }
  .tabbar a.active { color: var(--brand); background: var(--brand-soft); }
  .tabbar a.active i { transform: translateY(-1px) scale(1.08); }
  .tabbar a:active i { transform: scale(.85); }
  .tabbar .tab-badge { position: absolute; top: 5px; left: calc(50% + 6px); 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); }
  .tabbar .tab-fab { flex: 0 0 62px; }
  .tabbar .tab-fab span.fab { width: 54px; height: 54px; margin-top: -26px; border-radius: 18px; display: grid; place-items: center; background: var(--grad-brand); color: #fff; box-shadow: var(--sh-brand), 0 0 0 5px var(--bg); }
  .tabbar .tab-fab span.fab i { font-size: 26px; }

  #toasts { top: calc(10px + var(--safe-t)); right: 10px; left: 10px; width: auto; }

  /* 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 .38s var(--ease); 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: 44px; 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; }
  .drawer { width: 100vw; }
  .cmdk-root { padding: calc(10px + var(--safe-t)) 10px; }
  .notif-panel { position: fixed; top: calc(64px + var(--safe-t)); left: 10px; right: 10px; width: auto; }

  .grid { gap: 14px; }
  .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) + 16px); z-index: 5; background: var(--glass-strong); 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: 20px; }
  .card-head { padding: 16px 16px 0; }
  .card-body { padding: 14px 16px 18px; }
  .card-foot { padding: 12px 16px; }
  .list-item { padding: 12px 16px; }
  .stat { padding: 16px; }
  .stat-value { font-size: 25px; }
  .stat-ico { width: 42px; height: 42px; font-size: 22px; border-radius: 13px; }
  .hero { padding: 22px 20px; border-radius: 24px; }
  .hero-illus { display: none; }
  .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: 46px; font-size: 16px; }
  .textarea { font-size: 16px; }
  .btn { height: 44px; }
  .btn-sm { height: 36px; }
  .hide-mobile { display: none !important; }
  .show-mobile { display: revert !important; }
  .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: 16px 6px; }
  .app-icon { width: 58px; height: 58px; border-radius: 18px; font-size: 28px; }
  .app-tile { font-size: 11.5px; padding: 6px 0; }
  .steps { overflow-x: auto; }
  .step { min-width: 90px; }

  /* Table → 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 td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table-stack td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 600; 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: 8px; }
  .table-stack td.primary { font-size: 15px; padding-bottom: 6px; }
}
@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: 20px; }
  .hero h1, .hero h2 { font-size: 21px; }
}
@media (hover: none) {
  .btn:hover, .card-hover:hover, a.card:hover, .icon-btn:hover { transform: none; }
}

@media print {
  body { background: #fff; font-size: 12pt; }
  .sidebar, .topbar, .tabbar, .app-footer, .page-actions, .no-print, .filters, .pager, #toasts, .app-bg, .sb-backdrop { 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; }
  .print-only { display: block; }
  .print-head.print-only { display: flex; }
  a { color: inherit; }
  @page { size: A4; margin: 14mm; }
}
