:root {
  --bg: #0A1220;
  --sidebar: #0C1526;
  --surface: #111B2E;
  --border: #1E2A40;
  --track: #1F2B42;
  --line: #26344D;
  --text: #F2F0EB;
  --text-2: #C9CEDA;
  --muted: #9AA3B5;
  --gold: #D4B483;
  --gold-ink: #14130F;
  --blue: #6FA8EC;
  --good: #7FD1B9;
  --watch: #E8B65A;
  --stop: #F08A7A;
  --c-best: #B88A35;
  --c-rest: #3B82D6;
  --c-waste: #D9604F;
  --c-other: #8C6FD8;
  --radius: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'IBM Plex Sans Thai', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-weight: 600; }
h2 { font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack-8 { display: flex; flex-direction: column; gap: 8px; }

/* แบรนด์ */
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 48px; height: 48px; border-radius: 12px; background: #FBFAF7; padding: 4px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; letter-spacing: 0.14em; font-size: 15px; }
.brand-sub { font-size: 11px; letter-spacing: 0.3em; color: var(--gold); }

/* ปุ่ม */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px; border-radius: 999px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent; }
.btn-outline { background: transparent; color: var(--gold); border-color: var(--gold); }
.btn-outline:hover { background: rgba(212, 180, 131, 0.1); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line); font-weight: 500; }
.btn-ghost:hover { border-color: var(--muted); }
.btn:focus-visible, .dropzone:focus-within { outline: 2px solid var(--blue); outline-offset: 3px; }

/* หน้าอัปโหลด */
.upload-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.upload-card { width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 20px; }
.upload-card h1 { font-size: clamp(26px, 5vw, 34px); letter-spacing: -0.01em; margin-top: 12px; }
.lead { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.7; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 44px 24px; border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--surface); color: var(--gold); cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--gold); background: #142039; }
.dz-title { color: var(--text); font-size: 17px; font-weight: 600; }
.dz-sub { color: var(--muted); font-size: 14px; }
.error { margin: 0; padding: 12px 16px; border-radius: 12px; background: rgba(240, 138, 122, 0.12); color: var(--stop); font-size: 14px; }
.howto { border: 1px solid var(--border); border-radius: 14px; padding: 14px 18px; }
.howto summary { cursor: pointer; font-size: 14px; color: var(--text-2); }
.howto ol { margin: 12px 0 0; padding-left: 20px; color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.howto b { color: var(--text); font-weight: 600; }
.privacy { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }

/* Dashboard */
.dashboard { display: flex; flex-wrap: wrap; min-height: 100vh; }
.sidebar { flex: 1 1 240px; max-width: 100%; padding: 32px 24px; background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 28px; }
.account-card { margin-top: auto; padding: 16px; border: 1px solid var(--border); border-radius: 14px; display: flex; flex-direction: column; gap: 6px; }
.file-name { font-size: 14px; font-weight: 600; word-break: break-word; }
.main { flex: 999 1 560px; min-width: 0; padding: 40px clamp(16px, 4vw, 56px) 64px; }
.container { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.page-head > div { display: flex; flex-direction: column; gap: 8px; }
.page-head h1 { font-size: clamp(26px, 4vw, 34px); letter-spacing: -0.01em; }
.page-head p { margin: 0; }
.eyebrow { font-size: 13px; letter-spacing: 0.2em; color: var(--gold); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card > p { margin: 0; }
.card-foot { padding-top: 14px; border-top: 1px solid var(--border); line-height: 1.6; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }

.score-card { flex-direction: row; align-items: center; gap: 24px; }
.ring-num { font-size: 34px; font-weight: 600; fill: var(--text); font-family: Inter, sans-serif; }
.ring-sub { font-size: 12px; fill: var(--muted); font-family: Inter, sans-serif; }
.score-label { font-size: 22px; font-weight: 600; }
.ai-head { display: flex; align-items: center; gap: 10px; color: var(--blue); font-size: 13px; }
.ai-text { margin: 0; font-size: 16px; line-height: 1.75; }
.ai-text.loading-text { color: var(--muted); }
.savings-card { border-color: var(--gold); justify-content: center; gap: 10px; }
.savings { font-size: 44px; font-weight: 600; letter-spacing: -0.02em; color: var(--gold); }

.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 6px; }
.kpi .value { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
.kpi .trend { font-size: 13px; }
.kpi .hint { font-size: 13px; color: var(--muted); line-height: 1.5; }
.t-good { color: var(--good); } .t-stop { color: var(--stop); } .t-muted { color: var(--muted); }

/* กราฟ */
.split-bar { display: flex; gap: 2px; height: 28px; }
.split-bar span { min-width: 3px; }
.split-bar span:first-child { border-radius: 4px 0 0 4px; }
.split-bar span:last-child { border-radius: 0 4px 4px 0; }
.legend { display: flex; flex-direction: column; gap: 12px; }
.legend-row { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-row .label { flex: 1; min-width: 0; color: var(--text-2); }
.legend-row .val { font-weight: 600; font-variant-numeric: tabular-nums; }
.legend-row .pct { width: 44px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) 48px; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .name { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { position: relative; height: 14px; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; }
.avg-line { position: absolute; top: -5px; bottom: -5px; border-left: 1px dashed #6B7690; }
.bar-row .val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* สิ่งที่ควรทำ */
.actions { list-style: none; margin: 0; padding: 0; counter-reset: act; }
.actions > li { counter-increment: act; display: flex; gap: 16px; padding: 18px 0; border-top: 1px solid var(--border); }
.actions > li::before { content: counter(act); width: 36px; height: 36px; border-radius: 50%; border: 1px solid #33425E; display: flex; align-items: center; justify-content: center; color: var(--gold); font-size: 14px; flex-shrink: 0; }
.actions .a-title { font-size: 16px; font-weight: 600; }
.actions .a-why { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.6; }

/* ตารางแคมเปญ */
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 12px; }
.legend-inline { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.good { background: var(--good); } .dot.watch { background: var(--watch); } .dot.stop { background: var(--stop); }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: #8E97AA; font-size: 12px; font-weight: 500; letter-spacing: 0.04em; padding: 10px 12px; }
td { padding: 16px 12px; border-top: 1px solid var(--border); vertical-align: top; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.note { color: var(--muted); line-height: 1.5; }
.c-name { font-weight: 500; }
.c-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.good { color: var(--good); background: rgba(127, 209, 185, 0.12); }
.pill.watch { color: var(--watch); background: rgba(232, 182, 90, 0.12); }
.pill.stop { color: var(--stop); background: rgba(240, 138, 122, 0.12); }
.campaign-cards { display: none; flex-direction: column; gap: 10px; }
.c-card { border: 1px solid var(--border); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.c-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.c-card .stats { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.c-card .note { font-size: 13px; color: var(--text-2); }

/* กำลังโหลด */
.loading { position: fixed; inset: 0; background: rgba(10, 18, 32, 0.85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; z-index: 10; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--track); border-top-color: var(--gold); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* มือถือ */
@media (max-width: 720px) {
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 16px; gap: 12px; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar .logo { width: 40px; height: 40px; }
  .account-card { display: none; }
  .main { padding-top: 24px; }
  .card { padding: 20px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 16px; }
  .kpi .value { font-size: 22px; }
  .kpi .hint { display: none; }
  .score-card { gap: 16px; }
  .score-card svg { width: 96px; height: 96px; }
  .savings { font-size: 36px; }
  .table-wrap { display: none; }
  .campaign-cards { display: flex; }
  #print-btn { display: none; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* พิมพ์รายงาน */
@media print {
  body { background: #fff; color: #111; }
  .sidebar, #print-btn, .loading { display: none !important; }
  .card, .kpi { border-color: #ddd; background: #fff; break-inside: avoid; }
  .muted, .kpi .hint, td.note { color: #555; }
}

/* ===== v2: ข้อมูลเชิงลึก ===== */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { color: var(--muted); text-decoration: none; font-size: 14px; padding: 10px 14px; border-radius: 10px; min-height: 40px; display: flex; align-items: center; }
.side-nav a:hover { background: rgba(59, 130, 214, 0.12); color: var(--text); }
html { scroll-behavior: smooth; }
section[id], header[id] { scroll-margin-top: 16px; }

.deep-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.deep-tile { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.deep-tile.missing { border-style: dashed; }
.deep-tile.missing .deep-val { color: #5F6B82; }
.deep-val { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.deep-tile .hint { font-size: 12px; color: var(--muted); line-height: 1.5; }

.daily-insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.daily-insights > div { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.di-val { font-size: 15px; font-weight: 600; }
.daily-charts { margin-top: 8px; }
.chart-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.line-chart { width: 100%; height: auto; display: block; overflow: visible; }
.line-chart .grid { stroke: var(--border); stroke-width: 1; }
.line-chart .axis { fill: var(--muted); font-size: 11px; font-family: Inter, sans-serif; }
.line-chart .avg { stroke: #6B7690; stroke-width: 1; stroke-dasharray: 4 4; }
.line-chart .cross { stroke: var(--muted); stroke-width: 1; }
.tooltip { position: fixed; z-index: 20; pointer-events: none; background: #1A2640; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; line-height: 1.5; color: var(--text); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); max-width: 260px; }
.empty-state { display: flex; gap: 16px; align-items: flex-start; padding: 18px; border: 1px dashed var(--line); border-radius: 14px; color: var(--gold); }
.empty-state p { margin: 0; }
.es-title { color: var(--text); font-weight: 600; margin-bottom: 4px !important; }
.empty-state b { color: var(--text-2); font-weight: 600; }

.steps { margin: 8px 0 0; padding-left: 18px; color: var(--text-2); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }

.camp-head, .camp summary { display: grid; grid-template-columns: minmax(0, 2.4fr) 140px 100px 80px 110px 20px; gap: 12px; align-items: center; }
.camp-head { color: #8E97AA; font-size: 12px; padding: 0 4px 8px; }
.camp-head::after { content: ''; }
.camp-list { display: flex; flex-direction: column; }
.camp { border-top: 1px solid var(--border); }
.camp summary { list-style: none; cursor: pointer; padding: 14px 4px; min-height: 52px; font-size: 14px; border-radius: 10px; }
.camp summary::-webkit-details-marker { display: none; }
.camp summary:hover { background: rgba(59, 130, 214, 0.06); }
.camp summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.camp .chev { color: var(--muted); transition: transform .15s; }
.camp[open] .chev { transform: rotate(180deg); }
.camp-body { padding: 4px 4px 22px; display: flex; flex-direction: column; gap: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat-grid > div { background: var(--bg); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.sv { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.issues { display: flex; flex-direction: column; gap: 10px; }
.issue { display: flex; gap: 12px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); }
.i-icon { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.issue.good .i-icon { color: var(--good); background: rgba(127, 209, 185, 0.14); }
.issue.watch .i-icon { color: var(--watch); background: rgba(232, 182, 90, 0.14); }
.issue.stop .i-icon { color: var(--stop); background: rgba(240, 138, 122, 0.14); }
.i-title { font-weight: 600; }
.i-why { margin: 2px 0 6px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.i-steps { margin: 0; padding-left: 18px; font-size: 14px; color: var(--text-2); display: flex; flex-direction: column; gap: 3px; }

.avail { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; }
.avail li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); font-size: 14px; }
.avail li.ok > span:first-child { color: var(--good); font-weight: 700; }
.avail li.no { color: var(--muted); border-style: dashed; }

@media (max-width: 720px) {
  .side-nav { display: none; }
  .camp-head { display: none; }
  .camp summary { grid-template-columns: minmax(0, 1fr) auto 16px; grid-template-areas: "name pill chev"; }
  .camp summary > :nth-child(1) { grid-area: name; }
  .camp summary > :nth-child(2) { grid-area: pill; }
  .camp summary > .chev { grid-area: chev; }
  .camp summary > .num { display: none; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .deep-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media print { .tooltip, .side-nav { display: none !important; } .camp-body { break-inside: avoid; } }

/* ===== v3: บัญชีผู้ใช้และแพ็กเกจ ===== */
a.brand { text-decoration: none; color: inherit; }
.btn-gold { background: var(--gold); color: var(--gold-ink); text-decoration: none; }
.btn-gold:hover { background: #E2C597; }
.btn-ghost { text-decoration: none; }
.btn-sm { min-height: 40px; padding: 8px 16px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.link-btn { background: none; border: none; padding: 6px 0; color: var(--blue); font: inherit; font-size: 13px; cursor: pointer; text-decoration: none; min-height: 32px; }
.link-btn:hover { text-decoration: underline; }
.upload-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.user-mini { display: flex; align-items: center; gap: 12px; }
.usage-note { padding: 12px 16px; border-radius: 12px; background: rgba(59, 130, 214, 0.1); color: var(--text-2); font-size: 14px; }
.usage-note.full { background: rgba(240, 138, 122, 0.12); color: var(--stop); }
.usage-note a { color: var(--gold); }
.history { display: flex; flex-direction: column; gap: 6px; }
.history-list { display: flex; flex-direction: column; gap: 2px; }
.history-item { display: flex; flex-direction: column; align-items: flex-start; gap: 0; text-align: left; background: none; border: none; color: var(--text-2); font: inherit; padding: 8px 12px; border-radius: 10px; cursor: pointer; min-height: 44px; }
.history-item:hover { background: rgba(59, 130, 214, 0.08); }
.history-item.active { background: rgba(59, 130, 214, 0.16); color: var(--text); }
.hi-name { font-size: 14px; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-plan { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan-pill { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--track); color: var(--text-2); }
.plan-pill.pro, .plan-pill.business { background: rgba(212, 180, 131, 0.16); color: var(--gold); }
.lock-card { display: flex; align-items: center; gap: 14px; padding: 18px; border: 1px dashed rgba(212, 180, 131, 0.5); border-radius: 14px; background: rgba(212, 180, 131, 0.05); color: var(--gold); flex-wrap: wrap; }
.lock-card > div { flex: 1 1 220px; }
.lock-card p { margin: 0; }
.lc-title { color: var(--text); font-weight: 600; }
.actions > li.locked-li::before { visibility: hidden; }
.actions > li.locked-li > div { flex: 1; }
@media (max-width: 720px) { .history { display: none; } }

/* ===== v4: เลือกแพ็กเกจและแจ้งเตือน ===== */
.plan-dialog { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 24px; padding: 28px; }
.plan-dialog::backdrop { background: rgba(5, 9, 16, 0.7); }
.pd-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pd-head h2 { font-size: 22px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--text-2); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.pd-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 16px 0 8px; }
.pd-plan { border: 1px solid var(--border); border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.pd-plan.featured { border-color: var(--gold); }
.pd-top { display: flex; justify-content: space-between; align-items: center; }
.pd-top h3 { margin: 0; font-size: 18px; }
.pd-price { margin: 0; font-size: 32px; font-weight: 700; }
.pd-price span { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.pd-plan ul { margin: 0 0 8px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; flex: 1; font-size: 14px; color: var(--text-2); }
.pd-plan li::before { content: '✓  '; color: var(--gold); font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; max-width: calc(100vw - 32px); background: #1A2640; border: 1px solid var(--gold); color: var(--text); padding: 14px 20px; border-radius: 14px; font-size: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4); }

/* ===== v5: แนะนำคอนเทนต์ ===== */
.ideas { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.idea { border: 1px solid var(--border); border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 14px; background: linear-gradient(180deg, rgba(59, 130, 214, 0.05), transparent 120px); }
.idea h3 { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.5; }
.idea-n { font-size: 12px; letter-spacing: 0.16em; color: var(--gold); }
.idea-why { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.idea-meta { display: grid; gap: 10px; }
.idea-meta > div { display: flex; flex-direction: column; gap: 2px; font-size: 14px; color: var(--text-2); }
.hooks { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--text-2); }
.caption-box { background: var(--bg); border-radius: 12px; padding: 12px 14px; }
.caption-head { display: flex; justify-content: space-between; align-items: center; }
.caption { margin: 6px 0 0; white-space: pre-line; font-size: 14px; line-height: 1.7; }
.idea-cta { font-size: 13px; color: var(--muted); }
.idea-cta b { color: var(--gold); font-weight: 600; }
.idea.locked { gap: 12px; }
.loading-text { color: var(--muted); }
.pd-features { list-style: none; margin: 8px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px 16px; font-size: 14px; color: var(--text-2); }
.pd-features li::before { content: '✓  '; color: var(--gold); font-weight: 700; }
.plan-dialog { width: min(820px, calc(100vw - 32px)); }
.pd-plans { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ===== v6: แนะนำกลุ่มเป้าหมาย ===== */
.segments { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.segments:empty { display: none; }
.seg { border: 1px solid var(--border); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.seg-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.seg-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.seg .dot { margin: 0 0 0 4px; vertical-align: middle; }
.seg-zero { font-size: 12px; color: var(--stop); position: absolute; left: 0; top: -1px; }
.aud-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.aud { border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.aud h3 { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.5; }
.aud-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.aud-type { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: rgba(59, 130, 214, 0.14); color: var(--blue); }
.aud-type.t-focus, .aud-type.t-lookalike { background: rgba(127, 209, 185, 0.12); color: var(--good); }
.aud-type.t-exclude { background: rgba(240, 138, 122, 0.12); color: var(--stop); }
.aud-type.t-location, .aud-type.t-broad { background: rgba(212, 180, 131, 0.14); color: var(--gold); }
.aud-type.t-data { background: var(--track); color: var(--text-2); }

/* ===== v7: ใช้งานบนมือถือ ===== */
.acc-menu { display: contents; }
.acc-summary { display: none; }
.m-sections { display: none; }
.js-copy { min-height: 44px; padding: 0 4px; }
@media (max-width: 720px) {
  .acc-menu { display: block; flex-basis: 100%; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
  .acc-summary { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 48px; cursor: pointer; list-style: none; font-size: 14px; color: var(--text-2); }
  .acc-summary::-webkit-details-marker { display: none; }
  .acc-summary .chev { margin-left: auto; color: var(--muted); transition: transform .15s; }
  .acc-menu[open] .acc-summary .chev { transform: rotate(180deg); }
  .acc-menu[open] .history { display: flex; padding: 4px 14px 8px; }
  .acc-menu[open] .account-card { display: flex; margin: 0 14px 14px; }
  .m-sections { display: flex; gap: 8px; overflow-x: auto; position: sticky; top: 0; z-index: 4; margin: -24px -16px 16px; padding: 10px 16px; background: rgba(10, 18, 32, 0.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); scrollbar-width: none; }
  .m-sections::-webkit-scrollbar { display: none; }
  .m-sections a { flex-shrink: 0; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-2); text-decoration: none; font-size: 13px; white-space: nowrap; }
  .m-sections a.on { border-color: var(--gold); color: var(--gold); }
  section[id], header[id] { scroll-margin-top: 72px; }
  .sidebar .btn-outline { min-height: 44px; padding: 8px 14px; font-size: 13px; }
  .page-head h1 { font-size: 24px; }
  .savings { font-size: 32px; }
  .plan-dialog { padding: 20px; border-radius: 20px; }
  .ideas, .aud-list, .segments, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

.for-touch { display: none; }
@media (hover: none) and (pointer: coarse) { .for-touch { display: inline; } .for-mouse { display: none; } }
@media (max-width: 720px) {
  .seg .bar-row { grid-template-columns: 76px minmax(0, 1fr) 52px; }
  .seg .bar-row .name { font-size: 13px; }
  .seg-zero { font-size: 11px; white-space: nowrap; }
}

/* ===== v8: คลิปสอนใช้งาน ===== */
.tut { display: flex; flex-direction: column; gap: 16px; outline: none; }
.tut-tabs { display: flex; gap: 8px; }
.tut-tab { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text-2); font: inherit; font-size: 14px; cursor: pointer; }
.tut-tab.on { border-color: var(--gold); color: var(--gold); }
.tut-body { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 36px; align-items: center; }
.tut-phone { height: min(620px, 70vh); width: auto; max-width: 72vw; aspect-ratio: 390 / 844; border-radius: 40px; padding: 10px; background: #05090F; border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); margin: 0 auto; touch-action: pan-y; }
.tut-screen { position: relative; width: 100%; height: 100%; border-radius: 30px; overflow: hidden; background: var(--bg); }
.tut-screen img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; opacity: 0; transition: opacity .45s ease; }
.tut-screen img.on { opacity: 1; }
.tut-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tut-count { font-size: 13px; letter-spacing: 0.12em; color: var(--gold); }
.tut-title { margin: 0; font-size: clamp(20px, 2.6vw, 28px); font-weight: 600; line-height: 1.4; }
.tut-text { margin: 0; color: var(--text-2); font-size: 16px; line-height: 1.75; min-height: 5.25em; }
.tut-bar { height: 3px; border-radius: 3px; background: var(--track); overflow: hidden; }
.tut-bar span { display: block; height: 100%; width: 0; background: var(--gold); }
.tut-ctrl { display: flex; gap: 10px; }
.tut-dots { display: flex; flex-wrap: wrap; gap: 4px; }
.tut-dots button { width: 28px; height: 28px; border: none; background: transparent; cursor: pointer; position: relative; padding: 0; }
.tut-dots button::after { content: ''; position: absolute; inset: 11px; border-radius: 50%; background: var(--line); }
.tut-dots button.on::after { background: var(--gold); inset: 9px; }
.tut-cta { align-self: flex-start; margin-top: 4px; }
.tut-video video { display: block; width: auto; max-width: 100%; max-height: 75vh; margin: 0 auto; border-radius: 16px; background: #000; }
.guide-dialog { width: min(860px, calc(100vw - 32px)); }
@media (max-width: 720px) {
  .tut-body { grid-template-columns: 1fr; gap: 20px; }
  .tut-phone { height: min(520px, 62vh); }
  .tut-text { min-height: 0; font-size: 15px; }
  .tut-ctrl { justify-content: center; }
  .tut-dots { justify-content: center; }
  .tut-cta { align-self: stretch; }
}
@media (prefers-reduced-motion: reduce) { .tut-screen img { transition: none; } }

.guide-link { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 12px 16px; border-radius: 14px; border: 1px solid rgba(212, 180, 131, 0.45); background: rgba(212, 180, 131, 0.06); color: var(--gold); font: inherit; font-size: 15px; font-weight: 500; cursor: pointer; text-align: left; }
.guide-link:hover { background: rgba(212, 180, 131, 0.12); }

.export-video { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.export-video video { width: 100%; max-height: 60vh; border-radius: 12px; background: #000; }

/* ===== v9: รหัสเปิดใช้งาน + ซื้อทาง Facebook ===== */
.redeem { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; padding: 16px; border: 1px solid rgba(212, 180, 131, 0.45); border-radius: 16px; background: rgba(212, 180, 131, 0.05); }
.redeem-row { display: flex; gap: 10px; }
.redeem-field { flex: 1; min-width: 0; font-family: Inter, monospace; letter-spacing: 0.08em; text-transform: uppercase; }
.buy-steps { display: flex; flex-direction: column; gap: 6px; }
.buy-steps ol { margin: 0; padding-left: 20px; font-size: 14px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }
.buy-steps b { color: var(--text); font-weight: 600; }
.pd-shop { margin: 4px 0 8px; }
.btn-fb { background: #1460C9; color: #fff; text-decoration: none; min-height: 52px; font-size: 15px; }
.btn-fb:hover { background: #1254B0; }
@media (max-width: 720px) { .redeem-row { flex-direction: column; } }

/* ช่องกรอกข้อมูล (ใช้ร่วมกันทุกหน้า) */
.field { width: 100%; min-height: 48px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 16px; box-sizing: border-box; }
.field:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: transparent; }
.field::placeholder { color: #6E7891; }
select.field { cursor: pointer; }
.field-label { font-size: 14px; color: var(--text-2); }
@media (max-width: 720px) {
  .pd-plans { gap: 8px; }
  .pd-plan { padding: 14px 16px; gap: 4px; display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .pd-plan .pd-top { grid-column: 1; }
  .pd-plan .pd-price { grid-column: 2; grid-row: 1 / span 2; font-size: 24px; }
  .pd-plan > p.muted { grid-column: 1; margin: 0; }
  .pd-plan .btn { grid-column: 1 / -1; }
}

/* ลบรายงาน / ลบบัญชี */
.head-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.danger-link { color: #F08A7A; }
.btn-danger { background: #C2412F; color: #fff; border: 1px solid #C2412F; }
.btn-danger:hover:not(:disabled) { background: #A93726; }
.btn-danger:disabled { opacity: 0.45; cursor: not-allowed; }
.confirm-dialog { width: min(480px, calc(100vw - 32px)); }
.confirm-dialog p { margin: 12px 0 0; line-height: 1.6; }
.confirm-list { margin: 10px 0 0; padding-left: 20px; color: var(--text-2); line-height: 1.8; font-size: 14px; }
.confirm-label { display: block; margin-top: 16px; }
.confirm-dialog .field { margin-top: 8px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .head-actions { flex-direction: row; align-items: center; gap: 12px; }
  .confirm-actions .btn { flex: 1; }
}
@media print { .head-actions .danger-link { display: none; } }
