/* tools.appth.net — Design System ตามกฎกลาง (Tiffany Blue) */

/* ── Fonts (self-host ผ่าน @fontsource) ─────────────── */
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter/inter-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter/inter-latin-600-normal.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter/inter-latin-700-normal.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Noto Sans Thai';
  src: url('/fonts/noto-sans-thai/noto-sans-thai-thai-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Noto Sans Thai';
  src: url('/fonts/noto-sans-thai/noto-sans-thai-thai-600-normal.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Noto Sans Thai';
  src: url('/fonts/noto-sans-thai/noto-sans-thai-thai-700-normal.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

/* ── Tokens ──────────────────────────────────────────── */
:root {
  --primary: #0ABAB5;
  --primary-hover: #089490;
  --primary-tint: #E6FAF9;
  --bg: #FFFFFF;
  --surface: #F8FFFE;
  --border: #D1F0EE;
  --text: #1A2E2E;
  --muted: #6B9090;
  --danger: #EF4444;
  --warning: #F59E0B;
  --success: #10B981;

  /* badge สีชนิดไฟล์ */
  --badge-pdf: #EF3B2D;
  --badge-doc: #1D4ED8;
  --badge-jpg: #E8A409;
  --badge-png: #8B2FD6;
  --badge-epub: #8B2FD6;
  --badge-xls: #15803D;
  --badge-ppt: #A34E68;
  --badge-media: #5546E0;
  --badge-txt: #7C3AED;

  --radius-card: 12px;
  --radius-btn: 8px;
  --radius-badge: 20px;
  --shadow-card: 0 1px 3px rgba(26, 46, 46, 0.06);
  --shadow-card-hover: 0 6px 20px rgba(10, 186, 181, 0.15);
}

/* ── Base ────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  font-family: 'Noto Sans Thai', 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { font-weight: 700; line-height: 1.3; }
a { color: var(--primary-hover); text-decoration: none; }

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}

.main { flex: 1; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: #fff; color: var(--primary-hover); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-tint); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--primary-tint); color: var(--primary-hover); }

/* ── Topbar ──────────────────────────────────────────── */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 60px;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}
.brand-dim { color: var(--muted); font-weight: 400; }
.topbar-nav {
  display: none;
  gap: 4px;
  flex: 1;
}
.topbar-link {
  padding: 6px 12px;
  border-radius: var(--radius-btn);
  color: var(--text);
  font-size: 15px;
}
.topbar-link:hover { background: var(--primary-tint); color: var(--primary-hover); }
.topbar-link.active { color: var(--primary-hover); font-weight: 600; }
.topbar-user { display: flex; gap: 8px; margin-left: auto; align-items: center; }

/* ── Hamburger + Drawer (มือถือ) ─────────────────────── */
.nav-toggle {
  display: none;
  margin-left: auto;
  width: 42px; height: 42px;
  border: 1px solid var(--border); border-radius: 10px;
  background: #fff; cursor: pointer;
  flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  transition: border-color 0.15s, background 0.15s;
}
.nav-toggle:hover { border-color: var(--primary); }
.nav-toggle span {
  display: block; width: 20px; height: 2px; border-radius: 2px;
  background: var(--text);
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.nav-toggle.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(26,46,46,0.42);
  opacity: 0; transition: opacity 0.25s ease;
  backdrop-filter: blur(2px);
}
.nav-overlay.show { opacity: 1; }

.mobile-drawer {
  position: fixed; top: 0; right: 0; z-index: 70;
  width: 82%; max-width: 320px; height: 100%;
  background: #fff;
  box-shadow: -12px 0 40px rgba(26,46,46,0.18);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}
.mobile-drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.drawer-title { font-weight: 700; font-size: 17px; }
.drawer-close {
  width: 36px; height: 36px; border: none; background: var(--surface);
  border-radius: 9px; font-size: 16px; cursor: pointer; color: var(--muted);
}
.drawer-close:hover { background: var(--primary-tint); color: var(--primary-hover); }
.drawer-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.drawer-link {
  padding: 13px 14px; border-radius: 10px;
  color: var(--text); font-size: 16px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.drawer-link:hover, .drawer-link:active { background: var(--primary-tint); color: var(--primary-hover); }
.drawer-link.active { background: var(--primary-tint); color: var(--primary-hover); }
.drawer-divider { height: 1px; background: var(--border); margin: 14px 0; }
.drawer-user { display: flex; flex-direction: column; gap: 10px; }
.drawer-user .btn { text-align: center; padding: 12px; font-size: 15.5px; }

/* ── Hero (สดใส มีชีวิตชีวา) ──────────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  padding: 72px 0 56px;
  text-align: center;
  background:
    radial-gradient(1100px 460px at 50% -8%, var(--primary-tint) 0%, rgba(230,250,249,0) 62%),
    linear-gradient(180deg, #F2FEFD 0%, var(--bg) 78%);
}
.hero-inner { position: relative; z-index: 2; }
/* blobs เคลื่อนไหวเบาๆ เบื้องหลัง */
.hero-blobs { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(46px);
  opacity: 0.5;
  will-change: transform;
}
.blob-1 { width: 340px; height: 340px; left: -60px; top: -40px;
  background: radial-gradient(circle, #23D3C4, transparent 70%); animation: float1 13s ease-in-out infinite; }
.blob-2 { width: 300px; height: 300px; right: -50px; top: 10px;
  background: radial-gradient(circle, #4FC3F7, transparent 70%); animation: float2 16s ease-in-out infinite; }
.blob-3 { width: 260px; height: 260px; left: 42%; bottom: -110px;
  background: radial-gradient(circle, #7BE5B0, transparent 70%); animation: float1 19s ease-in-out infinite reverse; }
.hero-grid-lines {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(680px 340px at 50% 20%, #000 0%, transparent 72%);
  mask-image: radial-gradient(680px 340px at 50% 20%, #000 0%, transparent 72%);
  opacity: 0.35;
}
@keyframes float1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(24px,26px) scale(1.08); } }
@keyframes float2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-28px,18px) scale(1.12); } }

.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 16px; margin-bottom: 20px;
  background: rgba(255,255,255,0.75);
  border: 1px solid var(--border);
  border-radius: var(--radius-badge);
  font-size: 13.5px; font-weight: 600; color: var(--primary-hover);
  box-shadow: 0 2px 12px rgba(10,186,181,0.10);
  backdrop-filter: blur(6px);
  animation: pop-in 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}
.hero-title {
  font-size: 34px; line-height: 1.18; letter-spacing: -0.5px;
  margin-bottom: 14px;
  animation: rise-in 0.6s cubic-bezier(0.22,1,0.36,1) 0.05s both;
}
.grad-text {
  background: linear-gradient(100deg, #0ABAB5 10%, #2FB6E8 55%, #22C58C 95%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hero-sub { color: var(--muted); margin-bottom: 28px; font-size: 16px;
  animation: rise-in 0.6s cubic-bezier(0.22,1,0.36,1) 0.12s both; }

.hero-search { position: relative; max-width: 560px; margin: 0 auto;
  animation: rise-in 0.6s cubic-bezier(0.22,1,0.36,1) 0.18s both; }
.hero-search-icon { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); font-size: 18px; opacity: 0.7; pointer-events: none; }
.hero-search input {
  width: 100%;
  padding: 15px 22px 15px 52px;
  font-size: 16.5px; font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: #fff; color: var(--text); outline: none;
  box-shadow: 0 6px 24px rgba(26,46,46,0.08);
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}
.hero-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-tint), 0 10px 30px rgba(10,186,181,0.18);
  transform: translateY(-1px);
}
.hero-stats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px;
  animation: rise-in 0.6s cubic-bezier(0.22,1,0.36,1) 0.24s both; }
.hero-stat {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius-badge);
  background: rgba(255,255,255,0.7); border: 1px solid var(--border);
  font-size: 13.5px; color: var(--muted); backdrop-filter: blur(6px);
}
.hero-stat b { color: var(--text); font-weight: 700; }

.hero-small { padding: 36px 0 20px; text-align: center; position: relative;
  background: linear-gradient(180deg, var(--primary-tint) 0%, var(--bg) 100%); }
.hero-small h1 { font-size: 28px; margin-bottom: 10px; }

@keyframes pop-in { from { opacity: 0; transform: scale(0.9) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ── Category tabs (pill) ────────────────────────────── */
.tools-section { padding-top: 8px; }
.cat-tabs {
  display: flex; gap: 8px; margin: 28px 0 20px; flex-wrap: wrap;
  justify-content: center;
}
.cat-tab {
  padding: 9px 22px; border-radius: var(--radius-badge);
  border: 1.5px solid var(--border); background: #fff; color: var(--text);
  font-size: 14.5px; font-family: inherit; font-weight: 600; cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
}
.cat-tab:hover { border-color: var(--primary); color: var(--primary-hover); transform: translateY(-2px); }
.cat-tab.active {
  background: linear-gradient(120deg, var(--primary), #22C58C); border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px rgba(10,186,181,0.32);
}

/* ── Tool grid + cards (ลูกเล่นเยอะ) ──────────────────── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 18px;
  padding-bottom: 56px;
}
.tool-card {
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; min-height: 140px; padding: 26px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(26,46,46,0.05);
  text-align: center;
  transition: transform 0.22s cubic-bezier(0.22,1,0.36,1), box-shadow 0.22s, border-color 0.22s;
}
/* เส้นขอบ gradient จางๆ ตอน hover */
.tool-card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px;
  background: linear-gradient(130deg, var(--primary), #4FC3F7, #22C58C);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity 0.22s;
}
/* spotlight ตามเมาส์ (ตำแหน่งตั้งผ่าน JS --mx/--my) */
.card-spot {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  opacity: 0; transition: opacity 0.25s;
  background: radial-gradient(220px circle at var(--mx,50%) var(--my,0%), rgba(10,186,181,0.14), transparent 60%);
}
.tool-card:hover {
  transform: translateY(-6px);
  border-color: transparent;
  box-shadow: 0 18px 40px rgba(10,186,181,0.20), 0 6px 14px rgba(26,46,46,0.08);
}
.tool-card:hover::before { opacity: 1; }
.tool-card:hover .card-spot { opacity: 1; }
.tool-card:hover .card-badges { transform: translateY(-2px) scale(1.05); }
.tool-card:hover .card-go { opacity: 1; transform: translateX(0); }
.card-badges { transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1); }
.card-name { font-weight: 600; font-size: 15.5px; color: var(--text); position: relative; z-index: 1; }
.card-go {
  position: absolute; right: 14px; bottom: 12px;
  color: var(--primary-hover); font-weight: 700; font-size: 16px;
  opacity: 0; transform: translateX(-6px); transition: opacity 0.22s, transform 0.22s;
}
.tool-card.is-dev { opacity: 0.85; }
.tool-card.is-dev .card-name { color: var(--muted); }
.tool-card.is-dev:hover { transform: translateY(-3px); }
.card-dev-tag {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  font-size: 11px; font-weight: 600; color: var(--warning);
  background: #FEF3E2; padding: 2px 8px; border-radius: var(--radius-badge);
}
.grid-empty { text-align: center; color: var(--muted); padding: 48px 0 64px; grid-column: 1 / -1; }

/* reveal ตอน scroll เข้า viewport (ตั้ง .in ผ่าน JS) */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.22,1,0.36,1); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .blob { animation: none; }
}

/* ── Badges ──────────────────────────────────────────── */
.card-badges { display: flex; align-items: center; gap: 6px; }
.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 7px;
  color: #fff;
  font-family: 'Inter', 'Noto Sans Thai', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.3px;
}
.badge-pdf { background: var(--badge-pdf); }
.badge-doc { background: var(--badge-doc); }
.badge-jpg { background: var(--badge-jpg); }
.badge-png { background: var(--badge-png); }
.badge-epub { background: var(--badge-epub); }
.badge-xls { background: var(--badge-xls); }
.badge-ppt { background: var(--badge-ppt); }
.badge-media { background: var(--badge-media); }
.badge-txt { background: var(--badge-txt); }
.badge-arrow { color: var(--primary-hover); font-size: 14px; font-weight: 700; }
.badge-gap { width: 2px; }

/* ── Tool page ───────────────────────────────────────── */
.tool-page { padding: 24px 16px 64px; }
.breadcrumb { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary-hover); }
.tool-head { text-align: center; margin-bottom: 32px; }
.tool-head .card-badges { justify-content: center; margin-bottom: 12px; }
.tool-head h1 { font-size: 26px; margin-bottom: 8px; }
.tool-desc { color: var(--muted); }

.notice {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  text-align: center;
}
.notice-dev { border-color: #FDE4BE; background: #FFFBF3; }
.notice-dev strong { display: block; font-size: 18px; margin-bottom: 8px; }
.notice-dev p { color: var(--muted); margin-bottom: 16px; }

/* ── Misc pages ──────────────────────────────────────── */
.center-page { text-align: center; padding: 80px 16px; }
.center-page h1 { font-size: 42px; margin-bottom: 8px; }
.center-page p { color: var(--muted); margin-bottom: 24px; }

/* ── Footer ──────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: auto;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  padding-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
  gap: 8px;
  flex-wrap: wrap;
}
.footer-version { font-family: 'Inter', monospace; }

/* ── Breakpoints (mobile-first) ──────────────────────── */
/* มือถือ: โชว์ hamburger, ซ่อนปุ่ม/เมนู desktop */
@media (max-width: 767px) {
  .nav-toggle { display: flex; }
  .topbar-user { display: none; }
  .brand-dim { display: none; }
}
@media (min-width: 768px) {
  .topbar-nav { display: flex; }
  /* desktop: ไม่มี hamburger/drawer */
  .nav-toggle { display: none; }
  .mobile-drawer, .nav-overlay { display: none !important; }
  .hero h1 { font-size: 34px; }
  .tool-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 20px; }
}
@media (min-width: 1024px) {
  .hero { padding: 64px 0 40px; }
  .hero h1 { font-size: 38px; }
}

/* ── Tool page: upload/progress/result ───────────────── */
.tool-box {
  width: 100%; /* กันยุบเมื่อ content เป็น flex ที่ overflow:auto (เช่นหน้าแก้ไข PDF หลังซ่อน dropzone) */
  max-width: 640px;
  margin: 0 auto;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-card);
  background: #fff;
  padding: 32px 16px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.drag-over { border-color: var(--primary); background: var(--primary-tint); }
.dropzone-icon { font-size: 34px; margin-bottom: 8px; }
.dropzone-inner p { margin-bottom: 10px; }
.dropzone-hint { color: var(--muted); font-size: 13.5px; margin-top: 10px; }
.file-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.file-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-btn);
  padding: 8px 12px; font-size: 14.5px;
}
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-controls { display: flex; gap: 4px; }
.file-controls button {
  border: 1px solid var(--border); background: #fff; border-radius: 6px;
  width: 28px; height: 28px; cursor: pointer; color: var(--muted); font-size: 13px;
}
.file-controls button:hover { border-color: var(--danger); color: var(--danger); }
.text-input {
  width: 100%; padding: 12px 14px; font-family: inherit; font-size: 15.5px;
  border: 1px solid var(--border); border-radius: var(--radius-btn); resize: vertical;
}
.text-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
.tool-settings { display: flex; flex-wrap: wrap; gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 14.5px; flex: 1; min-width: 180px; }
.field > span { font-weight: 600; }
.field select, .field input[type="text"], .field input[type="password"], .field textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-btn);
  font-family: inherit; font-size: 15px; background: #fff; color: var(--text);
}
.field select:focus, .field input:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint);
}
.field-check { flex-direction: row; align-items: center; gap: 8px; }
.retention-note { color: var(--muted); font-size: 13px; margin-top: -8px; }
.btn-lg { padding: 12px 24px; font-size: 16.5px; }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 13.5px; }
.btn-danger-outline { color: var(--danger); border-color: #FECACA; }
.btn-danger-outline:hover { background: #FEF2F2; border-color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.progress-area { text-align: center; }
.progress-bar { height: 10px; background: var(--border); border-radius: 20px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--primary); border-radius: 20px; transition: width 0.4s; }
.status-text { margin-top: 8px; color: var(--muted); font-size: 14.5px; }
.result-area { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.result-ok { color: var(--success); font-weight: 700; font-size: 20px; }
.result-name { color: var(--muted); font-size: 14.5px; word-break: break-all; }
.alert-error {
  background: #FEF2F2; border: 1px solid #FECACA; color: #B91C1C;
  border-radius: var(--radius-btn); padding: 10px 14px; font-size: 14.5px;
}
.alert-success {
  background: #ECFDF5; border: 1px solid #A7F3D0; color: #047857;
  border-radius: var(--radius-btn); padding: 10px 14px; font-size: 14.5px;
}
.tool-note { text-align: center; color: var(--muted); font-size: 14px; margin-top: 16px; }

/* ── Auth pages ──────────────────────────────────────── */
.auth-page { display: flex; justify-content: center; padding: 40px 16px 64px; }
.auth-card {
  width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 32px 28px; box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; gap: 14px;
}
.auth-card h1 { font-size: 24px; text-align: center; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-sub, .auth-alt, .auth-hint { text-align: center; color: var(--muted); font-size: 14px; }
.account-username { font-size: 16px; }
.role-badge {
  background: var(--primary-tint); color: var(--primary-hover);
  border-radius: var(--radius-badge); padding: 2px 10px; font-size: 12.5px; font-weight: 600;
}
.section-title { font-size: 17px; margin-top: 8px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 8px 0; }

/* ── Tables (history/admin) ──────────────────────────── */
.history-page, .admin-page { padding: 32px 16px 64px; }
.history-page h1, .admin-page h1 { margin-bottom: 6px; }
.table-wrap { overflow-x: auto; margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius-card); background: #fff; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14.5px; min-width: 640px; }
.data-table th {
  text-align: left; padding: 10px 14px; background: var(--surface);
  border-bottom: 1px solid var(--border); font-weight: 600; white-space: nowrap;
}
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.cell-name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-actions { white-space: nowrap; }
.table-loading { text-align: center; color: var(--muted); padding: 24px !important; }
.status { padding: 2px 10px; border-radius: var(--radius-badge); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.status-done { background: #ECFDF5; color: #047857; }
.status-processing, .status-queued { background: #FEF3E2; color: #B45309; }
.status-error { background: #FEF2F2; color: #B91C1C; }
.status-hidden { background: #F1F5F9; color: #64748B; }
.status-purged { background: #F1F5F9; color: #94A3B8; }
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 16px; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--muted); display: flex; flex-direction: column; gap: 16px; align-items: center; }
.muted-note { color: var(--muted); font-size: 12.5px; font-weight: 400; }

/* ── Admin ───────────────────────────────────────────── */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 20px 0; }
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 16px; text-align: center;
}
.stat-num { font-size: 24px; font-weight: 700; color: var(--primary-hover); }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.admin-toolbar { display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.admin-toolbar select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-btn);
  font-family: inherit; font-size: 14.5px; background: #fff;
}
.admin-page .section-title { margin-top: 32px; font-size: 19px; }

/* ── Client PDF editors (sign/fill/edit) ─────────────── */
.client-tool { max-width: 960px; }
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-card); padding: 10px 12px;
}
.editor-sep { width: 1px; height: 24px; background: var(--border); }
.editor-pagenav { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 14.5px; }
.editor-hint { color: var(--muted); font-size: 13.5px; }
.pdf-stage-wrap { overflow: auto; display: flex; justify-content: center; padding: 8px 0; }
.pdf-stage { position: relative; box-shadow: 0 2px 12px rgba(26,46,46,0.15); background: #fff; }
.pdf-stage canvas { display: block; }
.sig-place { position: absolute; cursor: move; border: 1.5px dashed var(--primary); }
.sig-place img { width: 100%; display: block; pointer-events: none; }
.sig-del {
  position: absolute; top: -12px; right: -12px; width: 24px; height: 24px;
  border-radius: 50%; border: none; background: var(--danger); color: #fff; cursor: pointer; font-size: 12px;
}
.sig-grip {
  position: absolute; bottom: -7px; right: -7px; width: 14px; height: 14px;
  background: var(--primary); border-radius: 3px; cursor: nwse-resize;
}
.sig-modal {
  position: fixed; inset: 0; background: rgba(26,46,46,0.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.sig-modal-box {
  background: #fff; border-radius: var(--radius-card); padding: 20px;
  display: flex; flex-direction: column; gap: 12px; max-width: 560px; width: 100%;
}
.sig-modal-box canvas { border: 1px dashed var(--border); border-radius: 8px; width: 100%; touch-action: none; }
.sig-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.fill-form { display: flex; flex-direction: column; gap: 12px; }
.radio-group { display: flex; flex-wrap: wrap; gap: 10px; }
.radio-item { display: flex; align-items: center; gap: 4px; font-weight: 400; }
.ov-item { position: absolute; cursor: move; }
.ov-text {
  min-width: 40px; padding: 2px 6px; border: 1.5px dashed var(--primary);
  background: rgba(255,255,255,0.6); outline: none; white-space: pre-wrap;
  font-family: 'Noto Sans Thai', 'Inter', sans-serif; line-height: 1.35;
}
.ov-image img { display: block; border: 1.5px dashed var(--primary); }
/* แถบเครื่องมือ overlay (ขนาด/สี/ลบ) — อยู่ด้านบนใต้คำอธิบาย คุม overlay ที่เลือก */
.ov-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: 4px 0 2px; padding: 6px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.ov-toolbar .ov-tb-label { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.ov-toolbar button {
  border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer;
  padding: 4px 10px; font-size: 13px; color: var(--text);
}
.ov-toolbar button:hover { background: var(--primary-tint); }
.ov-toolbar button.ov-tb-del { margin-left: auto; border-color: var(--danger); color: var(--danger); }
.ov-toolbar button.ov-tb-del:hover { background: rgba(220,38,38,0.08); }
.ov-toolbar input[type="color"] { width: 30px; height: 26px; border: 1px solid var(--border); border-radius: 6px; padding: 0; cursor: pointer; background: #fff; }

/* ── เซกชันโปรโมตเครื่องมือแก้ไข PDF ─────────────────── */
.edit-promo {
  background: linear-gradient(180deg, var(--primary-tint) 0%, #fff 100%);
  border-top: 1px solid var(--border);
  padding: 48px 0 64px;
  scroll-margin-top: 72px;
}
.edit-promo-head { text-align: center; margin-bottom: 32px; }
.edit-promo-head h2 { font-size: 26px; margin-bottom: 8px; }
.edit-promo-head p { color: var(--muted); font-size: 16px; }
.edit-features {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  max-width: 920px;
  margin: 0 auto;
}
.edit-feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 28px 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.edit-feature:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-card-hover);
}
.edit-feature-icon {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  font-size: 28px;
  background: var(--primary-tint);
  border-radius: 50%;
}
.edit-feature-title { font-weight: 700; font-size: 16.5px; color: var(--text); }
.edit-feature-desc { color: var(--muted); font-size: 14px; line-height: 1.5; }

@media (min-width: 768px) {
  .edit-features { grid-template-columns: repeat(3, 1fr); gap: 20px; }
  .edit-promo-head h2 { font-size: 30px; }
}

/* ── Admin dashboard (สถิติการใช้งาน) ────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 8px 0 8px;
}
.dash-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
}
.dash-card-head { font-weight: 700; font-size: 16px; margin-bottom: 14px; }
.usage-chart { width: 100%; }
.usage-svg { width: 100%; height: auto; display: block; }
.grid-line { stroke: var(--border); stroke-width: 1; }
.axis-label { fill: var(--muted); font-size: 11px; font-family: 'Inter', sans-serif; }
.member-line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.member-area { fill: var(--primary); opacity: 0.10; }
.member-dot { fill: var(--primary); }
.guest-line { fill: none; stroke: var(--warning); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.guest-area { fill: var(--warning); opacity: 0.08; }
.guest-dot { fill: var(--warning); }
.chart-legend { display: flex; gap: 20px; justify-content: center; margin-top: 12px; font-size: 13.5px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-member { background: var(--primary); }
.legend-guest { background: var(--warning); }

.tool-bars { display: flex; flex-direction: column; gap: 10px; max-height: 380px; overflow-y: auto; }
.tool-bar-row { display: grid; grid-template-columns: 1fr; gap: 4px; }
.tool-bar-name { font-size: 14px; font-weight: 600; }
.tool-bar-track { height: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; }
.tool-bar-fill { height: 100%; background: var(--primary); border-radius: 20px; }
.tool-bar-val { font-size: 13px; color: var(--text); }
.tool-bar-split { color: var(--muted); font-size: 12px; }

@media (min-width: 1024px) {
  .dash-grid { grid-template-columns: 3fr 2fr; }
}

/* ── ปรับเซกชันแก้ไข PDF + หน้า tool ให้เข้าธีมสดใส ─────── */
.edit-promo-head h2 {
  background: linear-gradient(100deg, #0ABAB5 10%, #2FB6E8 60%, #22C58C 95%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  display: inline-block;
}
.edit-feature { transition: transform 0.22s cubic-bezier(0.22,1,0.36,1), box-shadow 0.22s, border-color 0.22s; }
.edit-feature:hover { transform: translateY(-6px); border-color: var(--primary); box-shadow: 0 18px 40px rgba(10,186,181,0.18); }
.edit-feature:hover .edit-feature-icon { transform: scale(1.12) rotate(-6deg); }
.edit-feature-icon { transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1); }

/* ── แก้ไข PDF: จุดคลิกข้อความเดิม (hotspot) ─────────── */
.text-hotspot {
  position: absolute;
  cursor: text;
  border-radius: 2px;
  background: rgba(10,186,181,0.10);
  outline: 1px dashed rgba(10,186,181,0.55);
  transition: background 0.12s;
  z-index: 3;
}
.text-hotspot:hover { background: rgba(10,186,181,0.28); }
.ov-item.ov-edit { border-radius: 2px; }
/* แก้ข้อความเดิม: กล่องแนบสนิท (ไม่มี padding/บรรทัดหนา) ให้ขนาด+ตำแหน่งตรงกับข้อความเดิม */
.ov-item.ov-edit .ov-text { border-color: var(--warning); background: transparent; padding: 0; line-height: 1; }

/* ── แก้ไข PDF: ปุ่มจับลาก (แท็บเล็กมุมบนซ้ายกล่อง) + กล่องที่เลือก ──── */
.ov-drag {
  position: absolute; top: -19px; left: 0;
  width: 24px; height: 18px; padding: 0; line-height: 16px;
  border: 1px solid var(--border); background: #fff; border-radius: 5px;
  cursor: move; font-weight: 700; font-size: 12px; color: var(--primary);
  box-shadow: var(--shadow-card); z-index: 5;
}
.ov-drag:hover { background: var(--primary-tint); color: var(--primary-hover); }
.ov-item.ov-selected { outline: 2px solid var(--primary); outline-offset: 1px; }
.ov-text:empty:before {
  content: attr(data-ph);
  color: #9CA3AF;
  pointer-events: none;
}

/* ── กรอก PDF: ช่องกรอกทับหน้า PDF จริง ──────────────── */
.form-field {
  border: 1px solid rgba(10,186,181,0.7);
  background: rgba(230,250,249,0.45);
  border-radius: 3px;
  font-family: 'Noto Sans Thai', 'Inter', sans-serif;
  color: #12303a;
  padding: 0 4px;
  outline: none;
  box-shadow: 0 0 0 1px rgba(10,186,181,0.15);
  transition: background 0.12s, box-shadow 0.12s;
}
.form-field:focus {
  background: #fff;
  box-shadow: 0 0 0 3px rgba(10,186,181,0.28);
  border-color: var(--primary);
}
textarea.form-field { resize: none; line-height: 1.2; padding: 2px 4px; }
.form-field.ff-btn { cursor: pointer; accent-color: var(--primary); padding: 0; }
/* ช่องเซ็นชื่อ (Sig) — แตะเพื่อเปิดกระดานวาดลายเซ็น */
.form-field.ff-sig {
  display: flex; align-items: center; justify-content: center; text-align: center;
  cursor: pointer; padding: 0; overflow: hidden;
  font-size: 12.5px; font-weight: 600; color: var(--primary);
  background: rgba(10,186,181,0.10); border: 1.5px dashed var(--primary);
}
.form-field.ff-sig:hover { background: rgba(10,186,181,0.20); }
.form-field.ff-sig.has-sig { background: transparent; }
.form-field.ff-sig img { max-width: 100%; max-height: 100%; pointer-events: none; }
.fill-flatten { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); }
