/* =========================================================================
 * WorkProof — Modern SaaS theme
 * Primary #2563EB · Secondary #0F172A · Background #F8FAFC
 * ========================================================================= */
:root {
  --primary: #1E2A4A;        /* deep navy ink — refined accent */
  --primary-d: #141d35;
  --primary-l: #ECEEF4;      /* navy tint */
  --on-primary: #ffffff;     /* สีตัวอักษรบนพื้น accent (ปรับอัตโนมัติตามความสว่าง) */
  --secondary: #111418;      /* ink */
  --bg: #FAFAF8;             /* warm off-white */
  --surface: #ffffff;
  --border: #ECEAE5;         /* warm hairline */
  --border-strong: #DEDBD3;
  --text: #111418;
  --muted: #6B6F76;
  --muted-l: #A7A39B;
  --success: #2F7A5B;
  --warn: #9A6B22;
  --danger: #A8443B;
  --info: #3A5A8C;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(17, 20, 24, .04), 0 1px 3px rgba(17, 20, 24, .03);
  --shadow-md: 0 4px 16px rgba(17, 20, 24, .06), 0 1px 4px rgba(17, 20, 24, .04);
  --shadow-lg: 0 16px 48px rgba(17, 20, 24, .10), 0 4px 12px rgba(17, 20, 24, .05);
  --sidebar-w: 264px;
  --rail-w: 76px;
  --side-w: var(--sidebar-w);   /* ความกว้างจริงของ sidebar (rail จะ override) */
  --topbar-h: 68px;
  --font: "Plus Jakarta Sans", "Noto Sans Thai", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -.005em;
}

/* ป้องกันเนื้อหาล้นแนวนอน (overflow ไปทางขวา) ทุกขนาดจอ
 * - ต้นเหตุหลัก: grid/flex item ตั้ง min-width:auto จึงไม่ยอมหดเมื่อเนื้อหากว้าง
 * - ตาข่ายกัน: overflow-x:clip (ไม่กระทบ sticky/fixed) */
html { overflow-x: hidden; }              /* propagate ไป viewport -> ตัด scrollbar แนวนอนแน่นอน */
body { overflow-x: clip; max-width: 100%; width: 100%; }
.main { min-width: 0; overflow-x: clip; max-width: 100%; }
.content, .shell, .topbar { min-width: 0; }
.stats > *, .charts-grid > *, .dash-grid > *, .plans > *, .card { min-width: 0; }
.tbl-wrap { max-width: 100%; }
svg.chart, .chart-fluid { max-width: 100%; }
.viewer .big img { max-width: 100%; }
.topbar .search-mini { flex: 0 1 300px; min-width: 0; }
.hbar-label { min-width: 0; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; color: var(--secondary); letter-spacing: -.02em; }
h1 { font-weight: 800; }
img { max-width: 100%; display: block; }
::selection { background: var(--primary); color: var(--on-primary); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: background .18s, border-color .18s, box-shadow .18s, transform .05s;
  white-space: nowrap; line-height: 1; letter-spacing: .005em;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 1px 2px rgba(17, 20, 24, .12); }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: #F4F2EE; border-color: var(--muted-l); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-sm { padding: 6.5px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.icon-btn {
  background: none; border: none; cursor: pointer; font-size: 22px; line-height: 1;
  color: var(--muted); padding: 4px 8px; border-radius: 8px; transition: .15s;
}
.icon-btn:hover { background: #F4F2EE; color: var(--text); }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; color: var(--text); }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  background: var(--surface); color: var(--text); transition: .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3.5px var(--primary-l); }
.field label { letter-spacing: -.01em; }
textarea.input { resize: vertical; min-height: 76px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* ---------- badges / status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-Draft { background: #F1EFEA; color: #6B6F76; }
.st-Pending { background: #F5EEDF; color: #8A6516; }
.st-In.Progress, .st-InProgress { background: #E7EAF2; color: #2E3E63; }
.st-Completed { background: #E6EFE9; color: #2F7A5B; }
.st-Cancelled { background: #F3E4E2; color: #9E3D34; }

/* =========================================================================
 * LOGIN
 * ========================================================================= */
.login-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
}
.login-aside {
  position: relative; overflow: hidden;
  background: linear-gradient(155deg, #243352 0%, #1E2A4A 45%, #111418 100%);
  color: #fff; padding: 64px; display: flex; flex-direction: column; justify-content: center;
}
.login-aside::after {
  content: ""; position: absolute; width: 460px; height: 460px; border-radius: 50%;
  right: -160px; top: -120px; background: radial-gradient(circle, rgba(255,255,255,.08), transparent 70%);
}
.login-aside .brand { font-size: 32px; font-weight: 800; margin-bottom: 10px; letter-spacing: -.03em; position: relative; }
.login-aside .tag { font-size: 16px; opacity: .8; margin-bottom: 44px; font-weight: 300; letter-spacing: .01em; position: relative; }
.login-aside ul { list-style: none; padding: 0; margin: 0; position: relative; }
.login-aside li { padding: 9px 0; opacity: .9; font-weight: 300; }
.login-aside li::before { content: "—  "; opacity: .55; }
.login-main { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 27px; margin-bottom: 7px; }
.login-card .sub { color: var(--muted); margin: 0 0 28px; }
.demo-accounts {
  margin-top: 22px; padding: 14px; background: var(--bg);
  border: 1px dashed var(--border); border-radius: var(--radius-sm); font-size: 13px;
}
.demo-accounts b { color: var(--secondary); }
.demo-accounts code {
  cursor: pointer; background: var(--surface); padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--border);
}
.demo-accounts code:hover { border-color: var(--primary); color: var(--primary); }

/* quick-login (ปุ่ม login ด่วนทีละ role) */
.ql-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 14px; color: var(--muted-l); font-size: 12px; }
.ql-divider::before, .ql-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.quick-logins { display: grid; gap: 8px; }
.ql-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-family: inherit; transition: .15s;
}
.ql-btn:hover { border-color: var(--primary); background: var(--primary-l); }
.ql-ic { width: 34px; height: 34px; border-radius: 9px; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 17px; flex: 0 0 auto; }
.ql-txt { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.ql-txt b { font-size: 13.5px; color: var(--text); }
.ql-txt small { font-size: 11.5px; color: var(--muted); }
.ql-go { color: var(--muted-l); font-size: 16px; transition: .15s; }
.ql-btn:hover .ql-go { color: var(--primary); transform: translateX(2px); }
.login-links { margin-top: 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; flex-wrap: wrap; }
.login-links a { font-weight: 600; }
.lang-fab {
  position: fixed; top: 16px; right: 16px; z-index: 30;
  min-width: 42px; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-family: inherit; font-weight: 700; font-size: 12px;
  cursor: pointer; box-shadow: var(--shadow); transition: .15s;
}
.lang-fab:hover { border-color: var(--primary); color: var(--primary); }
.login-aside a.brand { cursor: pointer; text-decoration: none; color: inherit; transition: opacity .15s; }
.login-aside a.brand:hover { opacity: .82; }
/* ปุ่มกลับหน้าแรก: แสดงทุกขนาดจอ มุมซ้ายบน ให้ผู้ใช้เห็นชัดว่ากดกลับหน้าแรกได้ */
.home-fab { position: fixed; top: 16px; left: 16px; z-index: 31; display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-family: inherit; font-weight: 700; font-size: 13px;
  text-decoration: none; box-shadow: var(--shadow); transition: .15s; }
.home-fab:hover { border-color: var(--primary); color: var(--primary); transform: translateX(-2px); }

/* =========================================================================
 * LANDING / PRICING  (หน้าขาย)
 * ========================================================================= */
.landing-body { background: var(--bg); color: var(--text); overflow-x: clip; }
.landing { min-height: 100vh; overflow-x: clip; overflow-wrap: break-word; }
.btn-lg { padding: 13px 26px; font-size: 15px; }

/* nav */
.lp-nav { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 18px;
  padding: 13px 22px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
.lp-logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; color: var(--text); }
.lp-links { display: flex; gap: 22px; margin-left: 12px; flex: 1; }
.lp-links a { color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; }
.lp-links a:hover { color: var(--primary); }
.lp-nav-act { display: flex; align-items: center; gap: 10px; }
.lp-icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 14px; font-weight: 700; cursor: pointer; transition: .15s; }
.lp-icon-btn:hover { border-color: var(--primary); color: var(--primary); }

/* hero */
.lp-hero { max-width: 1140px; margin: 0 auto; padding: 66px 24px 40px; display: grid;
  grid-template-columns: 1.05fr .95fr; gap: 48px; align-items: center; }
.lp-hero-txt, .lp-hero-art { min-width: 0; }
.lp-badge { display: inline-block; background: var(--primary-l); color: var(--primary);
  font-weight: 700; font-size: 12.5px; padding: 6px 13px; border-radius: 999px; margin-bottom: 18px; }
.lp-hero h1 { font-size: 46px; line-height: 1.08; letter-spacing: -.03em; margin: 0 0 18px; overflow-wrap: anywhere; }
.lp-hero h1 .hl { color: var(--primary); }
.lp-sub { font-size: 17px; color: var(--muted); line-height: 1.6; margin: 0 0 26px; max-width: 520px; }
.lp-hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.lp-hero-cta .btn-ghost { cursor: pointer; }
.lp-note { margin-top: 16px; font-size: 13px; color: var(--muted-l); }
.lp-hero-art { display: flex; justify-content: center; }

/* hero mock (จำลองหน้าแชร์งาน) */
.lp-art { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; transform: rotate(.5deg); }
.lp-art-top { display: flex; align-items: center; gap: 6px; padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--border); }
.lp-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.lp-art-url { margin-left: 10px; font-size: 11px; color: var(--muted-l); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 10px; }
.lp-art-body { padding: 16px; }
.lp-art-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.lp-art-logo { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center; font-weight: 800; }
.lp-art-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lp-art-tile { height: 78px; border-radius: 10px; display: flex; align-items: flex-end; padding: 8px; }
.lp-art-tile span { font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
.lp-art-tile.t1 { background: linear-gradient(135deg, #3a4a72, #1E2A4A); }
.lp-art-tile.t2 { background: linear-gradient(135deg, #2f6f8f, #1c4a63); }
.lp-art-tile.t3 { background: linear-gradient(135deg, #2f7a5b, #1c5240); }
.lp-art-tile.t4 { background: linear-gradient(135deg, #b07d2a, #7a5418); }

/* trust strip */
.lp-trust { text-align: center; padding: 18px 24px; color: var(--muted); font-size: 13.5px;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); }

/* generic section */
.lp-section { max-width: 1140px; margin: 0 auto; padding: 64px 24px; }
.lp-head { text-align: center; margin-bottom: 40px; }
.lp-h2 { font-size: 32px; letter-spacing: -.02em; margin: 0 0 10px; }
.lp-lead { color: var(--muted); font-size: 16px; max-width: 560px; margin: 0 auto; }

/* problem */
.lp-prob-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 34px; }
.lp-prob { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid #c4564a; border-radius: var(--radius); padding: 18px 20px; font-size: 14.5px; color: var(--text); line-height: 1.5; }
.lp-prob-ic { font-size: 22px; flex: 0 0 auto; }

/* features */
.lp-feat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.lp-feat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 22px; transition: .18s; }
.lp-feat:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); transform: translateY(-3px); }
.lp-feat-ic { width: 48px; height: 48px; border-radius: 12px; background: var(--primary-l);
  display: flex; align-items: center; justify-content: center; font-size: 23px; margin-bottom: 14px; }
.lp-feat h3 { font-size: 17px; margin: 0 0 8px; }
.lp-feat p { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 0; }

/* how it works */
.lp-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.lp-step { text-align: center; padding: 0 10px; }
.lp-step-n { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: var(--on-primary);
  font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.lp-step-ic { font-size: 38px; margin-bottom: 10px; }
.lp-step h3 { font-size: 18px; margin: 0 0 8px; }
.lp-step p { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 0 auto; max-width: 280px; }

/* pricing (reuse .plans/.plan) */
.lp-plans { max-width: 920px; margin: 0 auto; align-items: start; }
.plan.popular { border-color: var(--primary); box-shadow: var(--shadow-lg); position: relative; transform: scale(1.03); }
.lp-pop { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--primary);
  color: var(--on-primary); font-size: 11.5px; font-weight: 700; padding: 4px 14px; border-radius: 999px; white-space: nowrap; }
.lp-plans .plan .btn { margin-top: 8px; }

/* reviews / testimonials */
.lp-rev-sec { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); max-width: none; }
.lp-rev-sec > .lp-head, .lp-rev-grid { max-width: 1140px; margin-left: auto; margin-right: auto; }
.lp-rev-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.lp-rev { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 22px; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.lp-stars { color: #E8A93C; font-size: 14px; letter-spacing: 2px; }
.lp-rev-q { color: var(--text); font-size: 14.5px; line-height: 1.6; flex: 1; margin: 0; }
.lp-rev-who { display: flex; align-items: center; gap: 11px; }
.lp-rev-av { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex: 0 0 auto; }
.lp-rev-name { font-weight: 700; font-size: 14px; }
.lp-rev-role { color: var(--muted); font-size: 12.5px; }

/* FAQ accordion */
.lp-faq { max-width: 760px; margin: 0 auto; }
.lp-faq-item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 12px; overflow: hidden; }
.lp-faq-q { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%;
  text-align: left; padding: 18px 20px; background: none; border: 0; cursor: pointer; font-family: inherit;
  font-size: 15.5px; font-weight: 600; color: var(--text); transition: color .15s; }
.lp-faq-q:hover { color: var(--primary); }
.lp-faq-ic { flex: 0 0 auto; font-size: 20px; line-height: 1; color: var(--muted); transition: transform .2s, color .2s; }
.lp-faq-item.open .lp-faq-ic { transform: rotate(45deg); color: var(--primary); }
.lp-faq-a { max-height: 0; overflow: hidden; padding: 0 20px; color: var(--muted); font-size: 14px;
  line-height: 1.6; transition: max-height .25s ease, padding .25s ease; }
.lp-faq-item.open .lp-faq-a { max-height: 320px; padding: 0 20px 18px; }

/* nav badge (ตัวเลขแจ้งเตือน เช่น คำขอติดต่อใหม่) */
.nav a { position: relative; }
.nav-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #d64545; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.nav .nav-badge { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
.topnav .nav-badge { margin-left: 7px; }
/* rail mode (เมนูแบบไอคอนล้วน): ย่อ badge เป็นจุดมุมไอคอน ไม่ทับเลขเวลาเมนูแคบ */
[data-nav="rail"] .sidebar:not(:hover) .nav .nav-badge { right: 10px; top: 9px; transform: none;
  min-width: 16px; height: 16px; font-size: 10px; box-shadow: 0 0 0 2px var(--surface); }

/* Before/After comparison slider */
.ba-controls { margin-bottom: 14px; }
.ba-slider { position: relative; width: 100%; max-height: 70vh; overflow: hidden; border-radius: var(--radius-sm);
  background: #000; user-select: none; touch-action: none; cursor: ew-resize; }
.ba-slider .ba-before { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ba-after-wrap { position: absolute; top: 0; right: 0; height: 100%; width: 50%; overflow: hidden; }
.ba-after-wrap .ba-img { position: absolute; top: 0; right: 0; object-fit: cover; }
.ba-divider { position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; background: #fff;
  transform: translateX(-50%); box-shadow: 0 0 6px rgba(0,0,0,.45); pointer-events: none; }
.ba-handle { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 40px; height: 40px;
  border-radius: 50%; background: #fff; color: #1E2A4A; display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.ba-label { position: absolute; top: 12px; padding: 4px 11px; border-radius: 999px; background: rgba(0,0,0,.58);
  color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .02em; pointer-events: none; }
.ba-label-l { left: 12px; }
.ba-label-r { right: 12px; }

/* upload watermark toggle */
.wm-check { display: flex; align-items: center; gap: 9px; margin: 4px 0 6px; padding: 11px 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg);
  font-size: 13.5px; font-weight: 600; color: var(--text); cursor: pointer; }
.wm-check input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

/* plan usage bars + limit banner (Subscription) */
.usage-grid { display: grid; gap: 14px; }
.usage-row .usage-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.usage-warn { color: #c0392b; font-weight: 700; }
.progress-warn span { background: #d64545 !important; }
.lim-banner { margin-top: 12px; background: #FBEEE9; color: #9E3D34; border: 1px solid #E8C9C1;
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13.5px; font-weight: 600; }
[data-theme="dark"] .lim-banner { background: rgba(192,57,53,.14); border-color: rgba(192,57,53,.4); color: #E8A29A; }

/* Free-plan watermark on shared photos */
.photo-card.wm { position: relative; }
.photo-card.wm::after, .viewer .big.wm::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='170'%20height='104'%3E%3Ctext%20x='85'%20y='56'%20font-family='Arial'%20font-size='17'%20font-weight='bold'%20fill='%23ffffff'%20fill-opacity='0.55'%20text-anchor='middle'%20transform='rotate(-24%2085%2056)'%3EWorkProof%3C/text%3E%3C/svg%3E");
  background-repeat: repeat;
}
.viewer .big { position: relative; }

/* customer sign-off / signature */
.sig-pad-wrap { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); background: #fff; overflow: hidden; }
.sig-pad { display: block; width: 100%; height: 170px; touch-action: none; cursor: crosshair; background: #fff; }
.sig-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }
.sig-view { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px; display: inline-block; }
.sig-view img { display: block; max-width: 100%; height: auto; }
.approved-card .approved-badge { display: inline-block; background: var(--success, #2F7A5B); color: #fff; font-weight: 700;
  font-size: 13px; padding: 5px 14px; border-radius: 999px; }
.report-sheet .rep-signline { margin-top: 30px; max-width: 280px; }
.report-sheet .rep-sigbox { height: 70px; border-bottom: 1.5px solid #111; margin-bottom: 6px; }
.report-sheet .sig-view { border-color: #ddd; }

/* sales leads (Super Admin) */
.lead-actions { white-space: nowrap; }
.lead-actions .btn-sm { padding: 4px 9px; margin-left: 4px; }
.lead-actions .btn-sm:first-child { margin-left: 0; }
.lead-detail th { background: none; font-size: 13px; padding: 8px 10px; }
.lead-detail td { padding: 8px 10px; }

/* final CTA (always-dark band) */
.lp-final { text-align: center; padding: 72px 24px; margin-top: 24px; color: #fff;
  background: linear-gradient(155deg, #243352 0%, #1E2A4A 50%, #111418 100%); }
.lp-final h2 { font-size: 32px; letter-spacing: -.02em; margin: 0 0 12px; color: #fff; }
.lp-final p { color: rgba(255,255,255,.82); font-size: 16px; margin: 0 0 26px; }
.lp-final .btn-primary { background: #fff; color: #1E2A4A; border-color: #fff; }
.lp-final .btn-primary:hover { background: #eee; }
.lp-demo { margin-top: 18px; }
.lp-demo a { color: rgba(255,255,255,.9); font-weight: 600; font-size: 14px; border-bottom: 1px solid rgba(255,255,255,.4); }

/* footer */
.lp-foot { max-width: 1140px; margin: 0 auto; padding: 30px 24px; display: flex; justify-content: space-between;
  align-items: center; gap: 14px; flex-wrap: wrap; font-size: 13.5px; }
.lp-foot-brand { font-weight: 700; }

@media (max-width: 1100px) {
  .lp-feat-grid { grid-template-columns: repeat(2, 1fr); }
  .lp-prob-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .lp-hero { grid-template-columns: 1fr; padding-top: 40px; text-align: center; }
  .lp-hero .lp-sub { margin-left: auto; margin-right: auto; }
  .lp-hero-cta { justify-content: center; }
  .lp-hero h1 { font-size: 36px; }
  .lp-feat-grid, .lp-steps, .lp-rev-grid { grid-template-columns: 1fr; }
  .lp-links { display: none; }
  .lp-plans { max-width: 420px; }
}
@media (max-width: 560px) {
  .lp-hide-sm { display: none; }
  .lp-hero h1 { font-size: 30px; }
  .lp-h2 { font-size: 26px; }
  .plan.popular { transform: none; }
  .lp-art { transform: none; }
  .lp-foot { flex-direction: column; text-align: center; }
}

/* =========================================================================
 * APP SHELL (sidebar + topbar + content)
 * ========================================================================= */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--side-w); background: var(--surface); color: var(--muted);
  border-right: 1px solid var(--border);
  position: fixed; top: 0; bottom: 0; left: 0; display: flex; flex-direction: column;
  z-index: 50; transition: transform .26s cubic-bezier(.4, 0, .2, 1), width .2s cubic-bezier(.4, 0, .2, 1);
}
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(17, 20, 24, .42);
  z-index: 45; opacity: 0; transition: opacity .26s;
}
.sidebar .logo {
  padding: 22px 24px 20px; font-size: 20px; font-weight: 800; color: var(--secondary);
  letter-spacing: -.03em; display: flex; align-items: center; gap: 10px;
}
.sidebar .logo .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--primary); }

/* brand logo marks — ใช้ไฟล์โลโก้จริงใน img/ สลับ light/dark ตามธีมอัตโนมัติ */
.brand-ico { display: inline-block; flex: 0 0 auto; background: url(../img/logo-icon-light.png) center/contain no-repeat; }
[data-theme="dark"] .brand-ico { background-image: url(../img/logo-icon-dark.png); }
.brand-ico.on-dark { background-image: url(../img/logo-icon-dark.png) !important; }   /* บนพื้นเข้มเสมอ */
.brand-full { display: block; background: url(../img/logo-light.png) left center/contain no-repeat; }
[data-theme="dark"] .brand-full { background-image: url(../img/logo-dark.png); }
.brand-full.on-dark { background-image: url(../img/logo-dark.png) !important; }
.logo-ico { width: 33px; height: 24px; }      /* sidebar */
.tb-ico { width: 30px; height: 22px; }         /* topbar (mobile/top-nav brand) */
.lp-logo-ico { width: 31px; height: 23px; }    /* landing nav */
.lp-foot-ico { width: 26px; height: 19px; vertical-align: -4px; margin-right: 4px; }
.login-logo { width: 168px; height: 132px; margin-bottom: 16px; }   /* login hero (พื้น navy เสมอ) */
.nav { flex: 1; overflow-y: auto; padding: 8px 14px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px;
  color: var(--muted); font-weight: 500; margin-bottom: 3px; font-size: 14px; transition: .15s; letter-spacing: -.01em;
}
.nav a .ic { width: 18px; text-align: center; opacity: .75; }
.nav a:hover { background: #F4F2EE; color: var(--text); }
.nav a.active { background: var(--primary-l); color: var(--primary); font-weight: 600; }
.nav a.active .ic { opacity: 1; }
.nav a.active::before { content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--primary); }
.nav .nav-sec { padding: 18px 14px 7px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .12em; color: var(--muted-l); font-weight: 600; }
.sidebar .side-foot { padding: 16px; border-top: 1px solid var(--border); }

.main { flex: 1; margin-left: var(--side-w); display: flex; flex-direction: column; min-width: 0; transition: margin .26s cubic-bezier(.4, 0, .2, 1); }

/* topbar brand (โชว์เฉพาะโหมดเมนูแบบแถบบน) */
.topbar-brand { display: none; font-weight: 800; font-size: 18px; letter-spacing: -.03em; color: var(--secondary); align-items: center; gap: 8px; }

/* desktop: พับ sidebar สไลด์ซ่อน แล้วเนื้อหาขยายเต็ม */
@media (min-width: 861px) {
  .shell.collapsed .sidebar { transform: translateX(-100%); }
  .shell.collapsed .main { margin-left: 0; }
}
.topbar {
  height: var(--topbar-h); background: rgba(255, 255, 255, .8); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 30px; position: sticky; top: 0; z-index: 40;
}
.topbar .page-title { font-size: 18px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .search-mini {
  display: flex; align-items: center; gap: 9px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 999px; padding: 9px 16px; width: 300px; transition: .15s;
}
.topbar .search-mini:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3.5px var(--primary-l); background: var(--surface); }
.topbar .search-mini input { border: none; background: none; outline: none; width: 100%; font-size: 13.5px; font-family: inherit; color: var(--text); }
.user-chip { display: flex; align-items: center; gap: 11px; cursor: pointer; padding: 5px; border-radius: 999px; transition: .15s; }
.user-chip:hover { background: #F4F2EE; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.user-chip .u-name { font-weight: 600; font-size: 13px; letter-spacing: -.01em; }
.user-chip .u-role { font-size: 11px; color: var(--muted); }
.company-switch {
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text);
  background-color: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 12px; max-width: 210px; cursor: pointer; flex: 0 1 auto; min-width: 0;
}
.company-switch:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-l); }
@media (max-width: 640px) { .company-switch { max-width: 130px; padding: 6px 9px; padding-right: 30px; } }

/* ---------- ปรับ <select> ให้เข้าธีม (เอาลูกศร browser ออก + ใส่เชฟรอนเอง) ---------- */
select.input, .company-switch, .dd-btn {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B6F76' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 13px;
  padding-right: 34px;
}
select.input::-ms-expand { display: none; }
[data-theme="dark"] select.input, [data-theme="dark"] .company-switch, [data-theme="dark"] .dd-btn {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239AA0A9' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* ---------- custom dropdown (คุมรูปทรง popup ได้เต็มที่) ---------- */
.dd { position: relative; display: block; min-width: 0; }
.dd.dd-auto { display: inline-flex; vertical-align: middle; }
.dd > select { display: none; }                              /* ซ่อน native select (ยังเก็บค่า/ส่งฟอร์มได้) */
.dd-btn { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.dd:not(.dd-auto) .dd-btn { width: 100%; }
.dd-auto .dd-btn { width: auto; }
.dd.open .dd-btn { border-color: var(--primary); box-shadow: 0 0 0 3.5px var(--primary-l); }
.dd-menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 120;
  max-height: 280px; overflow-y: auto; display: none;
}
.dd.open .dd-menu { display: block; animation: ddIn .14s cubic-bezier(.4, 0, .2, 1); }
@keyframes ddIn { from { opacity: 0; transform: translateY(-5px); } }
.dd-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 11px; border-radius: 8px;
  font-size: 14px; color: var(--text); cursor: pointer; white-space: nowrap; transition: background .12s;
}
.dd-item:hover { background: #F4F2EE; }
[data-theme="dark"] .dd-item:hover { background: #20242D; }
.dd-item.sel { font-weight: 600; color: var(--primary); }
.dd-item.sel::after { content: "✓"; margin-left: auto; padding-left: 12px; }

.content { padding: 32px 36px; flex: 1; max-width: 1320px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 25px; }
.page-head .spacer { flex: 1; }
.muted { color: var(--muted); }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumb a { color: var(--muted); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.card-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card-head h3 { font-size: 15px; letter-spacing: -.01em; }
.card-head .spacer { flex: 1; }

/* ---------- stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); transition: box-shadow .2s, transform .2s; }
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat .ic { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 16px; }
.stat .v { font-size: 30px; font-weight: 700; color: var(--secondary); line-height: 1.05; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 5px; letter-spacing: -.005em; }
.ic-blue { background: var(--primary-l); color: var(--primary); }
.ic-green { background: #E6EFE9; color: #2F7A5B; }
.ic-purple { background: #EDEAF2; color: #6B5B8A; }
.ic-amber { background: #F5EEDF; color: #8A6516; }

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }

/* ---------- charts ---------- */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; align-items: stretch; }
/* balance: การ์ดในแถวสูงเท่ากัน + เนื้อหากราฟจัดกึ่งกลางแนวตั้ง */
.charts-grid > .card { display: flex; flex-direction: column; }
.charts-grid > .card > .card-pad { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.chart { display: block; }
.chart-fluid { width: 100%; height: auto; max-height: 280px; }
.chart-track { stroke: var(--border); opacity: .6; }
.chart-center-v { fill: var(--text); font-size: 27px; font-weight: 800; }
.chart-center-l { fill: var(--muted); font-size: 11px; letter-spacing: .02em; }
.chart-axis { fill: var(--muted-l); font-size: 10px; font-weight: 500; }
.chart-val { fill: var(--muted); font-size: 11px; font-weight: 700; }
.chart-grid { stroke: var(--border); stroke-width: 1; opacity: .7; }
.chart-axis-y { fill: var(--muted-l); font-size: 9.5px; font-weight: 500; }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2.75; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { stroke: none; }
.chart-dot { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.chart-dot-last { fill: var(--primary); stroke: var(--surface); stroke-width: 2; }
.chart-dot-halo { fill: var(--primary); opacity: .16; }
.chart-arc { cursor: default; transition: opacity .12s; }
.chart-donut:hover .chart-arc:not(:hover) { opacity: .45; }
.chart-bar { cursor: default; }
.chart-bar:hover { filter: brightness(1.08); }

/* line hover: guide line + highlight dot (โผล่เมื่อ hover คอลัมน์) */
.hitcol { cursor: default; }
.chart-guide { stroke: var(--primary); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0; transition: opacity .12s; }
.chart-hl { fill: var(--primary); stroke: var(--surface); stroke-width: 2; opacity: 0; transition: opacity .12s; }
.hitcol:hover .chart-guide { opacity: .5; }
.hitcol:hover .chart-hl { opacity: 1; }

/* tooltip */
.chart-tip {
  position: fixed; z-index: 300; pointer-events: none; left: 0; top: 0;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); border-radius: 10px; padding: 8px 11px; font-size: 12.5px;
  white-space: nowrap; display: flex; flex-direction: column; gap: 2px;
  opacity: 0; transform: translateY(4px); transition: opacity .13s, transform .13s;
}
.chart-tip.show { opacity: 1; transform: translateY(0); }
.chart-tip .tip-label { color: var(--muted); font-size: 11px; display: flex; align-items: center; gap: 7px; }
.chart-tip .tip-label::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--tip-dot, var(--primary)); flex: 0 0 auto; }
.chart-tip .tip-val { font-weight: 700; color: var(--secondary); font-size: 14px; padding-left: 16px; }

/* chart entrance animations */
.chart-donut { animation: wpDonutIn .55s cubic-bezier(.34, 1.1, .64, 1) both; transform-origin: center; }
.chart-line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: wpDraw 1.05s cubic-bezier(.4, 0, .2, 1) forwards; }
.chart-area { animation: wpFade .9s ease both; }
.chart-bar { transform-box: fill-box; transform-origin: bottom; animation: wpBarGrow .55s cubic-bezier(.34, 1.15, .64, 1) backwards; }
@keyframes wpDraw { to { stroke-dashoffset: 0; } }
@keyframes wpFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes wpBarGrow { from { transform: scaleY(0); } }
@keyframes wpDonutIn { from { opacity: 0; transform: scale(.9); } }
@media (prefers-reduced-motion: reduce) {
  .chart-donut, .chart-line, .chart-area, .chart-bar { animation: none; }
  .chart-line { stroke-dashoffset: 0; }
}
.chart-range button { padding: 6px 11px; font-size: 12.5px; font-weight: 600; }
.chart-row { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; justify-content: center; }
.legend { display: flex; flex-direction: column; gap: 9px; min-width: 150px; flex: 1; }
.legend-item { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend-item .dot { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.legend-item b { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--secondary); }
@media (max-width: 1100px) { .charts-grid { grid-template-columns: 1fr; } }

/* ranked horizontal bars (Top ลูกค้า/พนักงาน) */
.hbars { display: flex; flex-direction: column; gap: 15px; }
.hbars.has-axis { position: relative; padding-bottom: 24px; }
.hbar-grid { position: absolute; left: 0; right: 0; top: 0; bottom: 24px; pointer-events: none; z-index: 0; }
.hbar-gridline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--muted-l); opacity: .16; }
.hbar-axis { position: absolute; left: 0; right: 0; bottom: 0; height: 22px; }
.hbar-tick { position: absolute; top: 4px; font-size: 10px; color: var(--muted-l); font-weight: 500; white-space: nowrap; }
.hbar-row { border-radius: 8px; position: relative; z-index: 1; }
.hbar-row.clickable { cursor: pointer; }
.hbar-row.clickable:hover .hbar-label { color: var(--primary); }
.hbar-head { display: flex; align-items: center; gap: 9px; font-size: 13px; margin-bottom: 6px; }
.hbar-rank { width: 21px; height: 21px; border-radius: 6px; background: var(--primary-l); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; flex: 0 0 auto; }
.hbar-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hbar-val { margin-left: auto; color: var(--secondary); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 10px; }
.hbar-track { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.hbar-track > span {
  display: block; height: 100%; border-radius: 999px; transform-origin: left;
  background-image: linear-gradient(90deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 55%);
  transition: width .45s cubic-bezier(.4, 0, .2, 1);
  animation: wpHbar .6s cubic-bezier(.34, 1.1, .64, 1) backwards;
}
@keyframes wpHbar { from { transform: scaleX(0); opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .hbar-track > span { animation: none; } }

/* ---------- table ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { text-align: left; padding: 14px 22px; border-bottom: 1px solid var(--border); }
table.tbl th { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-l); background: #FCFBF9; font-weight: 600; }
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: #FAF8F4; }
table.tbl tbody tr.clickable { cursor: pointer; }
.row-actions { display: flex; gap: 6px; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .search-box { display: flex; align-items: center; gap: 9px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; flex: 1; min-width: 200px; transition: .15s; }
.toolbar .search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3.5px var(--primary-l); }
.toolbar .search-box input { border: none; outline: none; flex: 1; font-size: 14px; font-family: inherit; background: none; color: var(--text); }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* ---------- gallery ---------- */
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.view-toggle button { border: none; background: var(--surface); padding: 8px 12px; cursor: pointer; font-size: 14px; color: var(--muted); }
.view-toggle button.active { background: var(--primary); color: var(--on-primary); }

.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.photo-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; transition: .15s; }
.photo-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.photo-card .thumb { aspect-ratio: 4/3; object-fit: cover; width: 100%; background: #e2e8f0; }
.photo-card .meta { padding: 9px 11px; }
.photo-card .meta .cat { font-size: 11px; color: var(--primary); font-weight: 700; }
.photo-card .meta .desc { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-card .meta .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.photo-row { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--surface); cursor: pointer; transition: .15s; }
.photo-row:hover { background: #FAF8F4; border-color: var(--border-strong); }
.gallery-list .photo-row img { width: 84px; height: 64px; object-fit: cover; border-radius: 6px; }
[data-theme="dark"] .photo-row:hover { background: #1B1F26; }

/* ---------- timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 22px 8px; }
.tl-item::before { content: ""; position: absolute; left: -23px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--primary); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.tl-item.t-upload::before { background: var(--info); }
.tl-item.t-status::before { background: var(--warn); }
.tl-item.t-deliver::before { background: var(--success); }
.tl-item .tl-date { font-size: 12px; color: var(--muted); }
.tl-item .tl-text { font-weight: 600; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tabs button { border: none; background: none; padding: 12px 18px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; font-family: inherit; letter-spacing: -.01em; transition: color .15s; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: flex;
  align-items: center; justify-content: center; padding: 20px; z-index: 100;
  opacity: 0; transition: opacity .2s;
}
.modal-backdrop.show { opacity: 1; }
.modal {
  background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 480px;
  max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg);
  transform: translateY(10px); transition: transform .2s;
}
.modal-backdrop.show .modal { transform: translateY(0); }
.modal.lg { max-width: 720px; }
.modal.xl { max-width: 960px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { flex: 1; font-size: 17px; }
.modal-body { padding: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.confirm-msg { margin: 0 0 4px; }

/* ---------- photo viewer ---------- */
.viewer { display: grid; grid-template-columns: 1fr 240px; gap: 0; }
.viewer .big { background: #0f172a; display: flex; align-items: center; justify-content: center; min-height: 360px; }
.viewer .big img { max-height: 70vh; object-fit: contain; }
.viewer .side { padding: 18px; }
.viewer .side dl { margin: 0; }
.viewer .side dt { font-size: 11px; text-transform: uppercase; color: var(--muted); margin-top: 12px; letter-spacing: .04em; }
.viewer .side dd { margin: 2px 0 0; font-weight: 600; }
.viewer .side .actions { display: grid; gap: 8px; margin-top: 20px; }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--secondary); color: #fff; padding: 12px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); opacity: 0; transform: translateX(30px); transition: .3s;
  font-size: 14px; font-weight: 500; max-width: 340px;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-info { background: var(--secondary); }

/* ---------- progress (storage) ---------- */
.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }

/* ---------- subscription plans ---------- */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.plan { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 24px; text-align: center; }
.plan.current { border-color: var(--primary); box-shadow: var(--shadow-lg); }
.plan h3 { font-size: 18px; }
.plan .price { font-size: 32px; font-weight: 800; color: var(--secondary); margin: 10px 0; }
.plan .price small { font-size: 14px; color: var(--muted); font-weight: 500; }
.plan ul { list-style: none; padding: 0; margin: 16px 0; text-align: left; }
.plan li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.plan li::before { content: "✓"; color: var(--success); font-weight: 700; margin-right: 8px; }

/* ---------- public share / report ---------- */
.public-top { background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px 26px; display: flex; align-items: center; gap: 12px; }
.public-wrap { max-width: 1000px; margin: 0 auto; padding: 26px; }
.report-sheet { background: #ffffff; color: #1a1a1a; max-width: 800px; margin: 0 auto; padding: 48px; box-shadow: var(--shadow-lg); }
.report-sheet h1, .report-sheet h2, .report-sheet h3, .report-sheet b { color: #111418; }
.report-sheet .muted { color: #6B6F76; }
.report-sheet h1 { font-size: 26px; }
.report-section { margin-top: 28px; }
.report-section h2 { font-size: 16px; border-bottom: 2px solid var(--primary); padding-bottom: 6px; margin-bottom: 12px; }
.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.report-grid img { border-radius: 6px; border: 1px solid var(--border); }

/* ---------- avatars ---------- */
.avatar-img { border-radius: 50%; object-fit: cover; background: var(--border); flex: 0 0 auto; display: block; }
.emp-cell { display: flex; align-items: center; gap: 11px; }

/* ---------- role badges ---------- */
.role-badge { display: inline-flex; padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.role-CompanyOwner { background: #EDEAF2; color: #5E4F7D; }
.role-Manager { background: var(--primary-l); color: var(--primary); }
.role-Staff { background: #E6EFE9; color: #2F7A5B; }
.role-Viewer { background: #F1EFEA; color: #6B6F76; }
.role-SuperAdmin { background: #F3E4E2; color: #9E3D34; }

/* ---------- employee profile header ---------- */
.emp-profile { display: flex; align-items: center; gap: 18px; }

/* ---------- team chips (assigned members) ---------- */
.team-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.team-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer; transition: .15s;
}
.team-chip:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.team-chip .tc-name { font-weight: 600; font-size: 13px; }
.team-chip .tc-pos { font-size: 11px; color: var(--muted); }
.team-chip .tc-lead { font-size: 10px; background: var(--primary-l); color: var(--primary); padding: 1px 6px; border-radius: 999px; font-weight: 700; }
.team-chip .tc-remove { border: none; background: none; color: var(--muted-l); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 2px; }
.team-chip .tc-remove:hover { color: var(--danger); }

/* ---------- assign list (modal) ---------- */
.assign-list { max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.assign-row {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
}
.assign-row:hover { background: #FAF8F4; }
.assign-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--primary); }
.assign-row .tc-name { font-weight: 600; font-size: 14px; }
.assign-row .tc-pos { font-size: 12px; color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, 1fr); } .dash-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .shell.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar-backdrop { display: block; opacity: 1; }
  /* sidebar เป็น overlay บนมือถือ -> เนื้อหาเต็มกว้างทั้งซ้าย/ขวา */
  .main, [data-sidebar="right"] .main { margin-left: 0; margin-right: 0; }
  .content { padding: 22px 18px; }
  .login-wrap { grid-template-columns: 1fr; } .login-aside { display: none; }
  .login-main { padding-top: 72px; }   /* เว้นที่ให้ปุ่ม "กลับหน้าแรก" ที่ลอยมุมซ้ายบน ไม่ทับหัวข้อ */
  .grid-2 { grid-template-columns: 1fr; } .viewer { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: repeat(2, 1fr); }
  .report-sheet { padding: 28px 22px; }
  .emp-profile { gap: 14px; }
  .plans { grid-template-columns: 1fr; }
}
.menu-toggle { display: inline-flex; }

/* ---------- responsive: แท็บเล็ตเล็ก / มือถือ ---------- */
@media (max-width: 640px) {
  .topbar { padding: 0 16px; gap: 10px; }
  .topbar .search-mini { display: none; }          /* ใช้หน้า "ค้นหา" แทนบนจอเล็ก */
  .user-chip > div { display: none; }               /* เหลือเฉพาะ avatar */
  .user-chip { padding: 3px; gap: 0; }
  .content { padding: 18px 14px; }
  .page-head { gap: 10px; margin-bottom: 18px; }
  .page-head h1 { font-size: 21px; }
  .card-pad { padding: 16px; }
  .card-head { padding: 14px 16px; }
  table.tbl th, table.tbl td { padding: 11px 14px; }
  .stat { padding: 16px; }
  .stat .v { font-size: 26px; }
  .modal-backdrop { padding: 12px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .tabs button { padding: 11px 13px; }

  /* ตารางลิสต์: ซ่อนคอลัมน์รองบนมือถือ (แตะแถวเข้าดูรายละเอียดได้) เหลือคอลัมน์สำคัญ */
  .t-customers th:nth-child(3), .t-customers td:nth-child(3),
  .t-customers th:nth-child(4), .t-customers td:nth-child(4),
  .t-customers th:nth-child(5), .t-customers td:nth-child(5) { display: none; }       /* เหลือ ชื่อ · เบอร์ · จัดการ */

  .t-projects th:nth-child(3), .t-projects td:nth-child(3),
  .t-projects th:nth-child(4), .t-projects td:nth-child(4),
  .t-projects th:nth-child(5), .t-projects td:nth-child(5),
  .t-projects th:nth-child(6), .t-projects td:nth-child(6) { display: none; }          /* เหลือ รหัส · ชื่อ · สถานะ */

  .t-employees th:nth-child(2), .t-employees td:nth-child(2),
  .t-employees th:nth-child(3), .t-employees td:nth-child(3),
  .t-employees th:nth-child(4), .t-employees td:nth-child(4),
  .t-employees th:nth-child(5), .t-employees td:nth-child(5),
  .t-employees th:nth-child(7), .t-employees td:nth-child(7) { display: none; }         /* เหลือ พนักงาน · สถานะ */

  .t-leads th:nth-child(3), .t-leads td:nth-child(3),
  .t-leads th:nth-child(4), .t-leads td:nth-child(4),
  .t-leads th:nth-child(5), .t-leads td:nth-child(5) { display: none; }                 /* เหลือ บริษัท · ผู้ติดต่อ · สถานะ · จัดการ */
}

/* ---------- responsive: มือถือเล็ก ---------- */
@media (max-width: 440px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .report-grid { grid-template-columns: 1fr; }
  .report-sheet { padding: 20px 16px; }
  .page-head h1 { font-size: 19px; }
  .btn { padding: 9px 14px; }
  .emp-profile { flex-direction: column; text-align: center; }
  .emp-profile .row-actions { justify-content: center; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* ---------- print (report) ---------- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .report-sheet { box-shadow: none; max-width: none; padding: 0; }
}

/* =========================================================================
 * DARK MODE — โทน Ink Minimal กลับด้าน (เปิดด้วย <html data-theme="dark">)
 * ========================================================================= */
:root[data-theme="dark"] {
  --primary: #8593C4;        /* navy ทำให้สว่างขึ้นเพื่อ contrast บนพื้นเข้ม */
  --primary-d: #99A6D2;
  --primary-l: rgba(133, 147, 196, .16);
  --secondary: #F4F5F7;      /* heading = near-white */
  --bg: #0E1014;             /* near-black อุ่นเล็กน้อย */
  --surface: #16191F;
  --border: #262A32;
  --border-strong: #353B45;
  --text: #E6E8EC;
  --muted: #9AA0A9;
  --muted-l: #6C727C;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .45), 0 1px 4px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55), 0 4px 12px rgba(0, 0, 0, .4);
}

/* surface hovers / hairline backgrounds */
[data-theme="dark"] .btn-ghost:hover,
[data-theme="dark"] .icon-btn:hover,
[data-theme="dark"] .user-chip:hover { background: #20242D; }
[data-theme="dark"] .nav a:hover { background: #1B1F26; }
[data-theme="dark"] table.tbl th { background: #1A1D24; }
[data-theme="dark"] table.tbl tbody tr:hover { background: #1B1F26; }
[data-theme="dark"] .topbar { background: rgba(14, 16, 20, .72); }
[data-theme="dark"] .assign-row:hover { background: #1B1F26; }

/* toast = elevated surface (ไม่ใช่ ink ที่กลายเป็นสว่าง) */
[data-theme="dark"] .toast { background: #20242D; color: var(--text); border: 1px solid var(--border); }
[data-theme="dark"] .toast-success { background: #15392B; color: #8FE0BC; }
[data-theme="dark"] .toast-error { background: #3A1F1C; color: #F0A9A1; }

/* stat icon tints (ic-blue ตาม accent ผู้ใช้ จึงไม่ override) */
[data-theme="dark"] .ic-green { background: rgba(75, 160, 120, .15); color: #7FCBA4; }
[data-theme="dark"] .ic-purple { background: rgba(150, 130, 190, .16); color: #B6A6D8; }
[data-theme="dark"] .ic-amber { background: rgba(190, 150, 70, .16); color: #DCBE7A; }

/* status badges */
[data-theme="dark"] .st-Draft { background: #20242D; color: #9AA0A9; }
[data-theme="dark"] .st-Pending { background: #2E2616; color: #D6B673; }
[data-theme="dark"] .st-In.Progress, [data-theme="dark"] .st-InProgress { background: #1E2638; color: #A8B7E0; }
[data-theme="dark"] .st-Completed { background: #163024; color: #84D4AC; }
[data-theme="dark"] .st-Cancelled { background: #321F1D; color: #E59C92; }

/* role badges (Manager ตาม accent ผู้ใช้ จึงไม่ override) */
[data-theme="dark"] .role-CompanyOwner { background: #261F33; color: #BCAEDC; }
[data-theme="dark"] .role-Staff { background: #163024; color: #84D4AC; }
[data-theme="dark"] .role-Viewer { background: #20242D; color: #9AA0A9; }
[data-theme="dark"] .role-SuperAdmin { background: #321F1D; color: #E59C92; }

/* theme toggle button */
.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--muted); cursor: pointer; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center; transition: .15s; flex: 0 0 auto;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted-l); background: #F4F2EE; }
[data-theme="dark"] .theme-toggle:hover { background: #20242D; }

/* =========================================================================
 * LAYOUT PREFERENCES — density / corner radius / content width
 * ========================================================================= */
/* ความโค้งมุม */
:root[data-radius="sharp"] { --radius: 7px; --radius-sm: 5px; }
:root[data-radius="rounded"] { --radius: 22px; --radius-sm: 14px; }

/* ความกว้างเนื้อหา */
:root[data-width="full"] .content { max-width: none; }

/* ความหนาแน่น (compact) */
:root[data-density="compact"] .content { padding: 22px 26px; }
:root[data-density="compact"] .card-pad { padding: 15px; }
:root[data-density="compact"] .card-head { padding: 13px 16px; }
:root[data-density="compact"] table.tbl th,
:root[data-density="compact"] table.tbl td { padding: 9px 16px; }
:root[data-density="compact"] .stat { padding: 15px; }
:root[data-density="compact"] .stat .ic { width: 36px; height: 36px; margin-bottom: 10px; font-size: 17px; }
:root[data-density="compact"] .stat .v { font-size: 25px; }
:root[data-density="compact"] .stats { gap: 13px; margin-bottom: 20px; }
:root[data-density="compact"] .dash-grid { gap: 13px; }
:root[data-density="compact"] .btn { padding: 8px 14px; }
:root[data-density="compact"] .nav a { padding: 8px 13px; margin-bottom: 1px; }
:root[data-density="compact"] .page-head { margin-bottom: 16px; }
:root[data-density="compact"] { --topbar-h: 60px; }

/* =========================================================================
 * LAYOUT: ตำแหน่ง Sidebar (ซ้าย/ขวา) + โหมดเมนูแบบแถบบน (Top nav)
 * ========================================================================= */
/* --- Sidebar ฝั่งขวา --- */
[data-sidebar="right"] .sidebar { left: auto; right: 0; border-right: none; border-left: 1px solid var(--border); }
[data-sidebar="right"] .main { margin-left: 0; margin-right: var(--side-w); }
@media (min-width: 861px) {
  [data-sidebar="right"] .shell.collapsed .sidebar { transform: translateX(100%); }
  [data-sidebar="right"] .shell.collapsed .main { margin-right: 0; }
}
@media (max-width: 860px) {
  [data-sidebar="right"] .sidebar { transform: translateX(100%); }
  [data-sidebar="right"] .shell.nav-open .sidebar { transform: translateX(0); }
}

/* --- โหมดเมนูแบบแถบบน (Top navigation) --- */
.topnav { display: none; }
[data-nav="top"] .sidebar, [data-nav="top"] .sidebar-backdrop { display: none !important; }
[data-nav="top"] .main { margin-left: 0 !important; margin-right: 0 !important; }
[data-nav="top"] .menu-toggle { display: none; }
[data-nav="top"] .topbar-brand { display: flex; }
[data-nav="top"] .topbar .search-mini { width: 240px; }
[data-nav="top"] .topnav {
  display: flex; gap: 4px; align-items: center; padding: 0 30px; min-height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: var(--topbar-h); z-index: 39; overflow-x: auto;
}
.topnav a {
  display: flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 9px;
  color: var(--muted); font-weight: 500; font-size: 14px; white-space: nowrap; letter-spacing: -.01em; transition: .15s;
}
.topnav a .ic { opacity: .75; }
.topnav a:hover { background: #F4F2EE; color: var(--text); }
[data-theme="dark"] .topnav a:hover { background: #1B1F26; }
.topnav a.active { background: var(--primary-l); color: var(--primary); font-weight: 600; }
.topnav a.active .ic { opacity: 1; }
@media (max-width: 860px) { [data-nav="top"] .topnav { padding: 0 16px; } }

/* --- Sidebar แบบ mini rail (ไอคอนอย่างเดียว, กางออกตอน hover) --- */
:root[data-nav="rail"] { --side-w: var(--rail-w); }
:root[data-nav="rail"] .sidebar { overflow-x: hidden; }
:root[data-nav="rail"] .logo { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
:root[data-nav="rail"] .nav { padding: 8px 10px; }
:root[data-nav="rail"] .nav a { justify-content: center; padding-left: 0; padding-right: 0; }
:root[data-nav="rail"] .nav a .ic { opacity: .9; }
:root[data-nav="rail"] .nav a.active::before { display: none; }
:root[data-nav="rail"] .nav a .lbl,
:root[data-nav="rail"] .logo .logo-text,
:root[data-nav="rail"] .nav-sec,
:root[data-nav="rail"] .side-foot .lbl { display: none; }
:root[data-nav="rail"] .side-foot { padding: 12px 10px; }
:root[data-nav="rail"] .side-foot .btn { padding-left: 0; padding-right: 0; }

/* กางออก: ตอน hover (ลอยทับเนื้อหา) หรือปักหมุด (กางค้าง + ดันเนื้อหา) */
:root[data-nav="rail"] .sidebar:hover { width: var(--sidebar-w); box-shadow: var(--shadow-lg); z-index: 60; }
:root[data-nav="rail"][data-rail-pinned="on"] { --side-w: var(--sidebar-w); }

:root[data-nav="rail"] .sidebar:hover .logo,
:root[data-nav="rail"][data-rail-pinned="on"] .logo { justify-content: flex-start; padding-left: 24px; padding-right: 14px; gap: 10px; }
:root[data-nav="rail"] .sidebar:hover .nav a,
:root[data-nav="rail"][data-rail-pinned="on"] .nav a { justify-content: flex-start; padding-left: 14px; padding-right: 14px; }
:root[data-nav="rail"] .sidebar:hover .nav a.active::before,
:root[data-nav="rail"][data-rail-pinned="on"] .nav a.active::before { display: block; }
:root[data-nav="rail"] .sidebar:hover .nav a .lbl,
:root[data-nav="rail"] .sidebar:hover .logo .logo-text,
:root[data-nav="rail"] .sidebar:hover .nav-sec,
:root[data-nav="rail"] .sidebar:hover .side-foot .lbl,
:root[data-nav="rail"][data-rail-pinned="on"] .nav a .lbl,
:root[data-nav="rail"][data-rail-pinned="on"] .logo .logo-text,
:root[data-nav="rail"][data-rail-pinned="on"] .nav-sec,
:root[data-nav="rail"][data-rail-pinned="on"] .side-foot .lbl { display: inline; }
:root[data-nav="rail"] .sidebar:hover .side-foot .btn,
:root[data-nav="rail"][data-rail-pinned="on"] .side-foot .btn { padding-left: 11px; padding-right: 11px; }

/* ปุ่มปักหมุด rail (โผล่เมื่อ rail กางอยู่) */
.rail-pin {
  margin-left: auto; border: none; background: none; cursor: pointer; font-size: 14px;
  color: var(--muted); padding: 5px 7px; border-radius: 7px; display: none; line-height: 1;
}
.rail-pin:hover { background: #F4F2EE; color: var(--text); }
[data-theme="dark"] .rail-pin:hover { background: #20242D; }
.rail-pin.pinned { color: var(--primary); }
:root[data-nav="rail"] .sidebar:hover .logo .rail-pin,
:root[data-nav="rail"][data-rail-pinned="on"] .logo .rail-pin { display: inline-flex; }
@media (max-width: 860px) { .rail-pin { display: none !important; } }

/* บนมือถือ: rail กลับเป็น sidebar เต็ม (overlay) */
@media (max-width: 860px) {
  :root[data-nav="rail"] { --side-w: var(--sidebar-w); }
  :root[data-nav="rail"] .nav a { justify-content: flex-start; padding-left: 14px; padding-right: 14px; }
  :root[data-nav="rail"] .logo { justify-content: flex-start; padding-left: 24px; gap: 10px; }
  :root[data-nav="rail"] .nav a .lbl,
  :root[data-nav="rail"] .logo .logo-text,
  :root[data-nav="rail"] .nav-sec,
  :root[data-nav="rail"] .side-foot .lbl { display: inline; }
}

/* =========================================================================
 * APPEARANCE DRAWER (ปรับแต่งหน้าตา) — slide-in จากขวา
 * ========================================================================= */
.pref-backdrop { position: fixed; inset: 0; background: rgba(17, 20, 24, .28); z-index: 110; opacity: 0; transition: opacity .25s; }
.pref-backdrop.show { opacity: 1; }
.pref-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 92vw; z-index: 111;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  display: flex; flex-direction: column;
}
.pref-backdrop.show .pref-drawer { transform: translateX(0); }
.pref-head { display: flex; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.pref-head h3 { flex: 1; font-size: 17px; }
.pref-body { padding: 20px; overflow-y: auto; flex: 1; }
.pref-foot { padding: 14px 20px; border-top: 1px solid var(--border); }
.pref-group { margin-bottom: 24px; }
.pref-group > .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted-l); font-weight: 700; margin-bottom: 10px; display: block; }
.pref-group > .lbl em { font-style: normal; text-transform: none; letter-spacing: 0; color: var(--primary); margin-left: 6px; font-size: 12px; }

/* range slider */
.range { width: 100%; -webkit-appearance: none; appearance: none; height: 6px; border-radius: 999px; background: var(--border-strong); outline: none; cursor: pointer; }
.range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); cursor: pointer; }
.range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); cursor: pointer; }
.range:disabled { opacity: .45; cursor: not-allowed; }

/* segmented control */
.seg { display: flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  flex: 1; border: none; background: var(--surface); padding: 9px 6px; cursor: pointer;
  font-size: 13px; color: var(--muted); font-family: inherit; font-weight: 600;
  border-left: 1px solid var(--border); transition: .12s;
}
.seg button:first-child { border-left: none; }
.seg button:hover { color: var(--text); background: #F4F2EE; }
[data-theme="dark"] .seg button:hover { background: #20242D; }
.seg button.active { background: var(--primary-l); color: var(--primary); }

/* color swatches */
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.swatch {
  aspect-ratio: 1; border-radius: 12px; cursor: pointer; border: none; position: relative;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); transition: transform .12s;
}
.swatch:hover { transform: scale(1.06); }
.swatch.active::after {
  content: "✓"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 18px; text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.swatch.active { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08), 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }

/* custom color picker row */
.custom-color {
  display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 11px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
}
.custom-color input[type="color"] {
  -webkit-appearance: none; appearance: none; width: 34px; height: 34px; border: none; border-radius: 9px;
  background: none; cursor: pointer; padding: 0; flex: 0 0 auto;
}
.custom-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.custom-color input[type="color"]::-webkit-color-swatch { border: 1px solid var(--border-strong); border-radius: 9px; }
.custom-color .cc-text { flex: 1; }
.custom-color .cc-text b { display: block; font-size: 13px; }
.custom-color .cc-text span { font-size: 12px; color: var(--muted); }
.custom-color code { font-size: 12px; color: var(--muted); text-transform: uppercase; }

@media (max-width: 480px) { .pref-drawer { width: 100%; } }
