@font-face { font-family: 'TH Sarabun PSK'; font-weight: 400; font-display: swap; src: url('/fonts/THSarabunPSK.ttf') format('truetype'); }
@font-face { font-family: 'TH Sarabun PSK'; font-weight: 700; font-display: swap; src: url('/fonts/THSarabunNew-Bold.ttf') format('truetype'); }
@font-face { font-family: 'THSarabunPSK'; font-weight: 400; font-display: swap; src: url('/fonts/THSarabunPSK.ttf') format('truetype'); }
@font-face { font-family: 'THSarabunPSK'; font-weight: 700; font-display: swap; src: url('/fonts/THSarabunNew-Bold.ttf') format('truetype'); }
@font-face { font-family: 'TH Sarabun New'; font-weight: 400; font-display: swap; src: url('/fonts/THSarabunNew.ttf') format('truetype'); }
@font-face { font-family: 'TH Sarabun New'; font-weight: 700; font-display: swap; src: url('/fonts/THSarabunNew-Bold.ttf') format('truetype'); }

:root {
  --teal-900: #134e4a; --teal-800: #115e59; --teal-700: #0f766e; --teal-600: #0d9488;
  --teal-500: #14b8a6; --teal-400: #2dd4bf; --teal-200: #99f6e4; --teal-100: #ccfbf1; --teal-50: #f0fdfa;
  --gold: #f59e0b; --gold-soft: #fef3c7;
  --ink: #0f2926; --muted: #52736e; --line: #d5e8e5; --bg: #f3f8f7; --card: #fff;
  --danger: #dc2626; --danger-soft: #fee2e2; --ok: #059669; --ok-soft: #d1fae5;
  --radius: 16px; --shadow: 0 1px 3px rgba(15, 118, 110, .06), 0 8px 24px rgba(15, 118, 110, .08);
  --shadow-lg: 0 20px 50px rgba(15, 118, 110, .2);
  --font-sans: 'Sarabun', 'Leelawadee UI', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-head: 'Prompt', 'Sarabun', 'Leelawadee UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 15.5px; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.38;
  letter-spacing: -0.01em;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--teal-700); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1.15rem; border-radius: 12px; border: 1px solid transparent;
  background: var(--teal-700); color: #fff; font-family: var(--font-head);
  font-weight: 500; font-size: .95rem; cursor: pointer;
  transition: transform .12s, box-shadow .2s, background .2s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--teal-800); box-shadow: 0 6px 16px rgba(15, 118, 110, .26); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.ghost { background: #fff; color: var(--teal-800); border-color: var(--line); }
.btn.ghost:hover { background: var(--teal-50); box-shadow: none; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; box-shadow: 0 6px 16px rgba(220, 38, 38, .3); }
.btn.gold { background: var(--gold); color: #422006; }
.btn.gold:hover { background: #d97706; box-shadow: 0 6px 16px rgba(245, 158, 11, .35); }
.btn.sm { padding: .38rem .78rem; border-radius: 10px; font-size: .86rem; }
.btn.block { width: 100%; padding: .78rem; font-size: 1rem; }
.icon { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Forms ---------- */
.field { display: grid; gap: .38rem; margin-bottom: 1rem; }
.field label { font-weight: 600; font-size: .92rem; color: var(--teal-900); }
.input, select.input {
  width: 100%; padding: .68rem .95rem; border: 1.5px solid var(--line);
  border-radius: 12px; background: #fff; font-size: .96rem;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.input:focus { border-color: var(--teal-500); box-shadow: 0 0 0 4px rgba(20, 184, 166, .16); }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon .input { padding-left: 2.65rem; }
.input-icon .toggle { position: absolute; right: .45rem; top: 50%; transform: translateY(-50%); border: 0; background: transparent; padding: .4rem; cursor: pointer; color: var(--muted); border-radius: 8px; }
.input-icon .toggle .icon { position: static; transform: none; }
.hint { font-size: .86rem; color: var(--muted); line-height: 1.45; }
.alert { padding: .75rem 1rem; border-radius: 12px; font-size: .92rem; margin-bottom: 1rem; line-height: 1.45; }
.alert.error { background: var(--danger-soft); color: #991b1b; }
.alert.info { background: var(--teal-50); color: var(--teal-800); border: 1px solid var(--teal-200); }
.alert.warn { background: var(--gold-soft); color: #92400e; }

/* ---------- Auth pages (ปรับสัดส่วนและระยะห่างไม่ให้วรรณยุกต์ซ้อนทับ) ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.08fr 1fr; }
.auth-hero {
  position: relative; overflow: hidden; color: #fff;
  padding: clamp(2rem, 4vw, 3.2rem);
  display: flex; flex-direction: column; justify-content: space-between; gap: 2rem;
  background:
    radial-gradient(1000px 500px at 0% 0%, rgba(20, 184, 166, .45) 0%, transparent 60%),
    linear-gradient(145deg, #093d39 0%, #0f766e 55%, #0d9488 100%);
}
.auth-hero::before, .auth-hero::after { content: ''; position: absolute; border-radius: 50%; pointer-events: none; }
.auth-hero::before { width: 420px; height: 420px; right: -140px; bottom: -140px; background: rgba(255, 255, 255, .06); }
.auth-hero::after { width: 240px; height: 240px; right: 90px; top: -80px; background: rgba(245, 158, 11, .12); }

.brand { display: flex; align-items: center; gap: .85rem; position: relative; z-index: 1; }
.brand img { width: 46px; height: 46px; border-radius: 13px; box-shadow: 0 6px 18px rgba(0, 0, 0, .22); flex: none; }
.brand b { font-family: var(--font-head); font-size: 1.2rem; font-weight: 600; display: block; line-height: 1.25; }
.brand span { font-size: .85rem; opacity: .85; display: block; line-height: 1.35; }

.hero-copy { position: relative; z-index: 1; max-width: 34rem; margin: auto 0; }
.hero-tag {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .85rem; border-radius: 999px;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .24);
  font-size: .84rem; font-weight: 600; margin-bottom: .9rem;
}
.hero-copy h1 {
  font-size: clamp(1.85rem, 2.7vw, 2.45rem);
  font-weight: 700;
  line-height: 1.38;
  margin: 0 0 .85rem;
  letter-spacing: -0.01em;
}
.hero-copy > p {
  font-size: 1rem;
  line-height: 1.65;
  opacity: .92;
  margin: 0 0 1.4rem;
}
.hero-points { display: grid; gap: .75rem; padding: 0; list-style: none; margin: 0; }
.hero-points li {
  display: grid;
  grid-template-columns: 2.75rem 1fr;
  align-items: center;
  gap: .85rem;
  background: rgba(255, 255, 255, .11);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, .2);
  padding: .8rem 1rem;
  border-radius: 14px;
}
.hp-icon {
  width: 2.75rem; height: 2.75rem; border-radius: 11px;
  background: rgba(255, 255, 255, .16);
  display: grid; place-items: center; color: #fde68a;
}
.hp-icon .icon { width: 1.35rem; height: 1.35rem; }
.hp-text { display: grid; gap: .15rem; min-width: 0; }
.hp-text b { font-family: var(--font-head); font-size: .98rem; font-weight: 600; line-height: 1.35; color: #fff; }
.hp-text span { font-size: .86rem; line-height: 1.45; opacity: .88; }

.hero-foot {
  position: relative; z-index: 1; font-size: .85rem; opacity: .85;
  display: flex; align-items: center; gap: .45rem;
}

.auth-panel { display: grid; place-items: center; padding: 2rem 1.5rem; background: linear-gradient(180deg, #fff, var(--teal-50)); }
.auth-card { width: 100%; max-width: 28rem; background: #fff; padding: 2rem; border-radius: 20px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.auth-card h2 { font-size: 1.6rem; color: var(--teal-800); margin-bottom: .25rem; }
.auth-card .sub { color: var(--muted); font-size: .94rem; margin: 0 0 1.25rem; }
.logo-mobile { display: none; }

/* ---------- Google OAuth SSO Button & Demo Picker ---------- */
.sso-pill {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .28rem .8rem; border-radius: 999px;
  background: #f8fafc; border: 1px solid #e2e8f0;
  font-size: .8rem; font-weight: 600; color: var(--teal-900);
  margin-bottom: .65rem;
}
.btn.google-btn {
  background: #fff; color: #1f2937;
  border: 1.5px solid #cbd5e1;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .06);
  font-weight: 600; gap: .65rem;
}
.btn.google-btn:hover {
  background: #f8fafc; border-color: var(--teal-500);
  box-shadow: 0 6px 16px rgba(15, 118, 110, .14);
}
.demo-sso-box {
  margin-top: 1.15rem; padding-top: 1rem;
  border-top: 1px dashed var(--line);
}
.demo-sso-head {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: .55rem;
}
.demo-sso-list { display: grid; gap: .45rem; }
.demo-sso-item {
  display: flex; align-items: center; gap: .7rem; width: 100%;
  padding: .55rem .8rem; border-radius: 12px;
  background: #f8fafc; border: 1px solid #e2e8f0;
  text-align: left; cursor: pointer; transition: all .15s;
}
.demo-sso-item:hover {
  background: var(--teal-50); border-color: var(--teal-400);
  transform: translateY(-1px);
}
.demo-sso-meta { min-width: 0; display: grid; line-height: 1.3; }
.demo-sso-meta b { font-size: .88rem; color: var(--teal-900); }
.demo-sso-meta span { font-size: .78rem; color: var(--muted); }

/* ---------- PDPA Consent Box & Legal Modal ---------- */
.pdpa-consent-box {
  background: var(--teal-50);
  border: 1px solid var(--teal-200);
  border-radius: 12px;
  padding: .8rem .95rem;
  margin-bottom: 1.1rem;
}
.pdpa-check-label, .pdpa-check-box {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: .6rem;
  font-size: .86rem;
  line-height: 1.5;
  color: var(--ink);
  cursor: pointer;
}
.pdpa-check-label input, .pdpa-check-box input {
  width: 1.1rem; height: 1.1rem; margin-top: .2rem; accent-color: var(--teal-700); cursor: pointer;
}
.pdpa-link {
  margin-top: .5rem; padding: 0; border: 0; background: none;
  color: var(--teal-700); font-weight: 600; font-size: .84rem;
  display: inline-flex; align-items: center; gap: .35rem;
  cursor: pointer; text-decoration: underline;
}
.pdpa-link:hover { color: var(--teal-900); }
.pdpa-inline-btn {
  border: 0; background: rgba(255, 255, 255, .2); color: #fff;
  padding: .1rem .5rem; border-radius: 6px; font-size: .78rem;
  cursor: pointer; font-weight: 600;
}
.pdpa-inline-btn:hover { background: rgba(255, 255, 255, .32); }

.pdpa-doc { font-size: .94rem; line-height: 1.65; color: var(--ink); }
.pdpa-banner {
  display: flex; align-items: center; gap: .8rem;
  padding: .85rem 1rem; border-radius: 12px;
  background: var(--teal-50); border: 1px solid var(--teal-200);
  color: var(--teal-900); margin-bottom: 1rem;
}
.pdpa-banner .icon { width: 1.8rem; height: 1.8rem; color: var(--teal-700); }
.pdpa-doc h4 { font-size: 1.02rem; color: var(--teal-800); margin: 1rem 0 .35rem; }
.pdpa-doc p { margin: 0 0 .6rem; }
.pdpa-doc ul { margin: 0 0 .8rem; padding-left: 1.3rem; }
.pdpa-doc li { margin-bottom: .35rem; }

.pdpa-gate-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; background: var(--bg); }
.pdpa-gate-card { max-width: 44rem; width: 100%; padding: 1.8rem; }
.pdpa-gate-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.pdpa-gate-head h2 { font-size: 1.35rem; margin: .25rem 0 .15rem; }
.pdpa-gate-head p { margin: 0; font-size: .9rem; }

/* ---------- App shell ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: 17.5rem 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 1.15rem .85rem; color: #d7f5f1;
  background: linear-gradient(180deg, #093d39 0%, #0f766e 100%);
  overflow-y: hidden; /* ไม่ต้องมีแถบเลื่อน */
}
.sidebar .brand {
  padding: 0 .4rem 1rem; color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  margin-bottom: .85rem;
}

/* Accordion Side Menu (ซ้อน / ขยาย) */
.nav { display: flex; flex-direction: column; gap: .35rem; }
.nav-accordion-group {
  border-radius: 12px;
  transition: background .15s;
}
.nav-group-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: .55rem .75rem; border: none; background: transparent; color: #d7f5f1;
  font-family: var(--font-head); font-weight: 600; font-size: .84rem; cursor: pointer;
  border-radius: 10px; text-align: left; transition: all .15s;
  letter-spacing: .02em;
}
.nav-group-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-group-btn .group-title { display: flex; align-items: center; gap: .5rem; }
.nav-group-btn .nav-chevron {
  width: .95rem; height: .95rem; display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease; opacity: .75;
}
.nav-accordion-group.open .nav-group-btn .nav-chevron {
  transform: rotate(180deg); opacity: 1;
}
.nav-accordion-group.open .nav-group-btn {
  color: #fff; font-weight: 700;
}

.nav-group-items {
  display: none;
  flex-direction: column;
  gap: .2rem;
  padding: .25rem 0 .35rem .6rem;
}
.nav-accordion-group.open .nav-group-items {
  display: flex;
}

.nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .52rem .75rem; border-radius: 10px; color: #ccfbf1;
  text-decoration: none; font-weight: 500; font-size: .88rem;
  transition: all .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav a.active {
  background: #fff; color: var(--teal-800);
  font-weight: 700; box-shadow: 0 4px 14px rgba(0, 0, 0, .16);
}

.main { padding: 1.8rem clamp(1rem, 3vw, 2.5rem) 3rem; min-width: 0; }
.mobilebar { display: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.page-head h1 { font-size: 1.7rem; color: var(--teal-900); }
.page-head p { margin: .25rem 0 0; color: var(--muted); font-size: .95rem; }

/* ---------- Topbar & User Menu (ขวา บน) ---------- */
.topbar {
  background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 25;
  padding: .65rem clamp(1rem, 3vw, 2.5rem);
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; min-height: 3.8rem;
}
.topbar-left {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; min-width: 0;
}
.topbar-right {
  display: flex; align-items: center; gap: .75rem; margin-left: auto; position: relative;
}

/* User Pill (ขวา บน) */
.user-pill-btn {
  display: flex; align-items: center; gap: .65rem;
  padding: .35rem .75rem .35rem .45rem;
  border: 1.5px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--teal-900);
  cursor: pointer; transition: all .15s; outline: none;
}
.user-pill-btn:hover, .user-pill-btn.active {
  border-color: var(--teal-400); background: var(--teal-50);
  box-shadow: 0 2px 8px rgba(15, 118, 110, .12);
}
.user-pill-btn .avatar {
  width: 2.1rem; height: 2.1rem; font-size: .95rem;
}
.user-pill-info {
  display: flex; flex-direction: column; text-align: left; line-height: 1.2;
}
.user-pill-name {
  font-weight: 700; font-size: .88rem; color: var(--teal-950);
  max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-pill-role {
  font-size: .74rem; color: var(--muted); font-weight: 500;
}
.user-pill-btn .chevron-icon {
  width: .9rem; height: .9rem; color: var(--muted); transition: transform .2s;
  display: flex; align-items: center; justify-content: center;
}
.user-pill-btn.active .chevron-icon {
  transform: rotate(180deg); color: var(--teal-700);
}

/* Floating Dropdown Menu */
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; width: 17.5rem;
  background: #fff; border: 1.5px solid var(--line); border-radius: 16px;
  box-shadow: 0 12px 35px rgba(15, 118, 110, .15); padding: .65rem;
  display: none; flex-direction: column; gap: .2rem; z-index: 100;
  animation: dropFade .15s ease-out;
}
.user-dropdown.show { display: flex; }
@keyframes dropFade { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.user-dropdown-head {
  display: flex; align-items: center; gap: .75rem; padding: .6rem .65rem .8rem;
}
.user-dropdown-head .avatar {
  width: 2.6rem; height: 2.6rem; font-size: 1.1rem;
}
.user-dropdown-head .name {
  font-weight: 700; font-size: .95rem; color: var(--teal-900); line-height: 1.2;
}
.user-dropdown-head .email {
  font-size: .78rem; color: var(--muted); margin-top: .15rem; word-break: break-all;
}
.user-dropdown-head .badge {
  margin-top: .3rem; font-size: .72rem; padding: .15rem .55rem;
}

.dropdown-divider {
  height: 1px; background: #eef2f6; margin: .3rem 0;
}

.dropdown-item {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .75rem;
  border-radius: 10px; border: none; background: transparent; color: #334155;
  font-family: var(--font-head); font-size: .88rem; font-weight: 600; text-decoration: none;
  cursor: pointer; text-align: left; width: 100%; transition: background .12s;
}
.dropdown-item:hover {
  background: var(--teal-50); color: var(--teal-900);
}
.dropdown-item.danger {
  color: #dc2626;
}
.dropdown-item.danger:hover {
  background: #fee2e2; color: #991b1b;
}
.dropdown-item .icon {
  width: 1.1rem; height: 1.1rem; opacity: .8;
}

/* Avatar general */
.avatar { width: 2.5rem; height: 2.5rem; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--gold), #fbbf24); color: #422006; font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; flex: none; }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid rgba(213, 232, 229, .8); padding: 1.35rem; }
.card + .card, .grid + .card, .card + .grid { margin-top: 1.35rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card-head h3 { font-size: 1.15rem; color: var(--teal-900); display: flex; align-items: center; gap: .5rem; }
.grid { display: grid; gap: 1.15rem; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
#detail .card { margin-top: 1.35rem; }
.stat { position: relative; overflow: hidden; border-radius: var(--radius); padding: 1.15rem 1.3rem; color: #fff; background: linear-gradient(135deg, var(--teal-700), var(--teal-500)); box-shadow: var(--shadow); }
.stat::after { content: ''; position: absolute; width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, .12); right: -25px; top: -35px; }
.stat.gold { background: linear-gradient(135deg, #d97706, #fbbf24); color: #422006; }
.stat.dark { background: linear-gradient(135deg, #134e4a, #0f766e); }
.stat small { display: block; opacity: .9; font-size: .88rem; }
.stat b { display: block; font-family: var(--font-head); font-size: 1.65rem; line-height: 1.25; margin-top: .2rem; position: relative; z-index: 1; }
.stat span { font-size: .84rem; opacity: .85; position: relative; z-index: 1; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table.table { width: 100%; border-collapse: collapse; min-width: 36rem; font-size: .93rem; }
.table th { text-align: left; background: var(--teal-50); color: var(--teal-800); font-weight: 600; font-size: .86rem; padding: .7rem .9rem; white-space: nowrap; border-bottom: 1px solid var(--line); }
.table td { padding: .65rem .9rem; border-bottom: 1px solid #edf4f3; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8fdfc; }
.table .actions { display: flex; gap: .4rem; justify-content: flex-end; flex-wrap: wrap; }
.table th.num { text-align: right; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .icon { width: 2.5rem; height: 2.5rem; color: var(--teal-200); margin-bottom: .4rem; }
.badge { white-space: nowrap; display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .7rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge.draft { background: var(--gold-soft); color: #92400e; }
.badge.published { background: var(--ok-soft); color: #065f46; }
.badge.role { background: var(--teal-100); color: var(--teal-800); }
.badge.off { background: var(--danger-soft); color: #991b1b; }
.toolbar { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar .input { max-width: 16rem; }
.toolbar .spacer { flex: 1; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; gap: 1rem; flex-wrap: wrap; font-size: .9rem; color: var(--muted); }

/* ---------- Slip list (user) ---------- */
.slip-list { display: grid; gap: .8rem; }
.slip-item { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 1rem; padding: .9rem 1.1rem; border: 1px solid var(--line); border-radius: 14px; background: #fff; transition: box-shadow .2s, transform .15s, border-color .2s; }
.slip-item:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--teal-200); }
.slip-month { width: 3.4rem; height: 3.4rem; border-radius: 13px; background: linear-gradient(135deg, var(--teal-100), var(--teal-50)); color: var(--teal-800); display: grid; place-items: center; text-align: center; line-height: 1.1; font-weight: 700; }
.slip-month small { display: block; font-size: .72rem; opacity: .75; }
.slip-title { font-weight: 600; font-size: 1.05rem; }
.slip-net { text-align: right; }
.slip-net small { display: block; color: var(--muted); font-size: .78rem; }
.slip-net b { font-family: var(--font-head); font-size: 1.2rem; color: var(--teal-700); }

/* ---------- Upload ---------- */
.dropzone { border: 2px dashed var(--teal-400); background: linear-gradient(180deg, var(--teal-50), #fff); border-radius: var(--radius); padding: 1.6rem 1rem; text-align: center; cursor: pointer; transition: background .2s, border-color .2s; }
.dropzone:hover, .dropzone.drag { background: var(--teal-100); border-color: var(--teal-600); }
.dropzone .icon { width: 2.4rem; height: 2.4rem; color: var(--teal-600); }
.dropzone b { display: block; font-size: 1.02rem; color: var(--teal-800); margin-top: .25rem; }
.dropzone .file { margin-top: .5rem; font-weight: 600; color: var(--teal-700); }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: .8rem; margin: 1rem 0; }
.result-box { padding: .8rem 1rem; border-radius: 14px; background: var(--teal-50); text-align: center; font-size: .88rem; }
.result-box b { display: block; font-family: var(--font-head); font-size: 1.45rem; line-height: 1.2; color: var(--teal-700); }
.result-box.bad { background: var(--danger-soft); } .result-box.bad b { color: var(--danger); }
.err-list { max-height: 12rem; overflow: auto; font-size: .88rem; background: #fff7f7; border: 1px solid var(--danger-soft); border-radius: 12px; padding: .65rem .95rem; margin: 0; list-style: none; }
.err-list li { padding: .2rem 0; }

/* ---------- Modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 47, 43, .55); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 1.25rem 1rem; z-index: 50; animation: fade .18s; }
.modal { background: #fff; border-radius: 20px; width: 100%; max-width: 36rem; max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg); animation: pop .22s cubic-bezier(.2, .9, .3, 1.2); }
.modal.wide { max-width: 80rem; width: 95vw; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.2rem 1.75rem; border-bottom: 1px solid var(--line); flex-shrink: 0; background: #fff; z-index: 2; }
.modal-head h3 { font-size: 1.28rem; color: var(--teal-900); margin: 0; font-weight: 700; }
.modal-body { padding: 1.6rem 1.85rem; overflow-y: auto; flex: 1 1 auto; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: .75rem; padding: 1rem 1.85rem; border-top: 1px solid var(--line); flex-shrink: 0; background: #fff; z-index: 2; }
.x { border: 0; background: var(--teal-50); width: 2.2rem; height: 2.2rem; border-radius: 50%; cursor: pointer; display: grid; place-items: center; color: var(--teal-800); }
.toasts { position: fixed; right: 1rem; top: 1rem; display: grid; gap: .6rem; z-index: 100; }
.toast { min-width: 15rem; max-width: 24rem; padding: .8rem 1rem; border-radius: 14px; background: #fff; box-shadow: var(--shadow-lg); border-left: 5px solid var(--teal-500); animation: slide .25s; font-weight: 600; font-size: .92rem; }
.toast.error { border-color: var(--danger); } .toast.success { border-color: var(--ok); }

/* ---------- Slip preview (modal) ---------- */
.slip-paper { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; font-size: .92rem; }
.slip-paper header { background: linear-gradient(120deg, var(--teal-700), var(--teal-500)); color: #fff; padding: .95rem 1.25rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.slip-paper header h4 { margin: 0; font-size: 1.2rem; }
.slip-paper header span { opacity: .92; font-size: .92rem; }
.slip-who { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .6rem 1rem; padding: .85rem 1.25rem; background: var(--teal-50); border-bottom: 1px solid var(--teal-100); }
.slip-who small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.2; }
.slip-who b { display: block; font-size: .94rem; }
.slip-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 1rem 1.25rem; }
.slip-box { border: 1px solid var(--line); border-radius: 12px; padding: .75rem 1rem; background: #fcfefe; }
.slip-box.ded { background: #fffdfd; border-color: #f3dada; }
.slip-cols h5 { margin: 0 0 .45rem; color: var(--teal-700); font-family: var(--font-head); font-size: .96rem; border-bottom: 2px solid var(--teal-700); padding-bottom: .3rem; }
.line { display: flex; justify-content: space-between; padding: .26rem 0; border-bottom: 1px dotted var(--line); }
.line.total { font-weight: 700; border-top: 2px solid var(--teal-700); border-bottom: 0; margin-top: .25rem; padding-top: .4rem; }
.slip-net-bar { display: flex; justify-content: space-between; align-items: center; margin: 0 1.25rem 1.25rem; padding: .8rem 1.15rem; border-radius: 14px; color: #fff; background: linear-gradient(120deg, #059669, #10b981); }
.slip-net-bar b { font-family: var(--font-head); font-size: 1.45rem; }

/* ---------- Misc ---------- */
.spinner { width: 1.05rem; height: 1.05rem; border: 2.5px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.loading { display: grid; place-items: center; padding: 3rem; color: var(--muted); }
.loading .spinner { border-color: var(--teal-100); border-top-color: var(--teal-600); width: 2rem; height: 2rem; margin-bottom: .6rem; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes slide { from { opacity: 0; transform: translateX(20px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.main > * { animation: rise .35s both; }

/* ---------- Portal Launcher Hub (หน้าหลักเลือกระบบ) ---------- */
.subnav { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .75rem clamp(1rem, 3vw, 2.5rem); background: #fff; border-bottom: 1px solid var(--line); }
.subnav-pills { display: flex; gap: .45rem; flex-wrap: wrap; }
.subnav-pills a { display: inline-flex; align-items: center; gap: .38rem; padding: .38rem .85rem; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: .86rem; color: var(--teal-800); background: var(--teal-50); border: 1px solid transparent; transition: all .15s; }
.subnav-pills a:hover { border-color: var(--teal-400); }
.subnav-pills a.active { background: var(--teal-700); color: #fff; }

.portal-hero { position: relative; overflow: hidden; border-radius: 20px; padding: 1.65rem 1.9rem; color: #fff; background: radial-gradient(700px 300px at 90% 0%, rgba(45, 212, 191, .35), transparent), linear-gradient(135deg, #093d39, #0f766e 60%, #0d9488); box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.portal-pill { display: inline-flex; align-items: center; gap: .38rem; padding: .22rem .8rem; border-radius: 999px; background: rgba(255, 255, 255, .15); border: 1px solid rgba(255, 255, 255, .25); font-size: .8rem; font-weight: 600; margin-bottom: .55rem; }
.portal-hero h1 { font-size: 1.75rem; margin: .1rem 0 .3rem; }
.portal-hero p { margin: 0; opacity: .92; font-size: .95rem; }
.portal-id-box { background: rgba(255, 255, 255, .13); border: 1px solid rgba(255, 255, 255, .24); backdrop-filter: blur(8px); padding: .85rem 1.25rem; border-radius: 15px; text-align: right; }
.portal-id-box small { display: block; font-size: .78rem; opacity: .88; }
.portal-id-box b { display: block; font-family: var(--font-head); font-size: 1.35rem; letter-spacing: .04em; color: #fde68a; line-height: 1.25; }
.portal-id-box span { font-size: .78rem; opacity: .9; display: inline-flex; align-items: center; gap: .3rem; }

.section-head { margin-bottom: 1rem; }
.section-head h2 { font-size: 1.3rem; color: var(--teal-900); }

.portal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1.2rem; }
.portal-card { display: flex; flex-direction: column; padding: 1.35rem; border-radius: 18px; background: #fff; border: 1.5px solid var(--line); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); transition: transform .18s, box-shadow .2s, border-color .2s; position: relative; overflow: hidden; }
.portal-card::before { content: ''; position: absolute; left: 0; top: 0; right: 0; height: 5px; background: linear-gradient(90deg, var(--teal-700), var(--teal-400)); }
.portal-card.emerald::before { background: linear-gradient(90deg, #059669, #34d399); }
.portal-card.amber::before { background: linear-gradient(90deg, #d97706, #fbbf24); }
.portal-card.navy::before { background: linear-gradient(90deg, #1e40af, #3b82f6); }
.portal-card.slate::before { background: linear-gradient(90deg, #334155, #64748b); }
.portal-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--teal-400); }
.portal-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .85rem; }
.portal-icon { width: 2.9rem; height: 2.9rem; border-radius: 13px; display: grid; place-items: center; background: var(--teal-50); color: var(--teal-700); flex: none; }
.portal-card.emerald .portal-icon { background: #ecfdf5; color: #059669; }
.portal-card.amber .portal-icon { background: #fffbeb; color: #d97706; }
.portal-card.navy .portal-icon { background: #eff6ff; color: #1d4ed8; }
.portal-card.slate .portal-icon { background: #f1f5f9; color: #334155; }
.portal-icon .icon { width: 1.45rem; height: 1.45rem; }
.portal-badge { font-size: .78rem; font-weight: 600; padding: .2rem .65rem; border-radius: 999px; background: var(--teal-50); color: var(--teal-800); }
.portal-card h3 { font-size: 1.2rem; color: var(--teal-900); margin-bottom: .35rem; }
.portal-card p { margin: 0 0 1rem; color: var(--muted); font-size: .9rem; line-height: 1.55; flex: 1; }
.portal-meta { padding: .55rem .8rem; border-radius: 10px; background: #f8fafc; border: 1px solid #e2e8f0; font-size: .84rem; font-weight: 600; color: var(--teal-800); margin-bottom: .85rem; }
.portal-cta { display: flex; justify-content: space-between; align-items: center; font-family: var(--font-head); font-weight: 600; font-size: .92rem; color: var(--teal-700); padding-top: .15rem; }

/* ---------- Dashboard Filter Pills ---------- */
.dept-pill { border: 1.5px solid var(--teal-200); background: #fff; color: var(--teal-900); padding: .38rem .85rem; border-radius: 20px; font-size: .84rem; font-weight: 600; cursor: pointer; transition: all .15s; outline: none; }
.dept-pill:hover { background: var(--teal-50); border-color: var(--teal-400); }
.dept-pill.active { background: var(--teal-700); border-color: var(--teal-700); color: #fff; box-shadow: 0 2px 6px rgba(15, 118, 110, .28); }

/* ---------- Financial Web Grid (ระบบกรอกข้อมูลเงินเดือนออนไลน์) ---------- */
.grid-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .85rem; margin-bottom: 1.25rem; }
.grid-kpi-box { background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: .85rem 1.1rem; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.grid-kpi-box small { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: .25rem; }
.grid-kpi-box b { display: block; font-size: 1.35rem; font-family: var(--font-head); font-weight: 700; color: var(--teal-900); }
.grid-kpi-box.green b { color: #059669; }
.grid-kpi-box.red b { color: #dc2626; }
.grid-kpi-box.emerald b { color: #047857; }

.grid-tab-bar { display: flex; gap: .4rem; border-bottom: 2px solid var(--line); margin-bottom: 1rem; overflow-x: auto; padding-bottom: 2px; }
.grid-tab { padding: .55rem 1.1rem; border: none; background: transparent; font-family: var(--font-head); font-weight: 600; font-size: .92rem; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -4px; transition: all .15s; white-space: nowrap; border-radius: 8px 8px 0 0; }
.grid-tab:hover { color: var(--teal-700); background: var(--teal-50); }
.grid-tab.active { color: var(--teal-800); border-bottom-color: var(--teal-600); background: #fff; font-weight: 700; }

.grid-table-wrap {
  overflow: auto; max-height: calc(100vh - 280px); min-height: 400px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  box-shadow: 0 2px 8px rgba(15, 118, 110, .05); position: relative;
}
.grid-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: .88rem; }
.grid-table th { padding: .5rem .6rem; font-weight: 700; font-size: .82rem; white-space: nowrap; border-right: 1px solid #d5e8e5; border-bottom: 1px solid #d5e8e5; position: sticky; top: 0; z-index: 10; }
.grid-table th.top-grp-base { background: #f1f5f9; color: #334155; }
.grid-table th.top-grp-inc { background: #dcfce7; color: #166534; border-bottom: 2px solid #86efac; }
.grid-table th.top-grp-ded { background: #fee2e2; color: #991b1b; border-bottom: 2px solid #fca5a5; }
.grid-table th.top-grp-net { background: #ccfbf1; color: #0f766e; border-bottom: 2px solid #5eead4; }

.grid-table th.sub-base { background: #f8fafc; color: #475569; top: 29px; z-index: 9; }
.grid-table th.sub-inc { background: #f0fdf4; color: #15803d; top: 29px; z-index: 9; }
.grid-table th.sub-ded { background: #fff1f2; color: #be123c; top: 29px; z-index: 9; }
.grid-table th.sub-net { background: #e6f7f5; color: #0f766e; top: 29px; z-index: 9; }

.grid-table td { padding: .32rem .4rem; border-right: 1px solid #eef2f6; border-bottom: 1px solid #eef2f6; vertical-align: middle; white-space: nowrap; background: #fff; }
.grid-table tr:hover td { background: #f8fafc; }
.grid-table tr.row-modified td { background: #fffbeb !important; }
.grid-table tr.row-new td { background: #f0fdfa !important; }

/* Sticky columns (seq, id, name) */
.grid-table .sticky-1 { position: sticky; left: 0; z-index: 5; background: #fff; }
.grid-table .sticky-2 { position: sticky; left: 42px; z-index: 5; background: #fff; }
.grid-table .sticky-3 { position: sticky; left: 140px; z-index: 5; background: #fff; box-shadow: 2px 0 5px rgba(0,0,0,.04); }
.grid-table th.sticky-1, .grid-table th.sticky-2, .grid-table th.sticky-3 { z-index: 20 !important; }

.grid-num-input {
  width: 6.8rem; padding: .32rem .45rem; border: 1px solid #cbd5e1; border-radius: 6px;
  font-family: var(--font-sans); font-size: .87rem; text-align: right; font-variant-numeric: tabular-nums;
  background: #fff; color: #0f172a; transition: border-color .15s, box-shadow .15s; outline: none;
}
.grid-num-input:focus { border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(20, 184, 166, .2); background: #f0fdfa; }
.grid-num-input::-webkit-inner-spin-button, .grid-num-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.grid-num-input[type=number] { -moz-appearance: textfield; }

.grid-calc-cell { padding: .4rem .65rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; font-size: .9rem; }
.grid-calc-inc { color: #166534; background: #f0fdf4 !important; }
.grid-calc-ded { color: #991b1b; background: #fef2f2 !important; }
.grid-calc-net { color: #047857; background: #ecfdf5 !important; font-size: .95rem; font-weight: 800; }

.grid-foot { position: sticky; bottom: 0; z-index: 15; background: #0f2926; color: #fff; }
.grid-foot td { background: #0f2926 !important; color: #fff; font-weight: 700; border-top: 2px solid var(--teal-400); border-bottom: none; border-right-color: #274d47; padding: .55rem .5rem; font-size: .9rem; text-align: right; font-variant-numeric: tabular-nums; }
.grid-foot .foot-label { text-align: left; position: sticky; left: 0; z-index: 18; background: #0f2926 !important; }

/* Column Highlight Spotlight */
.grid-table th.col-spotlight { outline: 2.5px solid #0d9488 !important; outline-offset: -2px; z-index: 12 !important; background: #e0f2fe !important; color: #0369a1 !important; }
.grid-table td.col-spotlight { background: #f0fdfa !important; border-left: 2px solid #14b8a6 !important; border-right: 2px solid #14b8a6 !important; }
.grid-table td.col-spotlight input { border-color: #0d9488 !important; font-weight: 700 !important; background: #fff !important; }
.grid-table tfoot td.col-spotlight { background: #134e4a !important; color: #fef08a !important; border-left: 2px solid #5eead4 !important; border-right: 2px solid #5eead4 !important; }

/* Column Insight Panel (ตัวกรองดูผลรวมแต่ละคอลัมน์) */
.col-insight-box {
  background: #f8fafc; border: 1.5px solid #cbd5e1; border-radius: 14px;
  padding: 1rem 1.25rem; margin-bottom: 1.15rem; transition: all .2s;
}
.col-insight-box.active {
  background: #f0fdfa; border-color: #5eead4; box-shadow: 0 4px 16px rgba(15, 118, 110, .08);
}
.col-insight-head {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .85rem;
}
.col-insight-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; margin-bottom: .85rem;
}
.col-insight-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .65rem .85rem;
}
.col-insight-card small { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: .2rem; }
.col-insight-card b { display: block; font-family: var(--font-head); font-size: 1.15rem; color: var(--teal-900); }
.col-dept-breakdown {
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; padding-top: .6rem; border-top: 1px dashed #cbd5e1;
}
.col-dept-pill {
  display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .65rem; border-radius: 8px;
  background: #fff; border: 1px solid #e2e8f0; font-size: .78rem; color: #334155; font-weight: 600;
}
.col-dept-pill b { color: var(--teal-700); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .logo-mobile { display: flex; align-items: center; gap: .6rem; justify-content: center; margin-bottom: 1.1rem; color: var(--teal-800); font-family: var(--font-head); font-weight: 600; font-size: 1.2rem; }
  .logo-mobile img { width: 40px; height: 40px; border-radius: 12px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; width: 17.5rem; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .mobilebar { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .mobilebar b { color: var(--teal-800); font-family: var(--font-head); font-size: .95rem; }
  .slip-item { grid-template-columns: auto 1fr; }
  .slip-item .slip-net, .slip-item .actions { grid-column: 1 / -1; }
  .slip-cols { grid-template-columns: 1fr; }
}
@media print { .sidebar, .mobilebar, .topbar, .toasts { display: none; } }
