:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1a2236;
  --text-2: #3d475c;
  --muted: #6b7489;
  --line: #e6e9f0;
  --line-2: #f0f2f6;
  --primary: #2563eb;
  --primary-soft: #eaf0ff;
  --side: #0f1629;
  --side-2: #182037;
  --side-text: #aeb7cc;
  --good: #14935a;
  --good-soft: #e5f6ed;
  --bad: #d63b3b;
  --bad-soft: #fdecec;
  --warn: #b7700a;
  --warn-soft: #fff4dd;
  --shopee: #EE4D2D;
  --lazada: #6C2BD9;
  --facebook: #1877F2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-hover: 0 6px 18px rgba(16, 24, 40, .09);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Noto Sans Thai', system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a.muted:hover { color: var(--primary); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); margin-top: 8px; min-height: 1em; }
.nowrap { white-space: nowrap; }
.num, .value, .big, td.num { font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 236px; flex-shrink: 0; background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; padding: 18px 12px; overflow-y: auto;
}
.brand { font-weight: 700; font-size: 17px; color: #fff; padding: 2px 10px 20px; letter-spacing: -.01em; }
.brand.big { font-size: 22px; color: var(--text); padding: 0; }
#nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; margin-bottom: 2px;
  font-weight: 500; transition: background .12s, color .12s;
}
#nav a:hover { background: var(--side-2); color: #fff; }
#nav a.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(37, 99, 235, .35); }
#nav a span { flex: 1; }
#nav a span.dot { flex: 0 0 10px; }
#nav a span.nav-logo { flex: 0 0 auto; display: inline-flex; background: #fff; border-radius: 6px; padding: 2px; }

/* โลโก้แพลตฟอร์ม */
.plogo { display: inline-block; vertical-align: middle; flex-shrink: 0; object-fit: contain; }
.plogo.fallback { display: inline-grid; place-items: center; color: #fff; border-radius: 5px; font-weight: 700; line-height: 1; }
.plogo.on-green { background: #fff; border-radius: 4px; padding: 1px; }
.with-logo { display: inline-flex; align-items: center; gap: 8px; }
.chip.pchip { background: #f1f3f7; color: var(--text-2); font-weight: 500; gap: 5px; padding: 2px 9px 2px 5px; white-space: nowrap; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: 16px 12px 6px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; border-top: 1px solid var(--side-2); }
.badge { background: var(--bad); color: #fff; font-size: 11px; border-radius: 10px; padding: 1px 7px; font-weight: 600; }
.view { flex: 1; overflow-y: auto; padding: 26px 30px 48px; }
.view.full { padding: 0; overflow: hidden; }

/* ---------- common ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 24px; display: flex; align-items: center; gap: 12px; letter-spacing: -.01em; }
.page-sub { margin-top: 4px; font-size: 13px; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--good); background: var(--good-soft); padding: 1px 9px; border-radius: 20px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.card-head h3 { margin: 0; }
.card-head.wrap { flex-wrap: wrap; align-items: center; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 6px 2px 10px; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.g-kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.g-kpi:has(> :nth-child(6):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 1260px) { .g-kpi:has(> :nth-child(6):last-child) { grid-template-columns: repeat(6, minmax(0, 1fr)); } .g-kpi .kpi .value { font-size: 24px; } }
@media (max-width: 700px) { .g-kpi:has(> :nth-child(6):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.g-plat { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g-plat:has(> :nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1260px) { .g-plat:has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g-plat:has(> :nth-child(4):last-child) .plat-card dl { grid-template-columns: repeat(2, 1fr); } .g-plat:has(> :nth-child(4):last-child) .shop-mini-row .muted { display: none; } .g-plat:has(> :nth-child(4):last-child) .plat-card .head { font-size: 15px; } }
@media (max-width: 700px) { .g-plat:has(> :nth-child(4):last-child) { grid-template-columns: 1fr; } }
.g-2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-half { grid-template-columns: 1fr 1fr; }
@media (max-width: 1200px) { .g-2, .g-half { grid-template-columns: 1fr; } }
.small { font-size: 12px; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 9px;
  font: inherit; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04); transition: border-color .12s, background .12s;
}
.btn:hover { border-color: #c5cddd; background: #fafbfd; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #1d4fd8; }
.btn.green { background: #06c755; border-color: #06c755; color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: wait; }
.link { background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; font: inherit; padding: 0; }
.link:hover { opacity: 1; text-decoration: underline; }

input, select, textarea {
  font: inherit; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.field input, label.field select { color: var(--text); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 3px; gap: 2px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.seg button { border: 0; background: none; padding: 5px 11px; font: inherit; cursor: pointer; color: var(--muted); border-radius: 7px; font-weight: 500; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.seg.sm button { padding: 3px 9px; font-size: 12px; }
.range-custom { display: inline-flex; gap: 6px; align-items: center; }
.range-custom input { padding: 6px 8px; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; background: #eef1f6; color: var(--muted); font-weight: 500; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.plat { color: #fff; font-weight: 600; }

/* ---------- KPI ---------- */
.kpi { position: relative; overflow: hidden; padding-bottom: 46px; }
.kpi-top { display: flex; align-items: center; gap: 9px; }
.kpi-ico { width: 30px; height: 30px; border-radius: 9px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex-shrink: 0; }
.kpi-ico svg { width: 17px; height: 17px; }
.kpi .label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 700; margin: 10px 0 4px; letter-spacing: -.02em; line-height: 1.2; }
.kpi-delta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kpi-sub { margin-top: 3px; }
.kpi:not(:has(.spark)) { padding-bottom: 18px; }
.kpi:not(:has(.spark)) .value { margin-top: 4px; }
.kpi .spark { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 40px; }
.pill { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 20px; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.neutral { background: #eef1f6; color: var(--text-2); }

/* ---------- platform cards ---------- */
.plat-card { border-top: 4px solid var(--c); cursor: pointer; transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; }
.plat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.plat-card .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 16px; }
.plat-main { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.plat-card .big { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-bottom: 4px; }
.plat-spark { width: 45%; height: 48px; }
.plat-spark .spark { width: 100%; height: 100%; }
.share { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.share .bar-track { flex: 1; }
.plat-card dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line-2); }
.plat-card dt { color: var(--muted); font-size: 12px; }
.plat-card dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.plat-foot { margin-top: 14px; font-size: 13px; color: var(--c); font-weight: 600; }
.bar-track { height: 6px; border-radius: 4px; background: #eef1f6; overflow: hidden; }
.bar-track > i { display: block; height: 100%; border-radius: 4px; background: var(--primary); }
.share-bar { height: 6px; border-radius: 4px; background: #eef1f6; margin-top: 10px; overflow: hidden; }
.share-bar > i { display: block; height: 100%; background: var(--c); }

/* ---------- charts ---------- */
.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 230px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: -4px 0 12px; font-size: 13px; color: var(--text-2); }
.legend .lg { display: inline-flex; align-items: center; gap: 7px; }
.legend .lg i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend .lg.dashed i { background: repeating-linear-gradient(90deg, #9aa3b5 0 4px, transparent 4px 7px); }
.legend .lg b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- status / products / efficiency ---------- */
.seg-bar { display: flex; gap: 2px; height: 10px; border-radius: 6px; overflow: hidden; margin-bottom: 14px; background: #eef1f6; }
.seg-bar i { display: block; min-width: 3px; }
.status-list { display: flex; flex-direction: column; }
.status-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; font-size: 13px; }
.status-row:hover { background: #f6f8fb; }
.status-row .st-ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.status-row .num { min-width: 34px; text-align: right; font-weight: 600; }
.status-row .pct { min-width: 46px; font-weight: 400; }
.status-row .amt { min-width: 76px; }
.prod-list { display: flex; flex-direction: column; gap: 12px; }
.prod-row { display: flex; align-items: center; gap: 12px; }
.prod-row .rank { width: 24px; height: 24px; border-radius: 7px; background: #eef1f6; color: var(--muted); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.prod-row .rank.top { background: var(--primary-soft); color: var(--primary); }
.prod-row .prod-name { font-size: 13px; font-weight: 500; margin-bottom: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod-row .num { text-align: right; white-space: nowrap; font-size: 13px; }
table.eff td { vertical-align: middle; }
table.eff tfoot td { font-weight: 600; border-bottom: 0; background: #fafbfd; }
.roas-cell { display: flex; align-items: center; gap: 10px; }
.roas-cell .bar-track { flex: 1; height: 8px; }
.roas-cell b { min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfd; position: sticky; top: 0; white-space: nowrap; border-bottom: 1px solid var(--line); }
td.num, th.num { text-align: right; white-space: nowrap; }
tbody tr:hover td { background: #fafbfd; }
td .items { color: var(--muted); font-size: 12px; max-width: 380px; margin-top: 2px; }
td .cust { font-weight: 500; }
td .order-no { font-family: Consolas, monospace; font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 4px; }
td select { padding: 3px 6px; font-size: 12px; }
.status-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 20px; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 10%, white); }
.status-select { color: var(--c); font-weight: 600; border-color: color-mix(in srgb, var(--c) 30%, white); background: color-mix(in srgb, var(--c) 6%, white); }
.st-pending { color: var(--warn); } .st-cancelled { color: var(--bad); } .st-completed { color: var(--good); } .st-returned { color: #7c3aed; }

/* ---------- chat (Messenger PC style) ---------- */
.chat { display: flex; height: 100vh; background: #fff; }
.chat-list { width: 340px; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.chat-list .top { padding: 16px 16px 8px; }
.chat-list h2 { margin: 0 0 12px; font-size: 22px; display: flex; justify-content: space-between; align-items: center; }
.chat-search { width: 100%; border-radius: 20px; background: #f0f2f5; border: 0; padding: 9px 14px; }
.chat-tabs { display: flex; gap: 6px; padding: 8px 16px; flex-wrap: wrap; }
.chat-tabs button.with-logo { gap: 5px; }
.chat-tabs button { border: 0; border-radius: 18px; padding: 6px 12px; background: none; font: inherit; cursor: pointer; color: var(--text); }
.chat-tabs button.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.conv-items { flex: 1; overflow-y: auto; padding: 4px 8px; }
.conv { display: flex; gap: 12px; padding: 10px; border-radius: 10px; cursor: pointer; align-items: center; }
.conv:hover { background: #f2f3f5; }
.conv.active { background: var(--primary-soft); }
.avatar { position: relative; width: 50px; height: 50px; border-radius: 50%; background: #d9dde6; color: #fff; display: grid; place-items: center; font-size: 19px; font-weight: 600; flex-shrink: 0; }
.avatar.sm { width: 38px; height: 38px; font-size: 15px; }
.avatar .pbadge { position: absolute; right: -3px; bottom: -3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; display: grid; place-items: center; box-shadow: 0 0 0 1px rgba(0,0,0,.06); }
.avatar.sm .pbadge { width: 19px; height: 19px; }
.avatar .pbadge .plogo.fallback { border-radius: 50%; }
.conv .meta { flex: 1; min-width: 0; }
.conv .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .preview { color: var(--muted); font-size: 13px; display: flex; gap: 4px; }
.conv .preview span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .name, .conv.unread .preview { font-weight: 700; color: var(--text); }
.conv .udot { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.chat-head .name { font-weight: 600; font-size: 16px; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 3px; }
.msg-row { display: flex; align-items: flex-end; gap: 8px; }
.msg-row.out { justify-content: flex-end; }
.bubble { max-width: 62%; padding: 8px 13px; border-radius: 18px; background: #e4e6eb; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.msg-row.out .bubble { background: var(--primary); color: #fff; }
.msg-time { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 6px; }
.composer { display: flex; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); align-items: center; }
.composer input { flex: 1; border-radius: 20px; background: #f0f2f5; border: 0; padding: 10px 16px; }
.send-btn { border: 0; background: none; color: var(--primary); font-size: 22px; cursor: pointer; }
.chat-empty { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; }
.grow { flex: 1; min-width: 0; }
.small { font-size: 12px; }
.icon-btn { border: 0; background: #f0f2f5; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 16px; color: var(--text); flex-shrink: 0; }
.icon-btn:hover { background: #e4e6eb; }
.icon-btn.on { background: var(--primary-soft); color: var(--primary); }
.link-btn { border: 0; background: none; color: var(--primary); cursor: pointer; font: inherit; font-size: 13px; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--bad); font-size: 12px; }
.ldot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 2px; vertical-align: middle; }

/* แผงข้อมูลลูกค้า (แบบ Meta Business Suite) */
.chat { position: relative; }
.chat-side { width: 330px; flex-shrink: 0; border-left: 1px solid var(--line); overflow-y: auto; background: #fff; }
.side-head { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.side-head .name { font-weight: 600; font-size: 16px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-side section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chat-side h4 { margin: 0 0 10px; font-size: 15px; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; }
.info-row { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; font-size: 13px; line-height: 1.4; word-break: break-word; }
.info-row .ico { width: 18px; text-align: center; flex-shrink: 0; opacity: .7; }
svg.ico { width: 16px; height: 16px; margin-top: 2px; color: var(--muted); opacity: 1; }
.info-row.is-empty { color: var(--muted); cursor: pointer; }
.info-row.is-empty:hover svg.ico { color: var(--primary); }
.tax-card { background: #f5f7fb; border-radius: 10px; padding: 10px 12px; }
.tax-name { font-weight: 600; margin-bottom: 4px; }
.mono { font-family: Consolas, monospace; letter-spacing: .02em; }
.form-sec { margin: 18px 0 10px; font-size: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.form-sec:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.tax-hint { font-size: 12px; margin-top: 6px; color: var(--muted); min-height: 1em; }
.tax-hint.ok { color: var(--good); }
.tax-hint.bad { color: var(--bad); }
.info-row.is-empty:hover { color: var(--primary); }
.order-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.order-sum > div { background: #f5f7fb; border-radius: 10px; padding: 8px 10px; }
.order-sum b { display: block; font-size: 16px; }
.order-sum span { color: var(--muted); font-size: 12px; }
.mini-order { padding: 7px 0; border-top: 1px dashed var(--line); font-size: 13px; }
.labels { display: flex; flex-wrap: wrap; gap: 6px; }
.label-chip { display: inline-flex; align-items: center; gap: 6px; background: #f0f2f5; border: 1px solid transparent; border-radius: 6px; padding: 3px 8px; font: inherit; font-size: 13px; color: var(--text); }
.label-chip i { width: 10px; height: 10px; border-radius: 50%; }
.label-chip button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 0 0 2px; font-size: 11px; }
.label-chip.add { cursor: pointer; background: #fff; border-color: var(--line); }
.label-chip.add::before { content: '+'; color: var(--muted); }
.label-chip.add:hover { border-color: var(--primary); }
.add-box { background: #f5f7fb; border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.add-box textarea { width: 100%; resize: vertical; }
.add-box .quick { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.add-box .quick .chip { border: 0; cursor: pointer; font: inherit; font-size: 12px; background: #fff; }
.add-foot { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.note { padding: 8px 0; border-top: 1px dashed var(--line); }
.note:first-of-type { border-top: 0; }
.note-text { white-space: pre-wrap; font-size: 13px; }
.note-meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.lbl-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.lbl-new { display: flex; gap: 8px; margin-top: 14px; }
.lbl-new input[type=color] { width: 44px; padding: 2px; height: 38px; }
.lbl-new input[name=name] { flex: 1; }
textarea { width: 100%; }
@media (max-width: 1250px) {
  .chat-side { position: absolute; right: 0; top: 0; bottom: 0; z-index: 5; box-shadow: -8px 0 24px rgba(0,0,0,.08); }
}

@media (max-width: 800px) { .chat-list { width: 100%; } .chat.has-active .chat-list { display: none; } .chat:not(.has-active) .chat-main { display: none; } }

/* ---------- settings ---------- */
.settings-group { margin-bottom: 16px; }
.settings-group h3 { display: flex; justify-content: space-between; align-items: center; }
.settings-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.toggle { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
.code { font-family: Consolas, monospace; background: #f3f5f9; padding: 2px 6px; border-radius: 6px; font-size: 12px; word-break: break-all; }
pre.preview { background: #f3f5f9; padding: 14px; border-radius: 10px; white-space: pre-wrap; font-family: inherit; margin: 0; }

/* ---------- modal / toast / login ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,20,35,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: #fff; border-radius: 14px; padding: 22px; width: min(620px, 100%); max-height: 90vh; overflow-y: auto; }
.modal-card h2 { margin: 0 0 16px; font-size: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.item-line { display: grid; grid-template-columns: 1fr 80px 110px 32px; gap: 8px; margin-bottom: 8px; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #1c2333; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.18); max-width: 360px; cursor: pointer; }
.toast.err { background: var(--bad); }
.login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 100; padding: 16px; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 32px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

@media (max-width: 760px) {
  .app { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar { width: 100%; padding: 10px; }
  #nav { display: flex; flex-wrap: wrap; gap: 4px; }
  #nav a { margin: 0; padding: 7px 10px; }
  #navPlatforms { display: contents; }
  .nav-label, .sidebar-foot { display: none; }
  .brand { padding-bottom: 10px; }
  .view { padding: 16px; }
  .chat { height: calc(100vh - 150px); }
}

/* ---------- หลายร้านต่อแพลตฟอร์ม ---------- */
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nav-count { font-size: 11px; opacity: .55; font-weight: 500; }
#nav a.active .nav-count { opacity: .85; }
.shop-mini { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 4px; }
.shop-mini-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.shop-mini-row b { font-variant-numeric: tabular-nums; min-width: 70px; text-align: right; }
.bar-track.thin { height: 4px; margin: 0 0 6px 16px; }
.ad-shops { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 4px; }
.rank { width: 24px; height: 24px; border-radius: 7px; background: #eef1f6; color: var(--muted); display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; }
.rank.top { background: var(--primary-soft); color: var(--primary); }
table.shops-table tr.clickable { cursor: pointer; }
table.shops-table tr.clickable:hover td { background: #f4f7ff; }
.shop-switch { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -6px 0 18px; }
.shop-switch .seg button { display: inline-flex; align-items: center; gap: 6px; }
.shop-switch .dot { width: 8px; height: 8px; }
.chat-shop { width: 100%; margin-top: 8px; border-radius: 20px; background: #f0f2f5; border: 0; padding: 7px 12px; font-size: 13px; }
.conv-shop { font-size: 11px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.unread .conv-shop { font-weight: 400; color: var(--muted); }
.shop-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.shop-col { background: #f8f9fc; border: 1px solid var(--line-2); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.shop-col-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 2px; }
.shop-item { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.shop-item.off { opacity: .6; }
.shop-item .chip { margin-top: 3px; }
.modal-card h2.with-logo { display: flex; }

/* ---------- ความหนาแน่นแบบกะทัดรัด (จอโน้ตบุ๊ก ~1280–1700px) ----------
   ให้เห็นภาพรวมแบบจอใหญ่: KPI 6 ใบ และแพลตฟอร์ม 4 ใบในแถวเดียว ใช้กับทุกหน้า */
@media (max-width: 1700px) {
  body { font-size: 13px; }
  .sidebar { width: 206px; padding: 16px 10px; }
  .brand { font-size: 16px; padding-bottom: 16px; }
  #nav a { padding: 8px 10px; gap: 9px; }
  .view { padding: 18px 22px 40px; }
  .page-head { margin-bottom: 14px; gap: 10px; }
  .page-head h1 { font-size: 21px; }
  .page-sub { font-size: 12px; }
  .grid { gap: 12px; margin-bottom: 12px; }
  .card { padding: 14px 16px; border-radius: 12px; }
  .card h3, .card-head h3 { font-size: 14px; }
  .card-head { margin-bottom: 10px; }
  .section-title { font-size: 12px; margin: 4px 2px 8px; }
  .btn { padding: 6px 11px; font-size: 13px; }
  .seg button { padding: 4px 9px; font-size: 13px; }
  .range-custom input { padding: 4px 6px; font-size: 13px; }
  input, select, textarea { padding: 6px 9px; font-size: 13px; }
  .chip, .pill { font-size: 11px; }

  .kpi { padding: 12px 14px; }
  .kpi-ico { width: 26px; height: 26px; border-radius: 8px; }
  .kpi-ico svg { width: 15px; height: 15px; }
  .kpi .label { font-size: 12px; line-height: 1.3; }
  .g-kpi .kpi .value { font-size: 21px; margin: 8px 0 3px; }
  .kpi-delta { gap: 6px; }
  .kpi-delta .small, .kpi-sub { font-size: 11px; }
  .kpi .spark { height: 32px; }

  .plat-card .head { margin-bottom: 10px; font-size: 14px !important; }
  .plat-card .big { font-size: 21px; }
  .plat-spark { height: 40px; }
  .share { margin-top: 10px; font-size: 11px; }
  .plat-card dl { gap: 8px; margin-top: 12px; padding-top: 10px; }
  .plat-card dt { font-size: 11px; }
  .plat-card dd { font-size: 13px; }
  .shop-mini { margin-top: 10px; padding-top: 8px; }
  .shop-mini-row { font-size: 12px; }
  .shop-mini-row b { min-width: 60px; }
  .plat-foot { margin-top: 10px; font-size: 12px; }

  th, td { padding: 8px 8px; }
  th { font-size: 11px; }
  .chart-box { height: 260px; }
  .chart-box.sm { height: 210px; }
  .legend { font-size: 12px; margin-bottom: 8px; }
  .status-row { padding: 6px 4px; font-size: 12px; }
  .prod-list { gap: 9px; }
  .prod-row .prod-name, .prod-row .num { font-size: 12px; }

  .chat-list { width: 300px; }
  .chat-side { width: 300px; }
  .avatar { width: 44px; height: 44px; font-size: 17px; }
  .chat-list h2 { font-size: 20px; }
}

/* ---------- กำไร ---------- */
.profit-hero { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }
.profit-hero b { font-size: 20px; font-variant-numeric: tabular-nums; }
.profit-hero b.pos { color: var(--good); }
.profit-hero b.neg { color: var(--bad); }
.profit-hero .arrow { color: var(--muted); font-size: 18px; padding-bottom: 2px; }
.seg-bar.tall { height: 16px; border-radius: 8px; }
.profit-list { display: flex; flex-direction: column; gap: 2px; }
.profit-row { display: flex; align-items: center; gap: 10px; padding: 5px 2px; font-size: 13px; }
.profit-row .sw { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.profit-row .num { min-width: 80px; text-align: right; font-variant-numeric: tabular-nums; }
.profit-row .pct { min-width: 52px; }
.profit-row.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; font-weight: 700; }
.warn-box { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 8px 12px; font-size: 13px; margin-top: 10px; }
.warn-box a { color: inherit; text-decoration: underline; }
.good-t { color: var(--good); }
.bad-t { color: var(--bad); }

/* ---------- เป้ายอดขาย ---------- */
.target-card { margin-bottom: 12px; }
.target-main { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.target-pct { font-size: 34px; font-weight: 800; line-height: 1; letter-spacing: -.03em; min-width: 84px; }
.target-pct small { font-size: 18px; }
.target-pct.ok { color: var(--good); }
.target-pct.behind { color: var(--warn); }
.target-main > .grow { min-width: 260px; }
.target-bar { position: relative; height: 14px; border-radius: 8px; background: #eef1f6; }
.target-bar > i { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, #22c55e, #16a34a); }
.target-bar .pace { position: absolute; top: -4px; bottom: -4px; width: 2px; background: #1a2236; border-radius: 2px; }
.target-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.target-stats { display: grid; grid-template-columns: repeat(4, auto); gap: 4px 22px; margin: 0; }
.target-stats dt { font-size: 11px; color: var(--muted); }
.target-stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.target-shops { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 18px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-2); }
.target-shops .ts { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.target-shops .ts .ellipsis { width: 96px; }
.target-shops .ts .bar-track { flex: 1; }
.target-shops .ts b { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.tg-shops { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }

/* ---------- กระเป๋าเงินโฆษณา ---------- */
.wallet-sum { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 12px; }
.wallet-sum > div { display: flex; flex-direction: column; }
.wallet-sum b { font-size: 18px; font-variant-numeric: tabular-nums; }
.wallets { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.wallet { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; background: #fbfcfe; min-width: 0; }
.wallet.low { border-color: #fca5a5; background: #fff7f7; }
.wallet-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; }
.wallet-head .with-logo { min-width: 0; }
.wallet-bal { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.wallet-bal.neg { color: var(--bad); }
.wallet-alert { color: var(--bad); font-size: 12px; font-weight: 600; }
.wallet dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 2px 0; }
.wallet dt { font-size: 11px; color: var(--muted); }
.wallet dd { margin: 0; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.topup-hist { margin-top: 12px; }
.topup-hist summary { cursor: pointer; color: var(--primary); font-size: 13px; margin-bottom: 8px; }

/* ---------- แจ้งเตือนออเดอร์ ---------- */
.order-toast { background: #fff; color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--good); box-shadow: 0 10px 30px rgba(16, 24, 40, .18); min-width: 280px; animation: slideIn .25s ease-out; }
.order-toast .ot-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.order-toast .ot-amt { font-size: 22px; font-weight: 800; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.order-toast .ot-sub { font-size: 12px; color: var(--muted); max-width: 320px; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.notif-controls { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; font-size: 12px; }
#nav a .badge { margin-left: auto; }

/* ---------- แชท: เครื่องมือเพิ่ม ---------- */
.composer { position: relative; }
.tool-btn { border: 0; background: #f0f2f5; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 16px; flex-shrink: 0; }
.tool-btn:hover { background: #e4e6eb; }
.qr-pop { position: absolute; left: 18px; right: 18px; bottom: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(16, 24, 40, .15); max-height: 300px; overflow-y: auto; z-index: 10; padding: 6px; }
.qr-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px 6px; font-size: 13px; }
.qr-item { display: flex; flex-direction: column; align-items: flex-start; width: 100%; border: 0; background: none; text-align: left; padding: 7px 8px; border-radius: 8px; cursor: pointer; font: inherit; gap: 1px; }
.qr-item:hover { background: var(--primary-soft); }
.qr-item span { font-size: 12px; color: var(--muted); max-width: 100%; }
.msg-stack { display: flex; flex-direction: column; gap: 3px; max-width: 62%; }
.msg-row.out .msg-stack { align-items: flex-end; }
.msg-stack .bubble { max-width: 100%; }
.msg-img { max-width: 260px; max-height: 260px; border-radius: 14px; display: block; border: 1px solid var(--line); background: #f0f2f5; }
.msg-flag { font-size: 11px; color: var(--muted); white-space: nowrap; padding: 0 4px; margin-bottom: 4px; }
.qr-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.qr-row { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; }
.chips-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.inline-form { display: flex; gap: 6px; }
.inline-form input { flex: 1; }
.days-pick { display: flex; gap: 4px; flex-wrap: wrap; }
.days-pick label { cursor: pointer; }
.days-pick input { display: none; }
.days-pick span { display: inline-grid; place-items: center; width: 34px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 12px; color: var(--muted); }
.days-pick input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.field.wide { grid-column: 1 / -1; }

.modal-card.wide { width: min(980px, 100%); }

/* ---------- ออเดอร์ที่ร้านจัดการเอง ---------- */
.lock { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.track { display: flex; align-items: center; gap: 4px; margin: 2px 0; }
.track .code { font-size: 11px; }
.need-ship { display: inline-block; font-size: 12px; font-weight: 600; color: var(--warn); background: var(--warn-soft); border-radius: 10px; padding: 1px 8px; white-space: nowrap; }
.queue-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.queue-chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.queue-chip b { font-variant-numeric: tabular-nums; }
.queue-chip.ship { border-color: #fcd34d; background: #fffbeb; color: #92400e; }
.queue-chip.pay { border-color: #bfdbfe; background: #eff6ff; color: #1e40af; }
.queue-chip:hover { filter: brightness(.97); }
.edit-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.items-ro { background: #f8f9fc; border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.items-ro > div { display: flex; justify-content: space-between; gap: 12px; }

/* ---------- ยืนยันลบร้าน ---------- */
.danger-box { background: var(--bad-soft); color: #7f1d1d; border: 1px solid #fecaca; border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 10px; }
.danger-box ul { margin: 6px 0 0; padding-left: 20px; }
.danger-box li { margin: 2px 0; }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-solid:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- ตัวแบ่งหน้า ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 12px; }
.pager-btns { display: flex; align-items: center; gap: 4px; }
.pager-btn { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--line); background: #fff; border-radius: 8px; font: inherit; font-size: 13px; cursor: pointer; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pager-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pager-btn.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pager-btn:disabled { opacity: .4; cursor: default; }
.pager-gap { color: var(--muted); padding: 0 2px; }

/* ---------- หน้าตั้งค่า (แท็บ) ---------- */
.settings-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.settings-tabs button { border: 0; background: none; font: inherit; font-weight: 500; color: var(--muted); padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.settings-tabs button:hover { color: var(--text); }
.settings-tabs button.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.info-box { background: var(--primary-soft); color: #1e3a8a; border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; line-height: 1.6; }
.plat-sets { display: flex; flex-direction: column; gap: 12px; }
.plat-set { border-left: 4px solid var(--c); }
.ps-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 16px; }
.ps-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 1100px) { .ps-grid { grid-template-columns: 1fr; } }
.ps-grid h4 { margin: 0 0 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ps-grid h4 .btn { margin-left: auto; }
.ps-app { background: #f8f9fc; border: 1px solid var(--line-2); border-radius: 12px; padding: 14px; }
.ps-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ps-shops { display: flex; flex-direction: column; gap: 8px; }
.ps-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; line-height: 1.5; }
.hint-label { font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.url-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.url-row .code { word-break: break-all; }
.steps { margin: 0 0 14px; padding-left: 20px; font-size: 13px; color: var(--text-2); line-height: 1.7; }
.last-src { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; margin-top: 8px; background: var(--good-soft); padding: 6px 10px; border-radius: 8px; }
.time-field { max-width: 180px; margin-top: 8px; }

/* สวิตช์เปิด/ปิด */
.switch-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; cursor: pointer; }
.switch-row .grow { display: flex; flex-direction: column; }
.switch-row b { font-weight: 500; font-size: 14px; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; background: #cfd5e1; border-radius: 24px; transition: background .15s; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + i { background: var(--good); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 3px solid var(--primary-soft); }
.switch.big { width: 52px; height: 30px; }
.switch.big i::after { width: 24px; height: 24px; }
.switch.big input:checked + i::after { transform: translateX(22px); }

/* ตอบแชทอัตโนมัติ */
.ar-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.ar-head h3 { margin: 0 0 4px; }
.ar-head p { margin: 0; }
.ar-status { margin-top: 12px; padding: 9px 12px; border-radius: 10px; font-size: 13px; font-weight: 500; }
.ar-status.open { background: var(--good-soft); color: var(--good); }
.ar-status.closed { background: #eef2ff; color: #3730a3; }
.ar-status.off { background: #f1f3f7; color: var(--muted); }
.days-pick.big span { width: 44px; height: 38px; font-size: 13px; border-radius: 10px; }
.time-range { display: flex; align-items: center; gap: 10px; }
.time-range input { font-size: 15px; padding: 8px 10px; }
.ar-card textarea { font-size: 14px; }

/* ตัวอย่างหน้าจอ: แชท LINE / มือถือ */
.line-chat { background: #8cabd9; border-radius: 14px; padding: 18px 16px; display: flex; align-items: flex-end; gap: 6px; min-height: 200px; }
.line-bubble { background: #fff; border-radius: 4px 18px 18px 18px; padding: 12px 14px; white-space: pre-wrap; font-size: 13px; line-height: 1.55; max-width: 92%; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.line-time { font-size: 10px; color: #f1f5ff; padding-bottom: 2px; }
.phone { border: 1px solid var(--line); border-radius: 22px; overflow: hidden; max-width: 340px; margin: 8px auto 0; box-shadow: var(--shadow-hover); }
.phone-bar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.phone-body { padding: 16px 12px; display: flex; flex-direction: column; gap: 6px; background: #fff; min-height: 220px; }
.pm { max-width: 80%; padding: 8px 12px; border-radius: 18px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.pm.in { background: #e4e6eb; align-self: flex-start; }
.pm.out { background: var(--primary); color: #fff; align-self: flex-end; }
.pm-flag { align-self: flex-end; font-size: 11px; color: var(--muted); }

/* หน้าเข้าระบบ: ปุ่มแสดงรหัส */
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { flex: 1; padding-right: 42px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 34px; height: 34px;
  border: 0; border-radius: 8px; background: none; cursor: pointer; padding: 0; color: #8a93a6; }
.pw-eye:hover { color: var(--text); background: #f1f3f7; }
.pw-eye.on { color: var(--primary); }
/* ซ่อนรหัสอยู่ = ตาปิด (ขีดฆ่า) · กดแสดงรหัส = ตาเปิด */
.pw-eye .eye-on, .pw-eye.on .eye-off { display: none; }
.pw-eye.on .eye-on { display: grid; }
.pw-eye span { display: grid; }

/* แท็บกรองแชท: บรรทัดเดียว — แพลตฟอร์มแสดงเฉพาะโลโก้ */
.chat-tabs { flex-wrap: nowrap; gap: 4px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.chat-tabs::-webkit-scrollbar { display: none; }
.chat-tabs button { white-space: nowrap; flex-shrink: 0; padding: 6px 11px; }
.chat-tabs button.tab-logo { padding: 5px 8px; display: inline-grid; place-items: center; border-radius: 10px; }
.chat-tabs button.tab-logo.on { background: var(--primary-soft); box-shadow: inset 0 0 0 1.5px var(--primary); }
.chat-tabs { padding-left: 12px; padding-right: 12px; gap: 2px; }
.chat-tabs button { padding: 6px 9px; }
.chat-tabs button.tab-logo { padding: 5px 6px; }

/* ปุ่มเพิ่มออเดอร์ (Facebook / แชท) */
.btn.add-order { background: var(--good); border-color: var(--good); color: #fff; font-weight: 600; }
.btn.add-order:hover { background: #0f7a4a; }
.items-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-size: 13px; color: var(--muted); }
.items-foot b { color: var(--text); font-size: 15px; }
td .items.ellipsis { max-width: 360px; }

/* ---------- นำเข้าออเดอร์ ---------- */
.imp-help { margin: 12px 0; font-size: 13px; }
.imp-help summary { cursor: pointer; color: var(--primary); }
.imp-help ul { margin: 8px 0; padding-left: 18px; }
.imp-help li { margin: 4px 0; }
.imp-help li img { vertical-align: -3px; }
.imp-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 6px; }
.imp-sum div { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.imp-sum span { display: block; font-size: 12px; color: var(--muted); }
.imp-sum b { font-size: 18px; }
.imp-sum b.good { color: var(--good); }
.imp-sample { font-size: 12px; margin-top: 6px; width: 100%; }
@media (max-width: 640px) { .imp-sum { grid-template-columns: repeat(2, 1fr); } }

.kpi-sub .nowrap { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- เชื่อมต่อร้าน (OAuth) ---------- */
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.auth-ok { background: var(--good-soft, #e8f7ef); border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 10px; }
.auth-ok .muted { margin-top: 4px; }
.auth-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.auth-paste-row { display: flex; gap: 8px; }
.auth-paste-row input { flex: 1; min-width: 0; }

/* หัวหน้า: ปุ่มช่วงวันที่อยู่บรรทัดเดียวกับชื่อหน้า — ข้อความวันที่ยาวให้ตัดบรรทัดในฝั่งซ้ายแทนการดันปุ่มลงบรรทัดใหม่
   (ฝั่งซ้ายคิดขนาดตั้งต้นแค่ 320px · ชื่อหน้าไม่ตัดบรรทัด · ปุ่มลงบรรทัดใหม่เฉพาะจอแคบจนวางไม่พอจริงๆ) */
.page-head > :first-child { flex: 1 1 320px; min-width: min-content; }
.page-head > .actions { flex: 0 0 auto; }
.page-head h1 { white-space: nowrap; }
.page-sub .live { white-space: nowrap; }

/* ค่าสำหรับหน้านักพัฒนา (พับเก็บไว้) */
.ps-more { margin-top: 10px; border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.ps-more summary { cursor: pointer; color: var(--text-2); }
.ps-more[open] summary { margin-bottom: 6px; }
.ps-more .switch-row { margin-top: 10px; }

/* ---------- ตั้งค่าแชทอัตโนมัติ (ออกแบบใหม่) ---------- */
.ar2, .qr2 { margin-bottom: 16px; }
.ar2-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.ar2-title { display: flex; gap: 12px; align-items: flex-start; }
.ar2-title h3 { margin: 0 0 3px; font-size: 16px; }
.ar2-title p { margin: 0; }
.ar2-ico { width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.ar2-toggle { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.ar2 .ar-status { margin-top: 14px; }
.ar2-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, 1fr); gap: 28px; margin-top: 18px; transition: opacity .2s; }
.ar2-grid.is-off .ar2-form { opacity: .55; }
.ar2-step { padding: 14px 0; border-top: 1px solid var(--line-2); }
.ar2-step:first-child { border-top: 0; padding-top: 2px; }
.ar2-step-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.ar2-step-h b { font-size: 14px; }
.ar2-n { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.ar2-presets { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip-btn { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 3px 12px; font: inherit; font-size: 12px; color: var(--text-2); cursor: pointer; }
.chip-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.days-pick.pill { gap: 6px; }
.days-pick.pill span { width: 44px; height: 36px; border-radius: 18px; font-size: 13px; transition: background .15s, border-color .15s; }
.days-pick.pill label:hover span { border-color: var(--primary); }
.time-range { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.time-box { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px 4px 12px; background: #fff; }
.time-box span { font-size: 12px; color: var(--muted); }
.time-box input { border: 0; padding: 6px 4px; font-size: 15px; font-weight: 600; background: transparent; }
.time-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.time-sep { color: var(--muted); }
.ar2 textarea { width: 100%; font-size: 14px; line-height: 1.55; resize: vertical; min-height: 96px; }
.ar2-side { background: #f7f8fb; border-radius: 14px; padding: 16px; align-self: start; }
.ar2-side-h { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: none; margin-bottom: 8px; }
.ar2-phone { max-width: none; margin: 0; box-shadow: 0 6px 20px rgba(16, 24, 40, .08); background: #fff; }
.ar2-phone .phone-body { min-height: 0; padding: 12px; }
.pb-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); display: grid; place-items: center; }
.pm-time { align-self: center; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.ar-week { display: flex; flex-direction: column; gap: 5px; }
.wk-row { display: grid; grid-template-columns: 22px 1fr 78px; align-items: center; gap: 8px; font-size: 12px; }
.wk-d { font-weight: 600; color: var(--text-2); }
.wk-t { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.wk-bar { position: relative; height: 12px; border-radius: 6px; background: #6366f1; overflow: hidden; }
.wk-bar.wk-disabled { background: #d5d9e2; }
.wk-open { position: absolute; top: 0; bottom: 0; background: #c7d7fe; }
.wk-off .wk-d, .wk-off .wk-t { color: #a5acbb; }
.wk-axis { margin-top: 2px; }
.wk-ticks { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.ar-legend { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.ar-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.lg-open { background: #c7d7fe; }
.lg-auto { background: #6366f1; }
.ar2-foot { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-2); }
#arDirty.dirty { color: var(--warn); font-weight: 600; }
.kbd { display: inline-block; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: 11px; background: #fff; line-height: 1.5; }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 16px; }
.qr-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; transition: border-color .15s, box-shadow .15s; min-width: 0; }
.qr-card:hover { border-color: #c7d2fe; box-shadow: var(--shadow); }
.qr-card-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; min-width: 0; }
.qr-card-t { font-size: 13px; color: var(--text-2); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.qr-acts { display: flex; gap: 2px; opacity: .55; transition: opacity .15s; }
.qr-card:hover .qr-acts { opacity: 1; }
.icon-btn.sm { width: 28px; height: 28px; font-size: 13px; }
.icon-btn.del:hover { background: var(--bad-soft); }
@media (max-width: 900px) { .ar2-grid { grid-template-columns: 1fr; } .ar2-head { flex-wrap: wrap; } }

/* ตัวอย่างข้อความ LINE (แท็บ) */
.lp-tabs { display: flex; flex-wrap: wrap; margin-bottom: 10px; }
.lp-sub { min-height: 22px; margin-bottom: 8px; display: flex; align-items: center; }
.lp-date { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }

/* ---------- เงินรอโอน ---------- */
.pend-card { margin-bottom: 16px; }
.pend-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.pend-stats > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--bg, #f5f7fb); }
.pend-stats span { font-size: 12px; color: var(--muted, #64748b); }
.pend-stats b { font-size: 18px; }
.pend-stats small { font-size: 11.5px; color: var(--muted, #64748b); }
.pend-stats .bad b { color: #dc2626; }
.pend-stats .muted-box { opacity: .75; border: 1px dashed var(--line, #d7dce5); background: transparent; }
.pend-more { margin-top: 12px; }
.pend-more summary { cursor: pointer; font-size: 13px; color: var(--primary, #2563eb); }
.pend-list { max-height: 340px; overflow: auto; margin-top: 8px; }
.pend-list .tbl th { position: sticky; top: 0; background: var(--card, #fff); }
.pend-list tr.pend-late td { background: #fef2f2; }
.pend-list tr.pend-unknown td { color: var(--muted, #64748b); }

/* ---------- นำเข้าหลายไฟล์ ---------- */
.imp-drop { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 12px 0 6px; padding: 18px; border: 2px dashed var(--line); border-radius: 12px; background: var(--bg); cursor: pointer; text-align: center; font-size: 14px; }
.imp-drop:hover, .imp-drop.over { border-color: var(--primary); background: var(--primary-soft); }
.imp-drop-ico { font-size: 26px; }
.imp-files { list-style: none; margin: 0; padding: 0; }
.imp-files li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.imp-file-res { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.imp-file-res summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.imp-file-res.bad { border-color: #fecaca; background: #fef2f2; }

/* ---------- ธุรกรรมเงิน ---------- */
.money-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 0 0 12px; }
.money-sum > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.money-sum span { font-size: 12.5px; color: var(--muted); }
.money-sum span small { font-size: 11.5px; }
.money-sum b { font-size: 20px; }
.money-sum > div > small { font-size: 12px; color: var(--muted); }
.money-tbl td { vertical-align: middle; }
.money-type { display: flex; gap: 10px; align-items: center; min-width: 0; }
.money-type > div { min-width: 0; max-width: 460px; }
.money-ico { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; background: #e0efff; }
.money-ico.wd { background: #fee2e2; }
.money-ico.out { background: #fef3c7; }
.money-ico.adj { background: #ede9fe; }
.money-sum .good, .money-tbl .good { color: var(--good); }

/* ---------- สินค้า & ต้นทุน / รายเดือน ---------- */
.cost-tbl .cost-in { width: 120px; text-align: right; }
.cost-tbl .with-logo img { margin-right: 2px; }
.month-tbl td, .month-tbl th { white-space: nowrap; }
[hidden] { display: none !important; }

.track-link { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); text-decoration: none; white-space: nowrap; }
.track-link:hover { background: var(--primary); color: #fff; }

/* แถบเตือนออเดอร์ค้างเงินนาน */
.late-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; padding: 10px 14px; border-radius: 10px; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; font-size: 14px; }
.late-bar .btn { margin-left: auto; }

/* สินค้าขายดีแบบกะทัดรัด */
.prod-list.compact { gap: 9px; }
.prod-list.compact .prod-name { font-size: 12.5px; margin-bottom: 3px; }
.prod-list.compact .num { font-size: 12.5px; }
.prod-list.compact .num .small { font-size: 11px; }
.prod-list.compact .rank { width: 22px; height: 22px; font-size: 11px; }
.bar-track.thin { height: 4px; }
.prod-card .prod-more { display: none; }
.prod-card.open .prod-more { display: flex; }
.prod-toggle { margin-top: 10px; font-size: 12.5px; }

/* การ์ดสินค้าที่ลูกค้าส่งมาในแชท */
.pcard { display: flex; gap: 12px; align-items: center; width: 320px; max-width: 100%; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 14px; color: var(--text); text-decoration: none; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); }
.pcard:hover { border-color: #c7cfdd; box-shadow: 0 2px 8px rgba(15, 23, 42, .08); }
.pcard img, .pcard-noimg { width: 72px; height: 72px; flex: none; border-radius: 10px; object-fit: cover; background: #f0f2f5; display: grid; place-items: center; font-size: 28px; }
.pcard-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pcard-title { font-weight: 500; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard-sold { font-size: 12px; color: var(--muted); }
.pcard-price { font-weight: 700; color: #fe2c55; font-size: 15px; }

/* ป้ายกำกับในรายการแชท (ชื่อป้าย + สี) */
.conv .name { display: flex; align-items: center; gap: 4px; }
.conv .name .nm { flex: 0 0 auto; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.ltag.more { --c: #64748b; flex: none; }
.ltag { flex: none; font-size: 11px; font-weight: 500; line-height: 1; padding: 3px 6px; border-radius: 999px; color: var(--c); background: color-mix(in srgb, var(--c) 14%, #fff); white-space: nowrap; }

/* ข้อความในแชท: รูปลูกค้าข้างข้อความ + เวลาเมื่อชี้เมาส์ (แบบ Messenger) */
.msg-line { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.msg-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.msg-row.out .msg-body { align-items: flex-end; }
.msg-stack { max-width: 70%; }

/* รูปโปรไฟล์ลูกค้า (วางทับตัวอักษรแรก) */
.avatar .avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: #fff; }
.msg-av { position: relative; flex: none; width: 28px; height: 28px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; overflow: hidden; align-self: flex-end; }
.msg-av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff; }
.msg-row.in:has(+ .msg-row.in) .msg-av { visibility: hidden; }
.msg-body { position: relative; }
.msg-body[data-tip]:hover::after { content: attr(data-tip); position: absolute; top: 50%; transform: translateY(-50%); z-index: 5; white-space: nowrap; background: rgba(30, 30, 30, .88); color: #fff; font-size: 12px; padding: 5px 9px; border-radius: 8px; pointer-events: none; }
.msg-row.in .msg-body[data-tip]:hover::after { left: calc(100% + 8px); }
.msg-row.out .msg-body[data-tip]:hover::after { right: calc(100% + 8px); }

/* แถบบอกว่าเป็นโหมดทดสอบ (โน้ตบุ๊ก) */
#testBanner { position: sticky; top: 0; z-index: 1000; background: #f59e0b; color: #fff; text-align: center; font-size: 13px; font-weight: 600; padding: 5px 12px; }

/* โลโก้ Marketing Online */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; flex: none; border-radius: 9px; background: #fff; padding: 2px; }
.login-logo { display: block; width: 220px; max-width: 70%; height: auto; margin: 0 auto 6px; }
.login-card > .muted { text-align: center; margin-top: 0; }
.brand > span { white-space: nowrap; font-size: 16px; }
.brand-mark { width: 32px; height: 32px; }

/* ================= จอมือถือ (กว้างไม่เกิน 760px) — อยู่ท้ายไฟล์เสมอ ให้ชนะกฎจอโน้ตบุ๊ก ================= */
.menu-btn { display: none; }
@media (max-width: 760px) {
  :root { --topbar: 54px; }
  body { font-size: 14px; }
  html, body { overflow-x: clip; } /* กันหน้าเลื่อนซ้าย-ขวา ถ้ามีข้อความยาวหลุดขอบ */
  .app { display: block; height: auto; min-height: 100vh; }

  /* 1) แถบบน: โลโก้ + ปุ่ม ☰ · กดแล้วเมนูเต็มจอ */
  .sidebar { position: sticky; top: 0; z-index: 40; width: 100%; height: var(--topbar); padding: 0 8px 0 14px;
    flex-direction: row; align-items: center; overflow: visible; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
  .sidebar .brand { flex: 1; padding: 0; font-size: 16px; }
  .menu-btn { display: grid; place-items: center; position: relative; width: 42px; height: 42px; border: 0; border-radius: 10px;
    background: transparent; color: #fff; font-size: 24px; cursor: pointer; }
  .menu-btn:active { background: var(--side-2); }
  .menu-dot { position: absolute; top: 8px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--side); }
  #nav, .sidebar-foot { display: none; }
  body.menu-open { overflow: hidden; }
  body.menu-open .sidebar { position: fixed; inset: 0; height: auto; flex-direction: column; align-items: stretch; padding: 0 14px 20px; overflow-y: auto; }
  body.menu-open .sidebar .brand { flex: none; height: var(--topbar); padding-right: 50px; }
  body.menu-open .menu-btn { position: absolute; top: 6px; right: 8px; }
  body.menu-open .menu-btn { font-size: 0; }
  body.menu-open .menu-btn::before { content: "✕"; font-size: 22px; }
  body.menu-open .menu-dot { display: none; }
  body.menu-open #nav { display: block; }
  body.menu-open #nav a { display: flex; padding: 12px 14px; margin-bottom: 4px; font-size: 16px; }
  body.menu-open #navPlatforms { display: block; }
  body.menu-open .nav-label { display: block; }
  body.menu-open .sidebar-foot { display: flex; margin-top: 16px; padding-top: 16px; }

  .view { padding: 14px 12px 40px; overflow: visible; }

  /* 2) หัวหน้า + ปุ่ม: ไม่ล้นจอ ปุ่มขึ้นบรรทัดใหม่ */
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-head > * { min-width: 0; max-width: 100%; flex: none !important; } /* บางหน้ากำหนด flex ไว้ในตัว HTML */
  .page-head h1 { font-size: 20px; }
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 auto; white-space: normal; justify-content: center; text-align: center; }

  /* 3) ปุ่มเลือกช่วงวันที่: แถวเดียว ปัดซ้าย-ขวาได้ ตัวหนังสือไม่แตกบรรทัด */
  .seg { display: flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { flex: none; white-space: nowrap; }

  /* 4) การ์ดตัวเลข 2 ใบต่อแถว */
  .g-kpi, .g-kpi:has(> :nth-child(6):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .g-kpi .card { padding: 12px; }
  .g-kpi .kpi .value, .g-kpi .value { font-size: 20px; }
  .kpi-sub .nowrap { white-space: normal; overflow: visible; } /* จอแคบ: ข้อความใต้ตัวเลขขึ้นบรรทัดใหม่แทนตัดเป็น … */
  .grid { gap: 10px; }
  .card { padding: 14px; }

  /* 5) ตารางออเดอร์ → การ์ดทีละออเดอร์ */
  .table-wrap:has(> table.orders) { overflow: visible; margin: 0; }
  table.orders, table.orders tbody { display: block; }
  table.orders thead { display: none; }
  table.orders tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 12px; margin-bottom: 10px;
    border: 1px solid var(--line); border-radius: 12px; background: #fff; }
  table.orders td { display: block; padding: 0; border: 0; min-width: 0; }
  table.orders td:nth-child(1) { order: 1; }                         /* วันที่ */
  table.orders td:nth-child(1) div { display: inline; margin-right: 6px; }
  table.orders td:nth-child(2) { order: 2; justify-self: end; }      /* ร้าน */
  table.orders td:nth-child(3) { order: 3; grid-column: 1 / -1; }    /* ลูกค้า / สินค้า */
  table.orders td:nth-child(4) { display: none; }                    /* จำนวนชิ้น (มี x1 ในชื่อสินค้าแล้ว) */
  table.orders td:nth-child(7) { order: 4; }                         /* สถานะ */
  table.orders td:nth-child(5) { order: 5; justify-self: end; font-size: 16px; } /* ยอดเงิน */
  table.orders td:nth-child(6) { order: 6; grid-column: 1 / -1; }    /* การจัดส่ง */
  table.orders td:nth-child(8) { order: 7; grid-column: 1 / -1; }    /* ปุ่มแก้ไข */
  table.orders td:empty, table.orders td:nth-child(6):not(:has(*)) { display: none; }
  table.orders .cust, table.orders .items { overflow-wrap: anywhere; }
  table.orders .order-no { white-space: normal; word-break: break-all; }

  /* 6) แชท: รายชื่อเต็มจอ → กดแล้วห้องแชทเต็มจอ (มีปุ่ม ‹ กลับ) · ข้อมูลลูกค้าเปิดทับเต็มจอ */
  .view.full { height: calc(100dvh - var(--topbar)); }
  .chat { height: 100%; }
  .chat .chat-list { width: 100%; border-right: 0; }
  .chat.has-active .chat-list { display: none; }
  .chat:not(.has-active) .chat-main, .chat:not(.has-active) .chat-side { display: none; }
  .chat .chat-side { position: fixed; top: var(--topbar); right: 0; bottom: 0; left: 0; width: auto; z-index: 30; }
  .chat-head { padding: 8px 10px; gap: 8px; }
  .msgs { padding: 12px 10px; }
  .msg-stack { max-width: 85%; }
  .composer { padding: 8px 10px; gap: 6px; }

  /* 7) ตั้งค่า: ช่องกรอกเรียงทีละบรรทัด */
  .settings-fields, .ps-fields, .ps-grid { grid-template-columns: 1fr; }
  .ps-app { padding: 12px; }

  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
  #testBanner { position: static; }
}
