/* ── RATCHADA design system — ครีม/ทอง ตามโลโก้ · minimal ─────────── */
:root {
  --gold: #d8bb8d;          /* ทองจากโลโก้ */
  --gold-deep: #a98a55;
  --brown: #887353;         /* น้ำตาลเงาโลโก้ */
  --brown-dark: #5f5340;
  --ink: #3f3f3f;           /* ถ่านจากตัวอักษรโลโก้ */
  --ink-2: #7a7469;
  --ink-3: #a9a49a;
  --cream: #f7f3ec;         /* พื้นครีม */
  --cream-2: #efe8dd;       /* ครีมเข้ม (แถบ/พื้นสถิติ) */
  --card: #fffdf9;
  --line: #e7ded0;
  --green: #4f8a5b;
  --amber: #c98a3c;
  --red: #c15a4e;
  --radius: 16px;
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Sarabun', -apple-system, sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 15px; }
.boot { display: flex; align-items: center; justify-content: center; height: 100vh; color: var(--ink-3); }

/* ── Layout ── */
.screen { max-width: 540px; margin: 0 auto; padding: 18px 16px calc(var(--nav-h) + var(--safe-b) + 24px); }

.appbar {
  background: var(--cream);
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 12px;
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--line);
}
.appbar-inner { max-width: 540px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.appbar .brand { display: flex; align-items: center; gap: 9px; }
.appbar .brand img { height: 30px; width: auto; }
.appbar .brand .tx { font-weight: 700; letter-spacing: .13em; font-size: 13px; color: var(--ink); }
.appbar .sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; letter-spacing: .01em; }

/* ── Cards ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; margin-bottom: 14px; }
.card h2 {
  font-size: 11.5px; font-weight: 700; color: var(--ink-3);
  letter-spacing: .11em; text-transform: uppercase; margin-bottom: 14px;
}
.card h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card h2 .r { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--ink-3); text-align: right; flex-shrink: 0; }

/* ── Stats (minimal: ไม่มีกล่องสี ใช้เส้นคั่น) ── */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.stat { text-align: center; padding: 2px 4px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: none; }
.stat .v { font-size: 30px; font-weight: 700; color: var(--ink); line-height: 1.15; letter-spacing: -.02em; }
.stat .l { font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.stat .t { font-size: 11px; color: var(--ink-3); margin-top: 1px; }

/* ── Progress ── */
.bar-row { margin-bottom: 13px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; margin-bottom: 5px; }
.bar-head .n { font-weight: 600; }
.bar-head .x { color: var(--ink-3); font-size: 12.5px; }
.bar { height: 5px; background: var(--cream-2); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--gold); min-width: 2%; transition: width .5s ease; }
.bar > i.ok { background: var(--green); } .bar > i.mid { background: var(--gold); } .bar > i.low { background: var(--red); }

/* ── หน้าแรก ── */
.home-goal { background: #fdf5e9; border: 1px solid #eddfc4; border-radius: 10px; padding: 10px 13px; font-size: 14px; font-weight: 600; color: var(--gold-deep); margin-bottom: 12px; }
.lnk-btn { width: 100%; margin-top: 10px; padding: 9px; border: 1px dashed var(--line); border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--gold-deep); }
.lnk-btn:active { background: var(--cream); }

/* ── Quick-add (แตะ +1) ── */
.qa-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
@media (min-width: 900px) { .qa-grid { grid-template-columns: repeat(6, 1fr); } }
.qa {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 13px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  font-size: 12px; color: var(--ink-2); font-weight: 600; transition: transform .12s, border-color .2s;
}
.qa:active { transform: scale(.95); border-color: var(--gold); background: #fdf9f2; }
.qa-ic { font-size: 20px; line-height: 1; filter: grayscale(.15); }
.qa-n {
  position: absolute; top: 6px; right: 8px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--gold); color: #55442099; color: #4a3c1c;
  font-size: 10.5px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.undo-bar { display: flex; align-items: center; gap: 12px; }
.undo-btn { color: var(--gold); font-weight: 700; font-size: 13px; text-decoration: underline; }

/* ── Leads ── */
.srch { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--cream); color: var(--ink); margin-bottom: 10px; }
.srch:focus { outline: none; border-color: var(--gold); background: var(--card); }
.fchips { display: flex; gap: 7px; margin-bottom: 6px; flex-wrap: wrap; }
.fchip { font-size: 12.5px; font-weight: 600; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); }
.fchip.on { background: #fdf5e9; border-color: var(--gold); color: var(--gold-deep); }
.fchip-lbl { font-size: 12px; color: var(--ink-3); align-self: center; }
.gbadge { flex-shrink: 0; width: 24px; height: 24px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.gbadge.g-A { background: #f3e6c8; color: #7a5e1c; }
.gbadge.g-B { background: #e7ecf2; color: #4d5f73; }
.gbadge.g-C { background: var(--cream-2); color: var(--ink-2); }
.gbadge.g-R { background: #f7ecea; color: var(--red); }
.gbadge.g-none { background: transparent; color: var(--ink-3); border: 1px dashed var(--line); }
.grades { display: flex; gap: 8px; }
.gpick { width: 46px; height: 40px; border-radius: 10px; border: 1px solid var(--line); font-size: 16px; font-weight: 700; color: var(--ink-2); }
.gpick.g-A.on { background: #f3e6c8; border-color: #d9b978; color: #7a5e1c; }
.gpick.g-B.on { background: #e7ecf2; border-color: #a9bdd4; color: #4d5f73; }
.gpick.g-C.on { background: var(--cream-2); border-color: var(--ink-3); color: var(--ink); }
.gpick:disabled { opacity: .5; }
.lnk { font-size: 13px; font-weight: 600; color: var(--gold-deep); }
.dtls { }
.dtl { padding: 8px 0; border-bottom: 1px solid var(--line); }
.dtl:last-child { border-bottom: none; }
.dtl-k { display: block; font-size: 10.5px; font-weight: 700; color: var(--gold-deep); letter-spacing: .06em; }
.dtl-v { display: block; font-size: 13.5px; margin-top: 2px; white-space: pre-wrap; }
.dtl-form textarea, .ex-label { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--cream); font-size: 13.5px; resize: vertical; }
.dtl-form textarea:focus, .ex-label:focus { outline: none; border-color: var(--gold); background: var(--card); }
.extra-row { display: flex; flex-direction: column; gap: 5px; }
.ex-label { font-weight: 700; }
.addfld { width: 100%; padding: 9px; border: 1px dashed var(--line); border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--gold-deep); margin-bottom: 10px; }

.lead-list { margin: 0 -16px; }
.lead-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.lead-row:last-child { border-bottom: none; }
.lead-row:active { background: var(--cream); }
.lead-main { flex: 1; min-width: 0; }
.lead-name { display: block; font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-name .pot { font-style: normal; font-size: 10px; font-weight: 700; margin-left: 6px; padding: 1px 5px; border-radius: 4px; background: var(--cream-2); color: var(--brown); }
.lead-sub { display: block; font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-right { text-align: right; flex-shrink: 0; }
.lead-meta { display: block; font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.stg { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--cream-2); color: var(--ink-2); white-space: nowrap; }
.stg.new { background: #eef2f7; color: #55677d; }
.stg.mid { background: #fdf3e3; color: var(--gold-deep); }
.stg.good { background: #e9f2ea; color: var(--green); }
.stg.bad { background: #f7ecea; color: var(--red); }

/* ── Listings (การ์ดเล็ก 3 คอลัมน์ · 9/หน้า) ── */
.lst-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
@media (min-width: 700px) { .lst-grid { grid-template-columns: repeat(3, 1fr); } }
.lst {
  display: flex; flex-direction: column; text-align: left; overflow: hidden;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  transition: border-color .15s, transform .12s;
}
.lst:active { transform: scale(.98); border-color: var(--gold); }
.lst.dead { opacity: .5; }
.lst-cover { position: relative; aspect-ratio: 16/10; background: var(--cream-2); overflow: hidden; }
@media (max-width: 699px) { .lst-cover { aspect-ratio: 16/8; } }  /* มือถือ: รูปเตี้ยลง */
.lst-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lst-cover.nopic::after { content: '🏢'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 30px; opacity: .3; }
.lst-cover-badges { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; font-size: 12px; }
.lst-cover-id { position: absolute; bottom: 6px; left: 6px; font-size: 10px; font-weight: 700; color: #fff; background: rgba(40,34,26,.6); padding: 2px 7px; border-radius: 5px; letter-spacing: .04em; }
.lst-body { display: flex; flex-direction: column; gap: 3px; padding: 9px 11px 10px; }
.lst-id { font-size: 11px; font-weight: 700; color: var(--ink-3); letter-spacing: .04em; }
.lst-badges { display: flex; align-items: center; gap: 4px; font-size: 11px; }
.gd { font-style: normal; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: var(--cream-2); color: var(--brown); }
.gd-A { background: #f3e6c8; color: #7a5e1c; }
.gd-B { background: #e7ecf2; color: #4d5f73; }
.gd-C { background: var(--cream-2); color: var(--ink-3); }
.lst-proj { font-size: 13.5px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lst-meta { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lst-foot { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; padding-top: 7px; border-top: 1px solid var(--line); }
.dcover { border-radius: 12px; overflow: hidden; margin-bottom: 12px; aspect-ratio: 16/10; background: var(--cream-2); }
.dcover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.share-btn { background: var(--gold-deep); margin-bottom: 14px; }
.lst-price { font-size: 14px; font-weight: 700; color: var(--ink); }
.lst-st { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.pg { font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; }
.pg:disabled { opacity: .35; }
.pg-n { font-size: 12.5px; color: var(--ink-3); }
.old { color: var(--ink-3); font-weight: 400; font-size: 12px; margin-left: 4px; }

/* ── ใบจอง ── */
.bk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bk-col2 { grid-column: 1 / -1; }
.bk-lb { font-size: 12px; font-weight: 700; color: var(--gold-deep); margin-bottom: 3px; display: block; }
.bk-in { width: 100%; background: var(--cream); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font-size: 14px; color: var(--ink); }
.bk-in:focus { outline: none; border-color: var(--gold); background: var(--card); }
.bk-typebtn { flex: 1; padding: 9px 8px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font-weight: 700; font-size: 13px; }
.bk-typebtn.on { background: var(--gold); border-color: var(--gold); color: #40331a; }
.bk-preview { overflow-x: auto; }
.bk-paper-wrap { display: flex; justify-content: center; min-width: 794px; }
.bk-paper { width: 794px; min-height: 1123px; background: #fff; color: #1f2430; padding: 52px 54px; font-family: 'Sarabun', sans-serif; position: relative; box-shadow: 0 4px 18px rgba(80,60,20,.14); }
.bk-hd { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 14px; }
.bk-logo { height: 64px; width: auto; }
.bk-doc { text-align: right; }
.bk-doc .t { font-family: 'Trirong', serif; font-size: 24px; font-weight: 700; color: #1f2430; line-height: 1.15; }
.bk-doc .e { font-size: 11px; font-weight: 600; letter-spacing: 3px; color: #9a7b2e; margin-top: 2px; }
.bk-rule { height: 2.5px; background: #1f2430; position: relative; }
.bk-rule::after { content: ''; position: absolute; left: 0; top: 0; height: 100%; width: 130px; background: #b8860b; }
.bk-ref { display: flex; justify-content: space-between; margin: 15px 0 6px; font-size: 13.5px; color: #3a4150; }
.bk-ref b { font-weight: 700; color: #1f2430; }
.bk-sech { font-family: 'Trirong', serif; font-size: 15px; font-weight: 600; color: #1f2430; margin: 20px 0 0; padding-bottom: 5px; border-bottom: 1.5px solid #b8860b; }
.bk-tbl { width: 100%; border-collapse: collapse; }
.bk-tbl td { border: 1px solid #d4d8e0; padding: 9px 13px; font-size: 14px; vertical-align: middle; }
.bk-tbl td.lb { background: #f4f1e9; width: 150px; color: #5a6172; font-weight: 600; font-size: 12.5px; }
.bk-tbl td.val { color: #1f2430; font-weight: 600; }
.bk-money { width: 100%; border-collapse: collapse; margin-top: 12px; }
.bk-money td { border: 1px solid #d4d8e0; padding: 11px 16px; font-size: 14.5px; }
.bk-money td.k { background: #f4f1e9; color: #5a6172; font-weight: 600; width: 62%; }
.bk-money td.v { text-align: right; font-weight: 700; color: #1f2430; font-variant-numeric: tabular-nums; }
.bk-money tr.tot td { background: #1f2430; color: #fff; border-color: #1f2430; font-size: 16px; }
.bk-money tr.tot td.k { background: #1f2430; color: #e8c879; }
.bk-terms { margin-top: 18px; border: 1px solid #d4d8e0; border-radius: 4px; padding: 13px 16px; background: #fcfbf7; }
.bk-terms h4 { font-family: 'Trirong', serif; font-size: 13px; font-weight: 600; color: #1f2430; margin-bottom: 6px; }
.bk-terms ol { margin: 0; padding-left: 18px; }
.bk-terms li { font-size: 12px; color: #4a5160; line-height: 1.8; margin-bottom: 2px; }
.bk-sign { display: flex; justify-content: space-between; gap: 30px; margin-top: 48px; }
.bk-sign .col { flex: 1; text-align: center; }
.bk-sign .ln { border-top: 1px solid #1f2430; margin: 32px 6px 0; }
.bk-sign .nm { font-size: 12.5px; color: #3a4150; margin-top: 8px; }
.bk-sign .nm .snm { font-weight: 600; color: #1f2430; margin-top: 4px; }
.bk-sign .nm .p { color: #9aa1b0; font-size: 11.5px; margin-top: 3px; }
.bk-sign .role { font-family: 'Trirong', serif; font-size: 13px; font-weight: 700; color: #1f2430; margin-bottom: 2px; }
.bk-foot { position: absolute; left: 54px; right: 54px; bottom: 28px; text-align: center; font-size: 10.5px; color: #9aa1b0; border-top: 1px solid #e7e3d6; padding-top: 9px; }
@media (max-width: 899px) { .bk-grid { grid-template-columns: 1fr 1fr; } }

/* ── รายได้ ── */
.gross { background: linear-gradient(135deg, #2a2317, #3f3320); border-color: #4a3c22; color: #f7f3ec; }
.gross h2 { color: #d8bb8d; }
.gross h2 .r { color: #b6a179; }
.gross-v { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0; }
.gross-pct { font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.gross-pct.low { color: #f0997b; } .gross-pct.mid { color: #f0c987; } .gross-pct.ok { color: #9fe1cb; }
.gross .bar { background: rgba(255,255,255,.12); margin-bottom: 10px; }
.gbar-row { display: flex; justify-content: space-between; font-size: 12px; color: #cbb98f; margin-bottom: 4px; }
.gtargets { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 6px; }
.gtag { font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.08); color: #cbb98f; }
.gtag.hit { background: #0f6e56; color: #cfeee2; }

/* ── รายได้ (เดิม) ── */
.kpi6 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 700px) { .kpi6 { grid-template-columns: repeat(6, 1fr); } }
.kpi { background: var(--cream); border-radius: 10px; padding: 11px 8px; text-align: center; }
.kpi .v { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.kpi .v.neg { color: var(--red); }
.kpi .l { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.exp { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.exp:last-child { border-bottom: none; }
.exp.total { border-top: 1.5px solid var(--line); border-bottom: none; margin-top: 4px; padding-top: 11px; font-weight: 700; }
.exp-body { flex: 1; min-width: 0; }
.exp-item { display: block; font-size: 13.5px; font-weight: 600; }
.exp-meta { display: block; font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.exp-amt { font-weight: 700; font-size: 14px; flex-shrink: 0; }
.paytag { font-style: normal; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 5px; margin-left: 5px; }
.paytag.ok { background: #e9f2ea; color: var(--green); }
.paytag.wait { background: #fdf3e3; color: var(--gold-deep); }

/* ── A-List drilldown ── */
.alrow { width: 100%; text-align: left; }
.algrp { padding: 10px 0; border-bottom: 1px solid var(--line); }
.algrp:last-child { border-bottom: none; }
.algrp-h { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.algrp-h span { color: var(--gold-deep); font-weight: 700; }
.algrp-ids { display: flex; flex-wrap: wrap; gap: 6px; }
.alid { font-size: 11.5px; font-weight: 600; color: var(--ink-2); background: var(--cream-2); padding: 3px 8px; border-radius: 6px; }

/* ── Token ── */
.rw-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
@media (min-width: 700px) { .rw-grid { grid-template-columns: repeat(4, 1fr); } }
.rw { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.rw:active { transform: scale(.97); border-color: var(--gold); }
.rw.off { opacity: .42; }
.rw-ic { font-size: 22px; }
.rw-l { font-size: 12.5px; font-weight: 600; text-align: center; }
.rw-c { font-size: 12px; font-weight: 700; color: var(--gold-deep); }
.rule { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.rule:last-child { border-bottom: none; }
.rule .plus { color: var(--green); }
.rule .minus { color: var(--red); }
.tadj { display: flex; gap: 5px; }
.tbtn { width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line); font-weight: 700; color: var(--ink-2); }
.tbtn:active { background: var(--cream); }

/* ── ประกาศ ── */
.nflist { margin: 0 -2px; }
.nf { display: flex; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.nf:last-child { border-bottom: none; }
.nf-ic { font-size: 17px; }
.nf-body { flex: 1; min-width: 0; }
.nf-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.nf-msg { display: block; font-size: 13.5px; margin-top: 3px; word-break: break-word; }
.nf-meta { display: block; font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.nf-acts { display: flex; gap: 7px; margin-top: 8px; }
.nf-ok, .nf-no { font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); }
.nf-ok { color: var(--green); } .nf-no { color: var(--red); }

.mob-only { display: block; }
@media (min-width: 900px) { .mob-only { display: none; } }

/* ── เป้าหมาย / เช็คลิสต์ ── */
.goaltext { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--cream); font-size: 14px; line-height: 1.5; resize: vertical; }
.goaltext:focus { outline: none; border-color: var(--gold); background: var(--card); }
.goals { display: flex; flex-direction: column; gap: 11px; }
.grow { display: flex; align-items: center; gap: 10px; }
.gic { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }
.gname { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; }
.gname i { font-style: normal; float: right; font-size: 12px; color: var(--ink-3); font-weight: 400; }
.gname .bar { display: block; margin-top: 5px; }
.gt { width: 56px; flex-shrink: 0; text-align: center; padding: 7px 4px; border: 1px solid var(--line); border-radius: 9px; background: var(--cream); font-weight: 700; }
.gt:focus { outline: none; border-color: var(--gold); background: var(--card); }
.gt:disabled { opacity: .5; }

.cklist { margin: 0 -4px; }
.ck { display: flex; align-items: center; gap: 9px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.ck:last-child { border-bottom: none; }
.ckbox { width: 21px; height: 21px; border-radius: 6px; border: 1.5px solid var(--line); flex-shrink: 0; font-size: 12px; font-weight: 700; color: transparent; }
.ck.on .ckbox { background: var(--gold); border-color: var(--gold); color: #40331a; }
.cktime { font-size: 11.5px; color: var(--ink-3); width: 40px; flex-shrink: 0; }
.cktext { flex: 1; font-size: 13.5px; min-width: 0; }
.ck.on .cktext { text-decoration: line-through; color: var(--ink-3); }
.ckdel { color: var(--ink-3); font-size: 12px; padding: 2px 5px; }
.ckadd { display: flex; gap: 6px; margin-top: 11px; }
.ckadd input, .ckadd select { flex: 1; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--cream); font-size: 13px; }
.ckadd input:focus, .ckadd select:focus { outline: none; border-color: var(--gold); background: var(--card); }
.ckplus { width: 40px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 10px; font-size: 17px; font-weight: 700; color: var(--gold-deep); }

/* ── ฟอร์มใน sheet ── */
.hintline { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; }
.hintline.ok { color: var(--green); }
.hintline.warn { color: var(--gold-deep); font-weight: 600; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.frow3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.pricebox { display: flex; align-items: center; gap: 12px; background: var(--cream); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.pricebox .k { display: block; font-size: 11px; color: var(--ink-3); }
.pricebox .v { font-size: 16px; font-weight: 700; }
.pricebox .v.new { color: var(--gold-deep); font-size: 13px; font-weight: 600; }
.pricebox .arw { color: var(--ink-3); }

/* ── Bottom sheet (lead detail) ── */
.sheet-bg { position: fixed; inset: 0; background: rgba(40,34,26,.35); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--card); border-radius: 20px 20px 0 0; padding: 18px 16px calc(20px + var(--safe-b));
  max-height: 88vh; overflow-y: auto; animation: up .22s ease;
}
@keyframes up { from { transform: translateY(20px); opacity: .6; } }
@media (min-width: 900px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 460px; border-radius: 18px; max-height: 84vh; }
  @keyframes up { from { transform: translate(-50%, -46%); opacity: .6; } }
}
.sheet-hd { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.sheet-t { font-size: 18px; font-weight: 700; }
.sheet .x { font-size: 17px; color: var(--ink-3); padding: 2px 6px; }
.sheet-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.act { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.act:active { background: var(--cream); }
.act.plain { color: var(--ink-3); font-weight: 400; border-style: dashed; }
.sheet-info { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-bottom: 12px; }
.sheet-info .k { font-size: 11px; color: var(--ink-3); display: block; }
.sheet-info .v { font-size: 13.5px; font-weight: 600; }
.sheet-rm { font-size: 13px; color: var(--ink-2); background: var(--cream); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.sheet-sec { font-size: 11.5px; font-weight: 700; color: var(--ink-3); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 10px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.stp { font-size: 12px; font-weight: 600; padding: 10px 2px; border-radius: 10px; border: 1px solid var(--line); color: var(--ink-3); }
.stp.done { background: #fdf5e9; border-color: #eddfc4; color: var(--gold-deep); }
.stp.cur { background: var(--gold); border-color: var(--gold); color: #40331a; }
.stp:disabled { opacity: .55; }
.rej { width: 100%; margin-top: 9px; padding: 11px; border-radius: 10px; border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--red); }
.rej.on { background: #f7ecea; border-color: #e9c9c3; }

/* ── Chips ── */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); }
.chip.gold { border-color: var(--gold); color: var(--gold-deep); background: #fdf9f2; }

/* ── Avatar (รูปเซล) ── */
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--cream-2); border: 1px solid var(--line); flex-shrink: 0; display: block; }
.avatar-fb { display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: var(--brown); }
.avatar.lg { width: 52px; height: 52px; }
.avatar.sm { width: 30px; height: 30px; }
.avatar.ring { border: 2px solid var(--gold); }

/* ── Ranking ── */
.rank-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: none; }
.rank-row.me { background: #fdf9f2; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.rank-no { width: 18px; text-align: center; font-weight: 700; color: var(--ink-3); font-size: 12.5px; }
.rank-no.top { color: var(--gold-deep); }
.rank-name { flex: 1; min-width: 0; }
.rank-name .a { display: block; font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-name .s { display: block; font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-val { font-weight: 700; font-size: 16px; color: var(--ink); flex-shrink: 0; white-space: nowrap; }
.rank-val small { font-weight: 400; font-size: 11px; color: var(--ink-3); margin-left: 2px; }

/* ── Table ── */
.tbl-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 440px; }
.tbl th { text-align: center; font-weight: 600; color: var(--ink-3); font-size: 11.5px; padding: 7px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { text-align: center; padding: 8px 6px; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.tbl tr:last-child td { border-bottom: none; }
.tbl td.z { color: var(--ink-3); opacity: .45; }
.tbl td.top { color: var(--gold-deep); font-weight: 800; background: #fdf3e0; }
.tbl td:first-child, .tbl th:first-child { text-align: left; font-weight: 600; color: var(--ink); position: sticky; left: 0; background: var(--card); }

/* ── Bottom nav (มือถือ) ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(255,253,249,.94); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 7px 4px calc(7px + var(--safe-b));
}
.bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink-3); font-size: 10px; font-weight: 600; padding: 3px 12px; }
.bottom-nav button svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.bottom-nav button.active { color: var(--gold-deep); }

/* ── Desktop: sidebar + grid ── */
.side-nav { display: none; }
@media (min-width: 900px) {
  body { background: var(--cream); }
  .bottom-nav { display: none; }
  .side-nav {
    display: flex; flex-direction: column; gap: 3px;
    position: fixed; top: 0; left: 0; bottom: 0; width: 224px; z-index: 30;
    background: var(--card); border-right: 1px solid var(--line); padding: 22px 14px;
  }
  .side-nav .logo { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
  .side-nav .logo img { height: 38px; }
  .side-nav .logo .tx { font-weight: 700; letter-spacing: .12em; font-size: 13px; }
  .side-nav .logo .s { font-size: 10.5px; color: var(--ink-3); letter-spacing: .06em; }
  .side-nav button {
    display: flex; align-items: center; gap: 11px; width: 100%;
    padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--ink-2);
  }
  .side-nav button svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.6; }
  .side-nav button:hover { background: var(--cream); }
  .side-nav button.active { background: #fdf5e9; color: var(--gold-deep); }
  .side-nav .foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
  .side-nav .foot .who { display: flex; align-items: center; gap: 9px; padding: 6px 8px; }
  .side-nav .foot .who .n { font-size: 13px; font-weight: 600; }
  .side-nav .foot .who .r { font-size: 11px; color: var(--ink-3); }
  .side-nav .foot button { font-size: 12.5px; color: var(--ink-3); font-weight: 500; }

  .appbar { display: none; }
  .screen { max-width: none; margin-left: 236px; padding: 26px 34px 44px; }
  .desk-head {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 14px;
    position: sticky; top: 0; z-index: 10; margin: -26px -34px 20px; padding: 22px 34px 14px;
    background: linear-gradient(var(--cream) 72%, rgba(247,243,236,0));
  }
  .desk-head h1 { font-size: 23px; font-weight: 700; letter-spacing: -.01em; }
  .desk-head .sub { font-size: 13px; color: var(--ink-3); }
  .grid-2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; align-items: start; }
  .grid-2 > .card { margin-bottom: 0; }
  .grid-2 .span { grid-column: 1 / -1; }
  .stat .v { font-size: 34px; }
  table.tbl { min-width: 0; font-size: 13.5px; }
  .tbl td { padding: 10px 8px; }
  .tbl tbody tr:hover td, .tbl tr:hover td { background: var(--cream); }
  .card { padding: 20px 20px; }

  /* คลิกได้ = มี hover ชัดเจนบนคอม */
  .lst:hover { border-color: var(--gold); box-shadow: 0 1px 0 var(--line); }
  .lead-row:hover, .rank-row:hover { background: var(--cream); }
  .qa:hover, .rw:hover:not(.off), .fchip:hover, .pg:not(:disabled):hover, .tbtn:hover { border-color: var(--gold); }
  .side-nav button:hover { background: var(--cream); }

  /* 3 คอลัมน์บนจอกว้าง */
  @media (min-width: 1400px) {
    .grid-2 { grid-template-columns: repeat(3, 1fr); }
    .grid-2 .span { grid-column: 1 / -1; }
    .lst-grid { grid-template-columns: repeat(3, 1fr); }
    .qa-grid { grid-template-columns: repeat(6, 1fr); }
  }
  .kbd { position: fixed; right: 18px; bottom: 14px; font-size: 11px; color: var(--ink-3); }
  .kbd b { font-weight: 600; background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; margin: 0 1px; }
}
.kbd { display: none; }
@media (min-width: 900px) { .kbd { display: block; } }
.desk-head { display: none; }
@media (min-width: 900px) { .desk-head { display: flex; } }
@media (max-width: 899px) { .grid-2 { display: block; } .grid-2 > .card { margin-bottom: 14px; } }

/* ── Login ── */
.login-wrap { min-height: 100vh; background: var(--cream); display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 34px 26px; width: 100%; max-width: 350px; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo img { height: 92px; margin-bottom: 12px; }
.login-logo .s { font-size: 12px; color: var(--ink-3); }
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 11.5px; font-weight: 700; color: var(--ink-3); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--cream); color: var(--ink);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--gold); background: var(--card); }
.btn-primary {
  width: 100%; background: var(--ink); color: var(--card); font-weight: 600; font-size: 15px;
  padding: 13px; border-radius: 12px; margin-top: 8px; letter-spacing: .02em;
}
.btn-primary:active { transform: scale(.985); }
.login-err { color: var(--red); font-size: 13px; text-align: center; margin-top: 10px; min-height: 18px; }

/* ── misc ── */
.muted { color: var(--ink-3); font-size: 12.5px; }
.center { text-align: center; }
.soon { text-align: center; padding: 44px 20px; }
.soon .big { font-size: 30px; margin-bottom: 12px; color: var(--gold); }
.soon .t { font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  background: var(--ink); color: var(--card); font-size: 13.5px;
  padding: 10px 18px; border-radius: 999px; z-index: 50; opacity: 0; transition: opacity .25s;
}
.toast.show { opacity: 1; }
.skeleton { background: var(--cream-2); border-radius: 6px; color: transparent !important; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
