/* affth.tech design system (ADR 0007 เฟส 1) — ออกแบบใน Google Stitch โปรเจกต์ "affth.tech — Multi-Tenant Portal"
   แปลงเป็น CSS ล้วน ไม่มี build step: token สี / ตัวอักษร / รัศมี + โครง App Shell (top bar, sidebar) + ชิ้นส่วนที่ทุกหน้าใช้
   สีหลัก teal — ห้ามใช้สีส้ม/โลโก้ของ Shopee (เงื่อนไข Shopee Affiliate ข้อ 8.5(ด)) */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f8fafc; --text: #0f172a; --muted: #64748b;
  --border: #e5e7eb; --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #e6f4f2;
  --ok: #047857; --ok-bg: #e7f6ee; --warn: #b45309; --warn-bg: #fef3e2;
  --bad: #b91c1c; --bad-bg: #fdecea; --idle-bg: #eef0f3;
  --m-shopee_hub: #0f766e; --m-short_links: #4f46e5; --m-ai_video_gen: #7c3aed; --m-autocut_studio: #e11d48;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04); --radius: 12px; --radius-sm: 10px;
  --font: "Sarabun", "Leelawadee UI", "Noto Sans Thai", Tahoma, system-ui, sans-serif;
  --font-head: "Kanit", "Sarabun", "Leelawadee UI", system-ui, sans-serif;
  --topbar: 56px; --sidebar: 232px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --surface: #111827; --surface-2: #0f172a; --text: #e5e7eb; --muted: #94a3b8;
    --border: #1f2937; --brand: #14b8a6; --brand-ink: #04201d; --brand-soft: #0f2f2c;
    --ok: #4cc584; --ok-bg: #173325; --warn: #f0a94b; --warn-bg: #3a2a12; --bad: #f2786a; --bad-bg: #3d1d19;
    --idle-bg: #1e293b; --shadow: none;
    --m-shopee_hub: #14b8a6; --m-short_links: #818cf8; --m-ai_video_gen: #a78bfa; --m-autocut_studio: #fb7185;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); }
h1, h2, h3, .logo, .head { font-family: var(--font-head); font-weight: 600; }
a { color: var(--brand); }
.logo { display: inline-flex; align-items: center; color: var(--text); text-decoration: none; font-size: 19px; letter-spacing: -.01em; }
.logo i { margin-right: 8px; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); display: inline-grid; place-items: center; }
.logo i::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2.5px solid var(--brand-ink); }
.logo b { color: var(--brand); font-weight: 600; }

/* ---------- ปุ่ม / ฟอร์ม ---------- */
button, a.btn {
  font: inherit; font-size: 14px; cursor: pointer; padding: 7px 14px; border-radius: var(--radius-sm); text-decoration: none;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; gap: 6px;
}
button:hover, a.btn:hover { border-color: var(--muted); }
button.primary, a.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
button.primary:hover, a.btn.primary:hover { filter: brightness(1.08); }
button.ghost, a.btn.ghost { background: transparent; border-color: transparent; }
button.danger { color: var(--bad); }
button:disabled { cursor: not-allowed; opacity: .55; }
input, select, textarea {
  font: inherit; padding: 8px 11px; border-radius: var(--radius-sm); min-width: 0;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.pill { font-size: 12px; padding: 1px 9px; border-radius: 999px; background: var(--idle-bg); color: var(--muted); white-space: nowrap; font-weight: 600; }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; border: 1px solid transparent; }
.alert.bad { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert:empty { display: none; }
.mdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--m, var(--muted)); flex: none; }

/* ---------- App Shell: top bar + sidebar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .org { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; min-width: 0; }
.topbar .org span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.topbar .spacer { flex: 1; }
.topbar select { padding: 6px 10px; font-size: 14px; max-width: 240px; }
.topbar .who { text-align: right; font-size: 13px; line-height: 1.25; }
.topbar .who small { display: block; color: var(--muted); }
.topbar .menu { display: none; }
.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px; font-size: 14px;
  background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.banner b { font-weight: 700; }
.banner button { margin-left: auto; border-color: currentColor; color: inherit; background: transparent; }
.layout { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: calc(100vh - var(--topbar)); }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar .group { display: flex; align-items: center; gap: 8px; margin: 12px 8px 4px; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.sidebar .group:first-child { margin-top: 2px; }
.sidebar .group .pill { margin-left: auto; letter-spacing: 0; text-transform: none; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-size: 14.5px; }
.sidebar a:hover { background: var(--surface-2); }
.sidebar a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.sidebar a.locked { color: var(--muted); }
.sidebar a.locked::after { content: "🔒"; margin-left: auto; font-size: 12px; opacity: .7; }
.sidebar .bottom { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.content { padding: 20px 24px 40px; max-width: 1200px; width: 100%; }
.pagehead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.pagehead h1 { font-size: 24px; margin: 0; }
.locked-card { text-align: center; padding: 36px 20px; }
.locked-card h2 { margin: 6px 0; }
.footnote { color: var(--muted); font-size: 12.5px; margin-top: 28px; }

.topbar button, .topbar a.btn { white-space: nowrap; }
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar select { max-width: 132px; }
  .topbar .logo { font-size: 17px; }
  .sidebar { position: fixed; z-index: 30; top: var(--topbar); bottom: 0; left: 0; width: min(280px, 85vw); transform: translateX(-105%); transition: transform .18s; box-shadow: 0 10px 30px rgba(0,0,0,.2); overflow-y: auto; }
  body.nav-open .sidebar { transform: none; }
  .topbar .menu { display: inline-flex; }
  .topbar .org, .topbar .who { display: none; }
  .content { padding: 16px; }
}

/* ---------- หน้าสาธารณะ (welcome / login) ---------- */
.pubbar { display: flex; align-items: center; gap: 10px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.pubbar .spacer { flex: 1; }
.hero { text-align: center; padding: 56px 16px 40px; }
.hero .eyebrow { display: inline-block; padding: 3px 12px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 13.5px; font-weight: 600; }
.hero h1 { font-size: clamp(30px, 5vw, 48px); line-height: 1.15; margin: 16px auto 10px; max-width: 760px; letter-spacing: -.01em; }
.hero p { color: var(--muted); font-size: 18px; margin: 0 auto 22px; max-width: 620px; }
.hero .cta { font-size: 16px; padding: 11px 22px; }
.section { max-width: 1160px; margin: 0 auto; padding: 24px 16px 120px; }
.section .kicker { color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.section h2 { font-size: 28px; margin: 4px 0 6px; }
.parts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 18px; }
.part { position: relative; text-align: left; display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: 16px; background: var(--surface); border: 1.5px solid var(--border); box-shadow: var(--shadow); cursor: pointer; font-size: 15px; }
.part:hover { border-color: var(--m); }
.part[aria-pressed="true"] { border-color: var(--m); box-shadow: 0 0 0 3px color-mix(in srgb, var(--m) 18%, transparent); }
.part .icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--m) 14%, transparent); color: var(--m); font-size: 19px; }
.part .tick { position: absolute; top: 16px; right: 16px; width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--border); display: grid; place-items: center; font-size: 13px; color: #fff; }
.part[aria-pressed="true"] .tick { background: var(--m); border-color: var(--m); }
.part[aria-pressed="true"] .tick::before { content: "✓"; }
.part h3 { margin: 4px 0 0; font-size: 18px; }
.part .tag { align-self: flex-start; font-size: 12.5px; padding: 1px 8px; border-radius: 6px; color: var(--m); background: color-mix(in srgb, var(--m) 10%, transparent); }
.part ul { margin: 4px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 14px; }
.part ul li::before { content: "✓ "; color: var(--m); font-weight: 700; }
.dock { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(1100px, calc(100% - 24px)); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(15, 23, 42, .12); }
.dock .sum { font-weight: 600; } .dock small { color: var(--muted); }
.dock .spacer { flex: 1; }
.pubfoot { border-top: 1px solid var(--border); padding: 18px 24px; color: var(--muted); font-size: 13px; text-align: center; }
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px;
  background: radial-gradient(60% 40% at 50% 0%, var(--brand-soft), transparent 70%), var(--bg); }
.auth .sub { color: var(--muted); margin: 6px 0 18px; }
.auth .card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 12px; background: var(--idle-bg); margin-bottom: 18px; }
.seg button { border: 0; background: transparent; justify-content: center; font-weight: 600; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.auth form { display: flex; flex-direction: column; gap: 12px; }
.auth label { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; font-weight: 600; }
.auth label small { font-weight: 400; color: var(--muted); }
.auth button.primary { justify-content: center; padding: 10px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.chips button[aria-pressed="true"] { border-color: var(--m); color: var(--m); background: color-mix(in srgb, var(--m) 10%, transparent); font-weight: 600; }
.auth .note { color: var(--muted); font-size: 13px; margin: 0; }
.auth .back { margin-top: 16px; font-size: 14px; color: var(--muted); }
