/* ECIP Demo — Minimal Enterprise (light) */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --s1: #2a78d6;  /* blue */
  --s2: #eb6834;  /* orange */
  --s3: #1baf7a;  /* aqua */
  --s4: #eda100;  /* yellow */
  --s5: #e87ba4;  /* magenta */
  --s6: #008300;  /* green */
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --radius: 10px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  font-family: "Segoe UI", "Leelawadee UI", system-ui, -apple-system, sans-serif;
  background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.5;
}
.shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--s1); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 16px;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .3px; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.nav { padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-group { display: flex; flex-direction: column; gap: 2px; padding-bottom: 4px; }
.nav-group + .nav-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.nav-group-title {
  font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); padding: 2px 10px 5px;
}
.nav a {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-size: 13.5px;
  transition: background .16s ease, color .16s ease, transform .16s ease, padding-left .16s ease;
}
/* แถบสีด้านซ้ายของเมนูที่เลือกอยู่ — ยืดขึ้นเมื่อ active */
.nav a::before {
  content: ''; position: absolute; left: 0; top: 50%; width: 3px; height: 0;
  background: var(--s1); border-radius: 0 3px 3px 0;
  transform: translateY(-50%); transition: height .22s cubic-bezier(.3,.8,.3,1);
}
.nav a:hover { background: rgba(11,11,11,.045); padding-left: 14px; }
.nav a.active { background: rgba(42,120,214,.10); color: var(--s1); font-weight: 600; padding-left: 14px; }
.nav a.active::before { height: 62%; }
.nav a.active .nav-ic { opacity: 1; transform: scale(1.1); }
.nav-ic { width: 18px; text-align: center; font-size: 13px; opacity: .85; transition: transform .18s ease, opacity .18s ease; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge {
  flex: none; min-width: 19px; height: 19px; padding: 0 6px; border-radius: 99px;
  background: var(--warning); color: #4a3200; font-size: 11px; font-weight: 800;
  display: grid; place-items: center; animation: pulse 1.8s ease-in-out infinite;
}
.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); }
.user-chip { display: flex; gap: 10px; align-items: center; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #ece9e2;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
  color: var(--ink-2); flex: none; line-height: 1;
  /* อักษรไทยมีสระบน-ล่าง — จัดกึ่งกลางด้วย line-height:1 และไม่ให้วงกลมยืด/หด */
}
/* สีพื้นอวาตาร์ 8 เฉด สลับตามตัวอักษรของชื่อ (คลาส av-0..av-7) ให้แถวในตารางแยกออกจากกันง่าย */
.av-0 { background: #e3edfb; color: #1f5fae; }
.av-1 { background: #e6f6ee; color: #10855c; }
.av-2 { background: #fdeee5; color: #c1531f; }
.av-3 { background: #efeafd; color: #5b3fd0; }
.av-4 { background: #fdf2dc; color: #9a6b06; }
.av-5 { background: #fce9f0; color: #b3416e; }
.av-6 { background: #e2f4f6; color: #10707d; }
.av-7 { background: #eceef2; color: #4a5568; }
/* อวาตาร์ที่เป็นรูปอัปโหลด — ครอบเต็มวงกลมไม่บิดสัดส่วน */
.avatar.av-photo { background: #ece9e2; padding: 0; overflow: hidden; }
.avatar.av-photo img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.avatar.xs { width: 26px; height: 26px; font-size: 11.5px; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.lg { width: 44px; height: 44px; font-size: 18px; }
.avatar.xl { width: 72px; height: 72px; font-size: 28px; }
button.avatar { border: 0; cursor: pointer; font-family: inherit; padding: 0; transition: box-shadow .15s, transform .15s; }
button.avatar:hover { box-shadow: 0 0 0 3px rgba(42,120,214,.25); transform: scale(1.05); }
/* กลุ่มอวาตาร์ผู้ใช้งานในตาราง Subscription — ซ้อนเหลื่อมกัน คลิกเปิดแท็บ Users ของรายการนั้น */
.user-stack { display: inline-flex; align-items: center; cursor: pointer; }
.user-stack .avatar { margin-left: -9px; box-shadow: 0 0 0 2px var(--card, #fff); }
.user-stack .avatar:first-child { margin-left: 0; }
.user-stack:hover .avatar { box-shadow: 0 0 0 2px rgba(42,120,214,.4); }
.avatar.av-more { background: #ece9e2; color: #6b6963; font-size: 10.5px; }
/* แท็บ "การใช้งานพนักงาน" ในเมนู Subscription */
.seg-tabs {
  display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 14px;
  background: var(--card, #fff); border: 1px solid var(--border); border-radius: 10px;
}
.seg-tabs .seg {
  border: 0; background: transparent; font-family: inherit; cursor: pointer;
  padding: 7px 16px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  transition: background .15s, color .15s;
}
.seg-tabs .seg:hover { color: var(--ink); }
.seg-tabs .seg.active { background: var(--s1, #2a78d6); color: #fff; box-shadow: 0 1px 4px rgba(42,120,214,.35); }
/* โครงหน้า: ตารางหลักซ้าย + แถบสรุปขวา */
.usage-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .usage-layout { grid-template-columns: 1fr; } }
/* ป้าย Owner พิเศษข้างชื่อพนักงาน */
.owner-badge {
  display: inline-flex; align-items: center; font-size: 10px; font-weight: 700;
  padding: 1px 7px; margin-left: 5px; border-radius: 999px; white-space: nowrap; vertical-align: 1px;
  background: linear-gradient(135deg, #f8d987, #eeb63c); color: #6b4d02;
  border: 1px solid #d9a41f; box-shadow: 0 1px 3px rgba(196,150,15,.35);
}
/* ไฮไลต์ทั้งแถวของพนักงานที่เป็นผู้ดูแล (Owner) ของบริการใดบริการหนึ่ง */
.sub-table tbody tr.is-owner-row > td:first-child { box-shadow: inset 3px 0 0 #eeb63c; }
.sub-table tbody tr.is-owner-row { background: linear-gradient(90deg, rgba(238,182,60,.10), rgba(238,182,60,0) 40%); }
.sub-table tbody tr.is-owner-row:hover { background: linear-gradient(90deg, rgba(238,182,60,.18), rgba(238,182,60,.03) 45%); }
/* ปุ่ม "ดูรายละเอียด" ท้ายแถว (ตามดีไซน์หน้าการใช้งานพนักงาน) */
.btn-detail {
  font: inherit; font-size: 11.5px; font-weight: 600; line-height: 1; white-space: nowrap;
  padding: 6px 10px; margin-right: 4px; border-radius: 7px; cursor: pointer;
  color: var(--s1, #2a78d6); background: #fff; border: 1px solid var(--s1, #2a78d6);
  transition: background .15s, color .15s;
}
.btn-detail:hover { background: var(--s1, #2a78d6); color: #fff; }
/* คอลัมน์บริการที่ใช้งาน: ไอคอน 3 ตัวแรก + ป้าย +N */
.svc-icons { display: inline-flex; align-items: center; gap: 5px; }
.svc-icons .svc-ico { display: inline-flex; cursor: pointer; transition: transform .15s; }
.svc-icons .svc-ico:hover { transform: translateY(-1px) scale(1.07); }
.svc-icons .svc-ico .svc-ic { margin-right: 0; }
.svc-icons .svc-ico.is-owner .svc-ic { box-shadow: 0 0 0 2px #eeb63c; }
.svc-more {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: #f1efe9; color: var(--ink-2); border: 1px solid var(--border);
  font-size: 10.5px; font-weight: 700; cursor: default;
}
/* การ์ดสรุปการใช้งานบริการ (แถบขวา) */
.tops-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.tops-row:last-of-type { border-bottom: 0; }
.tops-row:hover .tops-name { color: var(--s1, #2a78d6); }
.tops-name { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tops-n { font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
#me-name { cursor: pointer; }
#me-name:hover { color: var(--s1); }
/* แถวข้อมูลใน drawer/หน้าต่าง: ป้องกันข้อความยาวดันกรอบ */
.dr-cost-row { min-width: 0; gap: 10px; }
.dr-cost-row > * { min-width: 0; overflow-wrap: anywhere; }
.dr-user { min-width: 0; }
.dr-user .emp-name, .dr-user .emp-sub { overflow-wrap: anywhere; }

/* กล่องเตือนข้อมูลไม่สอดคล้อง (เช่น บัญชีไม่ตรงกับอีเมลพนักงาน) */
.warn-note {
  background: rgba(250,178,25,.12); border: 1px solid rgba(250,178,25,.4);
  color: #8a5a00; border-radius: 8px; padding: 8px 11px; font-size: 12px; margin: 8px 0;
}
/* ช่องเลือกรูปในฟอร์ม */
.photo-pick { display: flex; align-items: center; gap: 14px; }
.emp-head { display: flex; align-items: center; gap: 11px; }
.user-name { font-size: 12.5px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--muted); }

/* ---------- Main / topbar ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 5;
}
.page-title { font-size: 16px; font-weight: 700; }
.topbar-right { display: flex; gap: 12px; align-items: center; }
.asof { font-size: 12px; color: var(--muted); }
.btn-ghost {
  border: 1px solid var(--border); background: transparent; border-radius: 8px;
  padding: 5px 12px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; font-family: inherit;
}
/* เต็มความกว้างจอ — ไม่จำกัด max-width เพื่อใช้พื้นที่แสดงผลทั้งหมด */
.view { padding: 20px 28px 28px; width: 100%; }

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, 1fr); }
.cols-2 { grid-template-columns: 3fr 2fr; }
.cols-2e { grid-template-columns: 1fr 1fr; }
.mt { margin-top: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.card-title { font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.card-sub { font-size: 11.5px; color: var(--muted); margin-bottom: 12px; }
.clickable { cursor: pointer; transition: box-shadow .12s, border-color .12s; }
.clickable:hover { border-color: rgba(42,120,214,.45); box-shadow: 0 1px 6px rgba(11,11,11,.06); }

/* KPI tile */
.kpi-label { font-size: 12px; color: var(--ink-2); }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.3px; margin: 2px 0; }
.kpi-delta { font-size: 12px; color: var(--muted); }
.delta-up { color: var(--critical); }     /* ต้นทุนเพิ่ม = แย่ */
.delta-down { color: var(--good-text); }  /* ต้นทุนลด = ดี */

/* ---------- Charts ---------- */
.chart-wrap { position: relative; }
svg text { font-family: inherit; }
.axis-label { font-size: 10.5px; fill: var(--muted); }
.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--ink); color: #fff; border-radius: 8px;
  padding: 8px 11px; font-size: 12px; line-height: 1.55;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); max-width: 280px;
}
.tooltip .tt-title { font-weight: 700; margin-bottom: 2px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.tooltip .dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }
.legend-line { width: 14px; height: 0; border-top: 2px dashed var(--baseline); }

/* HTML bar rows (แผนก) */
.bar-row { display: grid; grid-template-columns: 150px 1fr 130px; gap: 10px; align-items: center; padding: 7px 4px; border-radius: 8px; cursor: pointer; }
.bar-row:hover { background: rgba(11,11,11,.035); }
.bar-name { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { position: relative; height: 14px; background: rgba(11,11,11,.05); border-radius: 4px; }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px 4px 4px 4px; background: var(--s1); min-width: 2px; }
.bar-fill.over { background: var(--critical); }
.budget-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-2); border-radius: 1px; }
.bar-val { font-size: 12px; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.bar-val small { color: var(--muted); }

/* Donut layout */
.donut-flex { display: flex; gap: 18px; align-items: center; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dl-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.dl-name { color: var(--ink-2); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-val { font-variant-numeric: tabular-nums; color: var(--ink); }
.dl-pct { color: var(--muted); width: 38px; text-align: right; }

/* อันดับ (Top-10 list) */
.rank {
  width: 22px; height: 22px; border-radius: 50%; background: rgba(11,11,11,.06);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700;
  color: var(--ink-2); flex-shrink: 0; font-variant-numeric: tabular-nums;
}
.rank.top { background: var(--s1); color: #fff; }
td .rank { margin-top: 2px; }
.mini-track { height: 5px; background: rgba(11,11,11,.05); border-radius: 3px; margin-top: 5px; max-width: 160px; }
.mini-fill { height: 100%; background: var(--s1); border-radius: 3px; min-width: 2px; }

/* Insight cards */
.insight { display: flex; gap: 12px; padding: 11px 4px; border-top: 1px solid var(--grid); }
.insight:first-of-type { border-top: 0; }
.insight-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 14px; flex-shrink: 0; }
.ic-saving   { background: rgba(12,163,12,.12); }
.ic-anomaly  { background: rgba(208,59,59,.12); }
.ic-renewal  { background: rgba(250,178,25,.16); }
.ic-budget   { background: rgba(236,131,90,.14); }
.insight-title { font-size: 12.8px; font-weight: 600; }
.insight-detail { font-size: 12px; color: var(--ink-2); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(11,11,11,.03); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num { text-align: right; }
.status-pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px;
  padding: 2px 9px; border-radius: 99px; border: 1px solid var(--border); color: var(--ink-2);
}
.status-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; }
.st-approved::before { background: var(--good); }
.st-pending::before { background: var(--warning); }

/* Budget heat table */
.heat-cell { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; padding: 7px 9px; border-radius: 6px; }
.heat-legend { display: flex; gap: 14px; margin-top: 10px; font-size: 11.5px; color: var(--muted); align-items: center; }
.heat-chip { width: 12px; height: 12px; border-radius: 3px; display: inline-block; vertical-align: -2px; margin-right: 4px; }

/* Utilization bar (subscription) */
.util { display: flex; align-items: center; gap: 8px; }
.util-track { width: 90px; height: 8px; background: rgba(11,11,11,.06); border-radius: 4px; overflow: hidden; }
.util-fill { height: 100%; border-radius: 4px; }
.chip-warn { font-size: 11px; color: #8a5a00; background: rgba(250,178,25,.15); padding: 2px 8px; border-radius: 99px; }
.chip-danger { font-size: 11px; color: var(--critical); background: rgba(208,59,59,.10); padding: 2px 8px; border-radius: 99px; }

/* Breadcrumb + filter row */
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.crumb a { color: var(--s1); text-decoration: none; }
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
select.filter {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 6px 10px; font-size: 12.5px; color: var(--ink); font-family: inherit;
}
.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }

/* ---------- Modal & Form ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(11,11,11,.35); z-index: 40;
  display: grid; place-items: center; padding: 20px;
  backdrop-filter: blur(4px); animation: fadein .18s ease both;
}
@keyframes fadein { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: 14px; width: 520px;
  /* กันหน้าต่างกว้างเกินจอ แม้ overlay จะอ้างอิงความกว้างอื่น */
  max-width: min(100%, calc(100vw - 32px));
  max-height: 90vh; overflow-y: auto; overflow-x: hidden; padding: 22px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,.22);
  animation: pop .24s cubic-bezier(.2, .9, .3, 1.15) both;
}
/* ตารางกว้าง ๆ ในหน้าต่าง (เช่น รายการบริการของพนักงาน) ให้เลื่อนในกรอบของตัวเอง */
.modal table { display: block; overflow-x: auto; max-width: 100%; }
.modal table thead, .modal table tbody { display: table; width: 100%; }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(10px); } }
.modal h3 { font-size: 15px; margin-bottom: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin-bottom: 0; }
.modal-x { font-size: 15px; }
/* min-width:0 สำคัญมาก — ค่าเริ่มต้นของ grid/flex item คือ min-width:auto ทำให้ช่องที่มีข้อความยาว
   (เช่น <option> ชื่อแผนกยาว ๆ) ดันคอลัมน์กว้างเกินกรอบ หน้าต่างจึงล้นและมีแถบเลื่อนแนวนอน */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-width: 0; }
.form-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 11.5px; color: var(--ink-2); font-weight: 600; }
/* ยกเว้น checkbox/radio — ถ้าโดน width:100% + padding ด้วย กล่องติ๊กจะยืดเต็มบรรทัดและดันข้อความไปชิดขวา */
.form-field input:not([type="checkbox"]):not([type="radio"]),
.form-field select, .form-field textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
  font-size: 13px; font-family: inherit; background: var(--surface); color: var(--ink);
  width: 100%; min-width: 0; max-width: 100%;
}
.form-field input[type="checkbox"], .form-field input[type="radio"] {
  width: 15px; height: 15px; flex: none; margin: 0; accent-color: var(--s1); cursor: pointer;
}
/* ข้อความยาวใน select ให้ตัดด้วย … แทนการดันกรอบให้กว้าง */
.form-field select { text-overflow: ellipsis; }
.form-field textarea { resize: vertical; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none; border-color: var(--s1); box-shadow: 0 0 0 3px rgba(42,120,214,.15);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.btn {
  border: 0; border-radius: 8px; padding: 8px 16px; font-size: 13px; cursor: pointer;
  font-family: inherit; font-weight: 600;
}
.btn-primary { background: var(--s1); color: #fff; }
.btn-primary:hover { background: #256abf; }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--ink-2); }
.btn-danger-ghost { background: transparent; border: 0; color: var(--critical); cursor: pointer; font-size: 12px; font-family: inherit; }
.icon-btn { background: transparent; border: 0; cursor: pointer; font-size: 13px; color: var(--ink-2); padding: 3px 6px; border-radius: 6px; }
.icon-btn:hover { background: rgba(11,11,11,.06); }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.dept-head {
  display: flex; align-items: baseline; gap: 10px; padding: 4px 2px 8px;
}
.dept-head .dh-name { font-size: 13.5px; font-weight: 700; }
.dept-head .dh-sum { font-size: 12px; color: var(--muted); }
.chip-note { font-size: 11px; color: #8a5a00; background: rgba(250,178,25,.14); padding: 1px 7px; border-radius: 99px; }

/* ================= High-tech (หน้าแผนก & อนุมัติ) ================= */
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.ht-card {
  position: relative; overflow: hidden;
  animation: rise .5s cubic-bezier(.2, .7, .3, 1) both;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.ht-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, #29b6e8, #2f7cf6 50%, #7a5cf0);
  opacity: .85;
}
.ht-card::after {  /* แสงกวาดตอน hover */
  content: ''; position: absolute; top: 0; left: -80%; width: 55%; height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,.55), transparent);
  transform: skewX(-20deg); transition: left .55s ease; pointer-events: none;
}
.ht-card:hover { transform: translateY(-3px); border-color: rgba(47,124,246,.5); box-shadow: 0 10px 30px rgba(47,124,246,.15); }
.ht-card:hover::after { left: 130%; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.dept-card { cursor: pointer; }
.dept-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dept-card-top .hc { font-size: 11.5px; color: var(--muted); }
.dept-card-top .dc-actions { margin-left: auto; opacity: 0; transition: opacity .15s; }
.ht-card:hover .dc-actions { opacity: 1; }
.code-chip {
  font-size: 10.5px; font-weight: 800; letter-spacing: .08em; color: #2f7cf6;
  background: rgba(47,124,246,.10); border: 1px solid rgba(47,124,246,.28);
  border-radius: 6px; padding: 2px 8px;
}
.dc-flex { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* วงแหวนการใช้งบ */
.ring { width: 78px; height: 78px; flex-shrink: 0; }
.ring-bg { fill: none; stroke: rgba(11,11,11,.07); stroke-width: 7; }
.ring-fg {
  fill: none; stroke: var(--s1); stroke-width: 7; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 32px 32px;
  transition: stroke-dashoffset 1s cubic-bezier(.3, .7, .3, 1);
  filter: drop-shadow(0 0 3px rgba(42,120,214,.45));
}
.ring-fg.over { stroke: var(--critical); filter: drop-shadow(0 0 3px rgba(208,59,59,.5)); }
.ring-txt { font-size: 13px; font-weight: 700; fill: var(--ink); }
.ring-sub { font-size: 8px; fill: var(--muted); }

/* ปุ่ม gradient + อนุมัติ/ปฏิเสธ */
.btn-glow {
  background: linear-gradient(100deg, #1e9df2, #4b6df5 55%, #6d5df6);
  color: #fff; box-shadow: 0 6px 16px rgba(60,100,240,.35);
  transition: transform .12s, box-shadow .12s;
}
.btn-glow:hover { transform: translateY(-1px); box-shadow: 0 9px 22px rgba(60,100,240,.5); }
.btn-approve { background: var(--good); color: #fff; padding: 4px 10px; font-size: 12px; }
.btn-approve:hover { background: #0a8f0a; }
.btn-reject { background: transparent; border: 1px solid rgba(208,59,59,.4); color: var(--critical); padding: 4px 10px; font-size: 12px; }
.btn-reject:hover { background: rgba(208,59,59,.08); }

/* ชิปแจ้งเตือนกะพริบ */
.pulse-chip {
  font-size: 12px; font-weight: 700; color: #8a5a00;
  background: rgba(250,178,25,.15); border: 1px solid rgba(250,178,25,.45);
  padding: 4px 12px; border-radius: 99px; animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(250,178,25,.35); } 50% { box-shadow: 0 0 0 6px rgba(250,178,25,0); } }

.st-rejected::before { background: var(--critical); }
tr.req-pending { background: rgba(250,178,25,.05); }

/* แบบฟอร์ม WS-20: เช็กบ็อกซ์ + ตารางรายการค่าใช้จ่ายใน modal */
/* ข้อความยาวหลายบรรทัด — ให้กล่องติ๊กอยู่บรรทัดแรกเสมอ ไม่ลอยกลางย่อหน้า */
.form-field label.ws-check {
  display: flex; align-items: flex-start; gap: 8px; padding: 3px 0;
  font-size: 12.5px; font-weight: 400; color: var(--ink); cursor: pointer; line-height: 1.5;
}
.form-field label.ws-check input { margin-top: 2px; }
.ws-item { display: grid; grid-template-columns: 1fr 68px 92px 102px; gap: 6px; margin-top: 4px; }
.ws-item-head span { font-size: 10.5px; color: var(--muted); }

@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .cols-2, .cols-2e { grid-template-columns: 1fr; }
  .cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) { .cols-3 { grid-template-columns: 1fr; } }

/* ================= หน้าล็อกอิน (ดีไซน์ VSquare) ================= */
.lg-wrap { display: flex; min-height: 100vh; background: var(--page); }
.lg-hero {
  position: relative;
  flex: 1 1 50%;
  color: #fff;
  background:
    radial-gradient(circle at 85% 90%, rgba(190, 120, 255, .55), transparent 45%),
    radial-gradient(circle at 10% 10%, rgba(80, 230, 255, .5), transparent 50%),
    linear-gradient(160deg, #29b6e8 0%, #2f7cf6 48%, #7a5cf0 100%);
  overflow: hidden;
  display: flex;
}
.lg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: 44px 44px;
}
.lg-content {
  position: relative; width: 100%;
  display: flex; flex-direction: column; justify-content: center;
  padding: 48px 56px;
}
.lg-brand { margin-bottom: 40px; position: relative; width: fit-content; }
.lg-wing { width: 34px; height: 34px; position: absolute; top: -18px; right: -12px; color: #fff; }
.lg-script { font-family: 'Segoe Script', 'Brush Script MT', cursive; font-size: 44px; line-height: 1; font-weight: 600; }
.lg-clinic { letter-spacing: .55em; font-size: 11px; margin-top: 6px; text-align: right; opacity: .95; }
.lg-title { font-size: clamp(40px, 5vw, 62px); font-weight: 800; line-height: 1.06; }
.lg-title em { font-style: italic; }
.lg-sub { margin-top: 22px; font-size: 17px; line-height: 1.7; opacity: .95; }
.lg-chips { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 34px; }
.lg-chip {
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.35);
  backdrop-filter: blur(4px); padding: 8px 14px; border-radius: 999px; font-size: 13px;
}
.lg-foot { position: absolute; bottom: 26px; left: 56px; font-size: 12px; opacity: .75; }
.lg-side {
  flex: 1 1 50%; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 70% 20%, #fff 0%, #f2f4f9 70%);
  padding: 32px;
}
.lg-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 18px;
  padding: 36px 34px 28px;
  box-shadow: 0 20px 60px rgba(30, 60, 120, .12), 0 2px 8px rgba(30, 60, 120, .06);
}
.lg-badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: #e7f7f5; color: #0fb5a6;
  font-size: 11px; font-weight: 700; letter-spacing: .12em;
  padding: 6px 12px; border-radius: 999px;
}
.lg-badge i { width: 7px; height: 7px; border-radius: 50%; background: #0fb5a6; }
.lg-card h2 { font-size: 30px; margin: 16px 0 4px; }
.lg-card-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 26px; }
.lg-label { display: block; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; color: #5a6375; margin-bottom: 7px; }
.lg-label small { font-weight: 600; color: var(--muted); letter-spacing: 0; }
.lg-field {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid #e6eaf2; border-radius: 11px;
  padding: 0 14px; margin-bottom: 18px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.lg-field:focus-within { border-color: #2f7cf6; box-shadow: 0 0 0 3px rgba(47,124,246,.12); }
.lg-field svg { width: 18px; height: 18px; color: #aab2c2; flex: none; }
.lg-field input { flex: 1; border: 0; outline: 0; background: none; padding: 13px 0; font-size: 14.5px; color: #1e2433; font-family: inherit; }
.lg-field input::placeholder { color: #b3bac8; }
.lg-eye { border: 0; background: none; padding: 4px; color: #aab2c2; display: flex; cursor: pointer; }
.lg-eye svg { width: 19px; height: 19px; }
.lg-eye:hover { color: #2f7cf6; }
.lg-error {
  background: #fdeeee; color: var(--critical); border: 1px solid #f5c9c7;
  border-radius: 10px; font-size: 13px; padding: 10px 13px; margin-bottom: 16px;
}
.lg-signin {
  width: 100%; border: 0; border-radius: 12px;
  background: linear-gradient(100deg, #1e9df2 0%, #4b6df5 55%, #6d5df6 100%);
  color: #fff; font-size: 15.5px; font-weight: 700; padding: 14px; margin-top: 4px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 8px 20px rgba(60, 100, 240, .35); cursor: pointer; font-family: inherit;
  transition: transform .12s, box-shadow .12s, opacity .12s;
}
.lg-signin:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(60, 100, 240, .45); }
.lg-signin:disabled { opacity: .6; transform: none; }
.lg-help { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 20px; }
.lg-help a { color: #2f7cf6; text-decoration: none; }
@media (max-width: 860px) {
  .lg-wrap { flex-direction: column; }
  .lg-hero { min-height: 300px; flex: none; }
  .lg-content { padding: 32px; }
  .lg-foot { position: static; margin-top: 24px; }
}

/* ================= จัดการผู้ใช้ ================= */
.role-badge, .stat-badge { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 3px 10px; }
.role-badge.superadmin { background: #efeafd; color: #6d4df0; }
.role-badge.user { background: rgba(11,11,11,.06); color: var(--ink-2); }
.stat-badge.active { background: rgba(12,163,12,.12); color: var(--good-text); }
.stat-badge.disabled { background: rgba(208,59,59,.10); color: var(--critical); }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell .avatar { flex: none; }
.user-cell small { color: var(--muted); font-size: 11.5px; display: block; }

/* ================= Subscription Management — ธีมใหม่ตามดีไซน์ ================= */
/* Sidebar โทนเข้ม */
.sidebar { background: #0e1626; border-right: 1px solid rgba(255,255,255,.06); }
.sidebar .brand-mark { background: #2f7cf6; border-radius: 10px; }
.sidebar .brand-name { color: #fff; font-size: 12.5px; line-height: 1.25; letter-spacing: .4px; }
.sidebar .brand-sub { color: rgba(255,255,255,.45); }
.sidebar .nav a { color: rgba(255,255,255,.72); }
.sidebar .nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav a.active { background: #2f7cf6; color: #fff; font-weight: 600; }
.sidebar .nav a.active::before { background: #9cc3ff; }
.sidebar .nav-group + .nav-group { border-top: 1px solid rgba(255,255,255,.08); }
.sidebar .nav-group-title { color: rgba(255,255,255,.38); }
.sidebar .sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); }
.sidebar .user-name { color: #fff; }
.sidebar .user-role { color: rgba(255,255,255,.5); }
.sidebar .avatar { background: rgba(255,255,255,.14); color: #fff; }
.sidebar .icon-btn { color: rgba(255,255,255,.6); }
.sidebar .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ป้ายสถานะ */
.pill { display: inline-block; font-size: 10.5px; font-weight: 700; border-radius: 99px; padding: 2px 9px; white-space: nowrap; }
.pill-green { background: rgba(12,163,12,.12); color: var(--good-text); }
.pill-blue  { background: rgba(42,120,214,.12); color: #1d5fb3; }
.pill-amber { background: rgba(250,178,25,.16); color: #8a5a00; }
.pill-red   { background: rgba(208,59,59,.12); color: var(--critical); }
.pill-gray  { background: rgba(11,11,11,.07); color: var(--ink-2); }
.t-red { color: var(--critical); } .t-amber { color: #b8730a; } .t-green { color: var(--good-text); }
.t-muted { color: var(--muted); } .t-ink2 { color: var(--ink-2); }

/* KPI แบบมีไอคอนสี */
.kpi-ic-card { display: flex; gap: 12px; align-items: flex-start; }
.kpi-ic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 19px; flex: none; margin-top: 2px; }

/* โครงหน้า Dashboard */
.dash-mid { display: grid; grid-template-columns: 1fr 340px; gap: 14px; }
.dash-bottom { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1280px) { .dash-bottom { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 1080px) { .dash-mid { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .dash-bottom { grid-template-columns: 1fr; } }

/* Smart Warnings */
.warn-list { max-height: 300px; overflow-y: auto; }
.warn-row { display: flex; gap: 10px; padding: 9px 6px; border-top: 1px solid var(--grid); text-decoration: none; color: inherit; border-radius: 8px; transition: background .14s, padding-left .14s; }
.warn-row:first-child { border-top: 0; }
.warn-row:hover { background: rgba(42,120,214,.06); padding-left: 10px; }
.warn-ic { font-size: 12px; margin-top: 2px; }
.warn-title { display: block; font-size: 12.5px; font-weight: 600; }
.warn-detail { display: block; font-size: 11.5px; color: var(--ink-2); }

/* ไอคอนบริการ + ตาราง subscription */
.svc-ic { width: 30px; height: 30px; border-radius: 8px; display: inline-grid; place-items: center; font-size: 13px; font-weight: 800; vertical-align: middle; margin-right: 8px; flex: none; }
/* โลโก้แบรนด์: พื้นขาว + ขอบบาง ให้โลโก้สีสด ๆ ดูสะอาดเหมือน App icon */
.svc-ic.svc-logo { background: #fff; border: 1px solid var(--grid); padding: 5px; box-shadow: 0 1px 2px rgba(11,11,11,.05); }
.svc-ic.svc-logo svg { width: 100%; height: 100%; display: block; }
.sub-table td { vertical-align: middle; }
/* ไอคอน + ชื่อ อยู่แถวเดียวกันเสมอ (flex) — ชื่อยาวตัดคำในคอลัมน์ตัวเอง ไอคอนไม่หลุดขึ้นบน */
.sub-cell { display: flex; align-items: center; gap: 9px; min-width: 170px; }
.sub-cell .svc-ic { margin-right: 0; }
.sub-name { min-width: 0; }
.sub-name b { display: block; line-height: 1.3; }
.sub-name small { display: block; color: var(--muted); font-size: 11px; }

/* Search box + filter bar */
.search-box { display: flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 0 10px; min-width: 220px; }
.search-box span { font-size: 12px; opacity: .55; }
.search-box input { border: 0; outline: 0; background: none; padding: 7px 0; font-size: 12.5px; font-family: inherit; width: 100%; color: var(--ink); }

/* License Utilization */
.util-block { padding: 8px 0 4px; border-top: 1px solid var(--grid); }
.util-block:first-of-type { border-top: 0; }
.util-head { display: flex; justify-content: space-between; font-size: 12px; gap: 8px; }
.util-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.util-track2 { height: 7px; background: rgba(11,11,11,.06); border-radius: 4px; margin: 5px 0 3px; overflow: hidden; }
.util-fill2 { height: 100%; border-radius: 4px; background: var(--good); transition: width .7s cubic-bezier(.25,.8,.3,1); }
.util-fill2.mid { background: var(--warning); }
.util-fill2.low { background: var(--critical); }
.util-foot { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); gap: 6px; flex-wrap: wrap; }

/* Cost per Employee */
.emp-row { display: flex; gap: 9px; align-items: center; padding: 7px 4px; border-top: 1px solid var(--grid); cursor: pointer; border-radius: 8px; font-size: 12.5px; }
.emp-row:first-of-type { border-top: 0; }
.emp-row:hover { background: rgba(11,11,11,.035); }
.emp-name { display: block; font-weight: 600; font-size: 12.5px; }
.emp-sub { display: block; font-size: 11px; color: var(--muted); }
.emp-items { padding: 2px 8px 8px 39px; }
.emp-item { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-2); padding: 2.5px 0; border-bottom: 1px dashed var(--grid); }
.emp-item:last-child { border-bottom: 0; }

/* Cost by Department */
.dept-block { padding: 9px 0 5px; border-top: 1px solid var(--grid); }
.dept-block:first-of-type { border-top: 0; }
.dept-head2 { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.dept-item { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-2); padding: 2.5px 0; }
.dept-item-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dept-item-val { width: 64px; text-align: right; font-variant-numeric: tabular-nums; flex: none; }

/* แถบแนวนอน */
.hb-row { display: grid; grid-template-columns: 92px 1fr 76px; gap: 9px; align-items: center; padding: 6px 2px; font-size: 12px; }
.hb-name { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-track { display: block; position: relative; height: 12px; background: rgba(11,11,11,.05); border-radius: 4px; overflow: hidden; }
.hb-fill { display: block; height: 100%; border-radius: 4px; width: 0; min-width: 2px; }
.hb-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* VAT Ready Report */
.vat-flex { display: flex; gap: 14px; align-items: center; margin-top: 6px; }
.vat-ring { width: 84px; flex: none; }
.vat-arc { transition: stroke-dashoffset 1s cubic-bezier(.3,.7,.3,1); }
.vat-row { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; border-bottom: 1px dashed var(--grid); gap: 8px; }
.vat-row:last-child { border-bottom: 0; }
.vat-ok { color: var(--good); font-weight: 800; }
.vat-total { margin-top: 10px; padding: 9px 12px; background: rgba(27,175,122,.08); border: 1px solid rgba(27,175,122,.25); border-radius: 10px; font-size: 12.5px; display: flex; justify-content: space-between; align-items: center; }

/* Drawer รายละเอียด Subscription */
.drawer-ov { position: fixed; inset: 0; background: rgba(11,11,11,.3); z-index: 45; animation: fadein .16s ease both; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: 400px; max-width: 94vw; background: var(--surface); box-shadow: -8px 0 30px rgba(0,0,0,.14); display: flex; flex-direction: column; animation: drawerIn .26s cubic-bezier(.25,.8,.3,1) both; }
@keyframes drawerIn { from { transform: translateX(60px); opacity: 0; } }
.dr-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 16px 18px 10px; }
.dr-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dr-tabs { display: flex; gap: 2px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.dr-tab { border: 0; background: none; font-family: inherit; font-size: 12.5px; padding: 8px 10px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.dr-tab.active { color: var(--s1); font-weight: 700; border-bottom-color: var(--s1); }
.dr-body { flex: 1; overflow-y: auto; padding: 14px 18px; }
.dr-grid { display: grid; grid-template-columns: 110px 1fr; gap: 7px 10px; font-size: 12.5px; }
.dr-grid > span { color: var(--muted); }
.dr-grid > b { font-weight: 600; word-break: break-word; }
.dr-cost { margin-top: 14px; background: rgba(42,120,214,.05); border: 1px solid rgba(42,120,214,.18); border-radius: 10px; padding: 10px 14px; }
.dr-cost-title { font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.dr-cost-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 3px 0; }
.dr-sec-title { font-size: 12px; font-weight: 700; margin-bottom: 6px; color: var(--ink); }
.dr-user { display: flex; gap: 9px; align-items: flex-start; padding: 7px 0; border-top: 1px solid var(--grid); font-size: 12.5px; }
.dr-user:first-of-type { border-top: 0; }
.dr-hist { display: flex; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--grid); }
.dr-hist:first-of-type { border-top: 0; }
.dr-actions { border-top: 1px solid var(--border); padding: 12px 18px 14px; }
.dr-qa { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.qa-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 2px; font-size: 15px; cursor: pointer; font-family: inherit; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink-2); transition: border-color .14s, background .14s, transform .14s; }
.qa-btn span { font-size: 9.5px; font-weight: 600; }
.qa-btn:hover { border-color: var(--s1); color: var(--s1); transform: translateY(-1px); }
.qa-btn.qa-danger:hover { border-color: var(--critical); color: var(--critical); background: rgba(208,59,59,.05); }

/* คำอธิบายใต้ชื่อหน้า (เช่น "จัดการข้อมูลพนักงานทั้งหมดขององค์กร") */
.pt-sub { font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 2px; }

/* หน้า Subscription: KPI 5 ใบ + chip หมวดหมู่ + เมนู ⋮ + แบ่งหน้า */
.kpis-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1280px) { .kpis-5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 860px) { .kpis-5 { grid-template-columns: repeat(2, 1fr); } }
.kpi-unit { font-size: 13px; font-weight: 400; color: var(--muted); }
.cat-chip { display: inline-block; font-size: 10.5px; font-weight: 700; border-radius: 7px; padding: 3px 8px; white-space: nowrap; }
.ow-cell { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; white-space: nowrap; }
.avatar.sm { width: 26px; height: 26px; font-size: 12px; flex: none; }
.avatar.xs { width: 24px; height: 24px; font-size: 11.5px; flex: none; }
.kebab-menu {
  position: fixed; z-index: 70; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 26px rgba(11,11,11,.16); padding: 5px; min-width: 170px;
  display: flex; flex-direction: column; animation: pop .16s cubic-bezier(.2,.9,.3,1.1) both;
}
.kebab-menu button {
  border: 0; background: none; font-family: inherit; font-size: 12.5px; text-align: left;
  padding: 7px 10px; border-radius: 7px; cursor: pointer; color: var(--ink);
}
.kebab-menu button:hover { background: rgba(42,120,214,.08); }
.kebab-menu button.k-danger { color: var(--critical); }
.kebab-menu button.k-danger:hover { background: rgba(208,59,59,.08); }
.pagi { display: flex; align-items: center; gap: 4px; padding-top: 12px; border-top: 1px solid var(--grid); margin-top: 4px; flex-wrap: wrap; }
.pagi .spacer { flex: 1; }
.pagi-btn {
  min-width: 28px; height: 28px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 7px; font-family: inherit; font-size: 12px; cursor: pointer; color: var(--ink-2);
  transition: border-color .13s, background .13s, color .13s;
}
.pagi-btn:hover:not([disabled]) { border-color: var(--s1); color: var(--s1); }
.pagi-btn.active { background: var(--s1); border-color: var(--s1); color: #fff; font-weight: 700; }
.pagi-btn[disabled] { opacity: .4; cursor: default; }

/* Reports: แท่งรายเดือน */
.rp-bars { display: flex; gap: 6px; align-items: stretch; height: 190px; padding-top: 8px; }
.rp-col { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rp-bar-wrap { flex: 1; display: flex; align-items: flex-end; background: rgba(11,11,11,.03); border-radius: 6px; overflow: hidden; }
.rp-bar { width: 100%; background: linear-gradient(180deg, #4b8fe0, #2a78d6); border-radius: 6px 6px 0 0; min-height: 2px; transition: height .7s cubic-bezier(.25,.8,.3,1); }
.rp-bar.future { background: rgba(11,11,11,.12); }
.rp-lab { text-align: center; font-size: 10px; color: var(--muted); }

/* ================= Responsive: จอแคบ / หน้าต่างเล็ก (ต้องอยู่ท้ายไฟล์เพื่อให้ทับ rule หลัก) ================= */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }      /* ฟอร์มทุกหน้าต่างเหลือคอลัมน์เดียว */
  .photo-pick { flex-wrap: wrap; }
  .ws-item { grid-template-columns: 1fr 1fr; }     /* รายการค่าใช้จ่ายในแบบฟอร์ม WS-20 */
  .modal { padding: 18px 16px; }
  .overlay { padding: 10px; }
}

/* ================= หน้า VAT Documents ================= */
.vat-layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
.vat-side { display: flex; flex-direction: column; gap: 14px; }
.vat-donut { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.vat-legend { width: 100%; display: flex; flex-direction: column; gap: 7px; }
.vat-lg-row { display: flex; align-items: center; gap: 7px; font-size: 11.5px; }
.vat-lg-name { flex: 1; color: var(--ink-2); min-width: 0; }
.vat-months { display: flex; flex-direction: column; }
.vat-mrow { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; padding: 4px 0; border-bottom: 1px solid var(--grid); }
.vat-mrow:last-child { border-bottom: 0; }
.vat-links { display: flex; flex-direction: column; gap: 8px; }
.vat-links a { font-size: 11.5px; color: var(--s1); text-decoration: none; }
.vat-links a:hover { text-decoration: underline; }
/* ขั้นตอนการขอคืน VAT */
.vat-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-top: 6px; position: relative; }
.vat-step { display: flex; flex-direction: column; gap: 3px; font-size: 12px; position: relative; padding-top: 6px; }
.vat-step b { font-size: 12.5px; }
.vat-step .t-muted { font-size: 11px; line-height: 1.5; }
.vat-step-no {
  width: 26px; height: 26px; border-radius: 50%; background: var(--s1); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; margin-bottom: 5px;
}
/* เส้นเชื่อมระหว่างขั้นตอน */
.vat-step:not(:last-child)::after {
  content: ''; position: absolute; top: 19px; left: 32px; right: -12px; height: 2px; background: var(--grid);
}
.pill-blue { background: rgba(42,120,214,.12); color: #1f5fae; }
.pdf-chip { font-size: 15px; cursor: default; }
@media (max-width: 1180px) {
  .vat-layout { grid-template-columns: 1fr; }
  .vat-steps { grid-template-columns: repeat(2, 1fr); }
  .vat-step:not(:last-child)::after { display: none; }
}

/* ================= หน้า Reports ================= */
.rp-filters { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.rp-filters .form-field { min-width: 150px; }
.rp-filters .spacer { flex: 1; }
.rp-3col { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.rp-dept-row { display: flex; align-items: center; gap: 9px; font-size: 11.5px; padding: 5px 0; }
.rp-dept-name { width: 78px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-dept-row .bar-track { height: 12px; }
/* แท่งเทียบรายปี */
.rp-years { display: flex; align-items: flex-end; justify-content: space-around; gap: 14px; height: 190px; padding-top: 6px; }
.rp-ycol { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; font-size: 11.5px; }
.rp-yval { font-size: 11.5px; }
.rp-ybar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.rp-ybar { width: 100%; background: #cfe0f7; border-radius: 6px 6px 0 0; transition: height .8s cubic-bezier(.25,.8,.3,1); }
.rp-ybar.now { background: linear-gradient(180deg, #34c08a, #1baf7a); }
.rp-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); padding: 14px 4px 0; }
@media (max-width: 1280px) { .rp-3col { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .rp-3col { grid-template-columns: 1fr; } }
/* ===== คลังเอกสาร PDF ===== */
/* กล่องลากไฟล์มาวาง */
.drop-zone {
  display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center;
  padding: 22px 16px; border: 2px dashed var(--border); border-radius: 12px; background: var(--bg);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.is-over { border-color: var(--s1, #2a78d6); background: #f2f7fe; }
.drop-zone.has-file { border-style: solid; border-color: #1baf7a; background: #f3fbf7; }
.dz-ic { font-size: 26px; line-height: 1; }
.dz-text { font-size: 12.5px; color: var(--ink-2); overflow-wrap: anywhere; }
/* ไทม์ไลน์เอกสารจัดกลุ่มตามเดือน */
.doc-group + .doc-group { margin-top: 16px; }
.doc-group-head {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  padding: 6px 2px; margin-bottom: 4px; border-bottom: 2px solid var(--grid);
}
.doc-group-head .t-muted { font-size: 11px; }
.doc-row {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) 150px 130px 90px 118px;
  align-items: center; gap: 10px; padding: 9px 6px; border-bottom: 1px solid var(--border);
  cursor: pointer; border-radius: 8px; transition: background .12s;
}
.doc-row:hover { background: #f6f9fe; }
.doc-ic { font-size: 17px; line-height: 1; }
.doc-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-main b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-main small { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-col { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-act { display: flex; gap: 2px; justify-content: flex-end; }
.doc-act .icon-btn { text-decoration: none; display: inline-grid; place-items: center; }
/* จอแคบ: ตัดคอลัมน์ที่รองลงมาออกก่อน เหลือชื่อเอกสาร ประเภท และปุ่มจัดการ */
@media (max-width: 1000px) {
  .doc-row { grid-template-columns: 26px minmax(0, 1fr) 130px 118px; }
  .doc-row .doc-dept, .doc-row .doc-date { display: none; }
}
@media (max-width: 700px) {
  .doc-row { grid-template-columns: 26px minmax(0, 1fr) 118px; }
  .doc-row .doc-type { display: none; }
}
/* หน้าต่างพรีวิว PDF */
.doc-preview { width: min(980px, 94vw); display: flex; flex-direction: column; max-height: 92vh; }
.doc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 11.5px; margin-bottom: 8px; }
.doc-note { font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; margin-bottom: 10px; }
.doc-frame { flex: 1; min-height: 58vh; width: 100%; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
/* รายงานรายเดือน: กราฟแท่งซ้าย + สัดส่วนหมวดหมู่ขวา */
.rp-2col { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .rp-2col { grid-template-columns: 1fr; } }
.rp-2col .rp-dept-name { width: 120px; }
/* บทวิเคราะห์: การ์ดข้อสังเกตแยกโทนสีตามความสำคัญ */
.rp-ins { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 10px; }
.rp-ins-row {
  display: flex; gap: 10px; align-items: flex-start; font-size: 12px; line-height: 1.55;
  padding: 10px 12px; border: 1px solid var(--border); border-left-width: 3px; border-radius: 9px; background: #fff;
}
.rp-ins-row b { font-size: 12.5px; }
.rp-ins-ic { font-size: 14px; line-height: 1.3; flex-shrink: 0; }
.rp-ins-row.is-ok       { border-left-color: #1baf7a; background: #f5fbf8; }
.rp-ins-row.is-info     { border-left-color: #2a78d6; background: #f6f9fe; }
.rp-ins-row.is-warn     { border-left-color: #e8930c; background: #fffaf2; }
.rp-ins-row.is-critical { border-left-color: #d03b3b; background: #fef7f7; }
