/* ==========================================================
   ระบบข้อมูลค่าตอบแทนการสอน — UI v4 (สไตล์แดชบอร์ด)
   เปลี่ยนเฉพาะหน้าตา: id / data-roles / ชื่อ class ที่ JS สร้าง ยังเหมือนเดิม
   ========================================================== */

/* ===== ตัวแปร ===== */
:root {
  --ink: #141414;
  --muted: #6a625f;
  --ground: #f5f2f1;
  --paper: #ffffff;
  --soft: #faf8f7;          /* พื้นแถวในรายการ */
  --line: #ebe5e3;
  --accent: #b3270a;        /* ตัวเลขเงิน/ลิงก์บนพื้นขาว */
  --ember: linear-gradient(168deg, #3d0000 0%, #8a0700 32%, #b83a08 68%, #c9460b 100%);
  --focus: #1b5fd1;
  --ok: #1d6a45;
  --err: #b42318;
  --r-xl: 28px;
  --r-l: 20px;
  --r-m: 14px;
  --header-h: 96px;         /* ความสูงแถบเมนูที่ติดด้านบน ใช้กับ scroll-margin-top */
  --sans: "Inter Tight", "Anuphan", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ===== พื้นฐาน ===== */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

/* ลิงก์ในเมนูกระโดดมาแล้วหัวข้อไม่ถูกแถบเมนูบัง */
main [id] { scroll-margin-top: calc(var(--header-h) + 12px); }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 32px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  padding: 8px 16px; background: var(--paper); border-radius: 999px; font-weight: 600; text-decoration: none;
}
.skip:focus { top: 10px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ===== Header: โลโก้ + เมนูแคปซูล + กล่องผู้ใช้ ===== */
/* แถบเมนูติดด้านบนตลอด: พื้นทึบเกือบเต็ม (ไม่มี blur ก็ไม่ซ้อน) + blur ถ้าเบราว์เซอร์รองรับ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  padding: 14px 0 10px;
  background: rgba(245, 242, 241, 0.97);
  border-bottom: 1px solid var(--line);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-header {
    background: rgba(245, 242, 241, 0.82);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    backdrop-filter: saturate(1.4) blur(14px);
  }
}

.header-inner { display: flex; align-items: center; gap: 20px; }

.brand { flex: none; display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { display: block; width: 40px; height: 40px; }
.brand-text { display: grid; line-height: 1.25; }
.brand-text strong { font-size: 15px; font-weight: 700; }
.brand-text small  { font-size: 12px; color: var(--muted); }

.pill-nav {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  max-width: max-content;
  margin: 0 auto;
  padding: 5px;
  overflow-x: auto;
  background: var(--paper);
  border-radius: 999px;
  scrollbar-width: none;
}
.pill-nav::-webkit-scrollbar { display: none; }

.pill-nav a {
  flex: none;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.15s ease, color 0.15s ease;
}
.pill-nav a:hover { background: #f1ecea; }
.pill-nav a.active { background: var(--ink); color: #ffffff; }

.nav-sep { display: none; flex: none; width: 1px; height: 20px; margin: 0 6px; background: var(--line); }
.pill-nav a[data-roles]:not([hidden]) ~ .nav-sep { display: block; }

#userBox {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding: 5px 5px 5px 16px;
  background: var(--paper);
  border-radius: 999px;
}
#userBox:not(:has(*)) { display: none; }

.user-chip { display: flex; flex-direction: column; align-items: flex-end; max-width: 190px; line-height: 1.3; }
.user-email {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; font-weight: 500;
}
.user-role {
  padding: 0 8px; border-radius: 999px;
  background: #fde6d8; font-size: 11.5px; font-weight: 600; color: var(--accent);
}

/* ===== ปุ่ม ===== */
.btn, .btn-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 22px;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-family: inherit; font-size: 14.5px; font-weight: 600; line-height: 1.4;
  color: #ffffff; text-decoration: none; cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover, .btn-pill:hover { background: #333333; }
.btn:active, .btn-pill:active { transform: scale(0.98); }

.btn.ghost, .btn-pill.light { background: transparent; color: var(--ink); border-color: #cfc7c4; }
.btn.ghost:hover, .btn-pill.light:hover { background: #f1ecea; }

.btn.small { padding: 6px 16px; font-size: 13.5px; white-space: nowrap; }
.btn-pill.big { padding: 15px 30px; font-size: 16px; }

.btn-pill.white { background: #ffffff; color: var(--ink); border-color: #ffffff; }
.btn-pill.white:hover { background: #fbeee6; }

.icon-btn {
  padding: 3px 9px; background: transparent; border: 1px solid var(--line);
  border-radius: 999px; font-size: 14px; cursor: pointer;
}
.icon-btn:hover { background: #f1ecea; }

/* ===== Hero (ผู้ที่ยังไม่ล็อกอิน) ===== */
.hero { padding: 64px 32px 36px; }

.eyebrow { margin-bottom: 14px; font-size: 16px; color: var(--muted); }

.hero h1 {
  max-width: 14em;
  font-size: clamp(34px, 5.6vw, 64px);
  font-weight: 500;
  line-height: 1.22;
  letter-spacing: -0.02em;
}
.hero-lede { max-width: 62ch; margin-top: 20px; color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

/* ผู้ใช้เข้าสู่ระบบแล้ว: ซ่อน hero สาธารณะ แล้วใช้แดชบอร์ดแทน */
body:has(#dashboard:not([hidden])) .hero { display: none; }

/* ===== แดชบอร์ด ===== */
.dash { padding-top: 40px; padding-bottom: 8px; }

.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.dash-head .eyebrow { margin-bottom: 6px; }
.greet { font-size: clamp(32px, 5vw, 56px); font-weight: 500; letter-spacing: -0.025em; line-height: 1.2; }
.dash-cta { display: flex; flex-wrap: wrap; gap: 10px; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 16px; }

.card { min-width: 0; padding: 32px; border-radius: var(--r-xl); }
.card.ember.overview { display: flex; flex-direction: column; }
.card.ember { background: var(--ember); color: #ffffff; }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-head h2 { font-size: 22px; font-weight: 500; }

.pill-select select {
  appearance: none;
  padding: 8px 34px 8px 16px;
  background: rgba(255, 255, 255, 0.16) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5l5 5 5-5' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 14px center;
  border: 0; border-radius: 999px;
  font-family: inherit; font-size: 14px; color: #ffffff; cursor: pointer;
}
.pill-select option { color: var(--ink); }

.kpi-label { font-size: 14px; color: rgba(255, 255, 255, 0.85); }
.kpi {
  margin: 2px 0 10px;
  font-size: clamp(40px, 5vw, 60px);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.kpi .dec { color: rgba(255, 255, 255, 0.62); }

.chip {
  align-self: flex-start;
  display: inline-block; padding: 3px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.18); font-size: 13.5px; color: #ffffff;
}

/* กราฟรายเดือน */
.chart { display: flex; flex-direction: column; flex: 1; margin-top: 22px; }
.plot { position: relative; flex: 1; min-height: 230px; margin-left: 46px; }

.gridline {
  position: absolute; left: 0; right: 0; height: 1px; background: rgba(255, 255, 255, 0.2);
}
.gridline span {
  position: absolute; left: -46px; top: -11px; width: 38px;
  font-size: 12px; text-align: right; color: rgba(255, 255, 255, 0.92); font-variant-numeric: tabular-nums;
}

.bars { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.col { position: relative; display: flex; align-items: flex-end; justify-content: center; height: 100%; }

.bar {
  position: relative;
  width: min(100%, 26px);
  min-height: 3px;
  padding: 0;
  background: rgba(255, 255, 255, 0.92);
  border: 0;
  border-radius: 999px 999px 4px 4px;
  cursor: pointer;
}
.bar.empty { background: rgba(255, 255, 255, 0.35); cursor: default; }
.bar:hover, .bar:focus-visible { background: #ffffff; outline-offset: 3px; outline-color: #ffffff; }

.tip {
  position: absolute; bottom: calc(100% + 10px); left: 50%; z-index: 5;
  display: none; min-width: 150px; padding: 10px 14px;
  background: #ffffff; color: var(--ink); border-radius: var(--r-m);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  font-size: 13px; line-height: 1.45; text-align: left; white-space: nowrap;
  transform: translateX(-50%); pointer-events: none;
}
.tip strong { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.bar:hover .tip, .bar:focus-visible .tip { display: block; }
.col:nth-child(-n+2) .tip { left: 0; transform: none; }
.col:nth-last-child(-n+2) .tip { left: auto; right: 0; transform: none; }

.months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; margin: 10px 0 0 46px; }
.months span { overflow: hidden; font-size: 12.5px; text-align: center; white-space: nowrap; color: rgba(255, 255, 255, 0.92); }

.chart-empty { margin: 8px 0 0 46px; font-size: 14px; color: rgba(255, 255, 255, 0.92); }
.chart-empty:empty { display: none; }

.card-note { margin-top: 16px; font-size: 12.5px; color: rgba(255, 255, 255, 0.85); }

/* การ์ดสถานะ */
.status-list { display: grid; gap: 8px; margin: 18px 0 20px; padding: 0; list-style: none; }
.status-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 16px; background: rgba(255, 255, 255, 0.14); border-radius: 999px; font-size: 14px;
}
.status-list b { font-variant-numeric: tabular-nums; font-weight: 600; }

.bank-card {
  position: relative; margin: 0 0 18px; padding: 16px 20px 18px;
  background: rgba(255, 255, 255, 0.2); border-radius: var(--r-l);
}
.bank-card::before, .bank-card::after {      /* เลียนแบบการ์ดซ้อนกันในภาพอ้างอิง */
  content: ""; position: absolute; left: 16px; right: 16px; height: 10px;
  background: rgba(255, 255, 255, 0.12); border-radius: 12px 12px 0 0;
}
.bank-card::before { top: -8px; }
.bank-card::after  { top: -14px; left: 32px; right: 32px; background: rgba(255, 255, 255, 0.07); }
.bank-card small { font-size: 12.5px; color: rgba(255, 255, 255, 0.9); }
.bank-card .mask { margin: 2px 0; font-size: 20px; font-weight: 500; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }

.card-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.card-actions .btn-pill { flex: 1 1 140px; }

/* การ์ดแยกตามประเภท */
.sub-title { margin: 32px 0 14px; font-size: 22px; font-weight: 500; }
.type-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.mini { padding: 24px; background: var(--paper); border-radius: var(--r-xl); }
.mini h3 { font-size: 16px; font-weight: 500; color: var(--muted); }
.mini .amt { margin-top: 26px; font-size: 32px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.mini .amt .dec { color: #a39a96; }
.mini .meta { margin-top: 2px; font-size: 13.5px; color: var(--muted); }
.type-empty { grid-column: 1 / -1; padding: 24px; background: var(--paper); border-radius: var(--r-xl); color: var(--muted); }

/* ===== Section ทั่วไป ===== */
.section { padding: 44px 32px; }
.section h2 { margin-bottom: 6px; font-size: 28px; font-weight: 500; letter-spacing: -0.02em; }
.section-lede { max-width: 70ch; margin-bottom: 24px; font-size: 14.5px; color: var(--muted); }

/* พื้นที่ทำงาน: การ์ดขาวโค้งมน */
.section.workspace {
  width: min(1176px, calc(100% - 64px));   /* ขอบเท่ากับเนื้อหาของ .wrap */
  margin: 16px auto;
  padding: 32px;
  background: var(--paper);
  border-radius: var(--r-xl);
}
.section.workspace h2 { font-size: 24px; }

/* ===== ตาราง = รายการแถวโค้งมน ===== */
.table-card { margin-bottom: 20px; overflow-x: auto; }
.workspace .table-card { margin-bottom: 0; }

table { width: 100%; border-collapse: separate; border-spacing: 0 8px; text-align: left; font-size: 14px; }
#claims table { min-width: 1040px; }
#review table { min-width: 820px; }
#claims td:nth-child(2), #claims td:nth-child(3), #claims td:nth-child(9) { min-width: 170px; }
#claims td:last-child { min-width: 130px; }
#review td:nth-child(3) { min-width: 170px; }

th { padding: 0 16px 4px; font-weight: 500; font-size: 13px; color: var(--muted); white-space: nowrap; background: transparent; border: 0; }
td { padding: 14px 16px; background: var(--soft); border: 0; vertical-align: middle; }
td:first-child { border-top-left-radius: 18px; border-bottom-left-radius: 18px; }
td:last-child  { border-top-right-radius: 18px; border-bottom-right-radius: 18px; }
tbody tr:hover td { background: #f4efed; }

.bullet { width: 40px; text-align: center; color: var(--accent); }

.rate { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); white-space: nowrap; }

/* ===== สถานะ ===== */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 12px; border-radius: 999px; background: #efeceb;
  font-size: 13px; font-weight: 600; color: #3f4856; white-space: nowrap;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.SUBMITTED { background: #ffeed2; color: #8a4f00; }
.status.VERIFIED  { background: #dce9fa; color: #17467f; }
.status.APPROVED  { background: #dcf1e5; color: #14583a; }
.status.PAID      { background: #d3efee; color: #0e5a58; }
.status.REJECTED  { background: #fbe0dc; color: #8f1f16; }
.status.RETURNED  { background: #efe2f9; color: #5b2a86; }

/* ===== ฟอร์ม ===== */
.form-card { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px 20px; }

.form-card label { display: grid; gap: 6px; align-content: start; font-size: 14px; font-weight: 500; }

.form-card input, .form-card select, .filters select {
  width: 100%; padding: 11px 16px;
  background: var(--soft);
  border: 1.5px solid transparent;
  border-radius: var(--r-m);
  font-family: inherit; font-size: 15px; color: var(--ink);
}
.form-card input:hover, .form-card select:hover, .filters select:hover { border-color: #ddd5d2; }
.form-card input[type="file"] { padding: 9px 14px; cursor: pointer; }

.form-card .actions, .form-card .estimate, .form-card .msg, .form-card .upload-field { grid-column: 1 / -1; }

.estimate { min-height: 1.7em; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }

.msg { font-size: 14px; font-weight: 500; }
.msg:empty { display: none; }
.msg.ok  { color: var(--ok); }
.msg.err { color: var(--err); }

.filters { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.filters select { width: auto; min-width: 190px; background: var(--soft); }

/* ===== อัปโหลดไฟล์ ===== */
.upload-field { display: flex; flex-direction: column; gap: 8px; }
.upload-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.upload-title { font-weight: 600; }
.upload-hint { font-size: 13px; color: var(--muted); }

.btn-add {
  width: 100%; padding: 16px; background: var(--soft);
  border: 2px dashed #cfc7c4; border-radius: var(--r-l);
  font-family: inherit; font-size: 14.5px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.btn-add:hover { background: #f4efed; }

.upload-error { color: var(--err); font-size: 14px; }
.upload-error:empty { display: none; }

.file-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.file-list:empty { display: none; }

.file-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 8px 8px 16px; background: var(--soft); border-radius: 999px;
}
.file-item.existing { background: #f1ecea; }
.file-size { color: var(--muted); }

.btn-remove {
  display: grid; place-items: center; width: 30px; height: 30px;
  border: none; border-radius: 50%; background: transparent;
  font-size: 16px; line-height: 1; color: var(--muted); cursor: pointer;
}
.btn-remove:hover { background: #fbe0dc; color: var(--err); }

.file-link { display: inline-flex; align-items: center; gap: 4px; margin: 0 8px 4px 0; font-size: 13.5px; color: #17467f; }
.file-icon { width: 16px; height: 16px; object-fit: contain; }

/* ===== Dialog ===== */
dialog { width: min(540px, 92vw); padding: 28px; border: none; border-radius: var(--r-xl); color: var(--ink); }
dialog::backdrop { background: rgba(40, 0, 0, 0.55); }
dialog h3 { margin-bottom: 16px; font-size: 20px; font-weight: 500; }

/* ล็อก scroll ของหน้าระหว่างที่ modal เปิดอยู่ */
body:has(dialog[open]) { overflow: hidden; }

/* modal แบบแผ่น (ขั้นตอน / การตั้งค่า): padding อยู่ด้านใน เพื่อให้คลิกพื้นหลังแยกจากเนื้อหาได้ */
dialog.sheet-dlg {
  width: min(880px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--ground);
}
.dlg-inner { padding: 28px; }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.dlg-head h3 { margin: 4px 0 0; font-size: 22px; }
.dlg-close {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px;
  background: var(--paper); border: 0; border-radius: 50%;
  font-family: inherit; font-size: 24px; line-height: 1; color: var(--ink); cursor: pointer;
}
.dlg-close:hover { background: #f1ecea; }
#processDlg .process-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* แถบแจ้งเตือนให้ตั้งชื่อที่แสดง */
.profile-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  width: min(1176px, calc(100% - 64px)); margin: 16px auto 0; padding: 10px 10px 10px 20px;
  background: #fdeee4; border-radius: var(--r-l); font-size: 14px; color: #5b4a43;
}

/* การตั้งค่า */
dialog.settings-dlg { width: min(640px, calc(100vw - 32px)); }
.settings-part { margin-top: 16px; padding: 22px; background: var(--paper); border-radius: var(--r-l); }
.settings-part h4 { margin-bottom: 4px; font-size: 17px; font-weight: 600; }
.settings-part .section-lede { margin-bottom: 14px; font-size: 13.5px; }
.gear-btn { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; color: var(--ink); }
.gear-btn svg { width: 20px; height: 20px; }

#histBody { max-height: 55vh; margin: 0 0 20px; padding: 0; overflow-y: auto; list-style: none; }
#histBody li { padding: 8px 0 12px 16px; border-left: 3px solid #e8a27c; font-size: 14px; }
#histBody small { color: var(--muted); }

.bank-info-box { padding: 14px 18px; background: var(--soft); border-radius: var(--r-l); }
.bank-info-box p { margin: 4px 0; }

/* ===== ส่วนข้อมูลอ้างอิง (สาธารณะ) ===== */
.type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 20px; }

.type-tag {
  display: inline-block; margin-bottom: 12px; padding: 2px 12px; border-radius: 999px;
  background: #efeceb; font-size: 12.5px; font-weight: 500;
}
.type-card h3 { margin-bottom: 6px; font-size: 18px; font-weight: 500; }
.type-card p { font-size: 14px; color: var(--muted); }

/* อัตรา: การ์ดไล่สีเหมือนภาพอ้างอิง ตัวเลขเงินเป็นจุดเด่น */
#rates .type-card { padding: 28px; background: var(--ember); border-radius: var(--r-xl); color: #ffffff; }
#rates .type-tag { background: rgba(255, 255, 255, 0.18); color: #ffffff; }
#rates .type-card p { color: rgba(255, 255, 255, 0.9); }
#rates .type-card strong { display: block; margin-top: 4px; font-size: 40px; font-weight: 500; line-height: 1.25; letter-spacing: -0.02em; color: #ffffff; }

#rules .type-card { padding: 26px; background: var(--paper); border-radius: var(--r-xl); }
#rules .type-card strong { color: var(--ink); }

.note-box { margin-top: 16px; padding: 18px 24px; background: #fdeee4; border-radius: var(--r-l); }
.note-box h4 { margin-bottom: 2px; font-size: 15px; }
.note-box p { font-size: 14px; color: #5b4a43; }

/* ขั้นตอน (เป็นลำดับจริง จึงมีหมายเลข) */
.process-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 0; padding: 0; list-style: none; }
.process-list li { display: grid; gap: 14px; align-content: start; padding: 24px; background: var(--paper); border-radius: var(--r-xl); }
.step-index { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--ink); font-weight: 600; color: #ffffff; }
.process-list h3 { margin-bottom: 4px; font-size: 16px; font-weight: 600; }
.process-list p { font-size: 13.5px; color: var(--muted); }

.dynamic-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 15px;
}

.active-filters-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f1f3f5;
  border: 1px solid #dcdfe6;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
}

.filter-chip select, .filter-chip input {
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 13px;
}

.btn-remove-filter {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-weight: bold;
}
.btn-remove-filter:hover {
  color: #ff4d4f;
}

.add-filter-dropdown {
  position: relative;
}

.filter-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid #eee;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-radius: 8px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 160px;
  padding: 4px 0;
}

.filter-menu button {
  padding: 8px 12px;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}
.filter-menu button:hover {
  background: #f5f5f5;
}

#documents .table-card { padding: 16px 20px; background: var(--paper); border-radius: var(--r-xl); }

/* ===== Footer ===== */
.site-footer { margin-top: 40px; padding: 28px 0 40px; font-size: 13px; color: var(--muted); }

/* ===== Responsive (ต้องอยู่ท้ายไฟล์) ===== */
@media (max-width: 1400px) {
  .brand-text { display: none; }     /* เหลือโลโก้อย่างเดียว เพื่อให้เมนูแคปซูลมีที่พอ */
}

@media (max-width: 1180px) {
  :root { --header-h: 140px; }
  .header-inner { flex-wrap: wrap; row-gap: 12px; }
  .pill-nav { order: 3; flex: 0 0 100%; max-width: 100%; }
  .user-email { display: none; }                 /* เหลือกลุ่มกับปุ่มออกจากระบบ (ดูอีเมลได้จาก title) */
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .process-list { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  :root { --header-h: 132px; }
  .site-header { padding: 10px 0 8px; }
  .wrap { padding: 0 16px; }
  .hero { padding: 40px 16px 24px; }
  .section { padding: 32px 16px; }
  .section.workspace { width: calc(100% - 24px); padding: 22px 16px; }
  .card { padding: 24px 20px; border-radius: 22px; }
  .brand-text small { display: none; }
  .plot, .months, .chart-empty { margin-left: 34px; }
  .gridline span { left: -34px; width: 28px; font-size: 11px; }
  .bars, .months { gap: 3px; }
  .months span { font-size: 10.5px; }
  .process-list { grid-template-columns: 1fr; }
  #processDlg .process-list { grid-template-columns: minmax(0, 1fr); }
  .dlg-inner { padding: 20px 16px; }
  .settings-part { padding: 18px 14px; }
  .profile-banner { width: calc(100% - 24px); padding: 10px 12px 10px 16px; }
  .user-chip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}