/* =====================================================================
   Payroll — Design System (โทนเขียวเข้ม · ชุดสีเดียวกับระบบ Apartment)
   ===================================================================== */
:root {
  /* มินิมอล + สีสด: พื้นขาว เส้นบาง พื้นที่โล่ง — สีน้ำเงินสดเป็นสีหลัก และชุดสีเสริมที่กลมกลืนสำหรับไอคอน/กราฟ/สถานะ */
  --bg: #f3f7f5;
  --surface: #ffffff;
  --surface-2: #f8fbfa;
  --border: #e0e9e6;
  --border-2: #cddbd6;
  --line: #edf3f0;
  --text: #13282a;
  --text-2: #2e4446;
  --muted: #5d706c;
  --faint: #91a29e;

  --primary: #027a6c;
  --primary-600: #026b5f;
  --primary-700: #015d5f;
  --primary-50: #eef8f5;
  --primary-100: #d9f1e9;
  --primary-200: #a9dfcf;
  --hdr: #ffffff;
  --hdr-2: #f1f6f4;
  /* ไล่เฉดสีหลักโทนเขียวเข้ม (ชุดเดียวกับ Apartment): ไฮไลต์เขียวมะนาว + เขียวหยก → เขียวเข้ม */
  --grad: radial-gradient(120% 140% at 0% 0%, rgba(65, 200, 137, .45) 0%, rgba(65, 200, 137, 0) 45%), linear-gradient(135deg, #08a488 0%, #027a6c 50%, #015d5f 100%);
  --grad-hover: radial-gradient(120% 140% at 0% 0%, rgba(65, 200, 137, .38) 0%, rgba(65, 200, 137, 0) 45%), linear-gradient(135deg, #07957c 0%, #026b5f 50%, #014c4e 100%);
  --grad-soft: linear-gradient(135deg, #effaf6 0%, #e1f3ec 100%);
  --grad-shadow: 0 6px 16px -6px rgba(2, 122, 108, .5);
  --brand-lime: #41c889;
  --brand-deep: #033f41;
  --c-brand: #0b8f7a;   --c-brand-bg: #e2f5ee;
  --c-orange: #f97316;  --c-orange-bg: #fff1e6;

  /* สีเสริม (ไอคอน การ์ด กราฟ) + พื้นอ่อนของแต่ละสี */
  --c-blue: #2f5bea;    --c-blue-bg: #eaf0ff;
  --c-indigo: #5b5bd6;  --c-indigo-bg: #eeeefc;
  --c-violet: #8b5cf6;  --c-violet-bg: #f3eefe;
  --c-sky: #0ea5e9;     --c-sky-bg: #e7f6fd;
  --c-teal: #0fb5a3;    --c-teal-bg: #e4f8f5;
  --c-emerald: #10a36b; --c-emerald-bg: #e5f7ef;
  --c-amber: #f59e0b;   --c-amber-bg: #fef4df;
  --c-rose: #f43f5e;    --c-rose-bg: #ffecef;

  --green: #0e8f5b; --green-bg: #eafaf2; --green-bd: #bfe9d4;
  --amber: #b45f06; --amber-bg: #fff6e5; --amber-bd: #f8dca6;
  --red: #e11d48;   --red-bg: #fff1f3;   --red-bd: #fbc7d1;
  --navy: #1e2f6b;  --navy-bg: #eef1fb;
  --gray-bg: #f1f4f9;

  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .04);
  --shadow-md: 0 8px 24px rgba(17, 24, 39, .08);
  --radius: 10px;
  --radius-sm: 7px;
  --hdr-h: 56px;
  --side-w: 240px;
  --font: 'IBM Plex Sans Thai', 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); min-height: 100vh; }
a { color: var(--primary-700); text-decoration: none; }
a:hover { color: var(--primary-600); text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.ic { flex-shrink: 0; vertical-align: -3px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
::selection { background: var(--primary-100); }

/* ============================== Header (เขียวเข้มไล่เฉด) ============================== */
.hdr {
  position: fixed; inset: 0 0 auto 0; height: var(--hdr-h); z-index: 60;
  display: flex; align-items: center; gap: 14px; padding: 0 18px 0 12px;
  background: linear-gradient(100deg, #023f41 0%, #035854 30%, #027a6c 68%, #0a9a80 100%); color: #fff;
  box-shadow: 0 6px 20px -12px rgba(1, 50, 48, .75);
}
.hdr::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(1200px 120px at 22% -40px, rgba(65, 200, 137, .30), transparent 60%); }
.hdr > * { position: relative; z-index: 1; }
.hdr-burger { display: none; background: none; border: 0; color: #fff; width: 36px; height: 36px; border-radius: var(--radius-sm); cursor: pointer; align-items: center; justify-content: center; }
.hdr-burger:hover { background: rgba(255, 255, 255, .18); }
.hdr-brand { display: flex; align-items: center; gap: 10px; color: #fff; min-width: calc(var(--side-w) - 28px); }
.hdr-brand:hover { color: #fff; text-decoration: none; }
.hdr-logo { width: 32px; height: 32px; border-radius: 10px; background: #fff; color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 16px;
  box-shadow: 0 6px 14px -6px rgba(0, 40, 36, .45); }
.hdr-name { font-weight: 600; font-size: 16px; letter-spacing: .2px; text-shadow: 0 1px 2px rgba(0, 30, 28, .3); }
.hdr-title { font-size: 12.5px; color: rgba(255, 255, 255, .88); border-left: 1px solid rgba(255, 255, 255, .38); padding-left: 10px; }
.hdr-context { position: relative; }
.hdr-ctx-btn {
  display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px;
  background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .3); border-radius: var(--radius-sm);
  color: #fff; cursor: pointer; font-size: 13px; max-width: 560px; backdrop-filter: blur(4px);
}
.hdr-ctx-btn .ic { color: rgba(255, 255, 255, .9); }
.hdr-ctx-btn:not([disabled]):hover { background: rgba(255, 255, 255, .27); }
.hdr-ctx-btn[disabled] { cursor: default; }
.ctx-company { color: rgba(255, 255, 255, .86); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.ctx-sep { color: rgba(255, 255, 255, .6); }
.ctx-branch { font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-spacer { flex: 1; }
.hdr-search { position: relative; display: flex; align-items: center; }
.hdr-search .ic { position: absolute; left: 11px; color: rgba(255, 255, 255, .9); pointer-events: none; z-index: 1; }
.hdr-search:focus-within .ic { color: var(--faint); }
.hdr-search input {
  width: 300px; height: 34px; padding: 0 12px 0 33px; border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .2); color: #fff; font-size: 13px;
}
.hdr-search input::placeholder { color: rgba(255, 255, 255, .85); }
.hdr-search input:focus { outline: none; background: #fff; color: var(--text); border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .35); }
.hdr-search input:focus::placeholder { color: var(--faint); }
.search-results { display: none; position: absolute; top: 42px; right: 0; width: 380px; background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); max-height: 420px; overflow-y: auto; z-index: 70; padding: 4px; }
.search-results.show { display: block; }
.search-results a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; color: var(--text); border-radius: var(--radius-sm); }
.search-results a:hover { background: var(--gray-bg); text-decoration: none; }
.search-results .sr-empty { padding: 14px; color: var(--muted); text-align: center; font-size: 13px; }
.hdr-user { display: flex; align-items: center; gap: 9px; background: none; border: 0; color: #fff; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); }
.hdr-user .ic { color: rgba(255, 255, 255, .9); }
.hdr-user:hover { background: rgba(255, 255, 255, .18); }
.hdr-avatar { width: 32px; height: 32px; border-radius: 50%; background: #fff; color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 13px; box-shadow: 0 4px 10px -4px rgba(0, 40, 36, .45); }
.hdr-user-text { display: flex; flex-direction: column; text-align: left; line-height: 1.2; }
.hdr-user-name { font-size: 13px; font-weight: 600; }
.hdr-user-role { font-size: 11px; color: rgba(255, 255, 255, .85); }
/* dropdown */
.dropdown { position: relative; }
.dd-menu { display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 230px; background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 5px; z-index: 80; }
.dd-menu.dd-right { left: auto; right: 0; }
.dd-menu.show { display: block; }
.dd-branch { min-width: 300px; max-height: 70vh; overflow-y: auto; }
.dd-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: var(--radius-sm); color: var(--text); text-align: left; cursor: pointer; font-size: 13px; }
.dd-item .ic { color: var(--faint); }
.dd-item:hover { background: var(--gray-bg); text-decoration: none; color: var(--text); }
.dd-item.active { background: var(--primary-50); color: var(--primary-700); font-weight: 600; }
.dd-item.active .ic { color: var(--primary); }
.dd-code { margin-left: auto; font-size: 11px; color: var(--muted); }
.dd-label { font-size: 11px; color: var(--muted); padding: 8px 10px 3px; font-weight: 600; }
.dd-head { padding: 8px 10px 9px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* ============================== Layout ============================== */
.layout { display: flex; padding-top: var(--hdr-h); min-height: 100vh; }
.layout-plain { padding-top: 0; }
.side {
  position: fixed; top: var(--hdr-h); bottom: 0; left: 0; width: var(--side-w); z-index: 50;
  background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
/* เลื่อนเฉพาะเมนู (ไม่ส่งต่อการเลื่อนไปทั้งหน้า) — ตำแหน่งเลื่อนถูกจำไว้ข้ามหน้า (ดู render_sidebar) */
.side-nav { flex: 1; overflow-y: auto; padding: 10px 12px 18px; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: transparent transparent; }
.side-nav:hover { scrollbar-color: rgba(255, 255, 255, .22) transparent; }
.side-nav::-webkit-scrollbar { width: 6px; }
.side-nav::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.side-nav:hover::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .22); }
/* ---- เมนูแบบหมวดพับ/ขยายได้ ---- */
.side { background: linear-gradient(180deg, #034a4b 0%, #023a3c 100%); border-right: 0; }
.side-top, .sg-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; background: none; border-radius: 10px;
  font: inherit; font-size: 13.5px; font-weight: 600; color: rgba(255, 255, 255, .88); cursor: pointer; text-align: left; }
.side-top { margin-bottom: 6px; }
.side-top:hover, .sg-head:hover { background: rgba(255, 255, 255, .07); text-decoration: none; color: #fff; }
.side-top.active { background: rgba(65, 200, 137, .16); color: #fff; box-shadow: inset 0 0 0 1px rgba(65, 200, 137, .28); }
.sg { margin-bottom: 2px; }
.sg-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-count { font-size: 11px; font-weight: 500; color: rgba(255, 255, 255, .72); background: rgba(255, 255, 255, .1); border-radius: 999px; padding: 0 7px; line-height: 18px; }
.sg-head > .ic:last-child { color: rgba(255, 255, 255, .45); transition: transform .2s ease; }
.sg:not(.is-open) .sg-head > .ic:last-child { transform: rotate(-90deg); }
.sg.has-active > .sg-head { color: #fff; }
.sg-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.sg-ic .ic { vertical-align: 0; }
.sg-brand { background: linear-gradient(135deg, #41c889, #08a488); box-shadow: 0 4px 10px -4px rgba(0, 0, 0, .35); }
.sg-violet { background: linear-gradient(135deg, #c4b5fd, #7c3aed); box-shadow: 0 4px 10px -4px rgba(124, 58, 237, .55); }
.sg-sky { background: linear-gradient(135deg, #7dd3fc, #0284c7); box-shadow: 0 4px 10px -4px rgba(2, 132, 199, .55); }
.sg-teal { background: linear-gradient(135deg, #5eead4, #0d9488); box-shadow: 0 4px 10px -4px rgba(13, 148, 136, .55); }
.sg-indigo { background: linear-gradient(135deg, #a5b4fc, #4f46e5); box-shadow: 0 4px 10px -4px rgba(79, 70, 229, .55); }
.sg-amber { background: linear-gradient(135deg, #fcd34d, #f59e0b); box-shadow: 0 4px 10px -4px rgba(245, 158, 11, .6); }
.sg-slate { background: linear-gradient(135deg, #94a3b8, #475569); box-shadow: 0 4px 10px -4px rgba(71, 85, 105, .5); }
/* พับ/ขยายแบบนุ่มนวล (ความสูงอัตโนมัติด้วย grid rows) */
.sg-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .22s ease; }
.sg.is-open > .sg-body { grid-template-rows: 1fr; }
.sg-inner { overflow: hidden; position: relative; padding-left: 21px; }
.sg-inner::before { content: ''; position: absolute; left: 20px; top: 4px; bottom: 6px; width: 1px; background: rgba(255, 255, 255, .12); }
.side-nav.no-anim .sg-body, .side-nav.no-anim .sg-head > .ic:last-child { transition: none; }
.side-link { position: relative; display: flex; align-items: center; gap: 9px; padding: 6px 10px 6px 14px; margin: 1px 0; border-radius: 8px; color: rgba(255, 255, 255, .74); font-size: 13.2px; }
.side-link .ic { color: rgba(255, 255, 255, .45); }
.side-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.side-link.active { background: rgba(65, 200, 137, .16); color: #fff; font-weight: 600; }
.side-link.active .ic { color: var(--brand-lime); }
.side-link.active::before { content: ''; position: absolute; left: -2px; top: 7px; bottom: 7px; width: 3px; border-radius: 3px; background: var(--brand-lime); }
.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: rgba(255, 255, 255, .45); padding: 8px 12px 8px 18px; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-fold { width: 28px; height: 28px; border: 0; background: none; border-radius: 7px; color: rgba(255, 255, 255, .5); cursor: pointer; display: grid; place-items: center; }
.side-fold:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.main { flex: 1; min-width: 0; margin-left: var(--side-w); padding: 22px 28px 56px; }
.layout-plain .main { margin-left: 0; max-width: 1100px; margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.crumbs { font-size: 12px; color: var(--faint); margin-bottom: 3px; }
.crumbs a { color: var(--muted); }
.crumb-sep { margin: 0 6px; color: #c3c8d1; }
.page-title { font-size: 20px; font-weight: 600; color: var(--text); line-height: 1.35; letter-spacing: -.1px; }
.page-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ============================== Panels ============================== */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-title { font-size: 14px; font-weight: 600; color: var(--text); }
.panel-title small { font-weight: 400; color: var(--muted); font-size: 12.5px; margin-left: 6px; }
.panel-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel-body { padding: 18px; }
.panel-body.p0 { padding: 0; }
.panel-foot { padding: 11px 18px; border-top: 1px solid var(--line); background: var(--surface-2); display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 1fr) 340px; }
.grid > .panel { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }

/* ============================== KPI ============================== */
.kpi { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; color: inherit; box-shadow: var(--shadow-sm); }
a.kpi:hover { border-color: var(--border-2); text-decoration: none; }
.kpi-label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
/* สถานะของตัวเลขแสดงเป็นจุดสีเล็กๆ หน้าชื่อ (แทนแถบสีด้านซ้าย) */
.kpi-label::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--border-2); flex-shrink: 0; }
.kpi-value { font-size: 22px; font-weight: 600; color: var(--text); line-height: 1.3; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; letter-spacing: -.2px; }
.kpi-value small { font-size: 12.5px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-red .kpi-label::before { background: var(--c-rose); }
.kpi-red .kpi-value { color: var(--red); }
.kpi-amber .kpi-label::before { background: var(--c-amber); }
.kpi-green .kpi-label::before { background: var(--c-emerald); }
.kpi-blue .kpi-label::before { background: var(--c-blue); }
.kpi-violet .kpi-label::before { background: var(--c-violet); }
.kpi-teal .kpi-label::before { background: var(--c-teal); }
.kpi-sky .kpi-label::before { background: var(--c-sky); }
/* การ์ดที่มีไอคอน: ไอคอนในกรอบสีอ่อนมุมขวาบน (แทนจุดสี) */
.kpi.has-icon { position: relative; }
.kpi.has-icon .kpi-label { padding-right: 40px; min-height: 30px; }
.kpi.has-icon .kpi-label::before { display: none; }
.kpi-icon { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #41c889, #027a6c); box-shadow: 0 5px 12px -5px rgba(2, 122, 108, .6); }
.kpi-blue .kpi-icon { background: linear-gradient(135deg, #60a5fa, #2563eb); box-shadow: 0 5px 12px -5px rgba(37, 99, 235, .6); }
.kpi-red .kpi-icon { background: linear-gradient(135deg, #fb7185, #e11d48); box-shadow: 0 5px 12px -5px rgba(225, 29, 72, .6); }
.kpi-amber .kpi-icon { background: linear-gradient(135deg, #fcd34d, #f59e0b); box-shadow: 0 5px 12px -5px rgba(245, 158, 11, .7); }
.kpi-green .kpi-icon { background: linear-gradient(135deg, #34d399, #059669); box-shadow: 0 5px 12px -5px rgba(5, 150, 105, .6); }
.kpi-violet .kpi-icon { background: linear-gradient(135deg, #c4b5fd, #7c3aed); box-shadow: 0 5px 12px -5px rgba(124, 58, 237, .55); }
.kpi-teal .kpi-icon { background: linear-gradient(135deg, #5eead4, #0d9488); box-shadow: 0 5px 12px -5px rgba(13, 148, 136, .6); }
.kpi-sky .kpi-icon { background: linear-gradient(135deg, #7dd3fc, #0284c7); box-shadow: 0 5px 12px -5px rgba(2, 132, 199, .55); }
.kpi-indigo .kpi-icon { background: linear-gradient(135deg, #a5b4fc, #4f46e5); box-shadow: 0 5px 12px -5px rgba(79, 70, 229, .55); }
.kpi-orange .kpi-label::before { background: var(--c-orange); }

/* ============================== Tables ============================== */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: 12px; text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #fafbfd; }
.tbl tfoot td { background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--border); border-bottom: 0; }
.tbl .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .c, .c { text-align: center; }
.tbl .r, .r { text-align: right; }
.tbl-sm td { padding: 5px 8px; }
.tbl-sm th { padding: 6px 8px; }
.tbl td.actions { white-space: nowrap; text-align: right; }
.tbl tr.row-muted td { color: var(--muted); }
.tbl tr.row-error td { background: #fff7f6; }
.tbl tr.row-warn td { background: #fffcf2; }
.tbl-scroll { max-height: 560px; overflow: auto; }
.tbl-scroll .tbl th { position: sticky; top: 0; z-index: 2; }
.emp-cell { display: flex; align-items: center; gap: 9px; min-width: 170px; }
.emp-cell .emp-name { font-weight: 500; display: block; line-height: 1.3; }
.emp-cell .emp-sub { font-size: 11.5px; color: var(--muted); }
.kv { width: 100%; border-collapse: collapse; font-size: 13.2px; }
.kv th { width: 38%; text-align: left; font-weight: 400; color: var(--muted); padding: 6px 10px 6px 0; vertical-align: top; }
.kv td { padding: 6px 0; font-weight: 500; }
.kv tr + tr th, .kv tr + tr td { border-top: 1px solid var(--line); }

/* ============================== Buttons ============================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 13px; border: 1px solid transparent; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; line-height: 1; }
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-100); }
.btn-primary { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--grad-shadow); }
.btn-primary:hover { background: var(--grad-hover); color: #fff; box-shadow: 0 8px 20px -6px rgba(2, 122, 108, .55); }
.btn-default { background: #fff; color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-default:hover { background: var(--surface-2); border-color: var(--border-2); color: var(--text); }
.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-success:hover { background: #12643c; color: #fff; }
.btn-danger { background: #fff; color: var(--red); border-color: var(--red-bd); }
.btn-danger:hover { background: var(--red-bg); color: var(--red); }
.btn-danger-solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger-solid:hover { background: #8f1f17; color: #fff; }
.btn-link { background: none; border: 0; color: var(--primary); padding: 0 4px; height: auto; }
.btn-link:hover { text-decoration: underline; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 12px; }
.btn-lg { height: 38px; padding: 0 18px; font-size: 14px; }
.btn-icon { width: 28px; padding: 0; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn.is-busy { opacity: .7; cursor: progress; }
form.inline { display: inline; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ============================== Forms ============================== */
.input, .select, .textarea { width: 100%; height: 34px; padding: 0 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; font-size: 13.5px; color: var(--text); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-2); }
.textarea { height: auto; min-height: 64px; padding: 7px 10px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236a7689' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; cursor: pointer; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.input[disabled], .select[disabled], .textarea[disabled], .input[readonly] { background: var(--surface-2); color: var(--text-2); }
.input-sm, .select-sm { height: 28px; font-size: 12.5px; padding: 0 8px; }
.select-sm { padding-right: 24px; background-position: right 7px center; }
.input.num { text-align: right; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.field > label, .field-label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 4px; }
.req { color: var(--red); margin-left: 2px; }
.help { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--red); }
.field-error { font-size: 11.5px; color: var(--red); margin-top: 3px; }
.form-section { font-size: 13.5px; font-weight: 600; color: var(--primary-700); padding: 4px 0 8px; margin: 10px 0 12px; border-bottom: 1px solid var(--line); }
.form-section:first-child { margin-top: 0; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13.5px; }
.check input { width: 15px; height: 15px; accent-color: var(--primary); }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; padding-top: 5px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.filters .input, .filters .select { width: auto; min-width: 140px; height: 32px; font-size: 13px; }
.filters .input.grow { min-width: 220px; }
.filters .filter-label { font-size: 12.5px; color: var(--muted); }

/* ============================== Badges / Alerts ============================== */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; line-height: 19px; white-space: nowrap; border: 1px solid transparent; }
.b-gray { background: var(--gray-bg); color: #4b5563; }
.b-blue { background: var(--primary-50); color: var(--primary-700); border-color: var(--primary-100); }
.b-navy { background: var(--navy-bg); color: var(--navy); border-color: #dfe4ee; }
.b-green { background: var(--green-bg); color: var(--green); border-color: var(--green-bd); }
.b-amber { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-bd); }
.b-red { background: var(--red-bg); color: var(--red); border-color: var(--red-bd); }
.b-violet { background: var(--c-violet-bg); color: var(--c-violet); border-color: var(--c-violet-bg); }
.alert { display: flex; gap: 9px; align-items: flex-start; padding: 10px 14px; border: 1px solid; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; }
.alert-info { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary-700); }
.alert-ok { background: var(--green-bg); border-color: var(--green-bd); color: #125c38; }
.alert-warn { background: var(--amber-bg); border-color: var(--amber-bd); color: #6b4604; }
.alert-error { background: var(--red-bg); border-color: var(--red-bd); color: #93261d; }
.alert ul { margin: 4px 0 0 18px; }
.text-red { color: var(--red) !important; }
.text-green { color: var(--green) !important; }
.text-amber { color: var(--amber) !important; }
.text-blue { color: var(--primary) !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.mono { font-family: Consolas, 'Courier New', monospace; font-size: 12.5px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }

/* expiry */
.exp { font-variant-numeric: tabular-nums; white-space: nowrap; }
.exp-expired { color: #fff; background: var(--red); padding: 1px 6px; border-radius: 3px; font-weight: 500; }
.exp-d30 { color: var(--red); font-weight: 600; }
.exp-d60 { color: var(--amber); font-weight: 600; }
.exp-d90 { color: #9b6b00; }
.exp-d120 { color: var(--primary); }

/* ============================== Tabs ============================== */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; background: var(--surface); scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
.tabs::-webkit-scrollbar { height: 4px; }
.tabs::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }
.tab { padding: 10px 14px 9px; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary-700); border-bottom-color: var(--primary); font-weight: 600; }
.tab .badge { margin-left: 5px; }

/* ============================== Avatars ============================== */
.av { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 600; flex-shrink: 0; }
.av-sm { width: 28px; height: 28px; font-size: 12.5px; }
.av-md { width: 36px; height: 36px; font-size: 15px; }
.av-lg { width: 56px; height: 56px; font-size: 22px; }

/* ============================== Empty / Pager ============================== */
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-top: 1px solid var(--line); gap: 10px; flex-wrap: wrap; }
.pager-info { font-size: 12.5px; color: var(--muted); padding: 10px 16px; }
.pager .pager-info { padding: 0; }
.pager-links { display: flex; gap: 4px; }
.pg { min-width: 30px; height: 28px; padding: 0 8px; display: inline-grid; place-items: center; border: 1px solid var(--border-2); border-radius: 4px; color: var(--text-2); font-size: 12.5px; background: #fff; }
.pg:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pg.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pg-dots { padding: 0 3px; color: var(--muted); }

/* ============================== Modal / Toast ============================== */
.modal { display: none; position: fixed; inset: 0; background: rgba(15, 28, 50, .45); z-index: 200; align-items: flex-start; justify-content: center; padding: 7vh 16px 16px; overflow-y: auto; }
.modal.show { display: flex; }
.modal-box { background: #fff; border-radius: 8px; width: 100%; max-width: 540px; box-shadow: 0 16px 48px rgba(10, 25, 50, .3); }
.modal-box.wide { max-width: 820px; }
.modal-box.xwide { max-width: 1040px; }
.modal-head { display: flex; align-items: center; padding: 13px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15px; font-weight: 600; flex: 1; color: var(--text); }
.modal-close { background: none; border: 0; width: 30px; height: 30px; border-radius: 4px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.modal-close:hover { background: var(--gray-bg); color: var(--text); }
.modal-body { padding: 16px 18px; }
.modal-foot { padding: 11px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 8px 8px; }
.toast-zone { position: fixed; right: 18px; bottom: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1b2a40; color: #fff; padding: 10px 16px; border-radius: 5px; font-size: 13px; min-width: 240px; max-width: 420px; box-shadow: 0 8px 24px rgba(0,0,0,.2); border-left: 4px solid var(--primary-200); }
.toast.ok { border-left-color: #58b184; }
.toast.error { border-left-color: #f0857a; }

/* ============================== Sheet (ตารางบันทึกแบบ Grid) ============================== */
.sheet-wrap { overflow: auto; max-height: calc(100vh - 290px); min-height: 280px; border-top: 1px solid var(--border); }
.sheet { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.sheet th { position: sticky; top: 0; z-index: 3; background: #eef2f7; color: var(--text-2); font-weight: 600; font-size: 12.3px; text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border-2); border-right: 1px solid var(--line); white-space: nowrap; }
.sheet td { padding: 4px 8px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); background: #fff; vertical-align: middle; }
.sheet .sticky-1, .sheet .sticky-2 { position: sticky; z-index: 2; }
.sheet th.sticky-1, .sheet th.sticky-2 { z-index: 4; }
.sheet .sticky-1 { left: 0; width: 34px; min-width: 34px; text-align: center; }
.sheet .sticky-2 { left: 34px; min-width: 220px; box-shadow: 1px 0 0 var(--border); }
.sheet tr:hover td { background: #f7f9fc; }
.sheet tr.is-dirty td { background: #fffbea; }
.sheet tr.is-error td { background: #fff4f3; }
.sheet tr.is-locked td { background: #f6f7f9; color: var(--muted); }
.sheet tr.is-hidden { display: none; }
.sheet .select, .sheet .input { height: 28px; font-size: 12.8px; }
.sheet .cell-num { width: 96px; text-align: right; }
.sheet .cell-err { border-color: var(--red) !important; background: #fff6f5; }
.sheet td.cell-dirty { background: #fff6d6 !important; }
.sheet .cell-note-btn { border: 0; background: none; color: #9aa7b8; cursor: pointer; padding: 2px; }
.sheet .cell-note-btn.has-note { color: var(--primary); }
.sheet .sub { font-size: 11px; color: var(--muted); line-height: 1.2; }
.st-select { min-width: 190px; }
.st-work { color: var(--primary-700); }
.st-late { color: var(--amber); background-color: #fffaf0 !important; }
.st-absent { color: var(--red); background-color: #fff6f5 !important; }
.st-leave { color: var(--green); background-color: #f4faf6 !important; }
.st-weekly_off, .st-public_holiday { color: #56657a; background-color: #f4f6f9 !important; }
.st-work_weekly_off, .st-work_public_holiday { color: var(--navy); background-color: #eef2f8 !important; font-weight: 500; }
.st-unset { color: var(--red); border-style: dashed !important; }
.sheet-actions { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px; align-items: center; padding: 10px 16px; background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -4px 12px rgba(16,32,64,.06); flex-wrap: wrap; }
.sheet-summary { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.sheet-summary b { color: var(--text); font-weight: 600; }
.bulk-bar { display: flex; gap: 8px; align-items: center; padding: 8px 16px; background: var(--primary-50); border-bottom: 1px solid var(--primary-200); font-size: 13px; flex-wrap: wrap; }
.warn-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #d49b1f; margin-left: 4px; vertical-align: 1px; }

/* date navigator */
.date-nav { display: flex; align-items: center; gap: 6px; }
.date-nav .input { width: 150px; }
.date-nav .dow { font-size: 13px; color: var(--text-2); min-width: 64px; }

/* ============================== Steps (workflow) ============================== */
.steps { display: flex; gap: 0; margin: 4px 0; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; font-size: 12.8px; color: var(--muted); padding-right: 10px; }
.step + .step::before { content: ''; width: 26px; height: 1px; background: var(--border-2); margin-right: 10px; }
.step-no { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border-2); display: grid; place-items: center; font-size: 12px; background: #fff; }
.step.done { color: var(--text-2); }
.step.done .step-no { background: var(--green); border-color: var(--green); color: #fff; }
.step.current { color: var(--primary-700); font-weight: 600; }
.step.current .step-no { background: var(--grad); border-color: transparent; color: #fff; box-shadow: var(--grad-shadow); }
.step.bad .step-no { background: var(--red); border-color: var(--red); color: #fff; }
.steps-sm .step { font-size: 12px; padding-right: 6px; gap: 6px; }
.steps-sm .step + .step::before { width: 14px; margin-right: 6px; }
.steps-sm .step-no { width: 22px; height: 22px; font-size: 11px; }

/* issues list */
.issue-list { list-style: none; }
.issue-list li { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.issue-list li:last-child { border-bottom: 0; }
.lvl { display: inline-block; min-width: 58px; text-align: center; font-size: 11px; font-weight: 600; border-radius: 3px; padding: 1px 6px; height: 19px; }
.lvl-error { background: var(--red-bg); color: var(--red); }
.lvl-warning { background: var(--amber-bg); color: var(--amber); }

/* branch picker */
.branch-pick { display: flex; flex-direction: column; gap: 14px; align-items: center; margin-top: 16px; }
.branch-pick-group { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.branch-pick-company { width: 100%; text-align: center; font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }

/* charts */
.chart-box { position: relative; height: 270px; }
.chart-box.sm { height: 200px; }
.legend-list { display: flex; flex-direction: column; gap: 6px; font-size: 12.8px; }
.legend-list .lg { display: flex; align-items: center; gap: 8px; }
.legend-list .lg i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-list .lg span { flex: 1; color: var(--text-2); }
.legend-list .lg b { font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-mini { height: 6px; background: var(--gray-bg); border-radius: 3px; overflow: hidden; }
.bar-mini i { display: block; height: 100%; background: var(--grad); border-radius: inherit; }

/* profile header */
.profile { display: flex; gap: 16px; align-items: center; padding: 16px; flex-wrap: wrap; }
.profile-name { font-size: 18px; font-weight: 600; color: var(--text); }
.profile-meta { font-size: 12.8px; color: var(--muted); margin-top: 2px; display: flex; gap: 12px; flex-wrap: wrap; }
.profile-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================== Login (Enterprise) ============================== */
.lg-body { margin: 0; min-height: 100vh; background: #f4f6f9; }
.lg-shell { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(420px, 1fr); min-height: 100vh; }
.lg-brand { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 44px 56px 28px; color: #fff; overflow: hidden;
  background-color: #027a6c;
  background-image: radial-gradient(900px 520px at 12% 0%, rgba(65, 200, 137, .42), transparent 60%),
    linear-gradient(145deg, #08a488 0%, #027a6c 42%, #015d5f 78%, #033f41 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M48 0H0v48' fill='none' stroke='%23ffffff' stroke-opacity='.08'/%3E%3C/svg%3E");
  background-blend-mode: normal, normal, overlay; }
.lg-brand::after { content: ''; position: absolute; right: -180px; bottom: -180px; width: 520px; height: 520px; border-radius: 50%; border: 1px solid rgba(255,255,255,.07); box-shadow: 0 0 0 70px rgba(255,255,255,.02), 0 0 0 140px rgba(255,255,255,.015); pointer-events: none; }
.lg-brand-inner { position: relative; z-index: 1; max-width: 560px; }
.lg-mark { display: flex; align-items: center; gap: 12px; margin-bottom: 56px; }
.lg-logo { display: inline-flex; line-height: 0; filter: drop-shadow(0 4px 12px rgba(0,0,0,.18)); }
.lg-logo.sm { filter: none; }
.lg-name { display: flex; flex-direction: column; font-size: 21px; font-weight: 600; letter-spacing: .3px; color: #fff; line-height: 1.15; }
.lg-name small { font-size: 11.5px; font-weight: 500; color: rgba(255, 255, 255, .82); letter-spacing: 1.4px; text-transform: uppercase; margin-top: 3px; }
.lg-headline { font-size: 30px; line-height: 1.38; font-weight: 600; color: #fff; margin-bottom: 14px; letter-spacing: .1px; }
.lg-lead { font-size: 14.5px; line-height: 1.75; color: rgba(255, 255, 255, .9); margin-bottom: 34px; max-width: 520px; }
.lg-points { list-style: none; display: grid; gap: 18px; margin-bottom: 40px; }
.lg-points li { display: flex; gap: 14px; align-items: flex-start; }
.lg-pi { flex-shrink: 0; width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.3); color: #fff; }
.lg-points strong { display: block; font-size: 14.5px; font-weight: 600; color: #f2f6fb; margin-bottom: 2px; }
.lg-points span { font-size: 13px; color: rgba(255, 255, 255, .85); line-height: 1.55; }
.lg-facts { display: flex; gap: 0; border-top: 1px solid rgba(255,255,255,.1); padding-top: 22px; max-width: 460px; }
.lg-facts > div { flex: 1; padding-right: 18px; }
.lg-facts > div + div { padding-left: 18px; border-left: 1px solid rgba(255,255,255,.1); }
.lg-facts b { display: block; font-size: 21px; font-weight: 600; color: #fff; line-height: 1.2; font-variant-numeric: tabular-nums; }
.lg-facts span { font-size: 12px; color: rgba(255, 255, 255, .82); }
.lg-brand-foot { position: relative; z-index: 1; font-size: 12px; color: rgba(255, 255, 255, .78); }
.lg-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 32px 24px; background: #fff; }
.lg-card { width: 100%; max-width: 400px; }
.lg-mobile-mark { display: none; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--primary-700); margin-bottom: 28px; }
.lg-title { font-size: 26px; font-weight: 600; color: var(--text); margin-bottom: 6px; letter-spacing: .1px; }
.lg-sub { font-size: 14px; color: var(--muted); margin-bottom: 26px; }
.lg-card .alert { align-items: center; }
.lg-field { margin-bottom: 16px; }
.lg-field label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.lg-input { position: relative; display: flex; align-items: center; }
.lg-input > .ic { position: absolute; left: 13px; color: #8b98ab; pointer-events: none; }
.lg-input input { width: 100%; height: 46px; padding: 0 44px 0 40px; border: 1px solid #cfd7e2; border-radius: 8px; font-size: 15px; background: #fbfcfe; color: var(--text); transition: border-color .15s, box-shadow .15s, background .15s; }
.lg-input input::placeholder { color: #a4afbf; }
.lg-input input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px var(--primary-100); }
.lg-input input:focus ~ .ic, .lg-input:focus-within > .ic { color: var(--primary); }
.lg-eye { position: absolute; right: 6px; width: 34px; height: 34px; border: 0; background: none; border-radius: 6px; color: #8b98ab; cursor: pointer; display: grid; place-items: center; }
.lg-eye:hover { background: var(--primary-50); color: var(--primary); }
.lg-caps { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--amber); margin-top: 6px; }
.lg-row { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 20px; }
.lg-forgot { font-size: 13px; color: var(--primary); cursor: help; }
.lg-submit { width: 100%; height: 48px; font-size: 15px; font-weight: 600; border-radius: 10px; gap: 8px; box-shadow: 0 10px 22px -8px rgba(2, 122, 108, .55); }
.lg-submit:disabled { opacity: .8; }
.lg-secure { display: flex; gap: 9px; align-items: flex-start; margin-top: 22px; padding: 12px 14px; background: #f0f9f6; border: 1px solid #cfeade; border-radius: 8px; font-size: 12px; line-height: 1.6; color: #5b6b82; }
.lg-secure .ic { color: var(--primary); margin-top: 2px; }
.lg-demo { margin-top: 18px; border: 1px solid var(--border); border-radius: 8px; }
.lg-demo summary { display: flex; align-items: center; gap: 7px; padding: 10px 14px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-2); list-style: none; }
.lg-demo summary::-webkit-details-marker { display: none; }
.lg-demo[open] summary { border-bottom: 1px solid var(--line); }
.lg-demo-list { max-height: 250px; overflow-y: auto; padding: 4px; }
.lg-demo-item { display: grid; grid-template-columns: 96px 1fr auto; gap: 8px; align-items: center; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: left; font-size: 12.5px; color: var(--text); }
.lg-demo-item:hover { background: var(--primary-50); }
.lg-demo-item .mono { color: var(--primary-700); font-weight: 600; }
.lg-demo-role { color: var(--text-2); }
.lg-demo-scope { color: var(--muted); font-size: 11.5px; }
.lg-foot { margin-top: 36px; font-size: 12px; color: #98a3b3; text-align: center; }
@media (max-width: 1000px) {
  .lg-shell { grid-template-columns: 1fr; }
  .lg-brand { display: none; }
  .lg-mobile-mark { display: flex; }
  .lg-main { min-height: 100vh; background: #f4f6f9; padding: 24px 16px; }
  .lg-card { background: #fff; padding: 30px 26px; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(20, 45, 85, .08); }
}
@media (max-height: 760px) and (min-width: 1001px) { .lg-mark { margin-bottom: 30px; } .lg-points { gap: 12px; margin-bottom: 26px; } .lg-headline { font-size: 26px; } }
/* ============================== Rules ============================== */
.rule-row { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.rule-row:last-child { border-bottom: 0; }
.rule-label { font-weight: 600; color: var(--text); }
.rule-value .tbl { max-width: 720px; }
.rule-table .input { min-width: 70px; }
.select.sev-error { color: var(--red); font-weight: 500; }
.select.sev-warning { color: var(--amber); }
.select.sev-off { color: var(--muted); }
@media (max-width: 1100px) { .rule-row { grid-template-columns: 1fr; gap: 8px; } }

.lt-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: 0; }
.perm-matrix th.role-col { text-align: center; min-width: 110px; white-space: normal; }
.perm-matrix td.c input { width: 16px; height: 16px; accent-color: var(--primary); }
.perm-matrix tr.perm-group td { background: var(--primary-50); color: var(--primary-700); font-weight: 600; }
.diff-old { color: var(--red); text-decoration: line-through; text-decoration-color: rgba(176, 38, 28, .4); }
.diff-new { color: var(--green); }

/* ============================== Forms: Editor ============================== */
.fm-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; align-items: start; }
.fm-main { margin-bottom: 0; display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 520px; }
.fm-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.fm-sep { width: 1px; height: 20px; background: var(--border-2); margin: 0 2px; }
.fm-canvas { flex: 1; overflow: auto; background: #dfe4ea; padding: 18px; }
.fm-side { position: sticky; top: calc(var(--hdr-h) + 12px); max-height: calc(100vh - var(--hdr-h) - 24px); overflow-y: auto; }
.fm-side .panel { margin-bottom: 12px; }
.fm-cat { max-height: 340px; overflow-y: auto; }
.fm-cat details { border-bottom: 1px solid var(--line); }
.fm-cat summary { padding: 7px 12px; cursor: pointer; font-size: 12.8px; font-weight: 600; color: var(--text-2); background: var(--surface-2); }
.fm-item { padding: 5px 12px 5px 20px; font-size: 12.5px; cursor: grab; border-top: 1px solid var(--line); }
.fm-item:hover { background: var(--primary-50); color: var(--primary-700); }
.fm-item.placing { background: var(--primary-100); color: var(--primary-700); font-weight: 600; }
.fm-p { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.fm-p.wide { width: 100%; }
.fm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.fm-in { border: 1px solid var(--line); border-radius: 5px; padding: 8px; margin-bottom: 8px; background: var(--surface-2); }
.fp-page { position: relative; margin: 0 auto 16px; background: #fff; box-shadow: 0 1px 5px rgba(20, 35, 60, .25); overflow: hidden; }
.fp-bg { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; pointer-events: none; }
.fp-ov { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.fp-ov .fp-label { fill: var(--primary); }
.fm-layer { position: absolute; inset: 0; }
.fm-box { position: absolute; border: 1px dashed rgba(31, 78, 140, .5); background: rgba(31, 78, 140, .05); cursor: move; border-radius: 2px; touch-action: none; }
.fm-box:hover { background: rgba(31, 78, 140, .1); }
.fm-box.sel { border: 1.5px solid var(--primary); background: rgba(31, 78, 140, .12); box-shadow: 0 0 0 2px rgba(31, 78, 140, .15); }
.fm-rs { position: absolute; right: -5px; top: 0; bottom: 0; width: 9px; cursor: ew-resize; }
.fm-box.sel .fm-rs::after { content: ''; position: absolute; right: 3px; top: 50%; width: 3px; height: 12px; margin-top: -6px; background: var(--primary); border-radius: 2px; }
.fm-blank { position: absolute; height: 2px; background: rgba(214, 138, 20, .5); pointer-events: none; }
.fm-pno { position: absolute; top: 4px; right: 6px; font-size: 11px; color: #8a96a8; background: rgba(255,255,255,.85); padding: 0 6px; border-radius: 3px; pointer-events: none; }
.lt-canvas { background: #dfe4ea; }
.lt-page { width: 210mm; min-height: 297mm; margin: 0 auto 18px; padding: 20mm 20mm 22mm 25mm; background: #fff; box-shadow: 0 1px 5px rgba(20, 35, 60, .25);
  font-family: 'Sarabun', 'IBM Plex Sans Thai', sans-serif; font-size: 15px; line-height: 1.75; color: #111; }
.lt-page:focus { outline: 2px solid var(--primary-200); }
.lt-page p { margin: 0 0 6px; }
.lt-page h3 { font-size: 17px; margin: 6px 0 10px; }
.lt-page table { border-collapse: collapse; width: 100%; }
.lt-page td, .lt-page th { padding: 3px 6px; vertical-align: top; }
.lt-page ul, .lt-page ol { margin: 0 0 6px 24px; }
.lt-page .blank { display: inline-block; min-width: 110px; border-bottom: 1px dotted #777; }
@media (max-width: 1100px) { .fm-wrap { grid-template-columns: 1fr; } .fm-side { position: static; max-height: none; } }

/* ============================== Forms: Print page ============================== */
.fp-body { background: #d9dee5; }
.fp-toolbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: #fff; border-bottom: 1px solid var(--border); box-shadow: 0 2px 8px rgba(16,32,64,.06); flex-wrap: wrap; }
.fp-tb-title { display: flex; flex-direction: column; line-height: 1.35; }
.fp-note { background: var(--green-bg); color: #175c38; padding: 7px 18px; font-size: 13px; border-bottom: 1px solid var(--green-bd); }
.fp-warn { background: var(--amber-bg); color: #6f4a00; padding: 7px 18px; font-size: 13px; border-bottom: 1px solid var(--amber-bd); }
#fpDocs { padding: 18px 0 30px; }
.fp-sheet { position: relative; width: 595.28pt; height: 841.89pt; margin: 0 auto 18px; background: #fff; box-shadow: 0 1px 6px rgba(20,35,60,.3); overflow: hidden; }
.fp-sheet .fp-page { margin: 0; box-shadow: none; position: absolute; left: 0; top: 0; }
.fp-void { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%) rotate(-28deg); font-size: 120px; font-weight: 700; color: rgba(176, 38, 28, .22);
  border: 8px solid rgba(176, 38, 28, .22); padding: 0 30px; border-radius: 16px; pointer-events: none; font-family: 'Sarabun', sans-serif; }
.lt-doc { position: relative; }
.lt-doc.is-cancelled::after { content: 'ยกเลิก'; position: absolute; left: 50%; top: 140mm; transform: translate(-50%, -50%) rotate(-28deg); font-size: 110px; font-weight: 700; color: rgba(176,38,28,.2);
  border: 8px solid rgba(176,38,28,.2); padding: 0 28px; border-radius: 16px; pointer-events: none; }
@media print {
  .fp-body { background: #fff; }
  #fpDocs { padding: 0; }
  .fp-sheet { margin: 0; box-shadow: none; break-after: page; page-break-after: always; }
  .fp-sheet:last-child { break-after: auto; page-break-after: auto; }
  .lt-doc + .lt-doc, .fp-doc + .lt-doc, .lt-doc + .fp-doc { break-before: page; page-break-before: always; }
  .lt-page { margin: 0; box-shadow: none; width: auto; min-height: 0; padding: 0; }
  .lt-page .blank { border-bottom-color: #555; }
}

/* ============================== Reports ============================== */
.rpt-link { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); color: var(--text); }
.rpt-link:last-child { border-bottom: 0; }
.rpt-link:hover { background: var(--primary-50); text-decoration: none; color: var(--text); }
.rpt-link-title { font-weight: 600; color: var(--primary-700); min-width: 210px; font-size: 13.5px; }
.rpt-link-desc { flex: 1; font-size: 12.5px; color: var(--muted); }
.rpt-link .ic { color: #9aa7b8; }
.rpt-table td { white-space: nowrap; }
.rpt-table tr.grp-row td { background: var(--primary-50); color: var(--primary-700); font-weight: 600; border-top: 1px solid var(--primary-200); }
.rpt-table tr.sub-row td { background: var(--surface-2); font-weight: 600; border-bottom: 1px solid var(--border); }
.rpt-table td.sign-cell { height: 30px; border-bottom: 1px dotted var(--border-2); }
.print-page { background: #fff; padding: 14px 18px; font-size: 12px; }
.print-page .tbl { font-size: 11.5px; }
.print-page .tbl th, .print-page .tbl td { padding: 4px 6px; }
.print-page .empty { padding: 12px; }
.print-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid var(--primary); padding-bottom: 8px; margin-bottom: 10px; }
.print-company { font-size: 12.5px; color: var(--text-2); }
.print-title { font-size: 17px; font-weight: 600; color: var(--text); }
.print-sub { font-size: 12px; color: var(--text-2); }
.print-meta { font-size: 11px; color: var(--muted); text-align: right; white-space: nowrap; }
.print-warn { font-size: 11.5px; color: var(--amber); margin-bottom: 8px; }
.print-sign { display: flex; justify-content: space-around; margin-top: 42px; font-size: 12px; }

/* ============================== Print ============================== */
.print-only { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .hdr, .side, .no-print, .page-actions, .filters, .sheet-actions, .toast-zone, .pager { display: none !important; }
  .layout { padding-top: 0; }
  .main { margin: 0; padding: 0; }
  .panel { border: 0; margin: 0; }
  .print-only { display: block; }
  .tbl th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rpt-table tr.grp-row td, .rpt-table tr.sub-row td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-page { padding: 0; }
  .tbl-scroll { max-height: none !important; overflow: visible !important; }
  tr { page-break-inside: avoid; }
  thead { display: table-header-group; }
  a { color: inherit; }
}

/* ============================== Dashboard ============================== */
.seg { display: inline-flex; max-width: 100%; overflow-x: auto; border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--surface); scrollbar-width: thin; }
.seg form { display: contents; }
.seg button { border: 0; border-left: 1px solid var(--border); background: none; height: 32px; padding: 0 12px; font: inherit; font-size: 13px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.seg form:first-child button { border-left: 0; }
.seg button:hover { background: var(--primary-50); color: var(--primary-700); }
.seg button.on { background: var(--grad); color: #fff; cursor: default; }
.stp { display: inline-flex; align-items: center; vertical-align: middle; margin-left: 4px; }
.stp i { position: relative; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--border-2); background: #fff; }
.stp i + i { margin-left: 9px; }
.stp i + i::before { content: ''; position: absolute; right: calc(100% + 1.5px); top: 50%; width: 9px; height: 1.5px; margin-top: -.75px; background: var(--border-2); }
.stp i.done { background: var(--green); border-color: var(--green); }
.stp i.done + i::before { background: var(--green); }
.stp i.current { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.stp i.bad { background: var(--red); border-color: var(--red); }
.dstrip { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; }
.dcell { display: block; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px 0 5px; text-align: center; background: var(--surface); color: var(--muted); font-size: 10.5px; line-height: 1.3; }
.dcell b { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.dcell .dbar { display: flex; gap: 2px; margin: 3px 6px 0; }
.dcell .dbar i { flex: 1; height: 4px; border-radius: 2px; background: var(--gray-bg); }
.dcell .dbar i.complete { background: #10b981; }
.dcell .dbar i.draft { background: #f59e0b; }
.dcell .dbar i.missing { background: #f43f5e; }
.dcell.hol { background: var(--primary-50); border-color: var(--primary-200); }
.dcell.future { opacity: .5; }
.dcell.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
a.dcell:hover { text-decoration: none; border-color: var(--primary); }
.dlegend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); margin-top: 10px; align-items: center; }
.dlegend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.mini-stat { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.mini-stat > span { font-size: 12px; color: var(--muted); }
.mini-stat > b { font-size: 15px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.mini-stat small { font-size: 11.5px; }
.mini-stat .bar-mini { margin-top: 3px; }
.mini-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.mini-row > span { color: var(--muted); }
.mini-row > b { font-weight: 600; font-variant-numeric: tabular-nums; }
/* ---- การ์ดกราฟ: ตัวเลขสรุปมุมขวาบน + legend โดนัทแบบรายการ ---- */
.chart-stat { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; }
.chart-stat .cs-label { color: var(--muted); }
.chart-stat b { font-size: 16px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.2px; }
.cs-delta { font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.cs-delta.up { color: var(--c-blue); background: var(--c-blue-bg); }
.cs-delta.down { color: var(--c-emerald); background: var(--c-emerald-bg); }
.donut-legend { display: flex; flex-direction: column; margin-top: 8px; }
.dl-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 50px; gap: 9px; align-items: center; font-size: 12.8px; padding: 7px 2px; border-bottom: 1px solid var(--line); }
.dl-row:last-child { border-bottom: 0; }
.dl-row i { width: 10px; height: 10px; border-radius: 3px; }
.dl-row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.dl-row small { color: var(--muted); font-size: 11.5px; margin-left: 4px; font-weight: 400; }
.dl-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.dl-row em { font-style: normal; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
/* ปุ่มสลับภาษา TH / EN */
.hdr-lang, .lg-lang { display: inline-flex; padding: 2px; border-radius: 999px; gap: 2px; }
.hdr-lang { background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .3); }
.hdr-lang a, .lg-lang a { font-size: 11.5px; font-weight: 600; letter-spacing: .4px; padding: 3px 10px; border-radius: 999px; text-decoration: none; }
.hdr-lang a { color: #fff; }
.hdr-lang a:hover { background: rgba(255, 255, 255, .2); color: #fff; text-decoration: none; }
.hdr-lang a.on { background: #fff; color: var(--primary); box-shadow: 0 3px 8px -4px rgba(0, 40, 36, .5); }
.lg-lang { position: absolute; top: 20px; right: 24px; background: var(--gray-bg); border: 1px solid var(--border); }
.lg-lang a { color: var(--muted); }
.lg-lang a:hover { color: var(--text); text-decoration: none; }
.lg-lang a.on { background: var(--grad); color: #fff; box-shadow: var(--grad-shadow); }
.lg-main { position: relative; }
/* ============================== Motion (เน้นสิ่งสำคัญ — ปิดอัตโนมัติเมื่อผู้ใช้ตั้งค่าลดการเคลื่อนไหว) ============================== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes ringRose { 0% { box-shadow: 0 0 0 0 rgba(244, 63, 94, .5); } 70% { box-shadow: 0 0 0 9px rgba(244, 63, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); } }
@keyframes ringAmber { 0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, .5); } 70% { box-shadow: 0 0 0 9px rgba(245, 158, 11, 0); } 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); } }
@keyframes ringBrand { 0% { box-shadow: 0 0 0 0 rgba(2, 122, 108, .5); } 70% { box-shadow: 0 0 0 8px rgba(2, 122, 108, 0); } 100% { box-shadow: 0 0 0 0 rgba(2, 122, 108, 0); } }
@keyframes blinkSoft { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes nudge { 0%, 84%, 100% { transform: translateX(0); } 88% { transform: translateX(-3px); } 92% { transform: translateX(3px); } 96% { transform: translateX(-2px); } }
@keyframes bell { 0%, 80%, 100% { transform: rotate(0); } 84% { transform: rotate(-12deg); } 88% { transform: rotate(10deg); } 92% { transform: rotate(-6deg); } 96% { transform: rotate(4deg); } }
@keyframes shine { from { transform: translateX(-130%) skewX(-22deg); } to { transform: translateX(230%) skewX(-22deg); } }
@keyframes growX { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes popIn { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
@keyframes gradFlow { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

@media (prefers-reduced-motion: no-preference) {
  /* เข้าหน้าแบบค่อยๆ ขึ้นทีละการ์ด */
  .main .page-head { animation: fadeUp .4s cubic-bezier(.2, .7, .2, 1) both; }
  .main .kpi, .main .panel { animation: fadeUp .5s cubic-bezier(.2, .7, .2, 1) both; }
  .grid > .kpi:nth-child(1) { animation-delay: .03s; } .grid > .kpi:nth-child(2) { animation-delay: .07s; }
  .grid > .kpi:nth-child(3) { animation-delay: .11s; } .grid > .kpi:nth-child(4) { animation-delay: .15s; }
  .grid > .kpi:nth-child(5) { animation-delay: .19s; } .grid > .kpi:nth-child(6) { animation-delay: .23s; }
  .grid > .panel:nth-child(2) { animation-delay: .08s; }
  /* การ์ดตัวเลข: ยกขึ้นเมื่อชี้ */
  .kpi { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
  a.kpi:hover { transform: translateY(-3px); box-shadow: 0 14px 28px -16px rgba(15, 23, 42, .35); }
  a.kpi:hover .kpi-icon { transform: scale(1.08) rotate(-4deg); }
  .kpi-icon { transition: transform .2s ease; }
  /* สิ่งที่ต้องรีบดู: วงแหวนกระพริบ */
  .kpi-red .kpi-icon { animation: ringRose 2s ease-out infinite; }
  .kpi-amber .kpi-icon { animation: ringAmber 2.4s ease-out infinite; }
  .kpi-red .kpi-value { animation: blinkSoft 2.4s ease-in-out 3; }
  .warn-dot.urgent { animation: ringRose 1.8s ease-out infinite; }
  .attn { animation: nudge 4s ease-in-out infinite; display: inline-block; }
  .attn-bell .ic { animation: bell 4s ease-in-out infinite; transform-origin: 50% 10%; }
  .badge.pop { animation: popIn .45s cubic-bezier(.3, 1.4, .5, 1) .35s both; }
  .badge.b-red.live { animation: blinkSoft 2s ease-in-out infinite; }
  /* ขั้นตอนปัจจุบัน / วันนี้ */
  .step.current .step-no { animation: ringBrand 2.2s ease-out infinite; }
  .stp i.current { animation: ringBrand 2.2s ease-out infinite; }
  .dcell.today { animation: ringBrand 2.2s ease-out infinite; }
  /* แถบความคืบหน้าวิ่งเข้าจากซ้าย */
  .bar-mini i { transform-origin: left center; animation: growX .9s cubic-bezier(.2, .7, .2, 1) .25s both; }
  /* ปุ่มหลัก: ประกายเมื่อชี้ + ไล่เฉดไหลช้าๆ */
  .btn-primary { position: relative; overflow: hidden; background-size: 180% 180%; animation: gradFlow 8s ease infinite; }
  .btn-primary::after { content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 38%; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent); transform: translateX(-130%) skewX(-22deg); pointer-events: none; }
  .btn-primary:hover::after { animation: shine .75s ease; }
  .btn { transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .1s ease; }
  .btn:active { transform: translateY(1px); }
  /* header ไล่เฉดเคลื่อนช้าๆ */
  .hdr { background-size: 160% 160% !important; animation: gradFlow 14s ease infinite; }
  /* เมนู */
  .side-link, .side-top, .sg-head { transition: background-color .15s ease, color .15s ease, padding-left .15s ease; }
  .side-link:hover { padding-left: 17px; }
  .side-link.active::before { animation: growX .35s ease both; transform-origin: center top; }
  /* ตาราง: ไฮไลต์แถวแบบนุ่ม */
  .tbl tbody tr td { transition: background-color .12s ease; }
}
@media print { *, *::before, *::after { animation: none !important; transition: none !important; } .main .kpi, .main .panel, .main .page-head { opacity: 1 !important; transform: none !important; } }

/* ============================== Responsive ============================== */
@media (max-width: 1280px) {
  .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hdr-title { display: none; }
  .hdr-search input { width: 220px; }
}
@media (max-width: 1100px) {
  .hdr-burger { display: inline-flex; }
  .hdr-brand { min-width: 0; }
  .side { transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.12); }
  body.side-open .side { transform: none; }
  .main { margin-left: 0; padding: 14px 14px 40px; }
  .g4, .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-side { grid-template-columns: 1fr; }
  .hdr-search { display: none; }
  .ctx-company { display: none; }
  .ctx-sep { display: none; }
}
@media (max-width: 700px) {
  .g2, .g3, .g4, .g5, .g6 { grid-template-columns: 1fr; }
  .hdr-user-text { display: none; }
  .form-grid .span-2 { grid-column: auto; }
}

/* ---------- คู่มือการใช้งาน ---------- */
.help-wrap { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.help-toc { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.help-toc-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 6px 6px; }
.help-toc a { padding: 6px 8px; border-radius: 8px; color: var(--text-2); font-size: 13px; line-height: 1.35; text-decoration: none; }
.help-toc a:hover { background: var(--primary-50); color: var(--primary-700); }
.help-doc { max-width: 900px; line-height: 1.75; color: var(--text-2); }
.help-doc .help-h2 { font-size: 19px; color: var(--text); margin: 30px 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--primary-100); scroll-margin-top: 80px; }
.help-doc .help-h2:first-child { margin-top: 0; }
.help-doc .help-h3 { font-size: 15.5px; color: var(--text); margin: 20px 0 8px; }
.help-doc p { margin: 0 0 10px; }
.help-doc .help-list { margin: 0 0 12px; padding-left: 22px; }
.help-doc .help-list li { margin: 3px 0; }
.help-doc .help-list ul, .help-doc .help-list ol { margin: 4px 0; padding-left: 20px; }
.help-doc code { background: var(--gray-bg); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; font-size: 12.5px; }
.help-doc .help-code { background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 12px 14px; font-size: 12.5px; overflow-x: auto; margin: 0 0 12px; }
.help-doc .help-tbl { margin: 4px 0 16px; }
.help-doc .help-tbl td, .help-doc .help-tbl th { vertical-align: top; }
.help-doc .help-note { margin: 8px 0 14px; }
.help-doc strong { color: var(--text); }
@media (max-width: 900px) { .help-wrap { grid-template-columns: 1fr; } .help-toc { position: static; } }
@media print { .help-toc { display: none; } .help-wrap { display: block; } }

/* ---------- ช่องวันที่ dd/mm/yyyy + ปฏิทิน ---------- */
.dpk { position: relative; display: inline-flex; align-items: center; vertical-align: middle; }
.field .dpk, .form-grid .dpk { display: flex; width: 100%; }
.dpk .dpk-text { padding-right: 30px; font-variant-numeric: tabular-nums; }
.field .dpk .dpk-text { width: 100%; }
.dpk .dpk-text.dpk-err { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.dpk-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer; }
.dpk-btn:hover { color: var(--primary); background: var(--primary-50); }
.dpk-btn:disabled { opacity: .4; cursor: default; }
.dpk-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 90; width: 268px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 40px -12px rgba(15, 23, 42, .28); }
.dpk-pop.up { top: auto; bottom: calc(100% + 6px); }
.dpk-pop.right { left: auto; right: 0; }
.dpk-head { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.dpk-head select { flex: 1; min-width: 0; height: 30px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font: inherit; font-size: 13px; padding: 0 4px; color: var(--text); }
.dpk-nav { width: 28px; height: 30px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: 16px; line-height: 1; color: var(--text-2); }
.dpk-nav:hover { border-color: var(--primary-200); color: var(--primary-700); }
.dpk-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dpk-dow { text-align: center; font-size: 11.5px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.dpk-dow.sun, .dpk-day.sun { color: var(--red); }
.dpk-day { height: 32px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font: inherit; font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.dpk-day:hover { background: var(--primary-50); color: var(--primary-700); }
.dpk-day.is-today { box-shadow: inset 0 0 0 1.5px var(--primary-200); font-weight: 600; }
.dpk-day.is-sel { background: var(--grad); color: #fff; font-weight: 600; box-shadow: var(--grad-shadow); }
.dpk-day:disabled { color: var(--faint); background: transparent; cursor: not-allowed; text-decoration: line-through; }
.dpk-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.dpk-link { border: 0; background: transparent; color: var(--primary-700); font: inherit; font-size: 13px; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.dpk-link:hover { background: var(--primary-50); }
.dpk-link:disabled { color: var(--faint); cursor: default; }

/* ---------- แถบวันที่ทั้งเดือน (บันทึกเวลา / OT) ---------- */
.day-strip { padding: 10px 16px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.ds-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13.5px; flex-wrap: wrap; }
.ds-head b { min-width: 110px; text-align: center; }
.ds-legend { display: flex; gap: 12px; margin-left: auto; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.ds-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1px solid transparent; }
.ds-legend .lg-complete { background: var(--green-bg); border-color: var(--green-bd); }
.ds-legend .lg-draft { background: var(--amber-bg); border-color: var(--amber-bd); }
.ds-legend .lg-missing { background: var(--red-bg); border-color: var(--red-bd); }
.ds-legend .lg-hol { background: var(--surface); border-color: var(--red); }
.ds-scroll { overflow-x: auto; padding: 2px 1px 4px; }
.ds-grid { display: grid; gap: 5px; }
.ds-day { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 7px 0 6px; border-radius: 9px;
  border: 1.5px solid var(--border); background: var(--gray-bg); color: var(--text-2); text-decoration: none !important; line-height: 1.1; min-width: 0;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s; }
.ds-day:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); color: var(--text); }
.ds-n { font-size: 16px; font-weight: 600; }
.ds-w { font-size: 11px; color: var(--muted); margin-top: 3px; }
.ds-day.is-complete { background: var(--green-bg); border-color: var(--green-bd); color: var(--green); }
.ds-day.is-draft { background: var(--amber-bg); border-color: var(--amber-bd); color: var(--amber); }
.ds-day.is-missing { background: var(--red-bg); border-color: var(--red-bd); color: var(--red); }
.ds-day.is-none { background: var(--surface-2); }
.ds-day.is-future { background: var(--surface); border-style: dashed; color: var(--faint); }
.ds-day.is-future .ds-w { color: var(--faint); }
.ds-day.is-sun .ds-w { font-weight: 700; }
.ds-day.is-hol::after { content: ''; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.ds-day.is-hol .ds-n { text-decoration: underline; text-decoration-color: var(--red); text-underline-offset: 3px; }
.ds-day.is-today { box-shadow: inset 0 -3px 0 var(--primary); }
.ds-day.is-sel { border-color: var(--primary); background: var(--grad); color: #fff; box-shadow: var(--grad-shadow); }
.ds-day.is-sel .ds-w { color: rgba(255, 255, 255, .9); }
.swap-sel { display: block; margin-top: 4px; min-width: 190px; max-width: 260px; }
.swap-sel[hidden] { display: none; }
.st-holiday_swap_work { color: var(--c-blue); background-color: var(--c-blue-bg) !important; font-weight: 500; }
.st-holiday_swap_off { color: #56657a; background-color: #eef1f6 !important; border-style: dotted !important; }
@media (max-width: 720px) { .ds-legend { margin-left: 0; width: 100%; } }

/* ---------- ดูตัวอย่างไฟล์ ---------- */
.pv-modal { padding-top: 3vh; }
.pv-box { max-width: min(1100px, 96vw); }
.pv-box .modal-head { gap: 8px; }
.pv-body { height: min(80vh, 900px); background: #3f4347; display: flex; align-items: center; justify-content: center; border-radius: 0 0 8px 8px; overflow: auto; }
.pv-body img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; cursor: zoom-in; }
.pv-body img.zoom { max-width: none; max-height: none; cursor: zoom-out; }
.pv-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
/* ---------- ตัวเลือกย่อย (ลิงก์) ---------- */
.seg .seg-item { display: inline-flex; align-items: center; gap: 4px; border-left: 1px solid var(--border); height: 34px; padding: 0 14px; font-size: 13px; color: var(--text-2); white-space: nowrap; text-decoration: none !important; }
.seg .seg-item:first-child { border-left: 0; }
.seg .seg-item:hover { background: var(--primary-50); color: var(--primary-700); }
.seg .seg-item.active { background: var(--grad); color: #fff; }
.seg .seg-item.active .badge { background: rgba(255, 255, 255, .25); color: #fff; }
/* ---------- เอกสารพนักงาน ---------- */
.doc-check { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface-2); }
.doc-check-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.doc-check-bar { height: 6px; border-radius: 3px; background: var(--red-bg); margin-top: 8px; overflow: hidden; }
.doc-check-bar span { display: block; height: 100%; background: linear-gradient(90deg, #10b981, #0e8f5b); border-radius: 3px; transition: width .4s ease; }
.doc-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; border: 1px solid; }
.doc-chip.ok { color: var(--green); background: var(--green-bg); border-color: var(--green-bd); }
.doc-chip.miss { color: var(--red); background: var(--red-bg); border-color: var(--red-bd); }
.doc-upload { border-color: var(--primary-200); box-shadow: var(--grad-shadow); }
.file-list { margin-top: 6px; line-height: 1.6; }
.progress { height: 5px; border-radius: 3px; background: var(--gray-bg); margin-top: 4px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--grad); border-radius: 3px; }

/* ---------- อนุมัติค่าแรง ---------- */
.appr-card { display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(300px, 2fr) auto; gap: 16px; align-items: center; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; background: var(--surface); transition: box-shadow .15s, border-color .15s; }
.appr-card:hover { box-shadow: var(--shadow-md); border-color: var(--primary-200); }
.appr-title { font-weight: 600; font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.appr-nums { display: grid; grid-template-columns: repeat(5, minmax(0, auto)); gap: 4px 18px; }
.appr-nums div { display: flex; flex-direction: column; min-width: 0; }
.appr-nums span { font-size: 11.5px; color: var(--muted); }
.appr-nums b { font-size: 15px; white-space: nowrap; }
.appr-nums em { font-style: normal; font-size: 11px; }
.appr-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.text-primary { color: var(--primary-700) !important; }
.mt-4 { margin-top: 4px; }
.side-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--c-rose); color: #fff; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; }
.sg-count.sg-alert { background: var(--c-rose) !important; color: #fff !important; }
@media (max-width: 1100px) { .appr-card { grid-template-columns: 1fr; } .appr-nums { grid-template-columns: repeat(3, minmax(0, 1fr)); } .appr-actions { justify-content: flex-start; } }

/* ---------- สรุปค่าแรง: ตารางแบบ Excel ---------- */
.xl-wrap { overflow: auto; max-height: calc(100vh - 300px); min-height: 320px; border-top: 1px solid var(--border); background: var(--surface); }
.xl { border-collapse: separate; border-spacing: 0; font-size: 12.5px; min-width: 100%; font-variant-numeric: tabular-nums; }
.xl th, .xl td { border-right: 1px solid #e2e6ec; border-bottom: 1px solid #e2e6ec; padding: 4px 8px; white-space: nowrap; background: var(--surface); }
.xl thead th { position: sticky; z-index: 3; background: #f6f7f9; font-weight: 600; text-align: center; }
.xl thead tr.xl-letters th { top: 0; height: 22px; padding: 2px 6px; font-size: 11px; color: #8a94a6; font-weight: 500; background: #eef0f3; }
.xl thead tr.xl-sides th { top: 22px; height: 24px; padding: 3px 6px; font-size: 11.5px; }
.xl thead tr.xl-head th { top: 46px; white-space: normal; min-width: 78px; max-width: 124px; line-height: 1.25; font-size: 12px; vertical-align: middle; }
.xl .xl-side-info { background: #eef2f7; color: var(--text-2); }
.xl .xl-side-income { background: #e5f5ec; color: var(--green); }
.xl .xl-side-deduct { background: #fdecec; color: #b42318; }
.xl .xl-side-net { background: var(--primary-100); color: var(--primary-700); }
.xl .xl-rn { position: sticky; left: 0; z-index: 2; width: 38px; min-width: 38px; max-width: 38px; text-align: center; color: #8a94a6; background: #eef0f3; font-size: 11px; padding: 4px 2px; }
.xl thead .xl-rn { z-index: 6; }
.xl .xl-fix { position: sticky; z-index: 2; }
.xl .xl-f0 { left: 38px; width: 48px; min-width: 48px; }
.xl .xl-f1 { left: 86px; width: 88px; min-width: 88px; }
.xl .xl-f2 { left: 174px; min-width: 210px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; box-shadow: 2px 0 0 #d5dae4; }
.xl thead .xl-fix { z-index: 5; }
.xl td.xl-n { text-align: right; }
.xl td.xl-strong { font-weight: 600; background: #f5fbf8; }
.xl td.xl-ded { color: #b42318; }
.xl tbody tr.xl-row:hover td { background: #eef8f4; }
.xl tr.xl-group td { background: #f1f4f8; font-weight: 600; color: #7a3a06; }
.xl tr.xl-sub td { background: #e8f5ef; font-weight: 600; border-bottom: 1px solid #b7dccd; }
.xl tfoot td { position: sticky; bottom: 0; z-index: 3; background: #d3eee3; font-weight: 700; border-top: 2px solid #5fb89c; }
.xl tfoot .xl-fix, .xl tfoot .xl-rn { z-index: 5; }
.xl tr.is-hidden { display: none; }
.xl tr.xl-dim { opacity: .45; }
.xl a { color: inherit; }
.xl a:hover { color: var(--primary-700); }

/* ---------- คลังเอกสาร ---------- */
.doc-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.doc-kpi { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none !important; transition: transform .15s, box-shadow .15s, border-color .15s; }
.doc-kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary-200); }
.doc-kpi-ic { grid-row: span 2; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--grad-soft); color: var(--primary-700); }
.doc-kpi-n { font-size: 20px; font-weight: 700; line-height: 1.1; }
.doc-kpi-l { font-size: 12.5px; color: var(--muted); }
.doc-list { display: flex; flex-direction: column; }
.doc-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.doc-list.compact .doc-item { padding: 8px 4px; }
.doc-item:hover { background: var(--surface-2); }
.doc-ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; }
.doc-ic-emp_doc { background: var(--c-sky-bg); color: var(--c-sky); }
.doc-ic-payslip { background: var(--c-emerald-bg); color: var(--c-emerald); }
.doc-ic-report { background: var(--c-amber-bg); color: var(--c-amber); }
.doc-ic-company { background: var(--c-indigo-bg); color: var(--c-indigo); }
.doc-ic-form { background: var(--c-violet-bg); color: var(--c-violet); }
.doc-ic-fw { background: var(--c-teal-bg); color: var(--c-teal); }
.doc-body { min-width: 0; }
.doc-title { font-weight: 600; overflow-wrap: anywhere; }
.doc-files { margin-top: 4px; }
.doc-files a { margin-right: 10px; }
.doc-meta { text-align: right; white-space: nowrap; }
@media (max-width: 720px) { .doc-item { grid-template-columns: auto 1fr; } .doc-meta { grid-column: 2; text-align: left; } }
.log-box { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.6; max-height: 320px; overflow: auto; white-space: pre-wrap; }
.log-box .text-green { color: #4ade80 !important; }
.log-box .text-red { color: #fca5a5 !important; }

/* ============================== แดชบอร์ดระดับองค์กร (v2.2) ============================== */
.dash-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.dash-bar .grow { flex: 1; }
.dash-tabs { display: flex; gap: 6px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; scrollbar-width: thin; }
.dash-tab { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: 9px; font-size: 13.5px; font-weight: 500; color: var(--text-2); white-space: nowrap; text-decoration: none !important; transition: background .15s, color .15s, box-shadow .15s; }
.dash-tab:hover { background: var(--surface); color: var(--primary-700); }
.dash-tab.active { background: var(--grad); color: #fff; box-shadow: var(--grad-shadow); }
.dash-tab.active .ic { color: #fff; }
.dash-tab .badge { background: rgba(255, 255, 255, .22); color: inherit; }
.dash-tab:not(.active) .badge { background: var(--red-bg); color: var(--red); }

/* ---------- KPI ระดับโปร ---------- */
.kpi-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.kpi-pro { flex: 1 1 250px; position: relative; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; text-decoration: none !important; color: var(--text); transition: transform .15s ease, box-shadow .15s ease, border-color .15s; }
.kpi-pro::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--kpi-color, var(--primary)); opacity: .9; }
a.kpi-pro:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary-200); }
.kpi-pro-top { display: flex; align-items: center; gap: 8px; }
.kpi-pro-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--kpi-soft, var(--primary-50)); color: var(--kpi-color, var(--primary-700)); flex: none; }
.kpi-pro-label { font-size: 12.5px; color: var(--muted); line-height: 1.25; }
.kpi-pro-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.kpi-pro-value { font-size: 25px; font-weight: 700; line-height: 1.1; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.kpi-pro-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi-pro-foot { display: flex; align-items: center; gap: 8px; font-size: 11.8px; color: var(--muted); min-height: 18px; flex-wrap: wrap; }
.kpi-pro.tone-red::before { background: var(--c-rose); }
.kpi-pro.tone-amber::before { background: var(--c-amber); }
.kpi-pro.tone-green::before { background: var(--c-emerald); }

.delta { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--gray-bg); color: var(--muted); }
.delta.good { background: var(--green-bg); color: var(--green); }
.delta.bad { background: var(--red-bg); color: var(--red); }
.delta.flat { background: var(--gray-bg); color: var(--muted); }

.spark { display: block; overflow: visible; }
.spark-line { fill: none; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { opacity: .13; stroke: none; }
.spark-empty { display: inline-block; width: 96px; height: 28px; }

/* ---------- การ์ดกราฟ/ข้อมูล ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.card-title .ic { color: var(--primary-700); }
.card-sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.card-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.card-body { padding: 14px 16px; flex: 1 0 auto; display: flex; flex-direction: column; }
.card-body.p0 { padding: 0; }
.card-body > .chart-box { flex: 1 0 auto; }
/* เนื้อหาในการ์ดยืดเต็มความสูงที่เหลือ เพื่อไม่ให้เกิดช่องว่างค้างท้ายการ์ด */
.card-body > .rank, .card-body > .tl, .card-body > .tbl-wrap { flex: 1 0 auto; }
.card-body > .rank > .rank-item, .card-body > .risk { flex: 1 0 auto; max-height: 104px; }
.card-body > .rank > .rank-item { align-content: center; }
.card-body > .empty { flex: 1 0 auto; display: flex; flex-direction: column; justify-content: center; }
.card-foot { padding: 9px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.card-metric { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.card-metric b { font-size: 16px; font-variant-numeric: tabular-nums; }
.card-metric span { font-size: 11.5px; color: var(--muted); }

.dash-grid { display: grid; gap: 16px; margin-bottom: 16px; align-items: stretch; }
/* คอลัมน์ที่ซ้อนการ์ดหลายใบ: ให้ใบสุดท้ายยืดเต็ม เพื่อให้ขอบล่างของทุกคอลัมน์ชนกันพอดี */
.dash-grid > div:not(.card) { display: flex; flex-direction: column; min-width: 0; }
.dash-grid > div:not(.card) > .card { flex: 1 0 auto; }
.dash-grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dash-grid.s21 { grid-template-columns: 2fr 1fr; }
.dash-grid.s12 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1150px) { .dash-grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 980px) { .dash-grid.c2, .dash-grid.c3, .dash-grid.s21, .dash-grid.s12 { grid-template-columns: 1fr; } }

/* ---------- รายการจัดอันดับพร้อมแถบ ---------- */
.rank { display: flex; flex-direction: column; }
.rank-item { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.rank-item:last-child { border-bottom: 0; }
.rank-item:hover { background: var(--surface-2); }
.rank-label { font-size: 13px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.rank-label small { color: var(--muted); font-size: 11.5px; }
.rank-val { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-val em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 11.5px; margin-left: 4px; }
.rank-bar { grid-column: 1 / -1; }
.dbar-wrap { display: block; height: 6px; border-radius: 3px; background: var(--gray-bg); overflow: hidden; }
.dbar-fill { display: block; height: 100%; border-radius: 3px; transition: width .5s ease; }

/* ---------- วงแหวนเปอร์เซ็นต์ ---------- */
.ring { position: relative; text-align: center; }
.ring svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--gray-bg); stroke-width: 9; }
.ring-fg { fill: none; stroke-width: 9; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.ring-val { position: absolute; inset: 0 0 auto; top: 50%; transform: translateY(-62%); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ring-val small { font-size: 11px; font-weight: 500; color: var(--muted); }
.ring-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- สถิติย่อยในการ์ด ---------- */
.stat-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; background: var(--line); border-radius: 8px; overflow: hidden; }
.stat-cell { background: var(--surface); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat-cell span { font-size: 11.5px; color: var(--muted); }
.stat-cell b { font-size: 16px; font-variant-numeric: tabular-nums; }
.stat-cell small { font-size: 11px; color: var(--muted); }

/* ---------- ไทม์ไลน์กิจกรรม ---------- */
.tl { position: relative; padding: 4px 16px 4px 28px; }
.tl::before { content: ''; position: absolute; left: 20px; top: 10px; bottom: 10px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 7px 0; font-size: 12.5px; }
.tl-item::before { content: ''; position: absolute; left: -12px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary-200); border: 2px solid var(--surface); box-shadow: 0 0 0 1.5px var(--primary-200); }
.tl-item.hot::before { background: var(--c-rose); box-shadow: 0 0 0 1.5px var(--c-rose); }
.tl-when { color: var(--muted); font-size: 11.5px; }
.tl-text { color: var(--text-2); }

/* ---------- แถวความเสี่ยง ---------- */
.risk { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.risk:last-child { border-bottom: 0; }
.risk-ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.risk-body { flex: 1; min-width: 0; }
.risk-title { font-size: 13px; font-weight: 500; }
.risk-sub { font-size: 11.5px; color: var(--muted); }
.risk-val { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

@media print {
  .dash-tabs, .dash-bar .seg, .dash-bar form, .btn { display: none !important; }
  .card, .kpi-pro { break-inside: avoid; box-shadow: none; }
}

/* ============================== ผังองค์กร ============================== */
.sticky-save { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px; align-items: center; justify-content: flex-end;
  padding: 10px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 -4px 12px rgba(16,32,64,.06); margin-bottom: 16px; }
.org-wrap { overflow-x: auto; padding-bottom: 6px; }
.org-tree, .org-tree ul { list-style: none; margin: 0; padding: 0; }
.org-tree li { position: relative; padding: 0 0 0 26px; margin: 6px 0; }
.org-tree > li { padding-left: 0; }
.org-tree li::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; border-left: 2px solid var(--line); }
.org-tree > li::before { display: none; }
.org-tree li::after { content: ''; position: absolute; left: 10px; top: 22px; width: 14px; border-top: 2px solid var(--line); }
.org-tree > li::after { display: none; }
.org-tree li:last-child::before { bottom: auto; height: 22px; }
.org-node { display: inline-flex; flex-direction: column; gap: 5px; min-width: 210px; max-width: 420px; padding: 9px 13px;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 10px; }
.org-node.is-short { border-left-color: var(--c-rose); background: var(--red-bg); }
.org-title { font-size: 13.5px; font-weight: 600; }
.org-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.org-count span { font-size: 11px; }
.org-people { display: flex; flex-wrap: wrap; gap: 5px 8px; margin-top: 2px; }
.org-person { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-2); text-decoration: none !important; }
.org-person:hover { color: var(--primary-700); }
.org-person .av { width: 20px; height: 20px; font-size: 10px; }
.org-more { font-size: 11.5px; color: var(--muted); align-self: center; }

/* ============================== ใบประเมิน ============================== */
.score-pick { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.score-dot input { position: absolute; opacity: 0; width: 0; height: 0; }
.score-dot span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-variant-numeric: tabular-nums; transition: background .12s, color .12s, border-color .12s; }
.score-dot:hover span { border-color: var(--primary-200); background: var(--primary-50); }
.score-dot input:checked + span { background: var(--grad); border-color: transparent; color: #fff; font-weight: 600; }
.score-dot input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }
.org-node.is-empty { border-left-color: var(--line); background: var(--surface-2); opacity: .75; }
.org-node.is-empty .org-title { font-weight: 500; color: var(--text-2); }
.score-pick { flex-wrap: nowrap; }

/* ============================== แผนหัก: เลือกพนักงานหลายคน ============================== */
.plan-bulk { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.pb-pick { min-width: 0; }
.pk-list { max-height: 380px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.pk-list .tbl th { position: sticky; top: 0; z-index: 2; }
.pk-list tbody tr { cursor: pointer; }
.pk-list tbody tr:hover td { background: var(--primary-50); }
.pk-list tbody tr:has(.pkChk:checked) td { background: var(--primary-50); }
.pk-foot { display: flex; align-items: center; gap: 8px; padding: 8px 2px 0; font-size: 13px; }
.pb-sum { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--primary-50); border: 1px solid var(--primary-100); font-size: 13px; line-height: 1.7; }
@media (max-width: 900px) { .plan-bulk { grid-template-columns: 1fr; } }

/* ============================== ศูนย์ยื่นแบบราชการ ============================== */
.gov-intro { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.gov-step { position: relative; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 44px 11px 14px; }
.gov-step b { display: block; font-size: 14px; color: var(--primary-700); margin-bottom: 2px; }
.gov-step span:not(.n) { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.gov-step .n { position: absolute; top: 10px; right: 12px; width: 24px; height: 24px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; box-shadow: var(--grad-shadow); }
.gov-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.gov-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); overflow: hidden; }
.gov-head { display: flex; gap: 12px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); background: linear-gradient(135deg, #f4fbf8 0%, #ffffff 70%); }
.gov-ic { width: 42px; height: 42px; flex-shrink: 0; border-radius: 12px; display: grid; place-items: center; color: #fff; background: var(--grad); box-shadow: var(--grad-shadow); }
.gov-ic .ic { vertical-align: 0; }
.gov-ic.sso { background: linear-gradient(135deg, #60a5fa, #1d4ed8); box-shadow: 0 6px 16px -6px rgba(29, 78, 216, .5); }
.gov-ic.cert { background: linear-gradient(135deg, #c4b5fd, #6d28d9); box-shadow: 0 6px 16px -6px rgba(109, 40, 217, .5); }
.gov-code { font-size: 17px; font-weight: 700; color: var(--text); line-height: 1.25; }
.gov-code small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.gov-desc { font-size: 12.5px; color: var(--muted); }
.gov-body { padding: 14px 16px 16px; }
.gov-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.gov-stats > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; min-width: 0; }
.gov-stats span { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gov-stats b { font-size: 16px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.gov-due { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); margin-bottom: 12px; }
.gov-due b { color: var(--primary-700); }
.gov-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.gov-card .tbl { margin: 4px 0; border: 1px solid var(--line); border-radius: 8px; }
.gov-how { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; font-size: 13px; }
.gov-how summary { cursor: pointer; font-weight: 600; color: var(--primary-700); }
.gov-how ol { margin: 8px 0 6px; padding-left: 22px; line-height: 1.75; color: var(--text-2); }
.gov-how .muted { font-size: 12px; }
.gov-check { list-style: none; }
.gov-check li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.gov-check li:last-child { border-bottom: 0; }
.gov-codes { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; }
.gov-codes a { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; background: var(--gray-bg); border-radius: 5px; padding: 1px 6px; }
@media (max-width: 1150px) { .gov-grid { grid-template-columns: 1fr; } .gov-intro { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* คำอธิบายใต้หัวคอลัมน์ */
.th-hint { font-size: 11px; font-weight: 400; color: var(--muted); line-height: 1.3; margin-top: 1px; white-space: normal; }

/* แดชบอร์ด: สรุปค่าแรงรายงวด */
.seg > button:first-child { border-left: 0; }
.seg.seg-sm button { height: 28px; padding: 0 10px; font-size: 12px; }
.wage-mx td.mx-type { vertical-align: middle; border-right: 1px solid var(--line); background: var(--surface); }
.wage-mx tr.mx-sub td { background: var(--surface-2); font-weight: 600; }
.wage-mx tr.mx-all td { background: var(--primary-50); }
.wage-mx tfoot td { background: var(--primary-50); color: var(--primary-700); font-weight: 700; }
.tbl tr.row-sel td { background: var(--primary-50); }
.wage-split { display: flex; flex-wrap: wrap; }
.wage-split > .tbl-wrap { flex: 1 1 640px; min-width: 0; }
.wage-split > .wage-donuts { flex: 0 0 280px; display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; border-left: 1px solid var(--line); }
.wage-donuts .chart-box { height: 150px; }

/* หน้าผลคำนวณรายคน: การมาทำงานในรอบ (ปฏิทินรายวัน + สรุป) */
.att-explain { padding: 10px 14px; border-radius: 8px; background: var(--primary-50); border: 1px solid var(--primary-100); color: var(--primary-700); margin-bottom: 12px; line-height: 1.6; }
.att-explain svg { vertical-align: -2px; }
.att-explain-calc { font-size: 13.5px; color: var(--text); margin-top: 2px; font-variant-numeric: tabular-nums; }
.att-stats { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; background: none; border-radius: 0; overflow: visible; }
.att-stats .stat-cell { border: 1px solid var(--line); border-radius: 8px; }
.att-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.att-dow { text-align: center; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 2px 0; }
.att-day { display: flex; flex-direction: column; gap: 1px; min-height: 62px; padding: 4px 7px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text-2); font-size: 11px; line-height: 1.3; text-decoration: none !important; overflow: hidden; transition: box-shadow .15s, transform .15s; }
.att-day:hover { box-shadow: 0 2px 8px rgba(15, 23, 42, .1); transform: translateY(-1px); }
.att-day .d { font-size: 13px; font-weight: 600; color: var(--text); }
.att-day .d small { font-size: 10px; font-weight: 500; color: var(--muted); }
.att-day .s { font-weight: 500; color: var(--primary-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-day .x { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-day .ot { margin-top: auto; font-size: 10.5px; font-weight: 600; color: #4338ca; }
.att-day.blank { visibility: hidden; }
.att-day.k-late { background: #fff8e6; border-color: #f2dca5; }
.att-day.k-late .s { color: #a16207; }
.att-day.k-hwork { background: #eef2fd; border-color: #c7d2f3; }
.att-day.k-hwork .s { color: #3b4fa8; }
.att-day.k-off, .att-day.k-hol { background: #f3f5f8; border-color: #e2e7ee; }
.att-day.k-off .s { color: #64748b; }
.att-day.k-hol .s { color: #7c3aed; }
.att-day.k-leave { background: #eefaf1; border-color: #c4e8cf; }
.att-day.k-leave .s { color: #15803d; }
.att-day.k-absent { background: #fff1f0; border-color: #f4c7c2; }
.att-day.k-absent .s { color: var(--red); font-weight: 600; }
.att-day.k-unset { border-style: dashed; border-color: #f1a9a1; }
.att-day.k-unset .s { color: var(--red); }
.att-day.k-out { opacity: .55; background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 6px, #f1f5f9 6px, #f1f5f9 12px); }
.att-day.k-out .s { color: var(--muted); }
.att-lists th { white-space: nowrap; width: 1%; }
@media (max-width: 640px) { .att-day { min-height: 48px; padding: 3px 4px; } .att-day .x, .att-day .ot { display: none; } }
.calc-sec td { background: var(--surface-2); font-weight: 600; }
.calc-sec td:first-child { color: var(--primary-700); }
/* งานเอกสารต่างด้าว: สรุปค่าใช้จ่าย */
.fw-cost-stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; background: none; border-radius: 0; overflow: visible; }
.fw-cost-stats .stat-cell { border: 1px solid var(--line); border-radius: 8px; }
