/* ---------------------------------------------------------------- tokens */
:root {
  --bg: #fbf7f6;
  --brand: #5b2140;
  --accent: #8a4560;
  --line: #e0d3d8;
  --ink: #2a2029;
  --muted: #6f6169;
  --white: #fff;
  --danger: #a3243b;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --radius: 8px; --radius-lg: 12px;
  --control-h: 40px; --control-h-sm: 32px;
  --fs-xs: 13px; --fs-sm: 14px; --fs-md: 15px; --fs-lg: 18px; --fs-xl: 22px;
}
* { box-sizing: border-box; }
/* Ticket 31 R5: body grows with the page, so the sticky phone bar holds past the first screen. Only the inbox
   (its .app grid scrolls inside) keeps the body at exactly the viewport height. */
html { height: 100%; }
body { min-height: 100%; }
body:has(> .app) { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--fs-md)/1.5 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }
button, input, select, textarea { font-family: inherit; font-size: var(--fs-md); line-height: 22px; }
input, select, textarea { color: var(--ink); }

/* ---------------------------------------------------------------- buttons: one system
   default = primary · .secondary (outline) · .danger · .ghost (text only) · size .small. a.button-link matches. */
button, a.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--control-h);
  padding: 8px var(--s4);
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: var(--white);
  font-size: var(--fs-md);
  line-height: 22px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
button svg, a.button-link svg { width: 16px; height: 16px; flex: none; }
button.secondary, a.button-link.secondary { background: var(--white); color: var(--brand); }
button.danger, a.button-link.danger { background: var(--danger); border-color: var(--danger); }
button.ghost, a.button-link.ghost { background: none; border-color: transparent; color: var(--accent); padding-inline: var(--s2); }
button.secondary:hover, a.button-link.secondary:hover, button.ghost:hover, a.button-link.ghost:hover { background: #f4ebf0; }
button.small, a.button-link.small { min-height: var(--control-h-sm); padding: 4px var(--s3); font-size: var(--fs-sm); }
button.ghost.small, a.button-link.ghost.small { padding-inline: var(--s2); }
button:disabled { opacity: .6; cursor: default; }

/* ---------------------------------------------------------------- form controls */
input:where(:not([type="checkbox"], [type="radio"], [type="file"])), select, textarea {
  width: 100%;
  min-height: var(--control-h);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px var(--s3);
  background: var(--white);
}
input:where(:not([type="checkbox"], [type="radio"], [type="file"])), select { height: var(--control-h); }
select, input[type="date"], input[type="month"], input[type="time"] { padding-block: 0; } /* their own inner box sets the height */
input[type="file"] { width: 100%; max-width: 100%; font-size: var(--fs-sm); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--brand); }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* compact controls: dense grids and inline table inputs only */
.table input:where(:not([type="checkbox"], [type="radio"], [type="file"])), .table select,
.count-grid input.count, .rc-cost input, select.tag-select {
  min-height: var(--control-h-sm);
  height: var(--control-h-sm);
  padding: 4px var(--s2);
  font-size: var(--fs-sm);
}
label { display: flex; flex-direction: column; gap: var(--s1); color: var(--muted); font-size: var(--fs-xs); }
label.check { flex-direction: row; align-items: center; gap: var(--s2); color: var(--ink); font-size: var(--fs-sm); }
.hint { font-size: var(--fs-xs); color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.brand { color: var(--brand); font-weight: 600; letter-spacing: .08em; text-decoration: none; }
[hidden] { display: none !important; }

/* flash banners: right under the page header */
p.ok, p.error, .warn, p.warn-text { margin: 0 0 var(--s3); padding: var(--s2) var(--s3); border-radius: var(--radius); border: 1px solid; font-size: var(--fs-sm); }
p.ok { background: #f4ebf0; border-color: #dcc4d1; color: var(--brand); }
p.error { background: #fde8ec; border-color: #f2b8c3; color: var(--danger); }
.warn, p.warn-text { background: #fff4e5; border-color: #f0d2a8; color: #6b4310; }
.error { color: var(--danger); }
.ok { color: var(--brand); }

/* forms: meta fields in a responsive grid, actions row at the bottom (primary right-most) */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--s3) var(--s4); margin-bottom: var(--s3); }
.form-grid > .full, .form-grid > label:has(textarea) { grid-column: 1 / -1; }
.form-grid > button { align-self: end; justify-self: start; }
.form-grid > label { justify-content: flex-end; } /* labels that wrap keep the fields of one row level */
.settings-form .form-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s2); margin-top: var(--s3); }
.form-actions > .danger, .form-actions > .push-left { margin-right: auto; }
.form-actions + .card { margin-top: var(--s3); }
.form-card { max-width: 720px; display: flex; flex-direction: column; gap: var(--s3); }
.form-card > h3, .form-card > p { margin: 0; }
.form-card > .form-grid, .form-card > .form-actions { margin: 0; }
@media (max-width: 767px) {
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .form-actions > button, .form-actions > a.button-link, .form-actions > form > button { width: 100%; }
  .form-actions > .confirm-step > button { width: 100%; }
  .form-actions > .confirm-step .cancel-form { align-items: stretch; }
  .form-actions > .confirm-step .op-links button { flex: 1; }
  .form-actions > form { flex-direction: column; }
  .form-actions > .danger, .form-actions > .push-left { margin-right: 0; }
}

/* login + mock forms */
.login-body { align-items: center; justify-content: center; padding: 16px; }
.login-card, .mock-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.mock-card { max-width: 520px; margin: var(--s5) auto; }
.login-card h1 { margin: 0; font-size: 28px; }
.login-card p, .mock-card h2, .mock-card p { margin: 0; }
.login-card button[type="submit"] { width: 100%; }

/* ticket 11: left sidebar (replaces the top bar). Fixed; pages make room with body padding. */
:root { --sb-w: 212px; --sb-rail: 60px; }
body:has(> .sidebar) { padding-left: var(--sb-w); }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sb-w);
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-right: 1px solid var(--line);
  overflow-x: hidden;
  overflow-y: auto;
}
.sb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 10px 12px 20px; min-height: 56px; }
.sb-head .brand { font-size: 20px; }
.sb-toggle, .sb-burger { background: none; border: 0; color: var(--muted); padding: var(--s2); min-height: 0; border-radius: var(--radius); display: grid; place-items: center; }
.sb-toggle:hover, .sb-burger:hover { background: var(--bg); color: var(--brand); }
.sb-icon { flex: none; display: block; }
.sb-nav { list-style: none; margin: 0; padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sb-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--control-h);
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--ink);
  font-weight: 400;
  justify-content: flex-start;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}
.sb-link:hover { background: var(--bg); }
.sb-link[aria-current="page"] { background: #f4ebf0; color: var(--brand); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand); }
.sb-link:focus-visible, .sb-toggle:focus-visible, .sb-burger:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sb-foot { border-top: 1px solid var(--line); padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.sb-foot form { margin: 0; }
.sb-foot .push-hint { padding: 0 12px 6px; white-space: normal; } /* ticket 46: notification on/off hint */
.sb-user { display: flex; align-items: center; gap: 10px; padding: 6px 12px; min-width: 0; }
.sb-avatar { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: var(--white); display: grid; place-items: center; font-size: 12px; }
.staff-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-bar { display: none; }
.sb-backdrop { position: fixed; inset: 0; z-index: 29; background: rgba(42, 32, 41, .45); }
@media (min-width: 768px) {
  .sb-collapsed body:has(> .sidebar) { padding-left: var(--sb-rail); }
  .sb-collapsed .sidebar { width: var(--sb-rail); }
  .sb-collapsed .sb-label, .sb-collapsed .sb-head .brand { display: none; }
  .sb-collapsed .sb-head { justify-content: center; padding-inline: 0; }
  .sb-collapsed .sb-nav, .sb-collapsed .sb-foot { padding-inline: 6px; }
  .sb-collapsed .sb-link, .sb-collapsed .sb-user { justify-content: center; padding-inline: 0; }
  .sb-collapsed .sb-toggle svg { transform: rotate(180deg); }
}
@media (max-width: 767px) {
  body:has(> .sidebar) { padding-left: 0; }
  .mobile-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
  .mobile-bar .brand { font-size: 18px; }
  .sb-toggle { display: none; }
  .sidebar { width: min(280px, 85vw); transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; }
  .sb-open .sidebar { transform: none; visibility: visible; transition: transform .2s ease; box-shadow: 4px 0 24px rgba(42, 32, 41, .18); }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .sb-open .sidebar { transition: none; }
}
.spacer { flex: 1; }

/* inbox */
.app { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px 1fr; }
.list { border-right: 1px solid var(--line); overflow-y: auto; background: var(--white); }
#conv-list { list-style: none; margin: 0; padding: 0; }
.conv a {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.conv a:hover { background: var(--bg); }
.conv.active a { background: var(--bg); box-shadow: inset 3px 0 0 var(--brand); }
.badge {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
}
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.conv-name, .conv-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-preview { color: var(--muted); font-size: 13px; }
.conv.unread .conv-name { font-weight: 600; }
.conv-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.conv.unread .dot { background: var(--accent); }

.thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.thread-head { display: flex; flex-wrap: wrap; row-gap: 6px; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--white); }
.back { display: none; text-decoration: none; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 72%; display: flex; flex-direction: column; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bubble {
  padding: 8px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.in .bubble { background: var(--white); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.out .bubble { background: var(--brand); color: var(--white); border-bottom-right-radius: 4px; }
.meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.reply { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--white); }
.reply textarea { flex: 1; resize: vertical; min-height: 44px; max-height: 200px; }
.reply .error { flex-basis: 100%; }
.reply > button { align-self: flex-end; }
.empty { padding: 24px 16px; margin: 0; }
.conn { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--white); padding: 6px 12px; border-radius: 8px; font-size: 13px; margin: 0; }

@media (max-width: 767px) {
  .app { grid-template-columns: 1fr; }
  .list { border-right: 0; }
  body.has-thread .list { display: none; }
  body:not(.has-thread) .thread { display: none; }
  .back { display: inline; }
  .msg { max-width: 85%; }
}

/* ---------------------------------------------------------------- tickets 03/04 */
.small { font-size: var(--fs-xs); }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: var(--fs-xs); }
:is(h1, h2, h3) .mono, :is(h1, h2, h3).mono { font-size: inherit; }
.thread-head .spacer { flex: 1; }
.reply textarea.has-draft { border-color: var(--accent); }

/* order panel: right column on wide screens, full-screen sheet otherwise */
.order-panel { background: var(--white); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.panel-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-body { flex: 1; overflow-y: auto; padding: 0 16px 24px; }
.panel-section { padding: 14px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.panel-section h3 { margin: 0; font-size: 15px; color: var(--brand); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.row-4 { grid-template-columns: 1.3fr 1fr 1fr 1fr; }
.row-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
input[readonly] { background: var(--bg); }
@media (min-width: 1280px) {
  body.panel-open .app { grid-template-columns: 300px 1fr 420px; }
}
@media (max-width: 1279px) {
  .order-panel { position: fixed; inset: 0; z-index: 20; border-left: 0; }
}
/* 768-1279px: keep the chat visible while ordering; the conversation list makes room. */
@media (min-width: 768px) and (max-width: 1279px) {
  body.panel-open .app { grid-template-columns: 1fr minmax(360px, 420px); }
  body.panel-open .list { display: none; }
  .order-panel { position: static; border-left: 1px solid var(--line); }
}
/* Ticket 16: the same panel as a page (/orders/new), in the page flow at every width. */
.order-panel.page-form { position: static; border: 1px solid var(--line); border-radius: 12px; max-width: 560px; }
.order-panel.page-form .panel-body { overflow: visible; }
#tracking-copy { width: 100%; }

.picker-head img { border-radius: 6px; object-fit: cover; background: var(--bg); }
.pc-name { font-size: 13px; line-height: 1.3; }
.pc-meta { font-size: 12px; color: var(--muted); }
.picker { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 10px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.picker-head { display: flex; align-items: center; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; min-height: var(--control-h-sm); background: var(--white); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 4px var(--s3); font-size: var(--fs-sm); font-weight: 400; line-height: 22px; }
.chip.on { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.chip.size { border-radius: var(--radius); flex-direction: column; justify-content: center; line-height: 1.2; min-width: 64px; min-height: var(--control-h); }
.chip.size small { font-size: 12px; color: var(--muted); }
.chip:disabled { opacity: .45; text-decoration: line-through; }
.picker-add { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.stepper button { background: none; border: 0; color: var(--brand); min-height: var(--control-h-sm); padding: 4px var(--s3); }
.stepper output { min-width: 28px; text-align: center; }
.cart { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cart-line { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; }
.cl-main { display: flex; flex-direction: column; min-width: 0; }
.cl-main small { font-size: 12px; }
.cl-total { min-width: 84px; text-align: right; }
.summary dl, .kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.summary dd, .kv dd { margin: 0; text-align: right; }
.summary button[type="submit"] { width: 100%; font-weight: 600; }

/* order progress */
.order-progress { display: flex; flex-direction: column; gap: 8px; }
.op-head { display: flex; align-items: center; gap: 10px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.step { display: flex; gap: 10px; align-items: flex-start; }
.step-icon { width: 22px; height: 22px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.step-main { display: flex; flex-direction: column; }
.step-main small { color: var(--muted); font-size: 12px; }
.step-done .step-icon { background: #2f7d4f; border-color: #2f7d4f; color: var(--white); }
.step-skipped .step-icon { background: var(--bg); }
.step-running .step-icon { border-color: var(--accent); color: var(--accent); }
.step-failed .step-icon { background: #a3243b; border-color: #a3243b; color: var(--white); }
.step-failed .step-main small { color: #a3243b; }
.op-links { margin: 0; }
.status { font-size: 12px; border-radius: 999px; padding: 1px 10px; border: 1px solid var(--line); white-space: nowrap; }
.status-needs_attention { background: #fde8ec; border-color: #f2b8c3; color: #a3243b; }
.status-partial { background: #fdf3e1; border-color: #efd29a; color: #7a5410; } /* ticket 39: รับบางส่วน */
.status-confirmed, .status-shipped { background: #eef3fb; border-color: #c9d8f0; color: #234a85; }
.status-delivered { background: #e7f4ec; border-color: #b9dcc6; color: #2a7347; }
.status-cancelled, .status-returned { background: var(--bg); color: var(--muted); }

/* list pages */
body.page { display: block; }
.page-main { max-width: 1200px; margin: 0 auto; padding: var(--s4); }
:where(.page-main) h3 { font-size: var(--fs-lg); margin: var(--s5) 0 var(--s3); } /* low specificity: card/panel/head h3 rules win */
.page-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; min-height: var(--control-h); margin-bottom: var(--s4); }
.page-head h2 { margin: 0; font-size: var(--fs-xl); line-height: 1.3; }
.page-head h3 { margin: 0; font-size: var(--fs-lg); }
.pickup-box { margin-bottom: var(--s4); }
.pickup-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.pickup-recent { margin: var(--s2) 0 0; padding-left: 1.2em; font-size: var(--fs-sm); }
.page-head form { margin: 0; }
.filters { display: flex; gap: var(--s2); margin-bottom: var(--s3); flex-wrap: wrap; align-items: center; }
.filters select { width: auto; }
.filters input:not([type="checkbox"]):not([type="radio"]) { flex: 1; min-width: 200px; width: auto; }
.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table th { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; white-space: nowrap; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table button, .table a.button-link { min-height: var(--control-h-sm); padding: 4px var(--s3); font-size: var(--fs-sm); } /* same as .small: rows stay compact */
.table-wrap + .card, .table-wrap + .table-wrap { margin-top: var(--s3); }
.table td.zero { color: #a3243b; font-weight: 600; }
.table.compact td { padding: 6px 0; }
.table.compact td + td { padding-left: var(--s3); }
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); align-items: start; }
.detail-grid > .card + .card { margin-top: 0; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s4); }
.card + .card { margin-top: var(--s3); }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card h3 { margin: 0 0 var(--s3); font-size: var(--fs-md); color: var(--brand); }
.card h3:not(:first-child) { margin-top: var(--s4); }
.cancel-form { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.cancel-form p { margin: 0; }
/* Ticket 12: cancel lives in the progress block (chat panel); the order page keeps its own in the side card. */
.op-cancel { margin-top: 12px; }
.op-cancel .cancel-form { margin-top: 0; }
#order-live .op-cancel { display: none; }
.parcel-status { display: block; }
.sync-form { margin: 6px 0 0; }
@media (max-width: 767px) {
  .detail-grid { grid-template-columns: 1fr; }
  .row-4 { grid-template-columns: 1fr 1fr; }
}

/* ticket 05: paging buttons, privacy page */
#more-convs, #older-msgs { display: block; margin: 8px auto; }
.privacy { max-width: 720px; }
.privacy h3 { color: var(--brand); margin-bottom: 4px; }
.table .filters { margin: 0; flex-wrap: nowrap; }
.table .filters input:not([type="checkbox"]) { min-width: 140px; }

/* ticket 07: channel logos + customer status tags */
.ch-icon { flex: none; display: block; border-radius: 4px; }
.tag {
  align-self: flex-start;
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  white-space: nowrap;
  background: var(--white);
  color: var(--muted);
}
.tag-interested { background: #f4ebf0; border-color: #dcc4d1; color: var(--brand); }
.tag-ordered { background: #e9f3ec; border-color: #bcd9c5; color: #2b6a43; }
.tag-preordered { background: #ecf0f7; border-color: #c8d3e6; color: #2f4b7a; }
/* return / exchange: warm "needs attention", deliberately not the error red */
.tag-return_requested { background: #fbeee3; border-color: #ecc9a8; color: #8a4512; }
.tag-size_exchange { background: #fbf3dc; border-color: #e8d39a; color: #7a5a0b; }
.conv-main .tag { margin: 2px 0; }
.status-form { margin: 0; display: flex; gap: 6px; flex: none; max-width: 100%; }
select.tag-select { width: auto; max-width: 100%; font-size: 13px; padding: 3px 8px; cursor: pointer; font-weight: 500; }
select.tag-select option { background: var(--white); color: var(--ink); }
.thread-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-filter { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--white); z-index: 1; }
.tag-filter label { font-size: 13px; white-space: nowrap; }
.tag-filter select { flex: 1; min-width: 0; font-size: 14px; }

/* ticket 08: batch label print */
.print-labels { display: none; }
/* While labels print, the page holds only the label images, one per sheet, scaled to fit (never cropped): an A6 iShip label
   on 76x130 mm paper prints at about 72%. @page size comes from print.js (LABEL_PAGE_SIZE). */
@media print {
  body.printing-labels { display: block; margin: 0; padding: 0; background: #fff; }
  body.printing-labels > :not(.print-labels) { display: none !important; }
  body.printing-labels .print-labels { display: block; }
  .print-labels img { display: block; width: 100vw; height: 100vh; object-fit: contain; object-position: center; break-after: page; page-break-after: always; }
  .print-labels img:last-child { break-after: auto; page-break-after: auto; }
}
.print-toast { z-index: 30; max-width: calc(100% - 32px); }
.print-toast a { color: var(--white); }
.print-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 12px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: 0 -4px 12px rgba(42, 32, 41, .06);
}
.table .pick { width: 36px; text-align: center; }
.table .pick input { width: 18px; height: 18px; vertical-align: middle; }
.status-printed { background: #e9f3ec; border-color: #bcd9c5; color: #2b6a43; }
.op-links { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filters label.check { white-space: nowrap; }

/* ticket 09: returns + size exchanges (reuses the existing button, tag and status styles) */
.case-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.case-orders { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.case-orders li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.case-page .stack, form.stack { display: flex; flex-direction: column; gap: var(--s3); align-items: flex-start; margin: 0 0 var(--s3); }
.case-page .stack > label, .case-page .stack > form, .case-page .stack > .form-grid { width: 100%; margin: 0; }
.case-page form { margin: 0 0 8px; }
.case-form { display: flex; flex-direction: column; gap: 12px; }
.case-form .table td { vertical-align: top; }
.case-form .table select, .case-form .table input { min-width: 90px; }
.radio-row, .inspect { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s2) var(--s3); margin: 0; display: flex; gap: 12px; flex-wrap: wrap; width: 100%; }
.radio-row legend, .inspect legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.draft-note pre { white-space: pre-wrap; font: inherit; margin: 6px 0 0; }
.timeline { padding-left: 18px; margin: 0; display: flex; flex-direction: column; gap: 4px; }
/* R7b: one colour pair per status (needs-review orange, approved blue, awaiting-return plum tint, received solid
   accent = act now, completed green, rejected danger tint, cancelled muted); every text/background pair >= 4.5:1. */
.case-requested { background: #fbeee3; border-color: #ecc9a8; color: #8a4512; }
.case-approved { background: #eef3fb; border-color: #c9d8f0; color: #234a85; }
.case-awaiting_return { background: color-mix(in srgb, var(--accent) 10%, var(--white)); border-color: color-mix(in srgb, var(--accent) 35%, var(--white)); color: var(--brand); }
.case-received { background: var(--accent); border-color: var(--accent); color: var(--white); }
.case-completed { background: #e7f4ec; border-color: #b9dcc6; color: #2a7347; }
.case-rejected { background: #fde8ec; border-color: #f2b8c3; color: var(--danger); }
.case-cancelled { background: var(--bg); color: var(--muted); }
/* R7b: received case = numbered steps; reject/cancel apart under "ไม่ดำเนินการต่อ" */
.case-next { list-style: none; margin: 0 0 var(--s3); padding: 0; display: flex; flex-direction: column; gap: var(--s4); }
.case-next h4, .case-stop h4 { margin: 0 0 var(--s2); font-size: var(--fs-sm); }
.case-next li.done h4 { color: var(--muted); font-weight: 500; }
.case-stop { margin: var(--s5) 0 var(--s4); padding-top: var(--s3); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--s2); }
.case-stop h4 { color: var(--muted); font-weight: 500; }
.case-stop .cancel-form { margin-top: var(--s2); width: 100%; }
.case-stop .cancel-form label { width: 100%; }
.refund-confirm { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3); background: var(--white); }
.refund-confirm p { margin: 0; }
/* new-case form: the new-size column only for a size exchange (without :has() it stays visible; the server ignores it on returns) */
.case-form:has(.case-type input[value="return"]:checked) .new-size { display: none; }
.case-form .cell-label > span { display: none; } /* the column heading names it on desktop */
@media (max-width: 767px) {
  /* new-case form: one block per item instead of a sideways-scrolling table */
  .case-form .table, .case-form .table tbody, .case-form .table tr, .case-form .table td { display: block; width: 100%; }
  .case-form .table thead { display: none; }
  .case-form .table tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .case-form .table td { border: 0; padding: 4px 10px; text-align: left; }
  .case-form .cell-label > span { display: inline; }
  /* /cases: one card per case (case no + status, customer + type) like /orders */
  #cases-table, #cases-table tbody { display: block; }
  #cases-table thead, #cases-table :is(.k-date, .k-order, .k-phone) { display: none; }
  #cases-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "no status" "name type"; align-items: center; column-gap: var(--s2); row-gap: 2px; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); }
  #cases-table tbody tr:last-child { border-bottom: 0; }
  #cases-table td { border: 0; padding: 0; min-width: 0; }
  #cases-table .k-no { grid-area: no; }
  #cases-table .k-status { grid-area: status; justify-self: end; }
  #cases-table .k-name { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
  #cases-table .k-type { grid-area: type; justify-self: end; color: var(--muted); font-size: var(--fs-xs); }
}

/* ---------------------------------------------------------------- ticket 10: quick replies + images */
.warn-text { color: #6b4310; }
.quick { flex-basis: 100%; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.quick .chip { flex: none; white-space: nowrap; }
.quick .chip:disabled { text-decoration: none; }
.reply .warn { flex-basis: 100%; margin: 0; }
.qr-attach { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.qr-attach li { position: relative; }
.qr-attach img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.qr-remove { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 50%; line-height: 1; }
.bubble-img { padding: 0; overflow: hidden; display: block; }
.bubble-img img { display: block; max-width: min(240px, 100%); max-height: 320px; object-fit: contain; background: var(--white); }
.qr-picker { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.qr-picker form { display: flex; flex-direction: column; gap: 10px; }
.qr-picker h3 { margin: 0; }
.qr-products { list-style: none; margin: 0; padding: 0; overflow-y: auto; max-height: 50vh; display: flex; flex-direction: column; gap: 4px; }
.qr-picker-actions { display: flex; justify-content: flex-end; gap: 8px; }
.spec-images { margin-top: 24px; }
.spec-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.spec-list > li { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.spec-thumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.spec-thumb { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.spec-thumb img, .qr-image img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.spec-upload { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.spec-upload input[type="file"] { max-width: 100%; }
.qr-image { border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; gap: 6px; }

/* ---------------------------------------------------------------- ticket 11: product picker, role images */
.product-results { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); }
.product-results > li + li { border-top: 1px solid var(--line); }
.product-results > li.muted { padding: 10px 12px; }
.product-row { width: 100%; justify-content: flex-start; gap: 10px; padding: 6px 10px; background: none; border: 0; color: var(--ink); border-radius: 0; font-weight: 400; white-space: normal; text-align: left; }
.product-row:hover { background: var(--bg); }
.product-row.selected { background: #f4ebf0; box-shadow: inset 3px 0 0 var(--brand); }
.product-row:focus-visible { outline-offset: -2px; }
.product-row img, .product-row .thumb-empty { width: 48px; height: 64px; flex: none; border-radius: 6px; object-fit: cover; background: var(--bg); }
.thumb-empty { display: inline-block; width: 56px; height: 56px; border-radius: 6px; background: var(--bg); }
.pr-main { display: flex; flex-direction: column; min-width: 0; }
.qr-products > li { padding: 4px 0; }
.qr-colours { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 2px 0 4px 28px; }
.qr-colours label.check { font-size: 14px; gap: 6px; }
.role-slots { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.role-slot { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; width: 172px; }
.role-slot img, .role-empty { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; color: var(--muted); }
.role-slot form { margin: 0; }
.role-slot input[type="file"] { font-size: 12px; }
.role-pick { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.role-preview { position: relative; cursor: pointer; display: block; }
.role-preview .role-file { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; font-size: 0; }
.role-preview:hover img, .role-preview:hover .role-empty, .role-preview:focus-within img, .role-preview:focus-within .role-empty { outline: 2px solid var(--accent, #5b2140); outline-offset: 1px; }
.role-preview.picked img { border: 2px dashed var(--accent, #5b2140); }
.role-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.role-actions .cancel-form { margin-top: 0; }
.role-actions .cancel-form .op-links { flex-wrap: nowrap; }
.role-up-all { margin-top: var(--s2); }
@media (max-width: 767px) {
  /* ticket 31 R5: ดูรูป / ลบ / ยืนยัน are 40px tall on the phone */
  .role-actions a, .role-actions button { min-height: 40px; min-width: 40px; display: inline-flex; align-items: center; justify-content: center; padding-inline: var(--s2); }
  .role-slot { width: calc(50% - 6px); } /* two slots a row, so one colour fits a phone screen */
  .role-up-all { min-height: 40px; }
}

/* Ticket 14: stock page */
.tabs { display: flex; gap: var(--s1); }
.tabs a { display: inline-flex; align-items: center; min-height: var(--control-h-sm); padding: 4px var(--s3); line-height: 22px; border-radius: var(--radius); text-decoration: none; color: var(--muted); border: 1px solid transparent; }
.tabs a:hover { color: var(--brand); }
.tabs a[aria-current] { background: var(--white); color: var(--brand); border-color: var(--line); font-weight: 500; }
.page-head a.button-link[aria-current] { background: #f4ebf0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); margin-bottom: var(--s3); }
.tile { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: 2px; min-width: 0; min-height: 88px; }
.tile b { font-size: var(--fs-xl); font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; }
.tile b.tile-text { font-size: var(--fs-md); }
.filters .chips { align-items: center; }
a.chip { text-decoration: none; }
.stock-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 12px; align-items: start; }
.stock-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s4); min-width: 0; }
.stock-card[hidden] { display: none; }
.sc-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.sc-thumb { width: 48px; height: 64px; flex: none; border-radius: 6px; object-fit: cover; background: var(--bg); }
.sc-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sc-title .status { margin-left: 6px; }
.sc-meta { display: flex; flex-direction: column; align-items: flex-end; font-size: 14px; white-space: nowrap; }
.sc-grid { overflow-x: auto; }
.sc-grid table { border-collapse: collapse; width: 100%; font-size: 14px; }
.sc-grid th, .sc-grid td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.sc-grid th { font-weight: 500; color: var(--muted); }
.sc-grid tbody th { text-align: left; color: var(--ink); }
.sc-grid td.out { background: #fbe3e7; color: #a3243b; font-weight: 600; }
.sc-grid td.low { background: #fdf0d5; color: #6b4310; font-weight: 600; } /* user 2026-10-18: keep the yellow fill for 1–2 */
/* Ticket 68: stock page = design groups (header + numbers) over one card per colour; colour cards side by side on desktop. */
.stock-groups { display: block; }
.stock-group { padding: var(--s4) 0 var(--s5); border-top: 1px solid var(--line); }
.stock-group:first-child { border-top: 0; padding-top: 0; }
.sg-head { display: flex; gap: var(--s3); align-items: flex-start; margin-bottom: var(--s2); }
.sg-name { font-size: var(--fs-lg); font-weight: 600; color: var(--brand); line-height: 1.3; }
.sg-colours { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: var(--s3); align-items: start; }
.sc-colour { padding: var(--s3); }
.sc-colour .sc-head { align-items: flex-start; }
.sc-colour .sc-grid { overflow-x: visible; }
.sc-colour .sc-grid table { table-layout: fixed; }
.sc-colour .sc-grid th, .sc-colour .sc-grid td { padding: 6px 2px; font-variant-numeric: tabular-nums; }
.sc-grid td.none { color: var(--muted); }
/* Ticket 24: grid shows on hand by default; .show-total (stock.js toggle) swaps in on hand + incoming. */
.stock-view { margin-bottom: 12px; }
.q-total, .show-total .q-hand { display: none; }
.show-total .q-total { display: inline; }
/* opening count */
.opening-form .stock-card { margin-bottom: var(--s3); }
.count-grid td { vertical-align: top; }
.count-grid input.count { width: 64px; text-align: right; }
.count-grid input.count-ok { width: 20px; height: 20px; margin: 0 0 0 6px; vertical-align: middle; accent-color: var(--accent); }
.count-grid .warn-text { display: block; font-size: 12px; }
/* receive by lot */
.rc-cost { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.rc-cost input { width: 110px; text-align: right; }
.rc-qc { margin-top: 8px; }
.sc-cost { margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.sc-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); }
.sc-chip svg { width: 14px; height: 14px; color: var(--muted); }
.sc-chip.pos svg, .sc-chip.pos b { color: #2f7a4f; }
.sc-chip.neg svg, .sc-chip.neg b { color: #a3243b; }
.order-no { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.order-thumb { position: relative; flex: none; width: 40px; height: 40px; }
.order-thumb img, .order-thumb .thumb-empty { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; display: block; }
.qty-badge { position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; box-sizing: border-box; padding: 0 4px; border-radius: var(--radius-lg); background: var(--brand); color: var(--white); border: 2px solid var(--white); font-size: 12px; line-height: 16px; text-align: center; font-weight: 600; }
/* Ticket 15: purchase / lot / cost tables scroll inside their card instead of wrapping codes and dates. */
.stock-table td { white-space: nowrap; }
.stock-table td.model { white-space: normal; min-width: 180px; }
.cost-model { display: flex; gap: 10px; align-items: center; }

/* Product thumbnails in square boxes: anchor to the top so ghost-mannequin ("form") shots keep neckline and shoulders.
   Catalogue photos in the same boxes get the same top crop. */
.product-row img, .picker-head img, .chip.swatch img, .order-thumb img, img.sc-thumb, .role-slot img { object-position: center top; }
/* Order picker colour chips: own swatch, greyed when every size is out (still clickable to see sizes) */
.chip.swatch { display: inline-flex; align-items: center; gap: 6px; padding-left: 4px; }
.chip.swatch img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex: none; background: var(--bg); }
.chip.soldout { opacity: .45; }
/* Stock page summary cards: icon + label, trend line on ชิ้นคงเหลือ */
.tile-label { display: flex; align-items: center; gap: 6px; }
.tile-label svg { flex: none; width: 18px; height: 18px; }
.spark { display: block; width: 100%; height: 28px; margin-top: 4px; }
.spark polyline { fill: none; stroke: var(--brand); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark .spark-dot { stroke: var(--brand); stroke-width: 5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-empty { margin-top: 4px; }

/* Ticket 17: vendor product rows, reorder table, order message */
.vendor-products input, .vendor-products select, .reorder-table input, .reorder-table select { width: auto; }
.reorder-table select { max-width: 220px; }
.po-message textarea { margin-top: var(--s2); }
.tabs { flex-wrap: wrap; } /* 7 admin tabs: wrap on phones instead of widening the page */
.tabs a { white-space: nowrap; }

/* Ticket 18: dashboard */
.dash, .mkt { --up: #2f7d4f; --down: #a3243b; }
.dash .card { margin-bottom: var(--s3); min-width: 0; }
.dash .card + .card { margin-top: 0; }
.dash-period { align-items: flex-end; }
.dash-period .dash-date input { min-width: 0; width: 160px; flex: none; }
.dash-period button.on { box-shadow: 0 0 0 2px var(--accent); }
.kpi b { overflow-wrap: anywhere; }
.dash .tile-label svg { color: var(--muted); }
.dash-sec > summary { list-style: none; cursor: pointer; }
.dash-sec > summary::-webkit-details-marker { display: none; }
.dash-sec:not([open]) > summary h3 { margin-bottom: 0; }
.dash-sec .chev { margin-left: auto; display: flex; transform: rotate(180deg); transition: transform .15s; }
.dash-sec[open] > summary .chev { transform: rotate(-90deg); }
.delta { font-size: 12px; color: var(--muted); }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.review-line { display: flex; flex-wrap: wrap; gap: 6px 24px; align-items: baseline; }
.dash-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 1024px) { .dash-cols { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } .card .dash-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.legend { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 6px; }
span.swatch { display: inline-block; /* legend dash; not the order picker's .chip.swatch */ width: 14px; height: 3px; border-radius: 2px; }
.swatch.s-sales { background: var(--brand); }
.swatch.s-cost { background: var(--muted); }
.swatch.s-profit { background: var(--up); }
.trend { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px; }
.trend-y { position: relative; width: 52px; height: 220px; font-size: 12px; color: var(--muted); }
.trend-y span { position: absolute; right: 0; transform: translateY(-50%); white-space: nowrap; }
.trend-plot { min-width: 0; }
.trend-plot svg { display: block; width: 100%; height: 220px; overflow: visible; }
.trend-plot .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.trend-plot .grid.zero { stroke: var(--muted); }
.trend-plot .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.trend-plot .line.dot { stroke-width: 7; }
.trend-plot .s-sales { stroke: var(--brand); }
.trend-plot .s-cost { stroke: var(--muted); }
.trend-plot .s-profit { stroke: var(--up); }
.trend-plot .hit { fill: transparent; }
.trend-plot .hit:hover { fill: rgba(91, 33, 64, .06); }
.trend-x { position: relative; height: 18px; font-size: 12px; color: var(--muted); }
.trend-x span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.trend-x span:first-child { transform: none; }
.dash-model { display: flex; align-items: center; gap: 8px; }
.dash-models td.model { min-width: 160px; }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.bar-head { display: flex; justify-content: space-between; gap: 8px; }
.bar { height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; margin: 4px 0; }
.bar span { display: block; height: 100%; background: var(--brand); border-radius: 5px; }
a.tile-link { color: inherit; text-decoration: none; }
a.tile-link:hover { border-color: var(--accent); }
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank li { display: flex; align-items: center; gap: 8px; }
.rank li > span:nth-child(2) { flex: 1; min-width: 0; }
@media (max-width: 600px) { .trend-x span.alt { display: none; } .trend-y { width: 44px; } }
/* Ticket 19: dashboard customers / costs / shipping */
.dash .stack { display: flex; height: 14px; background: var(--bg); border-radius: 7px; overflow: hidden; margin: 4px 0 8px; }
.dash .stack span { display: block; height: 100%; }
.swatch.block { width: 10px; height: 10px; }
.c-goods { background: var(--brand); }
.c-inbound { background: var(--accent); }
.c-ship { background: var(--muted); }
.c-pack { background: #c9a227; }
.c-review { background: #d98ba8; }
.rank form { margin: 0; flex: none; }

/* Ticket 21: expenses */
a.tile-link.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.nowrap { white-space: nowrap; }
.bills { display: flex; gap: 4px; flex-wrap: wrap; }
.expense-form { max-width: 720px; }
.expense-form fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.expense-form .form-grid { margin-bottom: 0; }
/* Ticket 26: PO picker only for ค่าสั่งสินค้า (goods) */
.expense-form:not(:has(select[name="category"] option[value="goods"]:checked)) .po-pick { display: none; }
.bill-list { display: flex; gap: 8px; flex-wrap: wrap; }
.bill { display: flex; flex-direction: column; gap: 4px; }
.bill img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
/* Ticket 27 P&L */
.pnl { --tint: color-mix(in srgb, var(--brand) 6%, var(--white)); }
.pnl .pnl-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s3); margin-bottom: var(--s3); }
.pnl .pnl-month { display: flex; align-items: center; gap: var(--s2); }
.pnl .pnl-month .chip { justify-content: center; min-width: var(--control-h-sm); font-size: var(--fs-lg); text-decoration: none; }
.pnl .pnl-month b { white-space: nowrap; font-weight: 600; color: var(--brand); }
.pnl .chips a { text-decoration: none; }
.pnl .pnl-h { margin: var(--s4) 0 var(--s2); font-size: var(--fs-md); color: var(--brand); }
.pnl .pnl-overview { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); margin-bottom: var(--s3); }
@media (min-width: 1024px) { .pnl .pnl-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pnl .pnl-overview .card { margin: 0; }
.pnl .pnl-wf { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); }
.pnl .pnl-wf li { display: grid; grid-template-columns: 8.5em minmax(0, 1fr) 3.5em; gap: var(--s2); align-items: center; }
.pnl .pnl-wf-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pnl .pnl-wf-track { position: relative; height: 14px; background: var(--bg); border-radius: 3px; }
.pnl .pnl-wf-track span { position: absolute; top: 0; bottom: 0; min-width: 1px; background: var(--muted); border-radius: 3px; }
.pnl .pnl-wf li.total { font-weight: 600; }
.pnl .pnl-wf li.total span span { background: var(--brand); }
.pnl .pnl-wf li.neg span span { background: var(--down); }
.pnl .pnl-wf-val { text-align: right; font-variant-numeric: tabular-nums; }
.pnl .pnl-m6 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s2); }
.pnl .pnl-m6-col { display: flex; flex-direction: column; align-items: center; min-width: 0; }
/* Ticket 31: bars hang from a zero line (--zero from the top); a loss goes down. */
.pnl .pnl-m6-bars { position: relative; height: 140px; width: 100%; }
.pnl .pnl-m6-bars::after { content: ''; position: absolute; left: 0; right: 0; top: var(--zero); border-top: 1px solid var(--line); }
.pnl .pnl-m6-bars span { position: absolute; width: 40%; max-width: 18px; min-height: 1px; border-radius: 3px 3px 0 0; background: var(--brand); }
.pnl .pnl-m6-bars span.s { right: calc(50% + 1.5px); }
.pnl .pnl-m6-bars span.n { left: calc(50% + 1.5px); background: var(--up); }
.pnl .pnl-m6-bars span.n.neg { background: var(--down); }
.pnl .pnl-m6-bars span.below { border-radius: 0 0 3px 3px; }
.pnl .pnl-m6-col small { margin-top: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.pnl .pnl-m6-col small.v { margin-top: 0; color: var(--ink); font-variant-numeric: tabular-nums; }
.pnl .swatch.s-loss { background: var(--down); }
.pnl .pnl-month .chip.off { visibility: hidden; }
.pnl .pnl-table td:first-child, .pnl .pnl-table th:first-child { white-space: nowrap; }
.pnl .pnl-table tr.group td { padding-top: var(--s3); padding-bottom: var(--s1); font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.pnl .pnl-table tr.child td:first-child { padding-left: calc(var(--s3) + var(--s4)); }
.pnl .pnl-table tr.key td { background: var(--tint); font-weight: 600; }
.pnl .pnl-table tr.key td:first-child { border-left: 3px solid var(--brand); }
.pnl .pnl-table tr.net td { font-size: var(--fs-lg); border-bottom: 3px double var(--ink); }
.pnl .pnl-table td.up { color: var(--up); }
.pnl .pnl-table td.down { color: var(--down); }
.pnl .pnl-table :is(th, td) + :is(th, td) { border-left: 1px solid var(--line); } /* R6c: vertical grid */
.pnl .pnl-sub { display: block; font-size: var(--fs-xs); font-weight: 400; color: var(--muted); }
.pnl .pnl-set { display: block; font-weight: 400; }
/* Ticket 28: marketing tab (reuses the .pnl blocks) */
.mkt { --fb: #2a78d6; --ig: #e87ba4; --sales: #eb6834; --warn: #b26a12; }
.mkt .pnl-bar { margin-bottom: var(--s2); }
.mkt .mkt-sync { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-bottom: var(--s2); }
.mkt .mkt-sync form { margin: 0; }
.mkt-sq { display: inline-block; width: 8px; height: 8px; border-radius: 2px; vertical-align: middle; }
.mkt-sq.fb { background: var(--fb); }
.mkt-sq.ig { background: var(--ig); }
.mkt .swatch.mkt-line.fb { background: var(--fb); }
.mkt .swatch.mkt-line.ig { background: linear-gradient(90deg, var(--ig) 60%, transparent 0) 0 0 / 6px 3px repeat-x; }
.mkt .mkt-dot-key { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.mkt .trend-plot .mkt-line.fb { stroke: var(--fb); }
.mkt .trend-plot .mkt-line.ig { stroke: var(--ig); }
.mkt .trend-plot polyline.mkt-line.ig { stroke-dasharray: 6 4; }
.mkt .table td.num, .mkt .table th.num { white-space: nowrap; }
.mkt .mkt-tag { margin: 0; }
.mkt .mkt-tag select { min-width: 0; width: auto; max-width: 160px; font-size: var(--fs-sm); }
.mkt .mkt-prods { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-width: 200px; max-width: 280px; }
.mkt .mkt-prods .mkt-tag select { width: 96px; }
.mkt .mkt-chip { margin: 0; gap: 2px; padding-right: 4px; white-space: nowrap; max-width: 100%; min-width: 0; }
.mkt .mkt-chip span { overflow: hidden; text-overflow: ellipsis; }
.mkt .mkt-chip button { border: 0; background: none; padding: 0 4px; min-height: 0; line-height: 1; color: var(--muted); cursor: pointer; }
.mkt .badge { white-space: nowrap; }
/* Ticket 29: marketing visuals (Top 5 cards, funnel, bars, post thumbnails) */
.mkt .tile.kpi .spark { margin-top: auto; padding-top: 4px; }
.mkt-noimg { display: flex; align-items: center; justify-content: center; background: var(--bg); color: var(--muted); }
.mkt-noimg svg { width: 40%; height: 40%; max-width: 32px; max-height: 32px; }
.mkt .mkt-top { margin-bottom: var(--s3); scroll-margin-top: var(--s4); }
.mkt .mkt-top-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); margin: var(--s4) 0 var(--s2); }
.mkt .mkt-top-head .pnl-h { margin: 0; }
.mkt .mkt-top-note { margin: 0 0 var(--s2); }
.mkt .mkt-top-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s3); }
@media (max-width: 1023px) {
  .mkt .mkt-top-row { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 200px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: var(--s2); }
  .mkt .mkt-card { scroll-snap-align: start; }
}
.mkt .mkt-card { display: flex; flex-direction: column; min-width: 0; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; color: inherit; text-decoration: none; }
a.mkt-card:hover { border-color: var(--accent); }
.mkt .mkt-card-img { position: relative; aspect-ratio: 4 / 5; background: var(--bg); }
.mkt .mkt-card-pic { display: flex; width: 100%; height: 100%; object-fit: cover; }
.mkt .mkt-rank { position: absolute; top: 8px; left: 8px; min-width: 28px; padding: 2px 8px; border-radius: 999px; background: var(--brand); color: var(--white); font-size: var(--fs-sm); font-weight: 600; text-align: center; }
.mkt .mkt-fmt { position: absolute; top: 8px; right: 8px; background: var(--white); }
.mkt .mkt-card-body { display: flex; flex-direction: column; gap: 2px; padding: var(--s2) var(--s3) var(--s3); min-width: 0; }
.mkt .mkt-cap { margin: 0; font-size: var(--fs-sm); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em; }
.mkt .mkt-big { font-size: var(--fs-xl); font-weight: 600; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
/* Ticket 30: Top 5 insight rows: icon + short label + bold value; colour on the icon only (warning value too) */
.mkt .mkt-insec { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.mkt .mkt-insec-h { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; letter-spacing: .02em; }
.mkt .mkt-ins { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mkt .mkt-in { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 1.35; color: var(--ink); }
.mkt .mkt-in .sb-icon { width: 14px; height: 14px; color: var(--muted); }
.mkt .mkt-in.success .sb-icon { color: var(--up); }
.mkt .mkt-in.warning .sb-icon, .mkt .mkt-in.warning .mkt-in-v { color: var(--warn); }
.mkt .mkt-in-l { flex: 1; min-width: 0; }
.mkt .mkt-in-v { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mkt .mkt-fnote { margin: -8px 0 var(--s2); }
.mkt .mkt-funnel { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mkt .mkt-fstep { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); min-width: 0; padding: 6px var(--s3); border-radius: var(--radius); background: color-mix(in srgb, var(--fb) 12%, var(--white)); }
.mkt .mkt-fstep b, .mkt .mkt-fsales b { font-variant-numeric: tabular-nums; }
.mkt .mkt-frate { line-height: 1.2; }
.mkt .mkt-fsales { display: flex; justify-content: space-between; align-items: baseline; width: 100%; margin-top: var(--s2); padding-top: var(--s2); border-top: 3px solid var(--sales); }
.mkt .mkt-fsales b { color: var(--sales); font-size: var(--fs-lg); }
.mkt .mkt-fsplit { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); margin-top: var(--s3); padding-top: var(--s2); border-top: 1px solid var(--line); }
.mkt .mkt-fsplit > div { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.mkt .swatch.mkt-sw { width: 10px; height: 10px; }
.mkt .swatch.mkt-sw.fb { background: var(--fb); }
.mkt .swatch.mkt-sw.ig { background: var(--ig); }
.mkt .swatch.mkt-sw.sales { background: var(--sales); }
.mkt .mkt-track { display: flex; flex: 1; min-width: 0; height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.mkt .mkt-track span { display: block; height: 100%; background: var(--brand); }
.mkt .mkt-track .fb { background: var(--fb); }
.mkt .mkt-track .ig { background: var(--ig); }
.mkt .mkt-track .sales { background: var(--sales); }
.mkt .mkt-pnum { flex: none; min-width: 64px; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mkt .mkt-pbars { display: flex; flex-direction: column; gap: var(--s3); }
.mkt .mkt-prow { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
@media (min-width: 768px) { .mkt .mkt-prow { grid-template-columns: minmax(160px, 1.2fr) minmax(0, 2fr) minmax(0, 1.4fr); gap: var(--s3); align-items: center; } }
.mkt .mkt-pname { min-width: 0; display: flex; align-items: center; gap: var(--s2); }
.mkt .mkt-ptxt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkt .mkt-pimg { flex: none; width: 40px; height: 50px; border-radius: 4px; object-fit: cover; object-position: top; background: var(--tint); }
.mkt .mkt-pbar { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.mkt .mkt-types { margin-top: var(--s3); }
.mkt .mkt-types > input { position: absolute; opacity: 0; pointer-events: none; }
.mkt .mkt-types-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); }
.mkt .mkt-types-head h3 { margin: 0; }
.mkt .mkt-types label.chip { cursor: pointer; }
#mkt-by-cat:checked ~ .mkt-types-head label[for="mkt-by-cat"], #mkt-by-fmt:checked ~ .mkt-types-head label[for="mkt-by-fmt"], #mkt-by-sty:checked ~ .mkt-types-head label[for="mkt-by-sty"] { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
#mkt-by-cat:focus-visible ~ .mkt-types-head label[for="mkt-by-cat"], #mkt-by-fmt:focus-visible ~ .mkt-types-head label[for="mkt-by-fmt"], #mkt-by-sty:focus-visible ~ .mkt-types-head label[for="mkt-by-sty"] { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Ticket 45: group tables (medians at AGE_DAYS), one shown per radio; Reel watch line wraps */
.mkt .mkt-tgroup { display: none; }
#mkt-by-cat:checked ~ .by-cat, #mkt-by-fmt:checked ~ .by-fmt, #mkt-by-sty:checked ~ .by-sty { display: block; }
.mkt .mkt-watch { overflow-wrap: anywhere; }
.mkt .mkt-posts td { vertical-align: top; }
.mkt .mkt-post { display: flex; gap: var(--s2); min-width: 200px; max-width: 320px; }
.mkt .mkt-thumb { flex: none; width: 34px; height: 34px; border-radius: 6px; object-fit: cover; }
.mkt .mkt-post-text { display: flex; flex-direction: column; min-width: 0; }
.mkt .mkt-post-text > a, .mkt .mkt-post-text > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkt .mkt-split { display: block; white-space: nowrap; }
.mkt .mkt-labels { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
/* Ticket 30: audience (ผู้ชม) and buyers (ใครซื้อจริง) */
.mkt .au-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.mkt .au-ic { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: color-mix(in srgb, var(--ig) 14%, transparent); color: var(--ig); }
.mkt .au-ic .sb-icon { width: 16px; height: 16px; }
.mkt .au-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr)); gap: var(--s2); margin-bottom: var(--s3); }
.mkt .au-kpi { display: flex; gap: 10px; align-items: center; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 10px 12px; min-width: 0; }
.mkt .au-kpi .au-ic { width: 34px; height: 34px; border-radius: 10px; }
.mkt .au-kpi .au-ic .sb-icon { width: 18px; height: 18px; }
.mkt .au-kpi.warn .au-ic { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.mkt .au-kpi.ok .au-ic { background: color-mix(in srgb, var(--up) 14%, transparent); color: var(--up); }
.mkt .au-kpi > div { min-width: 0; }
.mkt .au-kpi b { display: block; font-size: var(--fs-xl); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.mkt .au-kpi .l { display: block; font-size: 12px; color: var(--muted); line-height: 1.35; }
.mkt .au-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: var(--s3); margin-bottom: var(--s3); }
.mkt .au-grid > .card { margin: 0; }
.mkt .au-ch { display: flex; gap: 10px; align-items: flex-start; margin-bottom: var(--s2); }
.mkt .au-ch h3 { margin: 0; }
.mkt .au-ch p { margin: 2px 0 0; }
.mkt .au-ins { display: flex; gap: var(--s2); align-items: flex-start; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin-bottom: var(--s3); }
.mkt .au-ins > .sb-icon { width: 16px; height: 16px; margin-top: 1px; color: var(--warn); }
.mkt .au-insight { margin: 0; font-size: 13px; line-height: 1.5; }
.mkt .au-insight b { font-weight: 600; }
.mkt .au-bars { display: grid; gap: var(--s2); }
.mkt .au-bar { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) minmax(3.5rem, auto); align-items: center; gap: var(--s2); font-size: 13px; }
.mkt .au-bar .lb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.mkt .au-bar .tr { display: block; height: 14px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.mkt .au-bar .fill { display: block; height: 100%; border-radius: 4px; }
.mkt .au-bar .v { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mkt .au-stack { display: flex; height: 14px; border-radius: 4px; overflow: hidden; gap: 2px; }
.mkt .au-stack span { display: block; }
.mkt .au-legend { margin: var(--s2) 0 0; }
.mkt .au-split-list { display: grid; gap: var(--s3); }
.mkt .au-split-list p { margin: 0 0 4px; }
.mkt .au-split { display: flex; height: 28px; border-radius: 6px; overflow: hidden; gap: 2px; }
.mkt .au-split span { display: block; min-width: 2px; }
.mkt .au-split-lg { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px var(--s2); margin-top: 6px; font-variant-numeric: tabular-nums; }
.mkt .au-foot { margin: var(--s2) 0 0; }
.mkt .au-cols { display: flex; align-items: flex-end; gap: 2px; height: 90px; border-bottom: 1px solid var(--line); }
.mkt .au-cols > div { flex: 1; display: flex; align-items: flex-end; min-width: 0; height: 100%; }
.mkt .au-cols span { display: block; width: 100%; border-radius: 2px 2px 0 0; background: var(--fb); }
.mkt .au-hx { display: flex; justify-content: space-between; margin-top: 4px; }
.mkt .au-heat { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; }
.mkt .au-heat span { height: 28px; border-radius: 2px; background: var(--bg); }
.mkt .au-lock { display: flex; gap: var(--s2); align-items: baseline; }
.mkt .au-big { font-size: var(--fs-xl); font-weight: 600; font-variant-numeric: tabular-nums; }
.mkt .au-prog { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-top: var(--s2); }
.mkt .au-prog span { display: block; height: 100%; background: var(--muted); }
.mkt .au-demo { display: grid; gap: var(--s3); }

/* Install-app button (mobile bar) and the iPhone help dialog. */
.mobile-bar .install-btn { margin-left: auto; min-height: var(--control-h-sm); padding: 4px 12px; font-size: var(--fs-sm); }
.install-help { max-width: min(360px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s4); }
.install-help::backdrop { background: rgba(42, 32, 41, .45); }
.install-help ol { padding-left: 20px; margin: var(--s2) 0 var(--s4); }
.install-help form { margin: 0; text-align: right; }

/* Dashboard on phones: whole baht, compact period filter and tiles, P&L table cut to the columns that matter. */
@media (max-width: 767px) {
  .dash .dec { display: none; }
  .dash .dec.keep { display: inline; } /* ticket 33: small amounts (cost/chat, CPC) keep satang */
  .page-main.dash { padding: var(--s3); }
  .dash .card { padding: var(--s3); }
  .dash-period { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--s2); }
  .dash-period .chips { grid-column: 1 / -1; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--s3)); padding: 2px var(--s3); }
  .dash-period .chip { flex: none; }
  .dash-period .dash-date { min-width: 0; }
  .filters.dash-period .dash-date input { width: 100%; min-width: 0; padding-inline: 8px; font-size: var(--fs-sm); }
  .dash .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .dash .tile { padding: 10px 12px; min-height: 0; }
  .dash .tile b { font-size: var(--fs-lg); }
  .dash .tiles > .tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .dash .table-wrap th:first-child, .dash .table-wrap td:first-child { position: sticky; left: 0; z-index: 1; background: var(--white); }
  .pnl .pnl-table :is(th, td) { padding-inline: 6px; }
  .pnl .pnl-table td:first-child { white-space: normal; min-width: 7em; }
}

/* ---------------------------------------------------------------- ticket 31 R1: phone chat-first */
/* unread chats badge: inbox nav item + mobile bar (nav.js fills it) */
.nav-badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--white); font-size: 12px; font-weight: 600; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.nav-badge[hidden] { display: none; }
.sb-link .nav-badge { margin-left: auto; }
.mobile-bar .brand { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
@media (min-width: 768px) {
  .sb-collapsed .sb-link { position: relative; }
  .sb-collapsed .sb-link .nav-badge { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; line-height: 18px; }
  #panel-chat { display: none; } /* the chat stays beside the panel */
}
/* order panel on a phone: newest customer messages on top */
.panel-chat .msg { max-width: 100%; }
.panel-chat .bubble { padding: 6px 10px; }
/* row checkboxes: the whole 40px cell is the hit area */
.pick-hit { display: inline-grid; place-items: center; min-width: 40px; min-height: 40px; cursor: pointer; }
.table .pick { padding-inline: 2px; width: 44px; }
@media (max-width: 767px) {
  /* tap targets at least 40px */
  .chip, .tabs a { min-height: var(--control-h); }
  .sb-burger { min-width: 40px; min-height: 40px; }
  .dash-sec > summary { display: flex; align-items: center; min-height: 40px; }
  .dash-sec > summary h3 { flex: 1; }
  .back, .back-link { display: inline-flex; align-items: center; min-height: 40px; padding-inline: var(--s1); }
  /* /orders: one card per order (T86, 3 lines: order + amount, recipient + status, delivery) instead of the table */
  #orders-table, #orders-table tbody { display: block; }
  #orders-table thead { display: none; }
  #orders-table tr { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: "pick no total" "pick no pay" "pick name status" "pick track track"; align-items: center; column-gap: var(--s2); row-gap: 2px; padding: var(--s2) var(--s3) var(--s2) 0; border-bottom: 1px solid var(--line); }
  #orders-table tbody tr:last-child { border-bottom: 0; }
  #orders-table td { border: 0; padding: 0; min-width: 0; }
  #orders-table .pick { grid-area: pick; width: auto; }
  #orders-table .o-no { grid-area: no; }
  #orders-table .o-total { grid-area: total; font-weight: 600; }
  #orders-table .o-pay { grid-area: pay; justify-self: end; }
  #orders-table .o-name { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #orders-table .o-name .o-phone { display: inline; }
  #orders-table .o-name .o-phone::before { content: " · "; }
  #orders-table .o-status { grid-area: status; }
  #orders-table .o-status :is(form, .button-link) { display: none; }
  #orders-table .o-track { grid-area: track; padding-top: 4px; }
}
.neg-amt { color: var(--danger); white-space: nowrap; }
/* Ticket 31 R3: lighter pages. */
.head-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.stock-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--s4); margin: 0 0 var(--s3); }
.stock-summary b { font-variant-numeric: tabular-nums; }
.stock-summary a { color: inherit; }
.stock-summary .spark { display: inline-block; vertical-align: middle; width: 64px; height: 18px; margin: 0 0 0 6px; }
.po-add { display: flex; flex-direction: column; gap: 4px; max-width: 420px; margin-bottom: var(--s3); }
.order-detail .op-head > a { display: none; } /* order no is the page heading; the live status badge stays */
.dash-summary { font-size: var(--fs-md); margin: 0 0 var(--s3); }
/* Ticket 31 R6: the "ต้องทำ" strip under the summary. */
.dash-todo { margin: 0 0 var(--s3); }
.dash-todo ul { list-style: none; margin: 4px 0 0; padding: 0; }
.dash-todo a { display: inline-flex; align-items: center; min-height: var(--control-h-sm); }
/* Tiles inside a dashboard card read as stat groups, not cards in a card. */
details.card .tile { background: none; border-color: transparent; padding-inline: 0; min-height: 0; }
@media (max-width: 767px) {
  .page-head .head-actions { width: 100%; }
}
/* Ticket 31 R4: product photos larger (3:4, top crop), states, motion. */
.stock-card .sc-thumb, .picker-head img, .picker-head .thumb-empty { width: 60px; height: 80px; flex: none; }
/* Primary hover/press. Element-level specificity: every classed button (secondary, ghost, chip, row) keeps its own look. */
button:where(:hover:not(:disabled)), a.button-link:where(:hover) { background-color: var(--accent); border-color: var(--accent); }
button:where(:active:not(:disabled)), a.button-link:where(:active) { filter: brightness(.94); }
.chip:where(:hover:not(:disabled)) { border-color: var(--accent); }
summary:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button[aria-busy="true"] { cursor: progress; }
::selection { background: #f4ebf0; color: var(--brand); }
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------- ticket 31 R5: products section */
/* Sidebar sub-menu: the current group opens under its parent; collapsed rail shows parents only (they open the first page). */
.sb-link[aria-current="true"] { color: var(--brand); font-weight: 600; }
.sb-sub { list-style: none; margin: 2px 0 4px; padding: 0 0 0 32px; display: flex; flex-direction: column; gap: 1px; }
.sb-sublink { display: flex; align-items: center; min-height: 34px; padding: 6px 12px; border-radius: var(--radius); color: var(--muted); text-decoration: none; font-size: var(--fs-sm); white-space: nowrap; }
.sb-sublink:hover { background: var(--bg); color: var(--brand); }
.sb-sublink[aria-current="page"] { background: #f4ebf0; color: var(--brand); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand); }
.sb-sublink:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (min-width: 768px) {
  .sb-collapsed .sb-sub { display: none; }
}
@media (max-width: 767px) {
  .sb-sublink { min-height: 44px; font-size: var(--fs-md); }
}
/* Section › page heading */
.page-head h2 .crumb { color: var(--muted); font-weight: 400; font-size: var(--fs-lg); }
.sync-at { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* ⋯ menu on คงเหลือ */
.more-menu { position: relative; }
.more-menu > summary { list-style: none; display: grid; place-items: center; min-width: var(--control-h); min-height: var(--control-h); border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); color: var(--brand); cursor: pointer; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu > summary:hover { border-color: var(--accent); }
.more-menu[open] > summary { background: #f4ebf0; }
.more-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 180px; padding: 4px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(42, 32, 41, .14); }
.more-list a { display: flex; align-items: center; min-height: var(--control-h); padding: 6px 12px; border-radius: 6px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.more-list a:hover, .more-list a:focus-visible { background: var(--bg); color: var(--brand); outline: none; }
/* KPI cards = stock filters */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s2); margin-bottom: var(--s3); }
.kpi { position: relative; display: flex; flex-direction: column; gap: 0; min-width: 0; padding: 10px 14px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); color: var(--ink); text-decoration: none; }
.kpi:where(a):hover, .kpi-btn:has(button:hover) { border-color: var(--accent); }
.kpi.on { background: #f4ebf0; border-color: var(--brand); }
.kpi.on .tile-label { color: var(--brand); }
.kpi:focus-visible, .kpi-btn button:focus-visible, .kpi-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.kpi .tile-label { font-size: var(--fs-sm); color: var(--muted); }
.kpi .tile-label svg { width: 16px; height: 16px; }
.kpi b { font-size: var(--fs-lg); font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-note { font-size: var(--fs-xs); color: var(--muted); }
.kpi-val { display: flex; flex-direction: column; }
.kpi .spark { width: 100%; height: 18px; margin-top: 2px; }
.kpi-btn { padding: 0; }
.kpi-btn button { all: unset; box-sizing: border-box; display: flex; flex-direction: column; width: 100%; height: 100%; padding: 10px 14px; border-radius: var(--radius-lg); cursor: pointer; }
.kpi-link { position: absolute; top: 4px; right: 4px; padding: 6px 10px; font-size: var(--fs-xs); border-radius: var(--radius); }
.stock-search { margin-bottom: var(--s3); }
@media (max-width: 767px) {
  .page-main:has(> .kpis) { padding-top: var(--s1); }
  .page-main:has(> .kpis) > .page-head { margin-bottom: 6px; flex-wrap: nowrap; }
  .page-main:has(> .kpis) > .page-head h2 { font-size: var(--fs-lg); white-space: nowrap; }
  .page-main:has(> .kpis) > .page-head h2 .crumb { font-size: var(--fs-md); }
  .page-main:has(> .kpis) > .page-head .head-actions { width: auto; flex-wrap: nowrap; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 2px; }
  .kpi, .kpi-btn button { padding: 4px 10px; max-height: 64px; }
  .kpi.kpi-main, .pnl .kpi { max-height: none; } /* ticket 31: the main profit keeps its two secondary lines; P&L tiles keep their change line */
  .kpi .tile-label { line-height: 1.25; }
  .kpi b { line-height: 1.2; }
  .kpi-btn { padding: 0; }
  .kpi .spark { display: none; }
  .kpi-val { flex-direction: row; align-items: baseline; gap: 4px; min-width: 0; }
  .kpi-val .kpi-note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* units stay on the phone: ไซซ์-สี vs แบบ */
  .kpi-cost { display: none; } /* phone: 2×2; มูลค่าทุน stays on desktop and under ต้นทุน */
  .kpi-link { top: 0; right: 0; min-height: 40px; display: inline-flex; align-items: center; } /* 40px tap target */
  .stock-search { position: sticky; top: var(--mbar-h, 53px); z-index: 9; background: var(--bg); margin: 0 calc(-1 * var(--s4)); padding: var(--s1) var(--s4); }
}
/* Ticket 31 R5: receive form, sticky total + submit; models not on the purchase order fold away */
.receive-bar { justify-content: space-between; }
.receive-bar b { font-variant-numeric: tabular-nums; }
.receive-bar [data-reset-counts] { margin-left: auto; } /* ticket 40: buttons sit together on the right */
@media (max-width: 600px) { .receive-bar > span:first-child { flex-basis: 100%; } .receive-bar [data-reset-counts] { margin-left: 0; } .receive-bar button { flex: 1; } }
.more-models { margin-bottom: var(--s3); }
.more-models > summary { min-height: 40px; display: flex; align-items: center; cursor: pointer; color: var(--accent); font-weight: 500; }
.more-models > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: var(--radius); }
.more-models[open] > summary { margin-bottom: var(--s2); }

/* ---------------------------------------------------------------- ticket 31 R6b: dashboard */
/* กำไรหลังค่าใช้จ่าย is the main figure: first, two columns wide, larger number. */
.kpi.kpi-main { grid-column: span 2; }
.kpi.kpi-main > b { font-size: var(--fs-xl); }
/* Phone-only switcher for the pages of one menu (desktop has the sidebar sub-menu); ticket 55: แดชบอร์ด 2, การตลาด 4. */
.dash-switch { flex-wrap: wrap; margin: calc(-1 * var(--s2)) 0 var(--s3); }
.dash-switch .chip { flex: 1 1 auto; justify-content: center; white-space: nowrap; text-decoration: none; }
@media (min-width: 768px) { .dash-switch { display: none; } }
/* Contrast ≥ 4.5:1 for coloured text (bars/icons keep the lighter tone). */
.mkt .mkt-fsales b { color: color-mix(in srgb, var(--sales) 70%, #000); }
.mkt .mkt-in.warning .mkt-in-v { color: color-mix(in srgb, var(--warn) 80%, #000); }
/* English source term next to the Thai label, small. */
.tile-label:has(.en) { flex-wrap: wrap; column-gap: 4px; row-gap: 0; }
.tile-label .en { font-size: 11px; color: var(--muted); white-space: nowrap; }
/* No cards in cards: insight box and tables inside a card lose their own frame. */
.mkt .au-ins { background: none; border: 0; padding: 0; }
.card .table-wrap { border: 0; border-radius: 0; background: none; }
/* Post labels: read-only until แก้ป้าย opens the controls. */
.mkt .mkt-edit > summary { display: inline-flex; align-items: center; min-height: var(--control-h-sm); color: var(--accent); cursor: pointer; }
.mkt .mkt-edit[open] { display: flex; flex-direction: column; gap: 4px; }
.mkt .mkt-edit .mkt-tag { display: flex; gap: 4px; align-items: center; }
.mkt .mkt-chip button { min-width: 28px; min-height: 28px; justify-content: center; }
@media (max-width: 767px) {
  .kpi.kpi-main { grid-column: 1 / -1; }
  .dash .tiles:has(> .kpi-main) > .tile:last-child { grid-column: auto; } /* main tile is the full row; the other six pair up */
  /* marketing tiles keep their second line and change (no 64px clip) */
  .mkt .kpi { max-height: none; }
  .mkt .kpi .small { overflow-wrap: anywhere; }
  .tile-label .en { display: none; }
  /* 40px tap targets */
  .mkt .mkt-chip button { min-width: 40px; min-height: 40px; margin: -8px -4px -8px 0; }
  .mkt .mkt-edit > summary, .mkt .mkt-edit button, .mkt .mkt-sync button { min-height: 40px; }
  .dash .tile a, .dash-sec p > a, .dash-todo a { display: inline-flex; align-items: center; min-height: 40px; }
}

/* ---------------------------------------------------------------- R7a: settings sub-pages, staff pages */
.settings-form { scroll-margin-top: 64px; } /* #anchor after save clears the sticky phone bar */
.tag.tag-temp { font-size: 11px; padding: 0 6px; vertical-align: 1px; background: #fbf3dc; border-color: #e8d39a; color: #7a5a0b; }
.settings-form .qr-image { border: 0; padding: 0; margin: 0; min-width: 0; }
.settings-form .qr-image legend { padding: 0; margin-bottom: var(--s1); color: var(--muted); font-size: var(--fs-xs); }
label.check.remove-check { min-height: 44px; align-self: flex-start; padding-right: var(--s2); cursor: pointer; }
label.check.remove-check input { width: 20px; height: 20px; }
.tgt-table .m-short { display: none; }
@media (max-width: 767px) {
  .tgt-table .m-long { display: none; }
  .tgt-table .m-short { display: inline; }
}
.staff-list { list-style: none; margin: 0 0 var(--s4); padding: 0; display: flex; flex-direction: column; gap: var(--s2); max-width: 720px; }
.staff-row { display: grid; grid-template-columns: 1fr 6em 5em; align-items: center; gap: var(--s3); color: var(--ink); text-decoration: none; }
.staff-row:hover { border-color: var(--brand); }
.staff-row.off .staff-name { color: var(--muted); }
.staff-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 767px) {
  .staff-row { grid-template-columns: auto 1fr; gap: var(--s1) var(--s3); }
  .staff-name { grid-column: 1 / -1; }
}
.cancel-form > .form-grid { align-self: stretch; margin: 0; }
.kv dd.mono { overflow-wrap: anywhere; }
/* Ticket 32: several bills in one new-expense save */
.bill-rows { display: flex; flex-direction: column; gap: 12px; }
.bill-rows > p { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bill-row { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.bill-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; min-height: var(--control-h); }

/* Ticket 33/34: ads + marketing strategy pages. One answer card, 3–4 headline tiles, the rest folded. */
.strat { margin-bottom: var(--s3); }
.strat h3 { margin: 0 0 var(--s2); font-size: var(--fs-md); color: var(--brand); }
.strat-answer { margin: 0 0 var(--s1); font-size: var(--fs-xl); font-weight: 600; line-height: 1.3; text-wrap: balance; }
.strat-answer.up, .strat-band.up { color: var(--up); }
.strat-answer.down, .strat-band.down { color: var(--danger); }
.strat-answer.check, .strat-band.check { color: var(--accent); }
.strat-band { font-weight: 600; }
.strat-why { margin: 0; max-width: 72ch; line-height: 1.6; }
.strat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); max-width: 80ch; }
.strat-list li { display: grid; grid-template-columns: 4.5em minmax(0, 1fr); gap: var(--s2); line-height: 1.6; }
.strat-list li > b { color: var(--brand); }
.strat-list a { white-space: nowrap; }
.fold { margin-top: var(--s4); }
.fold > summary { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s3) var(--s4); }
.fold > summary h3 { margin: 0; font-size: var(--fs-md); color: var(--brand); }
.fold[open] > summary { margin-bottom: var(--s3); }
.fold-title { white-space: nowrap; }
.fold > .tiles.kpis { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.fold-hint { font-weight: 400; }
.fold .pnl-h:first-of-type { margin-top: var(--s3); }
/* Ad pictures: square crop from the top so each card's number stays in view. */
.mkt .ads-creatives .mkt-card-img { aspect-ratio: 1; overflow: hidden; }
.mkt .ads-creatives .mkt-card-pic { object-position: center top; }
@media (min-width: 1024px) { .mkt .ads-creatives { grid-template-columns: repeat(auto-fill, minmax(180px, 220px)); } }
.mkt .mkt-card.ads-best { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ads-pace-sub { padding-left: var(--s3); }
.mkt-ads-table td.ads-set, .ads-who td.ads-set { padding-left: 1.25rem; }
.ads-who td.ads-set { white-space: nowrap; }
.mkt-ads-table td.ads-ad { padding-left: 2.5rem; }
.strat-band.muted { color: var(--muted); }
.fold > .chips { margin-bottom: var(--s3); }

/* Ticket 37: receive page picture zoom */
.thumb-zoom { padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: var(--radius); line-height: 0; }
.thumb-zoom:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
dialog.zoom { padding: 0; border: 0; border-radius: var(--radius-lg); background: var(--white); max-width: min(92vw, 640px); max-height: 92vh; overflow: hidden; }
dialog.zoom::backdrop { background: rgb(42 32 41 / 0.7); }
dialog.zoom img { display: block; max-width: min(92vw, 640px); max-height: 92vh; object-fit: contain; }
dialog.zoom form { position: absolute; top: var(--s2); right: var(--s2); }
.zoom-close { background: var(--white); border-radius: 50%; width: var(--control-h); height: var(--control-h); }

/* Ticket 38: purchase order card link to add a colour/size */
.po-add-sku { display: inline-block; margin-top: var(--s2); }

/* ---------------------------------------------------------------- ticket 42: public home (reveclothingth.com) */
body.home-body { display: block; }
.home-body ::selection { background: #ead9e1; color: var(--ink); }
.home { max-width: 680px; margin: 0 auto; padding: 72px var(--s4) var(--s6); }
.home [lang="en"] { display: block; color: var(--muted); }
.home-head { text-align: center; padding-bottom: 56px; border-bottom: 1px solid var(--line); }
.home-mark { margin: 0; font-size: clamp(44px, 12vw, 72px); font-weight: 500; line-height: 1.1; letter-spacing: .22em; padding-inline-start: .22em; }
.home-kind { margin: var(--s5) auto 0; max-width: 34em; font-size: var(--fs-md); line-height: 1.7; text-wrap: balance; }
.home-kind [lang="en"] { font-size: var(--fs-sm); }
.home-section { padding-block: 48px 0; }
.home-section h2 { margin: 0 0 var(--s5); font-size: var(--fs-lg); font-weight: 600; color: var(--brand); line-height: 1.4; }
.home-section h2 [lang="en"] { display: inline; margin-inline-start: var(--s2); font-size: var(--fs-sm); font-weight: 400; }
.home-channels { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.home-channel {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 64px; padding: var(--s3) var(--s4);
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg);
  color: var(--ink); text-decoration: none;
  transition: border-color .2s ease-out, box-shadow .2s ease-out;
}
.home-channel:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(91, 33, 64, .08); }
.home-channel svg { flex: none; width: 24px; height: 24px; }
.home-channel-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.home-channel-name { font-weight: 600; }
.home-channel-handle { font-size: var(--fs-sm); color: var(--muted); overflow-wrap: anywhere; }
.home-facts { margin: 0; }
.home-facts > div { padding-block: var(--s4); border-top: 1px solid var(--line); }
.home-facts > div:last-child { border-bottom: 1px solid var(--line); }
.home-facts dt { font-size: var(--fs-sm); color: var(--muted); }
.home-facts dt [lang="en"] { display: inline; margin-inline-start: 6px; font-size: var(--fs-xs); }
.home-facts dd { margin: var(--s1) 0 0; line-height: 1.7; }
.home-facts dd [lang="en"] { margin-top: 2px; font-size: var(--fs-sm); }
.home-facts address { font-style: normal; }
.home-legal-name { font-size: var(--fs-lg); font-weight: 600; letter-spacing: .02em; }
.home-foot { margin-top: 56px; display: flex; flex-direction: column; align-items: center; gap: var(--s5); text-align: center; font-size: var(--fs-sm); }
.home-foot nav { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2) var(--s5); }
.home-foot a { text-underline-offset: 3px; }
.home-foot a.home-staff { font-size: var(--fs-xs); color: var(--muted); }
@media (min-width: 640px) {
  .home { padding-top: 112px; }
  .home-channels { grid-template-columns: repeat(3, 1fr); }
  .home-facts > div { display: grid; grid-template-columns: 200px 1fr; gap: var(--s4); }
  .home-facts dt { padding-top: 2px; }
  .home-facts dt [lang="en"] { display: block; margin: 0; }
  .home-facts dd { margin: 0; }
}
@media (prefers-reduced-motion: reduce) { .home-channel { transition: none; } }

/* ticket 50: chat came from an ad */
.tag.ad-badge { align-self: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
/* ticket 59: status + ad chips on one wrapping row in the chat list; Meta vs app chat count on the ads page */
.conv-chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.conv-chips .tag { margin: 2px 0; white-space: nowrap; }
.mk-linked { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.ad-form { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.ad-form select { max-width: 100%; min-width: 0; }

/* ---------------------------------------------------------------- ticket 51: connection health */
.health-bar { flex: none; display: flex; align-items: center; gap: var(--s2); padding: 6px var(--s4); background: #fff4e5; border-bottom: 1px solid #f0d2a8; color: #6b4310; font-size: var(--fs-sm); line-height: 1.4; }
.health-bar.is-failed { background: #fde8ec; border-color: #f2b8c3; color: var(--danger); }
.health-bar .sb-icon { width: 18px; height: 18px; }
.health-bar p { margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* ticket 56: one line */
@media (max-width: 767px) { .health-bar .hb-wide { display: none; } }
.health-bar a, .health-bar > span { flex: none; color: inherit; font-weight: 600; text-underline-offset: 3px; }
.health .card { max-width: 880px; }
.health > p.ok, .health > p.warn { max-width: 880px; }
.health-list { list-style: none; margin: 0; padding: 0; }
.health-row { display: grid; gap: var(--s1) var(--s4); padding: var(--s3) 0; border-top: 1px solid var(--line); }
.health-row:first-child { border-top: 0; padding-top: 0; }
.health-row:last-child { padding-bottom: 0; }
.health-name { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); }
.health-facts { min-width: 0; font-size: var(--fs-sm); }
.health-facts p { margin: 0; }
.health-facts p + p { margin-top: 2px; }
.health-facts time { font-variant-numeric: tabular-nums; }
.health-tag.is-ok { background: #e9f3ec; border-color: #bcd9c5; color: #2b6a43; }
.health-tag.is-quiet, .health-tag.is-expiring { background: #fff4e5; border-color: #f0d2a8; color: #6b4310; }
.health-tag.is-failed { background: #fde8ec; border-color: #f2b8c3; color: var(--danger); }
.health-error { color: var(--danger); overflow-wrap: anywhere; }
.health-todo { font-weight: 600; color: var(--ink); }
.health-rules { max-width: 880px; margin-top: var(--s4); }
@media (min-width: 640px) {
  .health-row { grid-template-columns: 220px 1fr; align-items: start; }
}

/* ---------------------------------------------------------------- ticket 52 parts kept by ticket 57: the panel's forms, media, results, history */
.mk2 .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pp-sec { padding-top: var(--s3); margin-top: var(--s3); border-top: 1px solid var(--line); }
.pp-sec h4 { margin: 0 0 var(--s2); font-size: var(--fs-sm); color: var(--brand); }
.pp-dl { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); margin: var(--s2) 0; padding: 0; }
.pp-dl a { display: inline-flex; align-items: center; min-height: 40px; }
.pp-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); margin: 0; }
.pp-results div { background: var(--bg); border-radius: var(--radius); padding: var(--s2); }
.pp-results dt { font-size: var(--fs-xs); color: var(--muted); }
.pp-results dd { margin: 0; font-weight: 700; font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.pp-media { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--s2); margin: 0 0 var(--s3); padding: 0; }
.pp-media li { display: flex; flex-direction: column; gap: 2px; }
.pp-media img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: center top; border-radius: 6px; display: block; }
.pp-ref-pic { position: relative; display: block; }
.pp-ref-pic img { filter: saturate(.55); }
.pp-ref-label { position: absolute; inset: auto 0 0 0; padding: 4px 6px; background: rgba(42, 32, 41, .82); color: var(--white); font-size: 11px; font-weight: 700; line-height: 1.3; text-align: center; border-radius: 0 0 6px 6px; }
.pp-media-del button { min-height: 32px; padding-inline: 0; }
.pp-upload { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3); border: 1px dashed var(--line); border-radius: var(--radius); }
.pp-kind { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pp-kind label.check { min-height: 32px; }
.pp-upload button { align-self: flex-start; }
.pp-form fieldset { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2) var(--s3); min-width: 0; }
.pp-form fieldset:disabled { opacity: .7; }
.pp-form .pp-full { grid-column: 1 / -1; }
.pp-form button.pp-full { justify-self: start; }
.pp-hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); font-size: var(--fs-sm); }
.pp-hist li { display: flex; flex-wrap: wrap; gap: 2px var(--s2); }
.pp-hist-note { flex-basis: 100%; color: var(--ink); overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- ticket 56: marketing v2 (card language)
   From work/SALES-APP/marketing-redesign-2026-11-15/_src/mock-v2.css. Everything is `mk-*` under main.mk2 so it does
   not meet the app's own .card / .tile / .chip; 57/58 add their page parts (board, rank, adset, flow) here. */
:root { /* T91: --mk-* tokens moved here from .mk2 (same values) so every page can read them */
  --mk-card: #fff; --mk-tint: #f4ebf0; --mk-hair: #ece1e6;
  --mk-rose: #fbe9ee; --mk-sand: #f8f0e2; --mk-sage: #e9f3ec; --mk-sky: #ecf0f7; --mk-fog: #f3eeef;
  --mk-ok: #2b6a43; --mk-wait: #7a5a0b; --mk-ready: #2f4b7a; --mk-back: #8a4512; --mk-on-brand-2: #ead7e0;
  --mk-r-card: 18px; --mk-r-btn: 10px;
  --mk-shadow: 0 1px 2px rgba(91, 33, 64, .05), 0 12px 24px -18px rgba(91, 33, 64, .22);
}
.page-main.mk2 { max-width: 1280px; margin: 0; padding: 20px 32px 64px; }
.mk2 :where(h1, h2, p, ol, ul) { margin: 0; }
.mk2 :where(ol, ul) { padding: 0; list-style: none; }
.mk2 > .ok { margin: 0 0 var(--s3); }
.mk-ic { width: 18px; height: 18px; flex: none; }
.mk-ch { width: 16px; height: 16px; flex: none; border-radius: 4px; vertical-align: -3px; }
.mk-chtxt { font-size: 12px; color: var(--muted); }
.mk-val, .mk-ms, .mk-sizes { font-variant-numeric: tabular-nums; }
.mk-grow { flex: 1; }
.mk-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border: 1px solid var(--brand); border-radius: var(--mk-r-btn); background: var(--brand); color: #fff; font-weight: 500; text-decoration: none; white-space: nowrap; }
.mk-btn.light { background: #fff; color: var(--brand); border-color: #fff; }
.mk-btn .mk-ic { width: 16px; height: 16px; }

/* source chip: the campaign a post / plan item belongs to, or Organic */
.mk-src { display: inline-block; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: -4px; margin-left: 4px; padding: 0 8px; border-radius: 999px; background: var(--mk-tint); color: var(--brand); font-size: 12px; line-height: 20px; }
.mk-src.organic { background: var(--mk-fog); color: var(--muted); }

/* phone tabs + context row (campaign switcher, status line, data freshness) */
.mk-tabs { display: none; }
.mk-ctx { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; min-height: 44px; }
.mk-scope { display: flex; align-items: center; gap: 8px 14px; flex: 1; flex-wrap: wrap; min-width: 0; }
.mk-pick { position: relative; min-width: 0; }
.mk-pick > summary { list-style: none; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px 0 6px; background: var(--mk-card); border: 1px solid var(--mk-hair); border-radius: 14px; box-shadow: var(--mk-shadow); cursor: pointer; font-weight: 600; }
.mk-pick > summary::-webkit-details-marker { display: none; }
.mk-pick > summary .mk-ic:first-child { width: 32px; height: 32px; padding: 7px; border-radius: 10px; background: var(--mk-tint); color: var(--brand); }
.mk-pick > summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mk-pick > summary .mk-ic:last-child { color: var(--muted); }
.mk-menu { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: max-content; min-width: 100%; max-width: min(420px, 92vw); background: #fff; border: 1px solid var(--mk-hair); border-radius: 14px; box-shadow: 0 16px 32px -12px rgba(42, 32, 41, .3); padding: 6px; }
.mk-menu a { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 40px; padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.mk-menu a:hover { background: var(--mk-tint); }
.mk-menu a[aria-current] { color: var(--brand); font-weight: 600; background: var(--mk-tint); }
.mk-menu hr { border: 0; border-top: 1px solid var(--mk-hair); margin: 4px 0; }
.mk-menu .act { color: var(--accent); justify-content: flex-start; gap: 8px; }
.mk-menu .mk-sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.mk-pill { font-size: 12px; font-weight: 600; padding: 0 8px; border-radius: 999px; background: var(--mk-fog); color: var(--muted); white-space: nowrap; }
.mk-pill.keep { background: var(--mk-sage); color: var(--mk-ok); }
.mk-meta { color: var(--muted); font-size: 14px; }
.mk-meta b { font-weight: 600; color: var(--ink); }
.mk-meta b.run { color: var(--mk-ok); }
.mk-fresh { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.mk-fresh.stale { color: var(--mk-back); }
.mk-fresh button { border-color: var(--line); }

/* dashboard grid + cards */
.mk-dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.mk-dash .c3 { grid-column: span 3; } .mk-dash .c4 { grid-column: span 4; } .mk-dash .c5 { grid-column: span 5; }
.mk-dash .c7 { grid-column: span 7; } .mk-dash .c12 { grid-column: span 12; }
.mk-card { display: flex; flex-direction: column; min-width: 0; background: var(--mk-card); border: 1px solid var(--mk-hair); border-radius: var(--mk-r-card); box-shadow: var(--mk-shadow); }
.mk-card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0; }
.mk-card-h h2 { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; line-height: 1.4; }
.mk-card-h h2 small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.mk-more { font-size: 13px; white-space: nowrap; }
.mk-card-b { flex: 1; padding: 10px 16px 16px; }
.mk-card-f { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; padding: 10px 16px; border-top: 1px solid var(--mk-hair); font-size: 13px; color: var(--muted); }
.mk-card-f > .mk-ic { width: 16px; height: 16px; }
.mk-count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.mk-tile { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 10px; background: var(--mk-tint); color: var(--brand); flex: none; }
.mk-tile.rose { background: var(--mk-rose); color: var(--danger); }
.mk-tile.sand { background: var(--mk-sand); color: var(--mk-wait); }
.mk-tile.sage { background: var(--mk-sage); color: var(--mk-ok); }
.mk-tile.sky { background: var(--mk-sky); color: var(--mk-ready); }
.mk-tile.fog { background: var(--mk-fog); color: var(--muted); }

/* banner: the one plum field on a page */
.mk-banner { display: flex; align-items: center; gap: 14px 24px; flex-wrap: wrap; padding: 20px 24px; border-radius: var(--mk-r-card); background: var(--brand); color: #fff; box-shadow: var(--mk-shadow); }
.mk-banner h1 { font-size: 24px; font-weight: 600; line-height: 1.35; text-wrap: balance; }
.mk-banner p { color: var(--mk-on-brand-2); font-size: 14px; margin-top: 2px; }
.mk-banner .txt { flex: 1; min-width: 240px; }
.mk-round { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--mk-on-brand-2); }
.mk-days { display: flex; gap: 4px; flex-wrap: wrap; max-width: 260px; }
.mk-days li { width: 22px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .26); }
.mk-days .done, .mk-days .now { background: #fff; }
.mk-days .now { box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); }

/* KPI card */
.mk-kpi .mk-card-h h2 { font-weight: 500; color: var(--muted); font-size: 14px; }
.mk-val { font-size: 28px; font-weight: 600; line-height: 1.25; }
.mk-val.dim { color: var(--muted); }
.mk-val small { font-size: 14px; font-weight: 400; color: var(--muted); }
.mk-note { display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; margin-top: 4px; font-size: 13px; color: var(--muted); }
.mk-note.mk-warn { color: var(--mk-back); }
.mk-note span { display: inline-flex; align-items: center; gap: 4px; }
.mk-nodata { font-size: 15px; color: var(--muted); padding: 6px 0 2px; }
.mk-bar { position: relative; height: 6px; border-radius: 3px; background: #efe5e9; margin: 10px 0 6px; }
.mk-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--brand); }
.mk-bar u { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); border-radius: 1px; }

/* status chip: icon + word, one vocabulary for ad sets and posts */
.mk-st { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px 0 6px; border-radius: 999px; background: var(--mk-fog); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.mk-st .mk-ic { width: 14px; height: 14px; }
.mk-st.close { background: var(--mk-rose); color: var(--danger); }
.mk-st.watch, .mk-st.pending { background: var(--mk-sand); color: var(--mk-wait); }
.mk-st.keep, .mk-st.posted { background: var(--mk-sage); color: var(--mk-ok); }
.mk-st.ready { background: var(--mk-sky); color: var(--mk-ready); }
.mk-st.returned { background: #fbeee3; color: var(--mk-back); }

/* list rows inside cards */
.mk-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--mk-hair); color: inherit; text-decoration: none; }
.mk-rows > li:first-child > .mk-row { border-top: 0; padding-top: 2px; }
a.mk-row:hover .mk-t b { color: var(--brand); }
.mk-t { flex: 1; min-width: 0; }
.mk-t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-t b em { font-style: normal; color: var(--danger); }
.mk-t small { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-t small .mk-ch + .mk-ch { margin-left: 2px; }
.mk-t small:has(.mk-src) { white-space: normal; } /* the source chip never gets cut off */
.mk-row > .mk-ic:last-child { color: #b9a6ae; }
.mk-row.later .mk-t b { font-weight: 500; }
.mk-sublabel { padding: 10px 0 0; border-top: 1px solid var(--mk-hair); font-size: 12px; color: var(--muted); }
.mk-sublabel + li > .mk-row { border-top: 0; }
.mk-calm { display: flex; align-items: center; gap: 8px; padding: 6px 0; color: var(--muted); font-size: 14px; }
.mk-thumb { display: block; width: 40px; height: 50px; border-radius: 8px; object-fit: cover; background: var(--bg); flex: none; }
.mk-nopic, .mk-thumb.mkt-noimg { display: flex; align-items: center; justify-content: center; border: 1px dashed var(--line); color: var(--muted); }
.mk-thumb.mkt-noimg svg { width: 16px; height: 16px; }
.mk-stack { display: inline-flex; flex: none; }
.mk-stack img + img { margin-left: -16px; box-shadow: 0 0 0 2px #fff; }
.mk-m { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink); white-space: nowrap; }
.mk-m .mk-ic { width: 14px; height: 14px; color: var(--muted); }
.mk-card-f .mk-m { color: var(--muted); }
.mk-ms { display: flex; gap: 12px; flex: none; }
.mk-na { font-size: 13px; color: var(--muted); }
.mk-rows.cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 24px; }
.mk-rows.cols > li > .mk-row { border-top: 0; padding-top: 2px; }
.mk-emptybox { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 8px 8px; text-align: center; color: var(--muted); font-size: 14px; }
.mk-emptybox .mk-tile { width: 44px; height: 44px; border-radius: 14px; }
.mk-emptybox .mk-tile .mk-ic { width: 22px; height: 22px; }
.mk-emptybox b { color: var(--ink); font-weight: 600; }

/* week strip with pictures */
.mk-wk { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.mk-wk > div { text-align: center; min-width: 0; }
.mk-wk .d { display: block; font-size: 12px; color: var(--muted); }
.mk-wk .n { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; font-size: 14px; font-weight: 600; margin: 2px 0 6px; }
.mk-wk .today .n { background: var(--brand); color: #fff; }
.mk-wk .p { position: relative; display: block; aspect-ratio: 4 / 5; border-radius: 8px; background: var(--bg); margin-bottom: 6px; color: var(--muted); }
.mk-wk .p img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; display: block; }
.mk-wk .p.nopic { display: flex; align-items: center; justify-content: center; border: 1px dashed var(--line); }
.mk-wk .badge { position: absolute; right: -3px; bottom: -3px; display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: var(--mk-fog); color: var(--muted); box-shadow: 0 0 0 2px #fff; }
.mk-wk .badge .mk-ic { width: 13px; height: 13px; }
.mk-wk .badge.posted { background: var(--mk-ok); color: #fff; }
.mk-wk .badge.ready { background: var(--mk-ready); color: #fff; }
.mk-wk .badge.pending { background: #e3c25a; color: #4a3500; }
.mk-wk .badge.returned { background: #cf8a4f; color: #fff; }

/* stock per size */
.mk-sizes { display: flex; gap: 4px; flex: none; }
.mk-sizes span { min-width: 34px; padding: 2px 4px; text-align: center; border-radius: 8px; background: var(--bg); font-size: 11px; line-height: 1.35; color: var(--muted); }
.mk-sizes span b { display: block; color: var(--ink); font-size: 13px; font-weight: 600; }
.mk-sizes .out { background: var(--mk-rose); }
.mk-sizes .out b { color: var(--danger); }

@media (max-width: 1100px) and (min-width: 768px) {
  .mk-dash .c3 { grid-column: span 6; }
  .mk-dash .c4, .mk-dash .c5, .mk-dash .c7 { grid-column: span 12; }
  .mk-rows.cols { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .page-main.mk2 { padding: 0 16px 64px; }
  .mk-tabs { display: flex; gap: 4px; margin: 0 -16px 12px; padding: 8px 16px; background: #fff; border-bottom: 1px solid var(--mk-hair); }
  .mk-tabs a { flex: 1; text-align: center; padding: 6px 0; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; }
  .mk-tabs a[aria-current] { background: var(--mk-tint); color: var(--brand); font-weight: 600; }
  .mk-ctx { display: block; margin-bottom: 12px; min-height: 0; }
  .mk-scope { gap: 6px 10px; }
  .mk-pick { width: 100%; }
  .mk-pick > summary .mk-ic:last-child { margin-left: auto; }
  .mk-meta { font-size: 13px; }
  .mk-fresh { justify-content: flex-end; margin-top: 4px; }
  .mk-fresh button { min-height: 28px; padding: 2px 10px; font-size: 13px; }
  .mk-dash { gap: 12px; }
  .mk-dash .c4, .mk-dash .c5, .mk-dash .c7, .mk-dash .c12 { grid-column: span 12; }
  .mk-dash .c3 { grid-column: span 6; }
  .mk-dash .o1 { order: 1; } .mk-dash .o2 { order: 2; } .mk-dash .o3 { order: 3; } .mk-dash .o4 { order: 4; }
  .mk-dash .o5 { order: 5; } .mk-dash .o6 { order: 6; } .mk-dash .o7 { order: 7; } .mk-dash .o8 { order: 8; }
  .mk-banner { padding: 16px; gap: 12px; }
  .mk-banner h1 { font-size: 21px; }
  .mk-banner .txt { min-width: 0; flex-basis: 100%; }
  .mk-banner .mk-btn { width: 100%; }
  .mk-kpi .mk-card-h { padding: 12px 12px 0; gap: 8px; }
  .mk-kpi .mk-card-b { padding: 8px 12px 12px; }
  .mk-val { font-size: 24px; }
  .mk-kpi .mk-tile { width: 28px; height: 28px; border-radius: 9px; }
  .mk-kpi .mk-tile .mk-ic { width: 16px; height: 16px; }
  .mk-t b, .mk-t small { white-space: normal; }
  .mk-ms { gap: 8px; }
  .mk-row.wrap { flex-wrap: wrap; }
  .mk-row.wrap .mk-ms, .mk-row.wrap .mk-sizes { width: 100%; padding-left: 52px; }
  .mk-rows.cols { grid-template-columns: 1fr; }
  .mk-rows.cols > li + li > .mk-row { border-top: 1px solid var(--mk-hair); padding-top: 10px; }
}

/* ---------------------------------------------------------------- ticket 57: คอนเทนต์ (แผน / ผลโพสต์), from mock-v2.css */
.mk-btn.secondary { background: #fff; color: var(--brand); border-color: var(--line); }
.mk-btn.secondary:hover { background: var(--mk-tint); }
button.mk-btn { font: inherit; font-weight: 500; cursor: pointer; }
.mk-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--mk-r-btn); color: var(--muted); }
.mk-iconbtn:hover { background: var(--mk-tint); color: var(--brand); }
.mk-pagebar { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 16px; }
.mk-pagebar h1 { font-size: 24px; font-weight: 600; line-height: 1.3; }
.mk-seg { display: inline-flex; background: #f1e7ec; border-radius: 12px; padding: 3px; }
.mk-seg a { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none; }
.mk-seg a[aria-current] { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 1px 2px rgba(42, 32, 41, .12); }
.mk-seg .mk-ic { width: 16px; height: 16px; }
.mk-weeknav { display: inline-flex; align-items: center; gap: 2px; background: var(--mk-card); border: 1px solid var(--mk-hair); border-radius: 12px; padding: 2px; }
.mk-weeknav b { font-weight: 600; padding: 0 8px; white-space: nowrap; font-size: 14px; font-variant-numeric: tabular-nums; }
.mk-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mk-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; background: var(--mk-card); border: 1px solid var(--mk-hair); border-radius: 999px; color: var(--ink); font-size: 14px; line-height: 22px; text-decoration: none; white-space: nowrap; }
.mk-chip b { font-weight: 600; font-variant-numeric: tabular-nums; }
.mk-chip .mk-ic { width: 15px; height: 15px; color: var(--muted); }
.mk-chip:hover { border-color: var(--line); }
.mk-chip.on { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.mk-chip.on .mk-ic { color: var(--brand); }
.mk-filters { margin-bottom: 16px; }
.mk-subnote { margin: -8px 0 12px; font-size: 13px; color: var(--muted); }
.mk-flag { display: inline-flex; color: var(--mk-wait); }
.mk-flag .mk-ic { width: 14px; height: 14px; }
.mk2 > .ok, .mk2 > .error, .mk2 > .warn { margin: 0 0 12px; }
.mk-calm.mk-plan-empty { justify-content: center; padding: 24px 0; }

/* plan: week board + detail panel */
.mk-plan { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.mk-plan.has-panel { grid-template-columns: minmax(0, 1fr) 340px; }
.mk-plan-main { min-width: 0; }
.mk-board { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.mk-dcol { min-width: 0; min-height: 380px; padding: 0 6px 8px; background: var(--mk-card); border: 1px solid var(--mk-hair); border-radius: 14px; box-shadow: var(--mk-shadow); }
.mk-dcol > header { display: flex; align-items: center; gap: 6px; padding: 10px 4px 8px; font-size: 12px; color: var(--muted); line-height: 1.3; }
.mk-dcol > header b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 14px; font-weight: 600; }
.mk-dcol > header > span { flex: 1; min-width: 0; }
.mk-dcol.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--mk-shadow); }
.mk-dcol.today > header b { color: var(--brand); }
.mk2 input.mk-sel, .mk2 input.mk-dsel { width: 16px; height: 16px; min-height: 0; margin: 0; flex: none; accent-color: var(--brand); }
.mk-post { position: relative; display: block; margin-bottom: 12px; }
.mk-post .pic { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; aspect-ratio: 4 / 5; border-radius: 10px; overflow: hidden; background: var(--bg); color: var(--muted); font-size: 12px; text-decoration: none; }
.mk-post .pic.nopic { border: 1px dashed var(--line); }
.mk-post .pic > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.mk-post .when { position: absolute; left: 4px; top: 4px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px 2px 3px; border-radius: 999px; background: rgba(255, 255, 255, .95); font-size: 12px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.mk-post .when .mk-ch { width: 15px; height: 15px; }
.mk-post .ref { position: absolute; left: 4px; bottom: 4px; padding: 0 6px; border-radius: 6px; background: rgba(42, 32, 41, .82); color: #fff; font-size: 11px; line-height: 18px; }
.mk-post .mk-sel { position: absolute; right: 5px; top: 5px; }
.mk-post .ttl { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 6px 2px 5px; font-size: 13px; font-weight: 500; line-height: 1.4; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.mk-post .ttl:hover { color: var(--brand); }
.mk-post .meta { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.mk-post .mk-src { display: inline-block; max-width: 100%; margin: 4px 0 0; vertical-align: 0; }
.mk-post.open .pic, .mk-post:has(.mk-sel:checked) .pic { outline: 2px solid var(--brand); outline-offset: 2px; }
.mk-res { display: flex; flex-wrap: wrap; gap: 8px; margin: 5px 2px 0; }
.mk-res .mk-m { font-size: 12px; font-variant-numeric: tabular-nums; }
.mk-res.none { font-size: 12px; color: var(--muted); }
.mk-addp { display: flex; align-items: center; justify-content: center; min-height: 30px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); }
.mk-addp:hover { border-color: var(--brand); color: var(--brand); }
.mk-addp .mk-ic { width: 14px; height: 14px; }
.mk-agenda { display: none; }
.mk-scrim { display: none; }

.mk-detail { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.mk-detail .mk-card-h h2 { overflow-wrap: anywhere; }
.mk-x { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--mk-r-btn); color: var(--muted); flex: none; }
.mk-x:hover { background: var(--mk-tint); color: var(--brand); }
.mk-dmeta { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.mk-detail > .mk-card-b > :is(.ok, .error, .warn) { margin: 0 0 10px; }
.mk-bigpic { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; margin: 0 auto 12px; width: 190px; aspect-ratio: 4 / 5; border-radius: 12px; overflow: hidden; background: var(--bg); color: var(--muted); font-size: 13px; }
.mk-bigpic.nopic { border: 1px dashed var(--line); }
.mk-bigpic > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.mk-bigpic .ref { position: absolute; left: 6px; bottom: 6px; padding: 0 6px; border-radius: 6px; background: rgba(42, 32, 41, .82); color: #fff; font-size: 11px; line-height: 18px; }
.mk-cap { margin-bottom: 8px; padding: 10px 12px; border-radius: 12px; background: var(--bg); font-size: 14px; }
.mk-cap p { white-space: pre-line; overflow-wrap: anywhere; }
.mk-cap button { margin-top: 8px; }
.mk-info > li { display: flex; align-items: center; gap: 12px; padding: 7px 0; border-top: 1px solid var(--mk-hair); font-size: 14px; }
.mk-info > li > .mk-ic { width: 16px; height: 16px; color: var(--muted); }
.mk-info > li > span { width: 64px; flex: none; color: var(--muted); }
.mk-info > li > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.mk-dsec { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--mk-sky); }
.mk-dsec h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--mk-ready); }
.mk-inline { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.mk-dacts { margin: 12px 0 8px; }
.mk-dacts input[name="note"] { width: 100%; }
.mk-dacts .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.mk-dacts .row button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.mk-dacts .row .mk-ic { width: 16px; height: 16px; }
.mk-linkbtn { min-height: 32px; margin-top: 4px; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.mk-linkbtn:hover { background: none; color: var(--brand); }
.mk-dmore { margin-top: 4px; font-size: 14px; }
.mk-dmore > summary { display: inline-flex; align-items: center; min-height: 32px; color: var(--accent); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.mk-hist { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--mk-hair); font-size: 13px; color: var(--muted); }
.mk-hist > p { display: flex; align-items: flex-start; gap: 6px; }
.mk-hist > p .mk-ic { width: 15px; height: 15px; margin-top: 2px; }
.mk-hist details { margin-top: 6px; }
.mk-hist summary { cursor: pointer; }
.mk-hist .pp-hist { margin-top: 6px; }

/* bottom bar: only while something is ticked (CSS :has, so it works before plan.js runs) */
.mk-bulk { position: sticky; bottom: 0; z-index: 6; display: none; align-items: center; gap: 8px; margin: 24px -32px -64px; padding: 10px 32px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--mk-hair); box-shadow: 0 -8px 20px -12px rgba(42, 32, 41, .35); }
.mk2:has(.mk-sel:checked) .mk-bulk { display: flex; }
.mk-bulk > p { flex: 1; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mk-bulk .mk-ic { width: 16px; height: 16px; }
.mk-bulk [hidden] { display: none; }
.mk-ret { position: relative; }
.mk-ret > summary { list-style: none; cursor: pointer; }
.mk-ret > summary::-webkit-details-marker { display: none; }
.mk-ret-pop { position: absolute; right: 0; bottom: calc(100% + 8px); display: flex; flex-direction: column; gap: 8px; width: min(320px, 86vw); padding: 12px; background: #fff; border: 1px solid var(--mk-hair); border-radius: 14px; box-shadow: 0 16px 32px -12px rgba(42, 32, 41, .3); }

/* results: boost cards, ranked list */
.mk-dash .c8 { grid-column: span 8; }
.mk-boost { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mk-boost > li { display: flex; gap: 12px; min-width: 0; padding: 10px; border-radius: 14px; background: var(--bg); }
.mk-boost .mk-bpic { width: 72px; height: 90px; border-radius: 10px; object-fit: cover; flex: none; }
.mk-boost .mk-t { font-size: 13px; }
.mk-boost .mk-t b { white-space: normal; font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mk-boost .mk-t small { display: flex; align-items: center; gap: 4px; margin: 2px 0 6px; font-size: 12px; }
.mk-boost .mk-m { display: flex; }
.mk-bwarn { display: flex; align-items: flex-start; gap: 4px; margin-top: 4px; color: var(--mk-back); font-size: 12px; }
.mk-bwarn .mk-ic { width: 13px; height: 13px; margin-top: 2px; }
.mk-boost .mk-st { margin-top: 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.mk-bsrc { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.mk-bsrc .mk-src { margin: 0; vertical-align: 0; }
.mk-rank-h, .mk-rank > li { display: grid; grid-template-columns: 22px 40px minmax(0, 1.5fr) minmax(0, 1.1fr) 104px 96px minmax(0, 1fr); gap: 12px; align-items: center; }
.mk-rank-h { padding-bottom: 6px; border-bottom: 1px solid var(--mk-hair); font-size: 12px; color: var(--muted); }
.mk-rank-h > * { display: inline-flex; align-items: center; gap: 4px; }
.mk-rank-h a { color: var(--muted); text-decoration: none; }
.mk-rank-h a:hover, .mk-rank-h a.on { color: var(--brand); }
.mk-rank-h a.on { font-weight: 600; }
.mk-rank-h .mk-ic { width: 13px; height: 13px; }
.mk-rank > li { padding: 9px 0; border-top: 1px solid var(--mk-hair); }
.mk-rank > li:first-child { border-top: 0; }
.mk-rank .no { text-align: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mk-rank .mk-t > a, .mk-rank .mk-t > b { display: block; font-weight: 500; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-rank .mk-t > a:hover { color: var(--brand); }
.mk-rank .mk-t small { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; white-space: normal; }
.mk-rank .mk-t small .mk-src { margin: 0; vertical-align: 0; }
.mk-rank .mk-m b { font-weight: 600; font-variant-numeric: tabular-nums; }
.mk-rank .mk-m small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.mk-meter { display: flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; }
.mk-meter > span { flex: 1; height: 8px; border-radius: 4px; background: #efe5e9; overflow: hidden; }
.mk-meter i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.mk-meter b { min-width: 34px; text-align: right; font-weight: 600; }
.mk-nodata-row { grid-column: 4 / 7; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.mk-nodata-row .mk-ic { width: 15px; height: 15px; }
.mk-tags { min-width: 0; }
.mk-tags .mkt-labels { display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-start; }
.mk-tagc { display: inline-block; font-size: 12px; line-height: 20px; padding: 0 8px; border-radius: 999px; background: var(--mk-tint); color: var(--brand); white-space: nowrap; }
summary.mk-tagc { list-style: none; cursor: pointer; background: none; border: 1px dashed var(--line); color: var(--muted); }
summary.mk-tagc::-webkit-details-marker { display: none; }
summary.mk-tagc.edit { border-style: solid; border-color: transparent; text-decoration: underline; text-underline-offset: 3px; padding: 0 4px; }
.mk-tags .mkt-edit[open] { flex-basis: 100%; }
.mk-rank-more > summary { display: inline-flex; align-items: center; min-height: 36px; margin-top: 4px; color: var(--accent); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.mk-rank-more > summary::-webkit-details-marker { display: none; }
.mk-rank-more[open] > summary { display: none; }
.mk-fold { min-width: 0; }

@media (max-width: 1100px) {
  .mk-plan.has-panel { grid-template-columns: minmax(0, 1fr); }
  .mk-plan.has-panel .mk-detail { position: fixed; z-index: 30; top: 0; right: 0; bottom: 0; width: min(420px, 100%); max-height: none; border-radius: 0; }
  .mk-plan.has-panel .mk-scrim { display: block; position: fixed; inset: 0; z-index: 29; background: rgba(42, 32, 41, .35); }
  .mk-dash .c8 { grid-column: span 12; }
  .mk-boost { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) and (min-width: 768px) {
  .mk-board { overflow-x: auto; grid-template-columns: repeat(7, minmax(120px, 1fr)); }
}
@media (max-width: 767px) {
  .mk-pagebar { margin-bottom: 12px; }
  .mk-pagebar h1 { display: none; }
  .mk-pagebar .mk-seg { flex: 1 0 100%; }
  .mk-pagebar .mk-seg a { flex: 1; justify-content: center; }
  .mk-pagebar .mk-grow { display: none; }
  .mk-pagebar > .mk-btn { margin-left: auto; }
  .mk-weeknav { flex: 1; justify-content: space-between; }
  .mk-filters, .mk-pagebar .mk-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 12px; padding: 2px 16px; width: calc(100% + 32px); scrollbar-width: none; }
  .mk-pagebar .mk-chips { margin-bottom: 0; }
  .mk-board { display: none; }
  .mk-agenda { display: flex; flex-direction: column; gap: 12px; }
  .mk-aday .mk-card-h { padding: 10px 14px 0; }
  .mk-aday .mk-card-h h2 { font-size: 14px; }
  .mk-aday .mk-card-b { padding: 4px 14px 6px; }
  .mk-aday.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--mk-shadow); }
  .mk-arow { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--mk-hair); }
  .mk-arow:first-child { border-top: 0; }
  .mk-arow > a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 0; color: inherit; text-decoration: none; }
  .mk-arow .mk-thumb { width: 52px; height: 65px; border-radius: 10px; }
  .mk-arow .mk-t b { margin: 1px 0 4px; }
  .mk-arow .mk-t small { display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; }
  .mk-arow .mk-t small .mk-ic { width: 14px; height: 14px; }
  .mk-arow .mk-t small .mk-src { margin: 0; vertical-align: 0; }
  .mk-arow .mk-res { margin: 0; }
  .mk-arow .line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
  .mk-arow.open .mk-t b { color: var(--brand); }
  .mk2 .mk-arow input.mk-sel { width: 22px; height: 22px; }
  .mk-plan.has-panel .mk-detail { top: auto; left: 0; width: 100%; max-height: 92vh; border-radius: var(--mk-r-card) var(--mk-r-card) 0 0; }
  .mk-bulk { margin: 24px -16px -64px; padding-inline: 16px; }
  .mk-bulk > p { font-size: 13px; }
  .mk-bulk .mk-btn { padding: 8px 12px; }
  .pp-form fieldset { grid-template-columns: 1fr; }

  .mk-rank-h { display: none; }
  .mk-rank > li { grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: 4px 12px; padding: 10px 0; }
  .mk-rank .no, .mk-rank .mk-tags { display: none; }
  .mk-rank .mk-thumb { grid-row: 1 / 3; }
  .mk-rank .mk-t { grid-column: 2 / -1; }
  .mk-rank .mk-meter { grid-column: 2; }
  .mk-rank .mk-m small { display: none; }
  .mk-nodata-row { grid-column: 2 / -1; }
}

/* ---------------------------------------------------------------- ticket 58: โฆษณา + จัดการแคมเปญ (mockup-ads-v2 / mockup-campaigns-v2) */
.mk-dash > .mk-subnote { margin: -4px 0 0; }
.mk-sech { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-top: 8px; }
.mk-sech h2 { font-size: 18px; font-weight: 600; }
.mk-sech h2 small { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.ads-sets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.mk-adset { padding: 14px; }
.mk-adset .top { display: flex; gap: 12px; align-items: flex-start; }
.mk-adset .pic { width: 56px; height: 70px; border-radius: 10px; object-fit: cover; flex: none; background: var(--bg); }
.mk-adset .top > div { min-width: 0; }
.mk-adset .top small { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.mk-adset h3 { margin: 6px 0 0; font-size: 15px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.mk-adset .ads-label { display: block; margin-top: 6px; }
.mk-adset .why { margin: 10px 0 2px; min-height: 40px; font-size: 13px; color: var(--muted); }
.mk-adset .sp { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mk-adset .sp b { color: var(--ink); font-weight: 600; }
.mk-adset .sp .mk-late { color: var(--mk-back); }
.mk-adset.off { background: #fdfbfa; box-shadow: none; }
.mk-adset.off .pic { opacity: .55; }
.mk-mini { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--mk-hair); }
.mk-mini dt { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.mk-mini dt .mk-ic { width: 13px; height: 13px; }
.mk-mini dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mk-mini dd.na { color: var(--muted); font-weight: 400; }
.mk-keepchk { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.mk-keeptoggle { display: none; }
.mk-notice { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--mk-sand); color: var(--mk-wait); font-size: 14px; margin-bottom: 12px; }
.mk-notice .mk-ic { margin-top: 2px; }
.mk-notice b { font-weight: 600; }
.mk-flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin: 0; }
.mk-flow .step { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--bg); }
.mk-flow .step + .step::before { content: ""; position: absolute; left: -14px; top: 50%; margin-top: -6px; border: 6px solid transparent; border-left-color: #cdbcc4; }
.mk-flow dt { font-size: 13px; color: var(--muted); }
.mk-flow dd { margin: 0; }
.mk-flow dd b { font-size: 24px; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; }
.mk-flow dd small { display: block; font-size: 12px; color: var(--muted); }
.mk-chat { position: relative; }
.mk-card-f .mk-m b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.mk-how > summary { list-style: none; font-size: 13px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; white-space: nowrap; }
.mk-how > summary::-webkit-details-marker { display: none; }
.mk-how > p { position: absolute; z-index: 5; left: 16px; right: 16px; top: 52px; padding: 12px 14px; background: #fff; border: 1px solid var(--mk-hair); border-radius: 12px; box-shadow: 0 16px 32px -12px rgba(42, 32, 41, .3); font-size: 13px; line-height: 1.6; color: var(--ink); max-width: 72ch; }

/* small buttons, popovers (+ ผูก, ผูกเข้าแคมเปญ) */
.mk-btn.small { min-height: 32px; padding: 4px 12px; font-size: 14px; }
.mk-btn.ghost { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .35); }
.mk-btn.ghost:hover { background: rgba(255, 255, 255, .2); }
.mk-addpick, .mk-linkpick { position: relative; }
.mk-addpick > summary, .mk-linkpick > summary { list-style: none; cursor: pointer; }
.mk-addpick > summary::-webkit-details-marker, .mk-linkpick > summary::-webkit-details-marker { display: none; }
.mk-pop { position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; width: min(380px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 8px; padding: 10px; background: #fff; border: 1px solid var(--mk-hair); border-radius: 14px; box-shadow: 0 16px 32px -12px rgba(42, 32, 41, .3); font-size: 14px; font-weight: 400; color: var(--ink); white-space: normal; }
.mk-pop form { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.mk-pop-h { display: block; font-size: 13px; color: var(--muted); }
.mk-pop .mk-btn { align-self: flex-start; }
.mk-picks { max-height: 320px; overflow-y: auto; margin: 0 -4px; }
.mk-picks label { display: flex; flex-direction: row; color: var(--ink); font-size: 14px; align-items: center; gap: 10px; min-height: 44px; padding: 6px 4px; border-radius: 8px; cursor: pointer; }
.mk-picks label:hover { background: var(--mk-tint); }
.mk-picks input { width: 18px; height: 18px; flex: none; margin: 0; }
.mk-picks .mk-thumb { width: 36px; height: 45px; }
.mk-picks .mk-t small { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; white-space: normal; }
.mk-pop-field { display: flex; flex-direction: column; gap: 6px; color: var(--ink); font-size: 14px; }
.mk-linkpick { display: inline-block; margin-left: 6px; }
.mk-linkpick > summary, .mk-linkpick-new { font-size: 13px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.mk-linkpick-new { margin-left: 6px; }
.mk-linkpick .mk-pop { left: 0; right: auto; width: min(320px, calc(100vw - 32px)); }
.mk-linkpick .mk-pop button { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.mk-linkpick .mk-pop button:hover, .mk-linkpick .mk-pop button:focus-visible { background: var(--mk-tint); color: var(--brand); }
.mk-unlink { margin: 0; flex: none; }
.mk-unlink .mk-iconbtn { border: 0; background: none; padding: 0; cursor: pointer; }

/* จัดการแคมเปญ: list | detail */
.mk-pagebar.titled { margin-top: 4px; }
.mk-two { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; align-items: start; }
.mk-stackv { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.mk-campcard { padding: 14px; color: inherit; text-decoration: none; }
.mk-campcard:hover b { color: var(--brand); }
.mk-campcard[aria-current] { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--mk-shadow); }
.mk-campcard .top { display: flex; gap: 10px; align-items: flex-start; }
.mk-campcard b { display: block; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.mk-campcard small { display: flex; align-items: center; gap: 4px; margin-top: 2px; font-size: 13px; color: var(--muted); }
.mk-campcard small .mk-ic { width: 14px; height: 14px; }
.mk-counts { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--mk-hair); font-size: 13px; color: var(--muted); }
.mk-counts > span:not(.mk-st) { display: inline-flex; align-items: center; gap: 4px; }
.mk-counts > span:not(.mk-st) .mk-ic { width: 14px; height: 14px; }
.mk-counts b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.mk-campban { align-items: flex-start; }
.mk-campban h2 { font-size: 24px; font-weight: 600; line-height: 1.35; text-wrap: balance; }
.mk-campban .mk-btn { align-self: center; }
.mk-campnotes { white-space: pre-line; max-width: 72ch; }
.mk-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mk-facts > span { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; background: rgba(255, 255, 255, .13); font-size: 13px; color: #fff; }
.mk-facts .mk-ic { width: 14px; height: 14px; }
.mk-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.mk-grid2 .mk-card-h { min-height: 46px; }
.mk-pics { display: flex; gap: 8px; flex-wrap: wrap; }
.mk-pics figure { position: relative; margin: 0; width: 64px; font-size: 11px; color: var(--muted); line-height: 1.3; }
.mk-pics .pic { display: block; width: 64px; height: 80px; margin-bottom: 4px; border-radius: 10px; object-fit: cover; background: var(--bg); }
.mk-pics span.pic { display: flex; align-items: center; justify-content: center; }
.mk-pics figcaption { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.mk-pics figcaption .out { color: var(--danger); }
.mk-pics .mk-unlink { position: absolute; top: 2px; right: 2px; }
.mk-pics .mk-unlink .mk-iconbtn { width: 24px; height: 24px; border-radius: 50%; background: rgba(255, 255, 255, .92); color: var(--ink); box-shadow: 0 1px 3px rgba(42, 32, 41, .25); }
.mk-pics .mk-unlink .mk-ic { width: 14px; height: 14px; }
.mk-archive { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0; font-size: 13px; color: var(--muted); }
.mk-archive .mk-linkbtn { margin: 0; }
.mk-campform .form-grid { margin-bottom: 16px; }

@media (max-width: 1100px) and (min-width: 768px) {
  .ads-sets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mk-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mk-flow .step + .step::before { display: none; }
  .mk-two { grid-template-columns: 280px minmax(0, 1fr); }
  .mk-grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .mk-sech { margin-top: 4px; }
  .mk-sech h2 { font-size: 17px; }
  .ads-sets { grid-template-columns: 1fr; gap: 12px; }
  .mk-adset .why { min-height: 0; margin-top: 8px; }
  .mk-adset .pic { width: 44px; height: 55px; }
  .mk-mini { margin-top: 8px; padding-top: 8px; }
  .mk-mini > div { display: flex; align-items: baseline; gap: 6px; }
  .mk-mini dd { margin: 0; font-size: 15px; }
  /* เก็บ sets fold behind one row on phones */
  .mk-keeptoggle { display: flex; flex-direction: row; align-items: center; gap: 8px; min-height: 48px; padding: 8px 14px; background: var(--mk-card); border: 1px solid var(--mk-hair); border-radius: var(--mk-r-card); color: var(--muted); font-size: 14px; cursor: pointer; }
  .mk-keeptoggle > .mk-ic { margin-left: auto; transition: transform .2s ease-out; }
  .mk-keeptoggle .hide, .mk-keepchk:checked ~ .ads-sets .mk-keeptoggle .show { display: none; }
  .mk-keepchk:checked ~ .ads-sets .mk-keeptoggle .hide { display: inline; }
  .mk-keepchk:checked ~ .ads-sets .mk-keeptoggle > .mk-ic { transform: rotate(180deg); }
  .mk-keepchk:focus-visible ~ .ads-sets .mk-keeptoggle { outline: 2px solid var(--accent); outline-offset: 2px; }
  .mk-keepset { display: none; }
  .mk-keepchk:checked ~ .ads-sets .mk-keepset { display: flex; }
  .mk-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .mk-flow .step { padding: 10px; gap: 8px; }
  .mk-flow .step + .step::before { display: none; }
  .mk-flow .mk-tile { width: 28px; height: 28px; }
  .mk-flow dd b { font-size: 21px; }
  .mk-how > p { top: 48px; left: 12px; right: 12px; }
  .mk-pagebar.titled { margin-top: 12px; }
  .mk-pagebar.titled h1 { display: block; flex-basis: 100%; font-size: 21px; }
  .mk-pagebar.titled .mk-chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; width: auto; }
  .mk-pagebar.titled .mk-grow { display: block; }
  .mk-two { display: block; }
  .mk-two > * + * { margin-top: 12px; }
  .mk-campban { padding: 16px; }
  .mk-campban h2 { font-size: 21px; }
  .mk-campban .txt { flex-basis: 100%; min-width: 0; }
  .mk-campban .mk-btn { width: 100%; }
  .mk-grid2 { grid-template-columns: 1fr; gap: 12px; }
  .mk-linkpick .mk-pop { position: fixed; left: 16px; right: 16px; top: auto; bottom: 16px; width: auto; }
}

/* ---------------------------------------------------------------- ticket 61: chat header, day separators, reply box */
.th-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.th-menu .more-list { min-width: 200px; }
.day-sep { align-self: center; margin: 4px 0 0; padding: 2px 10px; font-size: 12px; color: var(--muted); }
.qr-undo { flex-basis: 100%; display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); }
.qr-undo span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply textarea { resize: none; overflow-y: auto; }
@media (max-width: 767px) {
  /* inside a chat the header has "back", so the brand bar gives its height to the conversation */
  body.has-thread .mobile-bar { display: none; }
  .thread-head { padding: 6px 8px 8px 4px; gap: 4px 6px; }
  .thread-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .thread-head .spacer { display: none; }
  .th-chips { order: 9; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-left: 8px; }
  .th-chips > * { flex: none; }
}
/* ---------------------------------------------------------------- ticket 67: the ดูรายละเอียด folds (ผลโพสต์ + โฆษณา)
   From work/SALES-APP/marketing-redesign-2026-11-15/details/_src/details.css: own classes are `d-*` under details.mkd, cards are mk-*.
   The summary is the card; opened, the jump row and the sections sit on the page ground (no card inside a card). */
.mkd > summary { list-style: none; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 10px 16px; background: var(--mk-card); border: 1px solid var(--mk-hair); border-radius: var(--mk-r-card); box-shadow: var(--mk-shadow); cursor: pointer; }
.mkd > summary::-webkit-details-marker { display: none; }
.mkd > summary b { font-weight: 600; white-space: nowrap; }
.mkd > summary > span:not(.mk-tile) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.mkd > summary > .mk-ic:last-child { margin-left: auto; color: var(--muted); transition: transform .15s; }
.mkd[open] > summary > .mk-ic:last-child { transform: rotate(180deg); }
.mkd :where(h3, dl, dd) { margin: 0; }
.mkd .d-sample { font-size: 12px; font-weight: 400; color: var(--muted); border: 1px dashed #cdbcc4; border-radius: 999px; padding: 0 8px; white-space: nowrap; }
.mkd .d-empty { color: var(--muted); font-size: 14px; }
.mkd .d-kpis { margin-top: 8px; }
.mkd .d-bfly.d-age { --vw: 112px; }
.mkd .mk-dash .c6 { grid-column: span 6; }
@media (max-width: 1100px) { .mkd .mk-dash .c6 { grid-column: span 12; } }
.mkd details.d-tv.d-first { margin-top: 0; border-top: 0; padding-top: 0; }
.mkd .d-lockbar { max-width: 420px; }
.mkd .d-foot .mk-ic { width: 14px; height: 14px; vertical-align: -2px; }
@media (max-width: 860px) {
  .mkd > summary > span:not(.mk-tile) { display: none; }
  .mkd > summary b { flex: 1; }
}
.mkd {
  --fb: #2a78d6; --ig: #e87ba4; --ln: #06c755;      /* channels: identity only */
  --fol: #7a3557; --new: #e3a53c;                    /* audience: follows already / new people */
  --s1: #cfa3b7; --s2: #b47a95; --s3: #985374; --s4: #7a3557; --s5: #5b2140; /* one-hue ramp: more = darker */
  --one: #7a3557;                                    /* a single series */
  --track: #f1e7ec; --grid: #ece1e6;
  --r-in: 12px; --r-card: 18px; --hair: var(--mk-hair); --tint: var(--mk-tint); --sage: var(--mk-sage); --ok: var(--mk-ok); --fog: var(--mk-fog);
}
.mkd [id] { scroll-margin-top: 64px; }


/* ---------- fold: an open summary bar, a jump row, then sections on the page ground (no card inside a card) */
.mkd .d-jump { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 6px 12px; margin: 0 -8px; padding: 10px 8px; background: var(--bg); }
.mkd .d-jump .mk-chips { flex: 1; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 1px; }
.mkd .d-jump .mk-chips::-webkit-scrollbar { display: none; }
.mkd .d-jump .d-range { flex: none; }
.mkd .d-sec-h { margin: 28px 0 12px; scroll-margin-top: 64px; }
.mkd .d-sec-h:first-of-type { margin-top: 8px; }
.mkd .d-sec-h h2 small { display: inline-block; }
.mkd .mk-card-h h2 small { display: block; margin-left: 0; }
.mkd .mk-card-h { align-items: flex-start; }
.mkd .mk-card-h h2 { padding-top: 5px; }
.mkd .mk-card-h .mk-tile { margin-top: 0; }
.mkd .mk-card-b > :last-child { margin-bottom: 0; }
.mkd .d-say { display: flex; gap: 8px; align-items: flex-start; padding: 8px 12px; margin-bottom: 14px; border-radius: var(--r-in); background: var(--bg); font-size: 14px; }
.mkd .d-say .mk-ic { width: 16px; height: 16px; margin-top: 3px; color: var(--accent); }
.mkd .d-say b { font-weight: 600; }
.mkd .d-foot { margin-top: 12px; font-size: 13px; color: var(--muted); }
.mkd .d-lg { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.mkd .d-lg li { display: inline-flex; align-items: center; gap: 6px; }
.mkd .d-lg b { color: var(--ink); font-weight: 600; }
.mkd .d-sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.mkd .d-lk { width: 14px; height: 2px; border-radius: 1px; flex: none; }
.mkd .d-pk { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--ink); box-shadow: 0 0 0 2px #fff; }
.mkd .d-fb { --c: var(--fb); } .mkd .d-ig { --c: var(--ig); } .mkd .d-ln { --c: var(--ln); } .mkd .d-fol { --c: var(--fol); } .mkd .d-new { --c: var(--new); }
.mkd .d-sw, .mkd .d-lk, .mkd .d-pt, .mkd .d-segs > span, .mkd .d-segt > span { background: var(--c, var(--one)); }

/* stat pair inside a card */
.mkd .d-stats { display: flex; flex-wrap: wrap; gap: 6px 28px; margin-bottom: 12px; }
.mkd .d-stats dt { font-size: 13px; color: var(--muted); }
.mkd .d-stats dd b { font-size: 24px; font-weight: 600; line-height: 1.3; }
.mkd .d-stats dd small { font-size: 13px; color: var(--muted); margin-left: 6px; }
.mkd .d-stats dd small .mk-ch { margin: 0 2px 0 6px; }

/* ---------- line plot (SVG stretches, labels and dots are HTML so they keep their shape) */
.mkd .d-plot { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; font-size: 12px; color: var(--muted); }
.mkd .d-yax { position: relative; min-width: 30px; height: var(--h); text-align: right; font-variant-numeric: tabular-nums; }
.mkd .d-yax span { position: absolute; right: 0; transform: translateY(50%); line-height: 1; }
.mkd .d-area { position: relative; height: var(--h); }
.mkd .d-area svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.mkd .d-area .d-g { stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.mkd .d-area .d-ln2 { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.mkd .d-area .d-pt { position: absolute; width: 9px; height: 9px; margin: 0 0 -4.5px -4.5px; border-radius: 50%; box-shadow: 0 0 0 2px #fff; }
.mkd .d-area .d-note { position: absolute; transform: translate(-50%, -8px); padding: 1px 6px; border-radius: 6px; background: #fff; color: var(--ink); font-size: 12px; white-space: nowrap; box-shadow: 0 0 0 1px var(--hair); }
.mkd .d-cross { position: absolute; top: 0; bottom: 0; width: 1px; background: #b9a6ae; display: none; pointer-events: none; }
.mkd .d-xax { grid-column: 2; position: relative; height: 22px; }
.mkd .d-xax span { position: absolute; top: 6px; transform: translateX(-50%); white-space: nowrap; line-height: 1; }
.mkd .d-xax span:first-child { transform: none; }
.mkd .d-xax span.d-end { transform: translateX(-100%); }

/* ---------- columns (daily counts) */
.mkd .d-colchart { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; font-size: 12px; color: var(--muted); }
.mkd .d-colchart + .d-colchart { margin-top: 14px; }
.mkd .d-cap { grid-column: 1 / -1; font-size: 13px; color: var(--ink); font-weight: 600; margin-bottom: 8px; }
.mkd .d-cap small { font-weight: 400; color: var(--muted); font-size: 13px; }
.mkd .d-cols { position: relative; display: flex; align-items: flex-end; height: var(--h); border-bottom: 1px solid #d8c8cf; }
.mkd .d-cols u { position: absolute; left: 0; right: 0; height: 1px; background: var(--grid); }
.mkd .d-col { position: relative; flex: 1; height: 100%; display: flex; flex-direction: column-reverse; align-items: center; gap: 2px; }
.mkd .d-col i { display: block; width: min(24px, 72%); flex: none; background: var(--c, var(--one)); }
.mkd .d-col i.d-top { border-radius: 4px 4px 0 0; }
.mkd .d-col:hover::before { content: ''; position: absolute; inset: 0 8%; background: rgba(91, 33, 64, .06); border-radius: 4px; }
.mkd .d-col b { position: absolute; left: 50%; transform: translateX(-50%); padding-bottom: 3px; color: var(--ink); font-weight: 600; font-size: 12px; white-space: nowrap; }
.mkd .d-rounds { grid-column: 2; display: flex; gap: 2px; margin-top: 2px; }
.mkd .d-rounds span { text-align: center; font-size: 12px; padding-top: 4px; border-top: 2px solid var(--s1); color: var(--muted); white-space: nowrap; overflow: hidden; }
.mkd .d-rounds span.d-gap { border-color: transparent; }

/* ---------- horizontal bars: label | bar + value at the tip */
.mkd .d-hb li { display: grid; grid-template-columns: var(--lb, 96px) minmax(0, 1fr); gap: 10px; align-items: center; min-height: 28px; font-size: 14px; }
.mkd .d-hb .d-lb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkd .d-hb .d-tr { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mkd .d-hb .d-tr i { display: flex; height: 12px; border-radius: 0 4px 4px 0; background: var(--c, var(--one)); width: calc((100% - var(--vw, 64px)) * var(--v)); flex: none; }
.mkd .d-hb .d-tr i.d-stk { background: none; gap: 2px; }
.mkd .d-hb .d-tr i.d-stk > i { height: 12px; border-radius: 0; width: auto; }
.mkd .d-hb .d-tr i.d-stk > i:last-child { border-radius: 0 4px 4px 0; }
.mkd .d-hb .d-tr b { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mkd .d-hb .d-tr small { color: var(--muted); font-size: 13px; white-space: nowrap; }
.mkd .d-hb li.d-zero { color: var(--muted); }
.mkd .d-hb li.d-zero .d-tr b { font-weight: 400; }
.mkd .d-hb.d-base { border-left: 1px solid #d8c8cf; margin-left: calc(var(--lb, 96px) + 10px); }
.mkd .d-hb.d-base li { margin-left: calc(-1 * (var(--lb, 96px) + 11px)); }

/* ---------- one whole split into parts */
.mkd .d-split + .d-split { margin-top: 14px; }
.mkd .d-split p { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.mkd .d-split p b { color: var(--ink); font-weight: 600; }
.mkd .d-segt { display: flex; gap: 2px; height: 28px; }
.mkd .d-segt > span { border-radius: 4px; padding-left: 8px; font-size: 13px; font-weight: 600; line-height: 28px; white-space: nowrap; color: #fff; min-width: 0; }
.mkd .d-segt > .d-new { color: #2a2029; }
.mkd .d-segs { display: flex; gap: 2px; height: 8px; }
.mkd .d-segs > span { border-radius: 4px; min-width: 3px; }

/* ---------- step table: from reach to sales, by channel */
.mkd .d-fun { display: grid; grid-template-columns: minmax(0, 1fr) repeat(4, minmax(44px, auto)); column-gap: 14px; align-items: center; font-variant-numeric: tabular-nums; }
.mkd .d-fun .d-hd { font-size: 12px; color: var(--muted); text-align: right; padding-bottom: 6px; display: flex; justify-content: flex-end; align-items: center; }
.mkd .d-fun .d-st0 { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px 0; }
.mkd .d-fun .d-st0 div { min-width: 0; flex: 1; }
.mkd .d-fun .d-st0 b { display: block; font-weight: 600; font-size: 14px; }
.mkd .d-fun .d-st0 .d-segs { margin-top: 5px; max-width: 150px; }
.mkd .d-fun .d-n { text-align: right; font-size: 14px; }
.mkd .d-fun .d-n.d-t { font-size: 20px; font-weight: 600; }
.mkd .d-fun .d-n.d-na { color: var(--muted); }
.mkd .d-fun .d-rate { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin: 4px 0 4px 9px; padding: 5px 0 5px 20px; border-left: 2px solid var(--track); font-size: 13px; color: var(--muted); }
.mkd .d-fun .d-rate b { color: var(--ink); font-weight: 600; }
.mkd .d-fun .d-sum { grid-column: 1 / -1; border-top: 1px solid var(--hair); margin: 8px 0 6px; }

/* ---------- audience headline strip */
.mkd .d-heads { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.mkd .d-heads li { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-left: 1px solid var(--hair); }
.mkd .d-heads li:first-child { border-left: 0; }
.mkd .d-heads b { display: block; font-size: 22px; font-weight: 600; line-height: 1.3; }
.mkd .d-heads div span { display: block; font-size: 13px; color: var(--muted); line-height: 1.4; }

/* demographics: three panels in one card, hairlines between */
.mkd .d-trio { display: grid; grid-template-columns: 1.1fr 1fr 1.1fr; }
.mkd .d-trio > div { padding: 0 20px; border-left: 1px solid var(--hair); min-width: 0; }
.mkd .d-trio > div:first-child { padding-left: 0; border-left: 0; }
.mkd .d-trio > div:last-child { padding-right: 0; }
.mkd .d-trio h3, .mkd .d-sub { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.mkd .d-trio h3 small, .mkd .d-sub small { font-weight: 400; color: var(--muted); }

/* ---------- products */
.mkd .d-prods li { display: grid; grid-template-columns: 40px minmax(0, 1.1fr) minmax(0, 1.4fr) 76px 76px; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--hair); }
.mkd .d-prods li:first-child { border-top: 0; }
.mkd .d-prods .d-hdr { padding: 0 0 6px; font-size: 12px; color: var(--muted); border-top: 0; }
.mkd .d-prods .d-hdr + li { border-top: 1px solid var(--hair); }
.mkd .d-prods .d-t b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkd .d-prods .d-t small { color: var(--muted); font-size: 13px; }
.mkd .d-prods .d-r { text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; }
.mkd .d-prods .d-r.d-na { color: var(--muted); }
.mkd .d-rbar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mkd .d-rbar .d-segs { width: calc((100% - 52px) * var(--v)); flex: none; }
.mkd .d-rbar b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- content types: three aligned bar columns */
.mkd .d-types > input { position: absolute; opacity: 0; pointer-events: none; }
.mkd .d-types .mk-seg label { white-space: nowrap; padding: 5px 14px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; }
.mkd #mkd-by-cat:checked ~ .mk-card-h label[for=mkd-by-cat], .mkd #mkd-by-fmt:checked ~ .mk-card-h label[for=mkd-by-fmt], .mkd #mkd-by-sty:checked ~ .mk-card-h label[for=mkd-by-sty] { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 1px 2px rgba(42, 32, 41, .12); }
.mkd .d-types > input:focus-visible ~ .mk-card-h .mk-seg { outline: 2px solid var(--accent); outline-offset: 2px; }
.mkd .d-tg { display: none; }
.mkd #mkd-by-cat:checked ~ .mk-card-b .d-by-cat, .mkd #mkd-by-fmt:checked ~ .mk-card-b .d-by-fmt, .mkd #mkd-by-sty:checked ~ .mk-card-b .d-by-sty { display: block; }
.mkd .d-trow { display: grid; grid-template-columns: minmax(0, 1.25fr) 64px repeat(3, minmax(0, 1fr)); gap: 16px; align-items: center; padding: 9px 0; border-top: 1px solid var(--hair); font-size: 14px; }
.mkd .d-trow.d-hdr { border-top: 0; padding: 0 0 6px; font-size: 12px; color: var(--muted); }
.mkd .d-trow.d-hdr span { display: inline-flex; align-items: center; gap: 5px; }
.mkd .d-trow .d-g { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 500; }
.mkd .d-trow .d-p { color: var(--muted); font-size: 13px; }
.mkd .d-mb { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mkd .d-mb i { height: 10px; border-radius: 0 4px 4px 0; background: var(--c, var(--one)); width: calc((100% - 48px) * var(--v)); flex: none; }
.mkd .d-mb b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mkd .d-mb .d-k { display: none; }
.mkd .d-trow.d-few .d-mb i { opacity: .38; }
.mkd .d-trow.d-few .d-mb b { font-weight: 400; color: var(--muted); }
.mkd .d-trow.d-none { color: var(--muted); }

/* ---------- buyers */
.mkd .d-heat { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; }
.mkd .d-heat li { text-align: center; font-size: 11px; color: var(--muted); line-height: 1.6; }
.mkd .d-heat i { display: flex; align-items: center; justify-content: center; height: 40px; border-radius: 4px; background: var(--track); font-style: normal; font-size: 13px; font-weight: 600; color: #fff; }
.mkd .d-heat .d-l1 { background: var(--s1); color: #2a2029; } .mkd .d-heat .d-l2 { background: var(--s2); color: #2a2029; } .mkd .d-heat .d-l3 { background: var(--s3); } .mkd .d-heat .d-l4 { background: var(--s4); } .mkd .d-heat .d-l5 { background: var(--s5); }
.mkd .d-heat li:nth-child(6n+1):not(:first-child) { margin-left: 4px; }
.mkd .d-parts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.mkd .d-parts span:not(:first-child) { padding-left: 4px; }
.mkd .d-scale { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.mkd .d-scale i { display: inline-flex; gap: 2px; }
.mkd .d-scale i u { width: 14px; height: 10px; border-radius: 2px; }
.mkd .d-chl li { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 10px; align-items: center; padding: 7px 0; font-size: 14px; }
.mkd .d-chl .d-nm { display: flex; align-items: center; gap: 6px; }
.mkd .d-chl .d-tr { display: flex; align-items: center; gap: 8px; }
.mkd .d-chl .d-tr i { background: var(--c); height: 12px; border-radius: 0 4px 4px 0; width: calc((100% - 150px) * var(--v)); flex: none; }
.mkd .d-chl .d-tr b { font-weight: 600; }
.mkd .d-chl .d-tr small { color: var(--muted); font-size: 13px; white-space: nowrap; }
.mkd .d-vcols { display: flex; align-items: flex-end; gap: 10px; height: 120px; border-bottom: 1px solid #d8c8cf; }
.mkd .d-vcols li { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.mkd .d-vcols i { width: min(24px, 60%); border-radius: 4px 4px 0 0; background: var(--one); }
.mkd .d-vcols i.d-hi { background: var(--s5); }
.mkd .d-vcols i.d-lo { background: var(--s1); }
.mkd .d-vcols b { font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.mkd .d-vlab { display: flex; gap: 10px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.mkd .d-vlab span { flex: 1; text-align: center; }

/* ---------- posts: scatter + list */
.mkd .d-scat { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; font-size: 12px; color: var(--muted); }
.mkd .d-scat .d-ttl { grid-column: 1 / -1; margin-bottom: 8px; }
.mkd .d-scat .d-area { background: linear-gradient(var(--grid), var(--grid)) 0 100% / 100% 1px no-repeat, linear-gradient(var(--grid), var(--grid)) 0 0 / 1px 100% no-repeat; }
.mkd .d-scat .d-q { position: absolute; left: var(--mx); bottom: var(--my); right: 0; top: 0; background: rgba(122, 53, 87, .06); border-radius: 0 var(--r-in) 0 0; }
.mkd .d-scat .d-mv { position: absolute; top: 0; bottom: 0; left: var(--mx); width: 1px; background: #cdbcc4; }
.mkd .d-scat .d-mh { position: absolute; left: 0; right: 0; bottom: var(--my); height: 1px; background: #cdbcc4; }
.mkd .d-scat .d-ql { position: absolute; padding: 4px 6px; font-size: 12px; line-height: 1.3; max-width: 46%; }
.mkd .d-scat .d-ql.d-tr { right: 0; top: 0; text-align: right; color: var(--brand); font-weight: 600; }
.mkd .d-scat .d-ql.d-tl { left: 0; top: 0; }
.mkd .d-scat .d-ql.d-br { right: 0; bottom: 0; text-align: right; }
.mkd .d-dot { position: absolute; width: 22px; height: 22px; margin: 0 0 -11px -11px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #dcc3ce; color: #2a2029; font-size: 11px; font-weight: 600; font-style: normal; box-shadow: 0 0 0 2px #fff; cursor: default; }
.mkd .d-dot.d-hi { background: var(--s4); color: #fff; }
.mkd .d-dot:hover { z-index: 2; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--s2); }
.mkd .d-scat .d-xt { grid-column: 2; text-align: right; margin-top: 2px; }
.mkd .d-plist li, .mkd .d-plist-h { display: grid; grid-template-columns: 22px 40px minmax(0, 1.5fr) minmax(0, 1.15fr) 78px 86px 52px; gap: 12px; align-items: center; }
.mkd .d-plist li { padding: 9px 0; border-top: 1px solid var(--hair); }
.mkd .d-plist-h { font-size: 12px; color: var(--muted); padding-bottom: 6px; border-bottom: 1px solid var(--hair); }
.mkd .d-plist-h span:nth-child(n+5), .mkd .d-plist .d-r { text-align: right; }
.mkd .d-plist li:first-child { border-top: 0; }
.mkd .d-plist .d-no { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: #dcc3ce; font-size: 11px; font-weight: 600; }
.mkd .d-plist .d-no.d-hi { background: var(--s4); color: #fff; }
.mkd .d-plist .d-no.d-na { background: var(--fog); color: var(--muted); }
.mkd .d-plist .d-t { min-width: 0; }
.mkd .d-plist .d-t b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkd .d-plist .d-t small { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.mkd .d-plist .d-r { font-size: 14px; font-variant-numeric: tabular-nums; }
.mkd .d-plist .d-r b { font-weight: 600; }
.mkd .d-plist .d-r small { display: block; color: var(--muted); font-size: 12px; }
.mkd .d-plist .d-r .d-k { display: none; }
.mkd .d-plist .d-na { color: var(--muted); }
.mkd .d-ret { grid-column: 3 / -1; display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; margin-top: -4px; font-size: 13px; color: var(--muted); }
.mkd .d-ret .d-steps { display: inline-flex; align-items: flex-end; gap: 2px; height: 22px; }
.mkd .d-ret .d-steps i { width: 12px; border-radius: 2px 2px 0 0; background: var(--s2); height: calc(var(--v) * 1%); }
.mkd .d-ret .d-steps i:first-child { background: var(--s1); }
.mkd .d-ret b { color: var(--ink); font-weight: 600; }
.mkd details.d-more > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; color: var(--accent); font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.mkd details.d-more > summary::-webkit-details-marker { display: none; }
.mkd details.d-more > summary .mk-ic { width: 15px; height: 15px; }
.mkd details.d-more[open] > summary .mk-ic { transform: rotate(180deg); }
.mkd details.d-more[open] > summary { margin-bottom: 10px; }

/* ---------- ads: pace */
.mkd .d-pace li { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 128px 112px; gap: 14px; align-items: center; padding: 7px 0; font-size: 14px; }
.mkd .d-pace .d-nm { display: flex; align-items: center; gap: 6px; min-width: 0; }
.mkd .d-pace .d-nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkd .d-pace .d-pc { padding-top: 12px; margin-top: 6px; border-top: 1px solid var(--hair); }
.mkd .d-pace .d-pc:first-child { border-top: 0; margin-top: 0; padding-top: 2px; }
.mkd .d-pace .d-pc .d-nm { font-weight: 600; }
.mkd .d-pace .d-pc .d-nm small { font-weight: 400; color: var(--muted); font-size: 13px; white-space: nowrap; }
.mkd .d-pace .d-set .d-nm { padding-left: 14px; }
.mkd .d-pace .mk-bar { margin: 0; height: 8px; border-radius: 4px; }
.mkd .d-pace .mk-bar i { border-radius: 4px; background: var(--one); }
.mkd .d-pace .d-pc .mk-bar { height: 10px; }
.mkd .d-pace .d-amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mkd .d-pace .d-amt small { color: var(--muted); font-size: 13px; }
.mkd .d-pace .mk-st { justify-self: start; }

/* ---------- ads: Facebook | Instagram, mirrored */
.mkd .d-bfly { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); column-gap: 10px; row-gap: 12px; align-items: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.mkd .d-bfly .d-hd { display: flex; align-items: center; gap: 6px; font-weight: 600; padding-bottom: 2px; }
.mkd .d-bfly .d-hd.d-l { flex-direction: row; justify-content: flex-end; }
.mkd .d-bfly .d-k { text-align: center; font-size: 13px; color: var(--muted); min-width: 84px; }
.mkd .d-bfly .d-l, .mkd .d-bfly .d-r { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mkd .d-bfly .d-l { flex-direction: row-reverse; }
.mkd .d-bfly .d-l > i, .mkd .d-bfly .d-r > i { height: 12px; flex: none; width: calc((100% - var(--vw, 62px)) * var(--v)); }
.mkd .d-bfly .d-l > i { border-radius: 4px 0 0 4px; background: var(--fb); }
.mkd .d-bfly .d-r > i { border-radius: 0 4px 4px 0; background: var(--ig); }
.mkd .d-bfly b { font-weight: 600; white-space: nowrap; }
.mkd .d-bfly .d-few > i { opacity: .38; }
.mkd .d-bfly .d-few b { font-weight: 400; color: var(--muted); }
.mkd .d-bfly .d-win b { display: inline-flex; align-items: center; gap: 4px; }
.mkd .d-bfly .d-win .mk-ic { width: 14px; height: 14px; color: var(--ok); }
.mkd .d-bfly .d-band { grid-column: 1 / -1; margin: 0 -8px; padding: 0 8px; display: grid; grid-template-columns: subgrid; align-items: center; }
.mkd .d-bfly .d-band.d-tg2 { background: var(--tint); border-radius: var(--r-in); padding-top: 8px; padding-bottom: 8px; }
.mkd .d-bfly .d-sm { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.mkd .d-bfly .d-k b { display: block; color: var(--ink); font-size: 14px; }
.mkd .d-bfly .d-txt { display: flex; flex-direction: column; line-height: 1.35; }
.mkd .d-bfly .d-l .d-txt { align-items: flex-end; text-align: right; }

/* ---------- ads: cost per chat on one baht axis */
.mkd .d-rng li, .mkd .d-rng-h { display: grid; grid-template-columns: 36px minmax(0, 1.15fr) 56px minmax(0, 1.6fr) 64px; gap: 12px; align-items: center; }
.mkd .d-rng li { padding: 7px 0; border-top: 1px solid var(--hair); }
.mkd .d-rng li.d-sublabel { display: block; padding: 12px 0 2px; }
.mkd .d-rng li.d-sublabel:first-child { border-top: 0; padding-top: 0; }
.mkd .d-rng li.d-sublabel + li { border-top: 0; }
.mkd .d-rng .mk-thumb { width: 36px; height: 45px; }
.mkd .d-rng .d-t { min-width: 0; }
.mkd .d-rng .d-t b { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.mkd .d-rng .d-t small { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkd .d-rng .d-c { font-size: 13px; color: var(--muted); white-space: nowrap; }
.mkd .d-rng .d-c b { color: var(--ink); font-weight: 600; font-size: 14px; }
.mkd .d-rng .d-v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.mkd .d-rng .d-ax, .mkd .d-rng-h .d-ax { position: relative; height: 24px; }
.mkd .d-rng .d-ax { background: linear-gradient(var(--grid), var(--grid)) 0 0 / 1px 100% no-repeat, linear-gradient(var(--grid), var(--grid)) 31.25% 0 / 1px 100% no-repeat, linear-gradient(var(--grid), var(--grid)) 62.5% 0 / 1px 100% no-repeat, linear-gradient(var(--grid), var(--grid)) 93.75% 0 / 1px 100% no-repeat; }
.mkd .d-rng .d-ax .d-rg { position: absolute; top: 9px; height: 6px; border-radius: 3px; background: var(--s1); left: var(--a); right: calc(100% - var(--b)); }
.mkd .d-rng .d-ax .d-d { position: absolute; top: 5px; left: var(--x); width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--s4); box-shadow: 0 0 0 2px #fff; }
.mkd .d-rng .d-dim .d-ax .d-d { background: #dcc3ce; }
.mkd .d-rng .d-dim .d-v { font-weight: 400; color: var(--muted); }
.mkd .d-rng .d-ax .d-txt { position: absolute; left: 0; top: 3px; font-size: 13px; color: var(--muted); background: #fff; padding-right: 6px; }
.mkd .d-rng-h { font-size: 12px; color: var(--muted); padding-bottom: 4px; }
.mkd .d-rng-h .d-ax span { position: absolute; top: 4px; transform: translateX(-50%); }
.mkd .d-rng-h .d-ax span:first-child { transform: none; }
.mkd .d-best { display: inline-flex; align-items: center; gap: 3px; height: 20px; padding: 0 8px 0 5px; border-radius: 999px; background: var(--sage); color: var(--ok); font-size: 12px; font-weight: 600; white-space: nowrap; }
.mkd .d-best .mk-ic { width: 13px; height: 13px; }

/* ---------- table view (the numbers behind a chart) */
.mkd details.d-tv { margin-top: 14px; border-top: 1px solid var(--hair); padding-top: 10px; }
.mkd details.d-tv > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: 14px; cursor: pointer; }
.mkd details.d-tv > summary::-webkit-details-marker { display: none; }
.mkd details.d-tv > summary .mk-ic { width: 15px; height: 15px; }
.mkd details.d-tv[open] > summary { margin-bottom: 10px; }
.mkd .d-tw { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.mkd table.d-t { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.mkd table.d-t th { font-size: 12px; font-weight: 400; color: var(--muted); text-align: left; padding: 0 12px 6px 0; white-space: nowrap; border-bottom: 1px solid var(--hair); }
.mkd table.d-t td { padding: 8px 12px 8px 0; border-top: 1px solid var(--hair); white-space: nowrap; }
.mkd table.d-t tr:first-child td { border-top: 0; }
.mkd table.d-t .d-n { text-align: right; }
.mkd table.d-t th:last-child, .mkd table.d-t td:last-child { padding-right: 0; }
.mkd table.d-t .d-grp td { font-weight: 600; background: var(--bg); padding-left: 8px; }
.mkd table.d-t .d-set td:first-child { padding-left: 14px; }
.mkd table.d-t .d-ad td:first-child { padding-left: 28px; color: var(--muted); }
.mkd table.d-t .d-nmc { display: flex; align-items: center; gap: 6px; white-space: normal; min-width: 180px; }
.mkd table.d-t .mk-st { height: 22px; }

/* ---------- region tile map (a rough layout, not a real map) */
.mkd .d-tmap { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 78px; gap: 4px; max-width: 420px; }
.mkd .d-tmap > div { grid-column: span 2; border-radius: 10px; padding: 9px 12px; line-height: 1.35; color: #fff; display: flex; flex-direction: column; justify-content: center; }
.mkd .d-tmap b { font-size: 14px; font-weight: 600; }
.mkd .d-tmap span { font-size: 20px; font-weight: 600; }
.mkd .d-tmap small { font-size: 12px; opacity: .92; }
.mkd .d-tmap .d-l1 { background: var(--s1); color: #2a2029; } .mkd .d-tmap .d-l2 { background: var(--s2); color: #2a2029; } .mkd .d-tmap .d-l3 { background: var(--s3); } .mkd .d-tmap .d-l5 { background: var(--s5); }
.mkd .d-tmap .d-l1 small, .mkd .d-tmap .d-l2 small { opacity: 1; }
.mkd .d-tmap .d-pt { grid-column: 2 / span 2; grid-row: 1; }
.mkd .d-tmap .d-nb { grid-column: 1 / span 2; grid-row: 2; }
.mkd .d-tmap .d-bk { grid-column: 3 / span 2; grid-row: 2; }
.mkd .d-tmap .d-sp { grid-column: 3 / span 2; grid-row: 3; }
.mkd .d-mapwrap { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 20px 28px; align-items: center; }
.mkd .d-compass { font-size: 12px; color: var(--muted); margin-top: 6px; }

.mkd .d-lockbox { display: flex; align-items: baseline; gap: 8px; }
.mkd .d-lockbox b { font-size: 28px; font-weight: 600; }

/* ---------- tooltip */
.mkd .d-tip { position: fixed; z-index: 20; pointer-events: none; max-width: 260px; padding: 8px 10px; border-radius: 10px; background: #2a2029; color: #fff; font-size: 13px; line-height: 1.45; white-space: pre-line; box-shadow: 0 8px 20px -8px rgba(42, 32, 41, .5); opacity: 0; transition: opacity .12s; }
.mkd .d-tip.d-on { opacity: 1; }
.mkd .d-tip b { font-weight: 600; }
.mkd .d-tip .d-k { display: inline-block; width: 12px; height: 2px; border-radius: 1px; vertical-align: middle; margin-right: 6px; }
.mkd [data-tip] { cursor: default; }

/* ---------- phone */
@media (max-width: 860px) {
  .mkd .d-jump { margin: 0 -16px; padding: 8px 16px; flex-wrap: wrap; border-bottom: 1px solid var(--hair); }
  .mkd .d-jump .mk-chips { flex: 1 0 100%; margin: 0 -16px; padding: 1px 16px; width: calc(100% + 32px); }
  .mkd .d-jump .d-range { flex-basis: 100%; }
  .mkd .d-jump .d-range .mk-chips { margin: 0; padding: 1px; width: 100%; }
  .mkd .d-sec-h { margin-top: 24px; }
  .mkd .mk-card-b { padding: 10px 14px 14px; }
  .mkd .mk-card-h { padding: 12px 14px 0; }
  .mkd .d-fun { column-gap: 8px; }
  .mkd .d-fun .d-st0 .mk-tile { display: none; }
  .mkd .d-fun .d-n.d-t { font-size: 18px; }
  .mkd .d-fun .d-rate { margin-left: 0; padding-left: 10px; }
  .mkd .d-heads { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mkd .d-heads li { padding: 12px 14px; border-left: 0; border-top: 1px solid var(--hair); }
  .mkd .d-heads li:nth-child(-n+2) { border-top: 0; }
  .mkd .d-heads li:nth-child(even) { border-left: 1px solid var(--hair); }
  .mkd .d-heads li:last-child { grid-column: 1 / -1; }
  .mkd .d-heads b { font-size: 20px; }
  .mkd .d-heads .mk-tile { width: 28px; height: 28px; }
  .mkd .d-trio { grid-template-columns: 1fr; }
  .mkd .d-trio > div { padding: 14px 0 0; margin-top: 14px; border-left: 0; border-top: 1px solid var(--hair); }
  .mkd .d-trio > div:first-child { padding-top: 0; margin-top: 0; border-top: 0; }
  .mkd .d-prods li { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 4px 10px; }
  .mkd .d-prods .d-hdr { display: none; }
  .mkd .d-prods .d-hdr + li { border-top: 0; }
  .mkd .d-prods .d-rbar { grid-column: 2 / -1; }
  .mkd .d-prods .d-r.d-o { grid-column: 3; grid-row: 1; }
  .mkd .d-prods .d-r.d-s { display: none; }
  .mkd .d-trow { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; }
  .mkd .d-trow.d-hdr { display: none; }
  .mkd .d-trow.d-hdr + .d-trow { border-top: 0; }
  .mkd .d-trow .d-mb { grid-column: 1 / -1; }
  .mkd .d-trow .d-mb .d-k { display: inline-flex; align-items: center; gap: 4px; width: 86px; flex: none; font-size: 12px; color: var(--muted); }
  .mkd .d-mb i { width: calc((100% - 142px) * var(--v)); }
  .mkd .d-heat { grid-template-columns: repeat(12, minmax(0, 1fr)); row-gap: 6px; }
  .mkd .d-heat li:nth-child(6n+1):not(:first-child) { margin-left: 0; }
  .mkd .d-heat i { height: 34px; }
  .mkd .d-parts { display: none; }
  .mkd .d-chl .d-tr i { width: calc((100% - 132px) * var(--v)); }
  .mkd .d-plist-h { display: none; }
  .mkd .d-plist li { grid-template-columns: 22px 40px minmax(0, 1fr); gap: 6px 10px; }
  .mkd .d-plist .d-rbar { grid-column: 2 / -1; }
  .mkd .d-plist .d-r { grid-column: auto; text-align: left; font-size: 13px; }
  .mkd .d-plist .d-r small { display: inline; margin-left: 4px; }
  .mkd .d-plist .d-r .d-k { display: inline; color: var(--muted); margin-right: 4px; }
  .mkd .d-plist .d-nums { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 2px 14px; }
  .mkd .d-ret { grid-column: 2 / -1; margin-top: 0; }
  .mkd .d-pace li { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; }
  .mkd .d-pace .d-nm { grid-column: 1; }
  .mkd .d-pace .mk-st { grid-column: 2; grid-row: 1; justify-self: end; }
  .mkd .d-pace .mk-bar { grid-column: 1; }
  .mkd .d-pace .d-amt { grid-column: 2; font-size: 13px; }
  .mkd .d-pace .d-set .d-nm { padding-left: 0; }
  .mkd .d-bfly { column-gap: 6px; font-size: 13px; }
  .mkd .d-bfly .d-k { min-width: 64px; font-size: 12px; }
  .mkd .d-bfly .d-l > i, .mkd .d-bfly .d-r > i { --vw: 54px; }
  .mkd .d-rng li, .mkd .d-rng-h { grid-template-columns: 36px minmax(0, 1fr) 56px; gap: 4px 10px; }
  .mkd .d-rng li .d-ax { grid-column: 2; }
  .mkd .d-rng li .d-v { grid-column: 3; }
  .mkd .d-rng li .d-c { text-align: right; }
  .mkd .d-mapwrap { grid-template-columns: 1fr; }
  .mkd .d-tmap { grid-auto-rows: 74px; }
  .mkd table.d-t .d-nmc { min-width: 150px; }
}
@media (min-width: 861px) {
  .mkd .d-plist .d-nums { display: contents; }
}
.mkd .d-scatwrap { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.mkd .d-starlist .mk-row .d-no { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--s4); color: #fff; font-size: 11px; font-weight: 600; flex: none; }
.mkd .d-bfly .d-sm span { white-space: nowrap; }
@media (max-width: 860px) {
  .mkd .d-scatwrap { grid-template-columns: 1fr; gap: 16px; }
  .mkd .d-xax span.d-alt { display: none; }
  .mkd .d-area .d-pt { width: 7px; height: 7px; margin: 0 0 -3.5px -3.5px; }
  .mkd .d-types .mk-card-h { flex-wrap: wrap; }
  .mkd .d-types .mk-card-h h2 { flex: 1 0 60%; }
  .mkd .d-types .mk-card-h .mk-seg { flex: 1 0 100%; }
  .mkd .d-types .mk-card-h .mk-seg label { flex: 1; text-align: center; }
  .mkd .d-prods .d-r.d-na { display: none; }
  .mkd .mk-kpi.c4 { grid-column: span 6; }
  .mkd .mk-kpi.c4:first-child { grid-column: span 12; }
  .mkd .d-rng-h { display: grid; }
  .mkd .d-rng-h > span:not(.d-ax) { display: none; }
  .mkd .d-rng-h .d-ax { grid-column: 2; }
  .mkd .d-bfly.d-age { --vw: 78px; }
  .mkd .d-bfly.d-age .d-l > i, .mkd .d-bfly.d-age .d-r > i { --vw: 78px; }
}

.mkd .d-xax.d-cx span { transform: translateX(-50%); }
.mkd .d-xax.d-cx span:first-child { transform: none; }
.mkd .d-xax.d-cx span.d-end { transform: translateX(-100%); }

/* T69 — every piece of a customer message (mockup-message-types.html) */
.msg:has(> .part-ctx, > .part-pics, > .part-img, > .part-card, > .part-file, > .part-video, > .part-audio, > .part-fallback, > .part-nofile) { gap: 4px; }
.part-pics { display: flex; gap: 4px; flex-wrap: wrap; }
.part-img img { display: block; width: 84px; height: 112px; object-fit: cover; object-position: center top; border-radius: 10px; border: 1px solid #ece1e6; background: var(--white); }
.msg > .part-img img { width: auto; height: auto; max-width: min(240px, 100%); max-height: 320px; object-fit: contain; }
.part-sticker { width: 96px; height: 96px; object-fit: contain; }
.part-video { display: block; width: 240px; max-width: 100%; max-height: 360px; border-radius: 12px; background: var(--ink); }
.part-audio { width: 240px; max-width: 100%; height: 40px; }
.part-file { display: flex; align-items: center; gap: 10px; width: 240px; max-width: 100%; padding: 8px 12px 8px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); color: var(--ink); text-decoration: none; font-size: 13px; }
.part-file-ic { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; border-radius: 8px; background: #f3eeef; color: var(--muted); font-size: 11px; font-weight: 600; }
.part-file > span:last-child { min-width: 0; }
.part-file b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part-file small { color: var(--muted); }
.part-ctx { display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 5px 10px 5px 5px; border: 1px solid #ece1e6; border-radius: 10px; background: #f3eeef; font-size: 12px; color: var(--muted); align-self: flex-start; }
.part-btn { padding: 4px 10px; }
.part-ctx img, .part-ctx video, .part-ctx .part-ph { width: 30px; height: 40px; flex: none; object-fit: cover; object-position: center top; border-radius: 5px; }
.part-ctx b { display: block; color: var(--ink); font-weight: 500; }
.part-card { display: flex; gap: 10px; width: 260px; max-width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); color: var(--ink); text-decoration: none; }
.part-card img, .part-card video, .part-card .part-ph { width: 54px; height: 72px; flex: none; object-fit: cover; object-position: center top; border-radius: 7px; }
.part-ph { display: flex; align-items: center; justify-content: center; background: #f3eeef; color: var(--muted); font-size: 11px; }
.part-card p { margin: 0; min-width: 0; font-size: 13px; line-height: 1.4; }
.part-card p b { display: block; font-weight: 600; }
.part-card p span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); overflow-wrap: anywhere; }
.part-card p em { display: inline-block; margin-top: 2px; font-style: normal; color: var(--accent); }
.part-fallback, .part-nofile { display: flex; flex-direction: column; gap: 6px; width: 260px; max-width: 100%; padding: 10px 12px; border: 1px dashed #cdbcc4; border-radius: 12px; background: var(--white); font-size: 13px; }
.part-fallback b, .part-nofile b { font-weight: 600; font-size: 14px; }
.part-fallback a, .part-nofile a { font-weight: 500; color: var(--accent); }
.part-url { overflow-wrap: anywhere; font-weight: 400 !important; }
.part-nofile form { margin: 0; }
.part-nofile button { min-height: 44px; }
/* T83: slip file input uses the app's secondary button; the browser shows the chosen file name beside it */
#slips input[type="file"] { font-size: var(--fs-sm); color: var(--muted); }
#slips input[type="file"]::file-selector-button {
  min-height: var(--control-h); margin-right: var(--s3); padding: 8px var(--s4);
  border: 1px solid var(--brand); border-radius: var(--radius);
  background: var(--white); color: var(--brand); font: inherit; font-size: var(--fs-md); font-weight: 500; cursor: pointer;
}
#slips input[type="file"]::file-selector-button:hover { background: #f4ebf0; }

/* T77: courier logo / monogram (CourierMark) and the courier picker rows in the order form */
.courier-mark { display: inline-block; flex: none; vertical-align: middle; border-radius: 8px; border: 1px solid var(--line); background: var(--white); object-fit: contain; }
.courier-mark.mono { display: inline-flex; align-items: center; justify-content: center; border: 0; color: var(--white); font-size: 11px; font-weight: 600; letter-spacing: .02em; line-height: 1; overflow: hidden; }
dd .courier-mark, button .courier-mark { border-radius: 5px; }
dd .courier-mark.mono, button .courier-mark.mono { font-size: 8px; }
.couriers { display: flex; flex-direction: column; gap: 6px; }
.crow { display: flex; flex-direction: row; align-items: center; color: var(--ink); font-size: var(--fs-md); gap: 10px; width: 100%; min-height: 52px; padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); cursor: pointer; }
.crow[hidden] { display: none; }
.crow input[type="radio"] { order: 4; width: 18px; height: 18px; flex: none; margin: 0; accent-color: var(--brand); }
.crow:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.crow.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.crow .nm { flex: 1; min-width: 0; }
.crow .nm b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow.on .nm b { font-weight: 600; color: var(--brand); }
.crow .nm small { display: block; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow .pr { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cmore summary { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--accent); cursor: pointer; }
.cmore[open] summary { margin-bottom: 6px; }
.cmore input[type="search"] { margin-bottom: 6px; }
/* T84 customer order page /o/<token> (mock-up: mockup-order-status-customer*.html). One column, phone first. */
body.pub {
  --hair: #ece1e6; --tint: #f4ebf0; --sand: #f8f0e2; --sky: #ecf0f7; --sage: #e9f3ec; --fog: #f3eeef;
  --ok: #2b6a43; --wait: #7a5a0b; --ready: #2f4b7a; --back: #8a4512;
  display: block; min-height: 100vh;
}
.pub h1, .pub h2, .pub p, .pub dl, .pub dd, .pub ol { margin: 0; }
.pub-in { max-width: 480px; margin: 0 auto; padding: 20px 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.pub-brand { text-align: center; font-size: 22px; letter-spacing: .28em; color: var(--brand); font-weight: 500; padding: 4px 0 2px; }
.pub-no { text-align: center; color: var(--muted); font-size: 14px; margin-top: -8px !important; }
.pub .card { padding: 16px; border-color: var(--hair); border-radius: 18px; box-shadow: 0 1px 2px rgba(91, 33, 64, .05), 0 12px 24px -18px rgba(91, 33, 64, .22); }
.pub .card + .card { margin-top: 0; }
.pub h2 { font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.pub-hero { text-align: center; }
.pub-hero h1 { font-size: 24px; font-weight: 600; line-height: 1.3; margin: 8px 0 4px; }
.pub-hero > p { color: var(--muted); font-size: 14px; }
.pub-badge { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; background: var(--fog); color: var(--muted); }
.pub-badge.wait { background: var(--sand); color: var(--wait); }
.pub-badge.prep { background: var(--tint); color: var(--brand); }
.pub-badge.ready { background: var(--sky); color: var(--ready); }
.pub-badge.ok { background: var(--sage); color: var(--ok); }
.pub-badge.back { background: #fbeee4; color: var(--back); }
.pub-steps { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 18px !important; padding: 0; list-style: none; }
.pub-steps li { position: relative; text-align: center; font-size: 13px; color: var(--muted); padding-top: 26px; }
.pub-steps li::before { content: ''; position: absolute; top: 9px; left: -50%; right: 50%; height: 2px; background: var(--line); }
.pub-steps li:first-child::before { display: none; }
.pub-steps li::after { content: ''; position: absolute; top: 2px; left: 50%; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: #fff; border: 2px solid var(--line); box-sizing: border-box; }
.pub-steps li.done { color: var(--ink); }
.pub-steps li.done::before, .pub-steps li.now::before { background: var(--brand); }
.pub-steps li.done::after { background: var(--brand); border-color: var(--brand); }
.pub-steps li.now { color: var(--brand); font-weight: 600; }
.pub-steps li.now::after { border-color: var(--brand); box-shadow: 0 0 0 4px var(--tint); }
.pub-steps small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.pub-track { margin-top: 14px; padding: 12px; background: var(--sky); border-radius: 12px; text-align: left; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pub-track p { flex: 1; min-width: 0; }
.pub-track small { color: var(--muted); display: block; font-size: 13px; }
.pub-track .mono { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.pub-val { user-select: all; -webkit-user-select: all; -webkit-touch-callout: default; }
.pub .button-link, .pub button { min-height: 44px; }
.pub-refresh { margin-top: 14px; }
.pub-copy { flex: none; font-size: 14px; padding-inline: 12px; }
.pub-amt { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pub-amt b { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; flex: 1; }
.pub-qr { display: block; width: 196px; height: 196px; margin: 14px auto 6px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-sizing: content-box; }
.pub-hint { text-align: center; font-size: 13px; color: var(--muted); }
.pub-hint.left { text-align: left; margin-top: 8px !important; }
.pub-bank { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hair); font-size: 14px; }
.pub-bank > span { flex: 1; min-width: 0; }
.pub-bank small { color: var(--muted); display: block; font-size: 13px; }
.pub-bank b { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 16px; }
.pub-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.pub-chat { width: 100%; min-height: 46px !important; font-size: 16px; }
.pub .ch { width: 20px; height: 20px; flex: none; border-radius: 5px; }
.pub-lines { display: flex; flex-direction: column; }
.pub-line { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--hair); }
.pub-line:first-child { border-top: 0; }
.pub-line img, .pub-noimg { width: 44px; height: 54px; border-radius: 8px; object-fit: cover; object-position: center top; display: block; background: var(--fog); }
.pub-line b { font-weight: 500; display: block; }
.pub-line small { color: var(--muted); font-size: 13px; }
.pub-line .q { color: var(--muted); }
.pub-sum { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding-top: 10px; border-top: 1px solid var(--hair); margin-top: 4px !important; }
.pub-sum dd { text-align: right; font-variant-numeric: tabular-nums; }
.pub-sum .tot { font-weight: 600; font-size: 16px; }
.pub-paid { margin-top: 12px !important; padding: 10px 12px; background: var(--sage); color: var(--ok); border-radius: 12px; font-size: 14px; }
.pub-paid b { color: var(--ink); font-variant-numeric: tabular-nums; }
.pub-addr { font-size: 14px; }
.pub-addr b { font-weight: 500; }
.pub-contact { display: flex; gap: 8px; flex-wrap: wrap; }
.pub-contact a { flex: 1 1 30%; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); text-decoration: none; font-size: 14px; }
.pub-contact a.on { border-color: var(--brand); color: var(--brand); font-weight: 500; }
.pub-foot { text-align: center; font-size: 12px; color: var(--muted); line-height: 1.7; }
.pub-foot a { color: var(--muted); display: inline-block; padding: 6px 2px; }
@media (min-width: 640px) {
  .pub-line { grid-template-columns: 52px minmax(0, 1fr) auto auto; gap: 12px; }
  .pub-line img, .pub-noimg { width: 52px; height: 64px; }
}

/* T88 customer slip upload on /o/<token> (behind the customer_slip_upload switch). */
.pub-msg { margin-top: 12px !important; padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.pub-msg.ok { background: var(--sage); color: var(--ok); }
.pub-msg.warn { background: var(--sand); color: var(--wait); }
.pub-upload { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hair); }
.pub-upload label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.pub-upload input[type='file'] { min-height: 44px; max-width: 100%; color: var(--ink); }
/* T74 send image in chat: image button, sheet (bottom on a phone, above the reply box on a computer), upload states */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.reply > .img-open { align-self: flex-end; width: 44px; min-height: 44px; padding: 0; }
.reply > .img-open svg { width: 22px; height: 22px; }
.reply.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.qr-thumb { position: relative; display: block; padding: 0; min-height: 0; border: 0; background: none; border-radius: 8px; }
.qr-attach .uploading img { opacity: .45; }
.qr-attach .uploading .qr-thumb::after { content: ''; position: absolute; inset: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: t74spin .8s linear infinite; }
.qr-attach .failed img { opacity: .35; border-color: var(--danger); }
.qr-state { position: absolute; inset: auto 0 4px; text-align: center; font-size: 12px; color: var(--danger); font-weight: 600; }
@keyframes t74spin { to { transform: rotate(360deg); } }
.img-sheet { padding: 0; border: 0; width: 100%; max-width: 100%; margin: auto 0 0; max-height: 88vh; border-radius: 16px 16px 0 0; background: var(--white); color: var(--ink); }
.img-sheet::backdrop { background: rgba(42, 32, 41, .35); }
.img-sheet .sheet { display: flex; flex-direction: column; max-height: 88vh; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 4px 16px; }
.sheet-head h3 { margin: 0; font-size: var(--fs-lg); }
.sheet-x { width: 44px; min-height: 44px; font-size: 24px; color: var(--ink); }
.sheet-tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.sheet-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); min-height: 44px; padding: 8px 12px; }
.sheet-tabs button[aria-selected='true'] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.sheet-body { overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.img-product { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.img-product select { flex: 1; min-width: 0; min-height: 44px; }
.img-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.img-grid > li { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.img-src label { aspect-ratio: 3 / 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--bg); cursor: pointer; text-align: center; font-size: var(--fs-sm); }
.img-src label svg { width: 26px; height: 26px; }
.img-src label:focus-within { outline: 2px solid var(--accent); }
.img-pick button { position: relative; display: block; padding: 0; min-height: 0; aspect-ratio: 3 / 4; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); overflow: hidden; }
.img-pick button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-pick button[aria-pressed='true'] { outline: 3px solid var(--brand); outline-offset: -1px; }
.img-no { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--white); border: 2px solid var(--white); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; }
.img-ai { position: absolute; left: 6px; bottom: 6px; background: rgba(42, 32, 41, .78); color: var(--white); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.img-cap { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-none { grid-column: 1 / -1; padding: 12px 0; }
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.sheet-foot button { min-height: 44px; }
.img-view { padding: 0; border: 0; background: none; max-width: 96vw; max-height: 92vh; }
.img-view::backdrop { background: rgba(0, 0, 0, .8); }
.img-view img { display: block; max-width: 96vw; max-height: 92vh; object-fit: contain; }
@media (min-width: 768px) {
  .img-sheet { position: fixed; inset: auto auto var(--sb, 120px) var(--sx, 50%); margin: 0; width: min(var(--sw, 640px), 720px); border: 1px solid var(--line); border-radius: var(--radius-lg); max-height: min(70vh, 640px); box-shadow: 0 12px 32px -12px rgba(42, 32, 41, .35); }
  .img-sheet .sheet { max-height: min(70vh, 640px); }
  .img-sheet::backdrop { background: transparent; }
  .img-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* T79 ข้อความลัด: "ทั้งหมด" chip + sheet, "/" list in the reply box, settings › chat manager */
.quick .qr-all-btn { position: sticky; left: 0; z-index: 1; font-weight: 600; border-color: var(--brand); color: var(--brand); box-shadow: 6px 0 6px -4px var(--white); }
.qr-all .sheet-head .spacer { flex: 1; }
.qr-all .sheet-head a { margin-right: 4px; }
.qr-all input[type='search'] { width: 100%; min-height: 44px; }
.qr-all-list { list-style: none; margin: 0 -16px; padding: 0; }
.qr-all-list button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 16px; background: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; color: var(--ink); font-weight: 400; text-align: left; white-space: normal; }
.qr-all-list button:hover { background: var(--bg); }
.qa-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.qa-text { color: var(--muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-meta { flex: none; color: var(--muted); font-size: var(--fs-sm); }
.qr-slash { flex-basis: 100%; list-style: none; margin: 0; padding: 4px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); max-height: 280px; overflow-y: auto; box-shadow: 0 8px 24px -12px rgba(42, 32, 41, .3); }
.qr-slash li { display: flex; flex-direction: column; padding: 6px 12px; cursor: pointer; }
.qr-slash li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-slash li[aria-selected='true'] { background: #f4ebf0; }
.qm-title { margin: 0 0 4px; font-size: var(--fs-xl); }
.qm-intro { margin: 0 0 16px; max-width: 640px; }
.qm-cols { display: grid; gap: 16px; align-items: start; }
@media (min-width: 1024px) { .qm-cols { grid-template-columns: minmax(0, 420px) minmax(0, 640px); } }
.qm-list { padding: 0; overflow: hidden; }
.qm-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.qm-list-head h4, .qm-edit h4 { margin: 0; font-size: var(--fs-lg); }
.qm-list #qm-msg { margin: 0 16px 8px; }
.qm-items { list-style: none; margin: 0; padding: 0; }
.qm-row { display: flex; align-items: center; gap: 4px; padding: 4px 12px 4px 4px; border-top: 1px solid var(--line); background: var(--white); }
.qm-row.on { background: #f4ebf0; }
.qm-row.dragging { opacity: .6; box-shadow: 0 4px 12px rgba(42, 32, 41, .2); }
.qm-handle { width: 44px; min-height: 44px; padding: 0; color: var(--muted); cursor: grab; touch-action: none; letter-spacing: -2px; }
.qm-name { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 8px 0; color: var(--ink); text-decoration: none; }
.qm-name strong { font-weight: 500; }
.qm-group { padding: 6px 16px; border-top: 1px solid var(--line); background: var(--bg); }
.qm-switch { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 52px; min-height: 44px; cursor: pointer; }
.qm-switch input { appearance: none; -webkit-appearance: none; width: 40px; height: 24px; margin: 0; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; }
.qm-switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--white); transition: transform .15s; }
.qm-switch input:checked { background: var(--brand); }
.qm-switch input:checked::after { transform: translateX(16px); }
.qm-switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.qm-edit { display: flex; flex-direction: column; gap: 12px; }
.qm-edit textarea { min-height: 120px; }
.qm-preview { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.qm-preview .msg { max-width: 100%; }
.qm-images { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; border: 0; padding: 0; margin: 0; }
.qm-images legend { padding: 0; margin-bottom: 6px; }
.qm-img { display: flex; flex-direction: column; gap: 4px; }
.qm-img img { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.qm-edit .form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.qm-del { margin-left: auto; color: var(--danger); text-decoration: underline; }

/* T75 ad picture in chat: thumbnail in the ad chips, the ad card in the thread */
.tag.ad-badge { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.tag.ad-badge > span { overflow: hidden; text-overflow: ellipsis; }
.ad-badge .ad-thumb { flex: none; width: 16px; height: 20px; margin: -2px 0 -2px -4px; border-radius: 3px; object-fit: cover; object-position: center top; }
.ad-badge .sb-icon { flex: none; width: 13px; height: 13px; }
a.tag.ad-badge { min-height: 24px; }
.adcard { align-self: center; display: flex; align-items: center; gap: 12px; width: min(440px, 100%); padding: 10px 12px 10px 10px; border: 1px solid #c8d3e6; border-radius: 14px; background: var(--white); scroll-margin-top: 16px; }
.adcard:target { box-shadow: 0 0 0 2px #c8d3e6; }
.adcard-img { flex: none; display: flex; align-items: center; justify-content: center; width: 66px; height: 88px; border-radius: var(--radius); background: #ecf0f7; color: #2f4b7a; overflow: hidden; }
.adcard-img .ad-thumb { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.adcard-img .sb-icon { width: 28px; height: 28px; }
.adcard-body { flex: 1; min-width: 0; }
.adcard-body p { margin: 0; }
.adcard .k { display: flex; align-items: center; gap: 5px; font-size: 12px; color: #2f4b7a; font-weight: 500; }
.adcard .k .sb-icon { width: 14px; height: 14px; }
.adcard b { display: block; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.adcard small { display: block; font-size: 12px; color: var(--muted); }
.adcard .row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 5px; }
.adcard .row strong { font-weight: 600; }
.adcard .link { color: var(--brand); text-decoration: underline; min-height: 30px; display: inline-flex; align-items: center; }
.op-ad { margin: 8px 0 0; }

/* T76 รูปจากเพจ: สินค้า › รูปสินค้า (two panes on a computer, stacked on a phone) and the send-image sheet's "โพสต์ในเพจ" tab */
.pp { margin-bottom: var(--s5); }
.pp > p { margin: 0 0 var(--s3); max-width: 70ch; }
.pp-cols { display: grid; gap: var(--s3); align-items: start; }
@media (min-width: 1024px) { .pp-cols { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); } }
.pp-cols .card + .card { margin-top: 0; }
.pp-list { padding: 0; overflow: hidden; }
.pp-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.pp-list .pp-head { padding: var(--s3) var(--s4); }
.pp-list ul { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow-y: auto; }
.pp-list a { display: flex; align-items: center; gap: var(--s3); padding: 8px var(--s4); border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.pp-list a[aria-current] { background: #f4ebf0; }
.pp-list a > span { display: flex; flex-direction: column; min-width: 0; }
.pp-list strong { font-weight: 500; }
.pp-list img, .pp-noimg { width: 36px; height: 48px; flex: none; object-fit: cover; object-position: center top; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); }
.pp-pane h4 { margin: var(--s4) 0 var(--s2); font-size: var(--fs-md); }
.pp-pane h4 .muted { font-weight: 400; }
.pp-chosen { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--s3); }
.pp-tile { display: flex; flex-direction: column; gap: 4px; min-width: 0; background: var(--white); }
.pp-tile.dragging { opacity: .6; }
.pp-handle { position: relative; display: block; aspect-ratio: 3 / 4; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: grab; touch-action: none; }
.pp-handle img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.pp-tile label.check { font-size: var(--fs-xs); }
.pp-tile [data-remove] { align-self: flex-start; padding-left: 0; color: var(--danger); }
.pp-posts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.pp-post { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); overflow: hidden; }
.pp-post-head { display: flex; align-items: center; justify-content: flex-start; gap: var(--s3); width: 100%; min-height: 64px; padding: 8px 12px; border: 0; border-radius: 0; background: none; color: var(--ink); text-align: left; }
.pp-post-head[aria-expanded='true'] { background: #f4ebf0; }
.pp-post-head img, .pp-post-head .pp-noimg { width: 40px; height: 52px; flex: none; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); }
.pp-post-text { display: flex; flex-direction: column; min-width: 0; }
.pp-post-text strong { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-photos { padding: var(--s3); border-top: 1px solid var(--line); background: var(--bg); }
.pp-photos-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s2); }
@media (min-width: 768px) { .pp-photos .img-grid { grid-template-columns: repeat(4, minmax(0, 160px)); } }
/* T80 สินค้าที่คุยอยู่: "คุยเรื่อง" bar under the thread header, sizes left, the chooser */
.focus { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--white); border-bottom: 1px solid var(--line); }
.focus[hidden] { display: none; }
.focus img { width: 36px; height: 48px; flex: none; object-fit: cover; object-position: center top; border-radius: 6px; border: 1px solid var(--line); }
.focus-main { flex: 1; min-width: 0; }
.focus-t { margin: 0; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.focus-t b { font-weight: 600; }
.focus .ghost { flex: none; min-height: 44px; text-decoration: underline; }
.sizes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.sz { padding: 0 7px; border-radius: 6px; background: #f3eeef; font-size: 12px; line-height: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.sz b { font-weight: 600; }
.sz.out { background: none; color: var(--muted); text-decoration: line-through; padding: 0 3px; }
.topic-list { list-style: none; margin: 0 -16px; padding: 0; }
.topic-list button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 16px; background: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; color: var(--ink); font-weight: 400; text-align: left; white-space: normal; }
.topic-list button:hover { background: var(--bg); }
.topic-list img, .topic-noimg { width: 42px; height: 56px; flex: none; object-fit: cover; object-position: center top; border-radius: 6px; background: #f3eeef; }
.qa-warn { display: block; }
.qa-warn[hidden] { display: none; }

/* T85 tracking links: button on the customer page, untested tag on the staff page, brand ticks in settings */
.pub-track .pub-trackbtn { flex-basis: 100%; }
.track-untested { font-size: 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: 999px; padding: 0 8px; white-space: nowrap; }
.track-brands { list-style: none; margin: 0 0 var(--s3); padding: 0; display: grid; gap: 8px; }
.track-brands li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 44px; }
.track-brands label { display: flex; align-items: center; gap: 8px; }

/* T87 order detail: summary first (mockup-orders-detail.html), the 7 system steps folded into the history box */
.order-detail { --hair: #ece1e6; --tint: #f4ebf0; --sand: #f8f0e2; --sky: #ecf0f7; --sage: #e9f3ec; --fog: #f3eeef; --ok: #2b6a43; --wait: #7a5a0b; --ready: #2f4b7a; --back: #8a4512; }
.order-detail .od-back { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-bottom: var(--s3); }
.order-detail .od-back a { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; }
.order-detail .od-back .ch { border-radius: 4px; }
.od-sum { margin-bottom: var(--s3); }
.od-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.od-head h2 { margin: 0; font-size: 22px; }
.od-money { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; background: var(--fog); color: var(--muted); }
.od-money.ok { background: var(--sage); color: var(--ok); }
.od-money.wait { background: var(--sand); color: var(--wait); }
.od-sum > .muted { margin: 4px 0 0; }
.od-now { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: var(--s3); padding: 12px 14px; border-radius: 12px; background: var(--tint); }
.od-now.wait { background: var(--sand); }
.od-now.ship, .od-now.ready { background: var(--sky); }
.od-now.ok { background: var(--sage); }
.od-now.bad { background: #fde8ec; }
.od-now.off { background: var(--fog); }
.od-now-t { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.od-now-t small { color: var(--muted); }
.od-now-t small.warn { color: var(--danger); }
.od-now-a { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.od-now-a form { margin: 0; }
.od-parcel { display: flex; align-items: center; gap: 10px; min-width: 0; }
.od-parcel > span { display: flex; flex-direction: column; min-width: 0; }
.od-parcel .mono { overflow-wrap: anywhere; }
.od-steps { margin-top: var(--s4) !important; }
.od-col { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.od-col > .card + .card { margin-top: 0; }
.od-grid { margin-bottom: var(--s3); }
.od-sys-open { margin-bottom: var(--s3); }
/* The live block keeps its step list here; its own buttons live in the "ตอนนี้" bar and the cards. */
.order-detail .order-progress .op-payment, .order-detail .order-progress .op-retry, .order-detail .order-progress .op-links, .order-detail .order-progress .op-cancel { display: none; }
.od-items { list-style: none; margin: 0 0 var(--s3); padding: 0; }
.od-items li { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; gap: 4px 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.od-items img, .od-noimg { width: 44px; height: 56px; object-fit: cover; object-position: center top; border-radius: 8px; border: 1px solid var(--line); background: var(--fog); }
.od-item-name { min-width: 0; overflow-wrap: anywhere; }
.od-item-name small { display: block; }
.od-q { color: var(--muted); white-space: nowrap; }
.od-p { white-space: nowrap; }
.od-totals .od-tot { font-weight: 600; }
.od-totals dd.od-tot small { display: block; font-weight: 400; }
.od-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: var(--s3); }
.od-card-head h3 { margin: 0 !important; }
.od-kv dd { text-align: left; overflow-wrap: anywhere; }
.od-kv .sync-form { display: inline; margin-left: 6px; }
.od-url { width: 100%; margin-bottom: var(--s2); font-size: 14px; color: var(--muted); }
.od-events { list-style: none; margin: 0; padding: 0; }
.od-events li { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding: 6px 0; }
.od-events time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.od-events small { display: block; }
.od-sys { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line); font-size: 14px; }
.od-sys summary { cursor: pointer; color: var(--accent); min-height: 32px; }
.od-end { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.od-end .op-cancel { margin: 0; }
.ad-form .ad-msg { display: block; margin-top: 4px; min-height: 1em; }
@media (max-width: 860px) {
  .od-events li { grid-template-columns: 92px minmax(0, 1fr); }
  .od-now-a > *, .od-now-a > form > button { flex: 1 1 auto; }
}
.order-detail .ad-form { justify-content: flex-start; }
.order-detail .ad-form select { flex: 1 1 100%; }
.order-detail .ad-form .ad-msg { flex-basis: 100%; }
.reply .draft-button { flex-basis: 100%; display: flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; min-height: 32px; color: var(--muted); }
.reply .draft-button input { width: 18px; height: 18px; margin: 0; flex: none; }
/* T86 orders list by work (mockup-orders-list.html): search on top, work chips with counts, one-line pickup bar, 5-part rows, load more */
.orders-list .page-head { margin-bottom: var(--s3); flex-wrap: nowrap; }
.ol-create > summary { width: auto; padding: 8px var(--s4); background: var(--brand); border-color: var(--brand); color: var(--white); font-weight: 500; white-space: nowrap; }
.ol-create[open] > summary, .ol-create > summary:hover { background: var(--accent); border-color: var(--accent); }
.ol-menu-btn { all: unset; box-sizing: border-box; display: flex; align-items: center; width: 100%; min-height: var(--control-h); padding: 6px 12px; border-radius: 6px; color: var(--ink); cursor: pointer; white-space: nowrap; }
.ol-menu-btn:hover, .ol-menu-btn:focus-visible { background: var(--bg); color: var(--brand); }
.more-list form { margin: 0; }
.ol-search { position: relative; display: flex; gap: var(--s2); margin-bottom: var(--s2); }
.ol-q { flex: 1; min-width: 0; margin: 0; }
.ol-q input[type="search"] { width: 100%; box-sizing: border-box; min-height: var(--control-h); }
.ol-filter > summary { list-style: none; display: inline-flex; align-items: center; min-height: var(--control-h); padding: 0 var(--s3); border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); color: var(--brand); cursor: pointer; white-space: nowrap; }
.ol-filter > summary::-webkit-details-marker { display: none; }
.ol-filter[open] > summary { background: #f4ebf0; }
.ol-filter-form { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2) var(--s3); width: min(420px, 100%); box-sizing: border-box; padding: var(--s3); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 6px 20px rgba(42, 32, 41, .14); }
.ol-filter-form label { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-sm); color: var(--muted); }
.ol-filter-form :is(select, input) { width: 100%; box-sizing: border-box; min-height: var(--control-h); }
.ol-filter-go { grid-column: 1 / -1; display: flex; justify-content: flex-end; align-items: center; gap: var(--s3); }
.ol-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--s3); }
.ol-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; box-sizing: border-box; padding: 0 var(--s3); border: 1px solid var(--line); border-radius: 999px; background: var(--white); color: var(--ink); font-size: var(--fs-sm); text-decoration: none; white-space: nowrap; }
.ol-chip:hover { border-color: var(--accent); }
.ol-chip b { font-weight: 600; font-variant-numeric: tabular-nums; }
.ol-chip.hot b { color: var(--danger); }
.ol-chip.on { background: var(--brand); border-color: var(--brand); color: var(--white); }
.ol-chip.on b { color: inherit; }
.pickup-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s3); padding: 10px var(--s3); background: #eef3f8; border: 1px solid #cfdcea; border-radius: var(--radius-lg); font-size: var(--fs-sm); }
.pickup-bar > p { margin: 0; }
.pickup-bar .pickup-line { flex: 1 1 auto; }
.pickup-bar .pickup-recent summary { font-size: var(--fs-xs); }
.pickup-bar .pickup-actions button { padding: 4px var(--s3); font-size: var(--fs-sm); }
.pickup-bar .pickup-recent { flex-basis: 100%; margin: 0; padding: 0; }
.pickup-bar .pickup-recent summary { cursor: pointer; color: var(--accent); width: max-content; }
.pickup-bar .pickup-recent ul { margin: 4px 0 0; padding-left: 1.2em; }
#orders-table tbody tr[data-href] { cursor: pointer; }
#orders-table tbody tr[data-href]:hover { background: #fcf8f9; }
#orders-table tbody tr:has(.pick-one:checked) { background: #f8eff3; }
#orders-table .order-no { text-decoration: none; color: var(--ink); }
#orders-table .o-id { display: inline-flex; flex-direction: column; line-height: 1.35; }
#orders-table .o-when { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); }
#orders-table .o-when img { border-radius: 3px; }
#orders-table .o-name .o-phone { display: block; font-size: var(--fs-xs); }
#orders-table .o-pay { padding-left: 0; }
.pay-tag { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; line-height: 1.5; color: var(--muted); white-space: nowrap; }
.pay-tag.paid { background: #e9f3ec; border-color: #bcd9c5; color: #2b6a43; }
#orders-table .o-track { min-width: 0; }
.o-ship { display: inline-flex; align-items: flex-start; gap: 8px; }
.o-ship .courier-mark { flex: none; border-radius: 4px; font-size: 10px; display: inline-grid; place-items: center; color: var(--white); }
.o-ship > span { display: flex; flex-direction: column; min-width: 0; }
#orders-table .o-track small { display: block; }
.o-err { color: var(--danger); }
.o-label:empty { display: none; }
.status-unprinted { background: #eef3f8; border-color: #cfdcea; color: #2f5677; }
#orders-table .o-status { text-align: right; }
.o-status .o-tags { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.o-status form { margin: 6px 0 0; }
.o-status > .button-link { margin-top: 6px; }
.load-more { margin: 0; padding: var(--s3); text-align: center; font-size: var(--fs-sm); border-top: 1px solid var(--line); }
.load-more a { display: inline-flex; align-items: center; min-height: var(--control-h-sm); }
.print-bar .print-picked { font-size: var(--fs-sm); }
@media (max-width: 767px) {
  .orders-list .page-head { margin-bottom: var(--s2); }
  .orders-list .page-head h2 { font-size: var(--fs-lg); }
  .ol-chips { margin-bottom: var(--s2); }
  .ol-chip { min-height: var(--control-h); }
  .pickup-box.pickup-bar { margin-bottom: var(--s2); padding: 6px var(--s3); }
  .pickup-bar .pickup-pre { display: none; }
  .pickup-bar { row-gap: 2px; }
  .pickup-bar .pickup-line { flex-basis: 0; }
  .orders-list.page-main { padding-top: var(--s2); }
  .pickup-bar .pickup-recent summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: auto; }
  #orders-table .o-name .o-phone { display: inline; font-size: inherit; }
  .ol-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(-1 * var(--s4)); padding-inline: var(--s4); }
  .ol-chips::-webkit-scrollbar { display: none; }
  .ol-filter-form { grid-template-columns: minmax(0, 1fr); width: 100%; }
  #orders-table .o-status .o-tags { flex-wrap: nowrap; }
  #orders-table .o-track { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; }
  .print-bar { flex-wrap: nowrap; gap: 8px; }
  .print-bar .spacer { display: none; }
  .print-bar .print-picked { flex: 1; white-space: nowrap; }
}

/* T78: chat list shows the work: search, filter buttons with counters, unread count / "รอตอบ", transfer + reply-window chips */
.list-top { display: flex; flex-direction: column; gap: 8px; padding: 12px 12px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--white); z-index: 2; }
.conv-search { position: relative; margin: 0; }
.conv-search .sb-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.conv-search input { width: 100%; min-height: var(--control-h); padding: 8px 12px 8px 38px; background: var(--bg); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.fchip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); color: var(--ink); font-size: 14px; white-space: nowrap; text-decoration: none; cursor: pointer; }
.fchip b { font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.fchip[aria-current] { background: var(--brand); border-color: var(--brand); color: var(--white); font-weight: 500; }
.fchip[aria-current] b { color: inherit; opacity: .8; }
.fstatus { position: relative; }
.fstatus summary { list-style: none; }
.fstatus summary::-webkit-details-marker { display: none; }
.fstatus-list { position: absolute; left: 0; top: calc(100% + 4px); z-index: 5; min-width: 200px; display: flex; flex-direction: column; padding: 4px; background: var(--white); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .12); }
.fstatus-list a { padding: 10px 12px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: 14px; }
.fstatus-list a:hover, .fstatus-list a[aria-current] { background: var(--bg); }
.fstatus-list a[aria-current] { font-weight: 600; color: var(--brand); }
.conv-preview { display: flex; align-items: center; gap: 6px; }
.conv-preview > span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-preview img { width: 22px; height: 28px; flex: none; object-fit: cover; object-position: center top; border-radius: 4px; border: 1px solid var(--line); }
.ubadge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: var(--white); font-size: 12px; font-weight: 600; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.waiting { font-size: 12px; font-weight: 500; color: var(--accent); white-space: nowrap; }
.conv:not(.unread) .ubadge, .conv.unread .waiting { display: none; }
.conv.unread .conv-preview { color: var(--ink); }
.conv.unread time { color: var(--brand); font-weight: 600; }
.tag-transfer { background: #fbf3dc; border-color: #e8d39a; color: #7a5a0b; }
.tag-window { display: inline-flex; align-items: center; gap: 3px; background: #fde8ec; border-color: #f2b8c3; color: var(--danger); }
.tag-window .sb-icon { width: 12px; height: 12px; }
.th-health { display: none; flex: none; width: 10px; height: 10px; border-radius: 50%; background: #d08a2c; }
.th-health.is-failed { background: var(--danger); }
@media (max-width: 767px) {
  .list-top { padding: 10px 16px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 1px 16px; }
  .filters::-webkit-scrollbar { display: none; }
  .fchip { min-height: 40px; padding: 0 14px; }
  .fstatus[open] { position: static; }
  .fstatus-list { left: 16px; right: 16px; top: auto; }
  /* inside a chat, staff see the connection warning as the dot on the chat header; admins keep the bar */
  body.has-thread:has(.th-health) .health-bar { display: none; }
  body.has-thread .th-health { display: inline-block; }
}
/* T70 LINE: sticker label, location card, follow/unfollow line; T71: taken back, answered from a Meta app, edited, reactions */
.part-stk { display: inline-flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 96px; max-width: 220px; min-height: 72px; padding: 8px 12px; border-radius: 16px; background: #f4ebf0; color: var(--brand); font-size: 13px; }
.part-stk b { font-weight: 600; }
.part-stk span { color: var(--muted); overflow-wrap: anywhere; }
.part-loc p { padding-left: 2px; }
.msg.msg-line { align-self: center; align-items: center; max-width: 92%; }
.sysline { display: inline-block; padding: 3px 12px; border: 1px solid #ece1e6; border-radius: 999px; background: var(--white); font-size: 13px; color: var(--muted); text-align: center; }
.part-gone { display: inline-flex; align-items: center; padding: 6px 12px; border: 1px dashed #cdbcc4; border-radius: 12px; color: var(--muted); font-size: 13px; font-style: italic; }
.msg.in.msg-line:has(> .part-gone) { align-self: flex-start; align-items: flex-start; }
.msg > .meta { order: 2; }
.part-via, .part-react { order: 1; font-size: 12px; color: var(--muted); }
.part-react { align-self: flex-start; margin-top: -6px; margin-left: 8px; padding: 0 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); line-height: 20px; }
.msg.out .part-react { align-self: flex-end; margin-left: 0; margin-right: 8px; }

/* T81: short order form from a chat (OrderPanel without page mode) */
.op-fields { display: contents; }
.op-fields[hidden], .addr-card[hidden], .parcel-line[hidden] { display: none; }
button.linkish { min-height: 36px; padding: 0 4px; border: 0; background: none; color: var(--accent); font-weight: 400; text-decoration: underline; text-underline-offset: 3px; }
button.linkish:hover { background: none; color: var(--brand); }
.panel-section h3.op-h { display: flex; align-items: center; gap: 8px; }
.op-h .linkish { margin-left: auto; font-size: 14px; }
.addr-card { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.addr-card p { margin: 0; }
.addr-card b { font-weight: 600; }
.parcel-line { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; }
.parcel-line .linkish { margin-left: auto; }
.pay2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pay-opt { position: relative; display: flex; flex-direction: column; justify-content: center; min-height: 56px; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius-lg); cursor: pointer; }
.pay-opt input { position: absolute; opacity: 0; pointer-events: none; }
.pay-opt b { font-size: 16px; font-weight: 600; }
.pay-opt small { font-size: 12px; color: var(--muted); }
.pay-opt:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); background: #f4ebf0; color: var(--brand); }
.pay-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.op-extra { gap: 4px; }
.op-link > summary { min-height: 36px; display: flex; align-items: center; justify-content: flex-start; text-align: left; width: fit-content; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.op-link[open] > summary { margin-bottom: 8px; }
.op-short .op-ad { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.order-panel:not(.page-form) .panel-body { padding-bottom: 0; }
.op-foot { position: sticky; bottom: 0; z-index: 3; margin: 0 -16px; padding: 10px 16px 12px; border-top: 1px solid var(--line); border-bottom: 0; background: var(--white); box-shadow: 0 -10px 24px -18px rgba(42, 32, 41, .35); gap: 4px; }
.op-total { display: flex; align-items: center; gap: 12px; }
.op-total p { flex: 1; min-width: 0; margin: 0; display: flex; flex-direction: column; }
.op-total small { font-size: 12px; color: var(--muted); }
.op-total .amt { font-size: 20px; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; color: var(--ink); }
.op-foot button[type="submit"] { width: auto; min-height: 48px; padding-inline: 20px; font-size: 16px; font-weight: 600; }
.op-hint { margin: 0; font-size: 12px; color: var(--muted); }
.op-foot .error { margin: 0; }
.op-peek { display: flex; align-items: center; gap: 8px; margin: 0; padding: 4px 8px 4px 12px; border-radius: var(--radius); background: var(--bg); border: 1px solid #ece1e6; font-size: 14px; }
.op-peek .cut { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peek-list[hidden] { display: none; }
.peek-list { display: flex; flex-direction: column; gap: 6px; }
.panel-section.panel-chat { gap: 6px; }

/* T82: chat after the order is saved: order bar (in place of the topic bar) and order system lines */
.order-bar { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid #e8d39a; background: #f8f0e2; color: #7a5a0b; font-size: 14px; }
.order-bar[hidden] { display: none; }
.order-bar:not([hidden]) + .focus { display: none; }
.ob-main { flex: 1; min-width: 0; }
.ob-main p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ob-t b { font-weight: 600; }
.ob-next { opacity: .9; }
.order-bar .button-link { flex: none; border-color: currentColor; color: inherit; }
.order-bar.ob-good { background: #e9f3ec; border-color: #bcd9c5; color: #2b6a43; }
.order-bar.ob-bad { background: #fde8ec; border-color: #f2b8c3; color: var(--danger); }
.sys-row { align-self: center; max-width: 92%; }
.sysline.sys-good { border-color: #bcd9c5; background: #e9f3ec; color: #2b6a43; }
.sysline.sys-bad { border-color: #f2b8c3; background: #fde8ec; color: var(--danger); }

/* T91 — New UI layer ("ui2"). Draft for ticket 91: append this block to public/app.css as it is.
   It carries the marketing card language (ticket 56, mk-*) and the work-first list parts of chat/orders
   (tickets 78/86/87) to every other staff page. Opt-in per page: <main class="page-main ui2">.
   Chat, orders, /o/ and the marketing pages do not carry the class, so nothing there changes.
   Tokens: the --mk-* set moves from `.mk2 {}` to `:root {}` with the same values (marketing keeps reading them). */

/* ---------- page frame: same box as .page-main.mk2 */
.page-main.ui2 { max-width: 1280px; margin: 0; padding: 20px 32px 64px; }
/* margins: only inside the new parts. The old pages keep their own paragraph and heading spacing. */
.ui2 :is(.page-head, .mk-card, .mk-banner, .ui-now, .ui-savebar, .ui-card-h) :where(h1, h2, h3, p, ol, ul) { margin: 0; }
.ui2 :is(.mk-card, .mk-banner) :where(ol, ul) { padding: 0; list-style: none; }
.ui2 .ui-sub { margin: 0; }
.ui2 .page-head { margin-bottom: 16px; min-height: 44px; gap: 8px 12px; }
.ui2 .page-head :is(h1, h2) { font-size: 22px; font-weight: 600; line-height: 1.3; }
.ui2 .page-head .crumb { color: var(--muted); font-weight: 400; font-size: 18px; }
.ui2 .ui-sub { color: var(--muted); font-size: 14px; }
.ui2 .ui-back { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; margin-bottom: 4px; font-size: 14px; color: var(--accent); text-decoration: none; }
.ui2 .ui-back:hover { text-decoration: underline; }
.ui2 .ui-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.ui2 .ui-actions form { margin: 0; }
.ui2 .ui-sec { margin: 24px 0 10px; font-size: 16px; font-weight: 600; color: var(--ink); }
.ui2 .ui-stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ui2 .ui-stack > .card + .card, .ui2 .mk-dash > .card + .card { margin-top: 0; }
.ui2 :is(.mk-rows, .mk-days, .od-items, .od-events) { list-style: none; margin: 0; padding: 0; }
.ui2 .mk-dash .c6 { grid-column: span 6; } .ui2 .mk-dash .c8 { grid-column: span 8; } .ui2 .mk-dash .c9 { grid-column: span 9; }

/* phone tabs: the pages of the current menu group (the sidebar sub-menu is inside the drawer on a phone).
   Rendered by Sidebar() right under the phone bar, above <main>; not for การตลาด, which has its own mk-tabs. */
.ui-tabs { display: none; }

/* login card in the same card shape (the login page has no <main class="ui2">) */
.login-card { border-color: var(--mk-hair); border-radius: var(--mk-r-card); box-shadow: var(--mk-shadow); }
.login-card button, .login-card input { border-radius: var(--mk-r-btn); }

/* ---------- controls */
.ui2 button, .ui2 a.button-link, .ui2 .more-menu > summary { border-radius: var(--mk-r-btn); }
.ui2 input:where(:not([type="checkbox"], [type="radio"], [type="file"])), .ui2 select, .ui2 textarea { border-radius: var(--mk-r-btn); border-color: #dfd2d8; }
.ui2 input::placeholder, .ui2 textarea::placeholder { color: #a8989f; }
.ui2 input[type="file"] { color: var(--muted); }
.ui2 input[type="file"]::file-selector-button { margin-right: 10px; min-height: 36px; padding: 0 14px; border: 1px solid var(--brand); border-radius: var(--mk-r-btn); background: #fff; color: var(--brand); font: inherit; font-weight: 500; cursor: pointer; }
.ui2 .hint { line-height: 1.5; }

/* ---------- cards, tables */
.ui2 .card, .ui2 .table-wrap { border-color: var(--mk-hair); border-radius: var(--mk-r-card); box-shadow: var(--mk-shadow); }
.ui2 .card { padding: 16px; }
.ui2 .card .card, .ui2 .card .table-wrap { box-shadow: none; border-radius: 12px; } /* no card look inside a card */
.ui2 .card h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; color: var(--ink); }
.ui2 .card h3:not(:first-child) { margin-top: 18px; }
.ui2 .ui-card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ui2 .ui-card-h h3 { flex: 1; min-width: 0; margin: 0; }
.ui2 .ui-card-h h3 small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.ui2 .table th, .ui2 .table td { padding: 10px 16px; border-bottom-color: var(--mk-hair); }
.ui2 .table th { padding-block: 12px; background: #fdfafb; }
.ui2 .table thead th:first-child { border-top-left-radius: var(--mk-r-card); }
.ui2 .table thead th:last-child { border-top-right-radius: var(--mk-r-card); }
.ui2 .table tbody tr[data-href] { cursor: pointer; }
.ui2 .table tbody tr[data-href]:hover, .ui2 .table tbody tr.row-link:hover { background: #fcf8f9; }
.ui2 .table a.row-title { color: var(--ink); font-weight: 600; text-decoration: none; }
.ui2 .table a.row-title:hover { color: var(--brand); }
.ui2 .table small { display: block; color: var(--muted); font-size: 13px; }
.ui2 .empty, .ui2 .table td.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* ---------- KPI tiles (existing .tiles/.tile) in the mk-kpi shape */
.ui2 .tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 16px; }
.ui2 .tile { border-color: var(--mk-hair); border-radius: var(--mk-r-card); box-shadow: var(--mk-shadow); padding: 14px 16px; gap: 4px; min-height: 96px; }
.ui2 .tile b { font-size: 26px; line-height: 1.25; }
.ui2 .tile .tile-label, .ui2 .tile > .muted:first-child { font-size: 14px; color: var(--muted); }
.ui2 a.tile { text-decoration: none; color: inherit; }
.ui2 a.tile:hover { border-color: var(--accent); }
.ui2 .tile.on { border-color: var(--brand); background: var(--mk-tint); box-shadow: 0 0 0 1px var(--brand); }

/* ---------- status pills: one shape; the colour pairs per status stay as they are */
.ui2 .status, .ui2 .tag { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border: 0; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap; }
.ui2 .status:not([class*="status-"], [class*="case-"]) { background: var(--mk-fog); color: var(--muted); }

/* ---------- flash banners */
.ui2 p.ok, .ui2 p.error, .ui2 .warn, .ui2 p.warn-text { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; }
.ui2 p.ok { background: var(--mk-sage); border-color: #cfe5d6; color: var(--mk-ok); }

/* ---------- "ตอนนี้" bar: what this record needs next (same idea as .od-now on the order page) */
.ui-now { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 14px; border-radius: 12px; background: var(--mk-tint); }
.ui-now.wait { background: var(--mk-sand); } .ui-now.ready { background: var(--mk-sky); } .ui-now.ok { background: var(--mk-sage); }
.ui-now.bad { background: #fde8ec; } .ui-now.off { background: var(--mk-fog); }
.ui-now-t { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ui-now-t small { color: var(--muted); font-size: 13px; }
.ui-now-a { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ui-now-a form { margin: 0; }

/* ---------- horizontal steps (case, purchase order) */
.ui-steps { list-style: none; display: flex; margin: 14px 0 0; padding: 0; }
.ui-steps li { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); text-align: center; }
.ui-steps li::before { content: ''; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #cdbcc4; background: #fff; z-index: 1; }
.ui-steps li + li::after { content: ''; position: absolute; top: 8px; right: 50%; width: 100%; height: 2px; background: #e3d6dc; }
.ui-steps li.done::before { background: var(--brand); border-color: var(--brand); }
.ui-steps li.done + li::after, .ui-steps li.now::after { background: var(--brand); }
.ui-steps li.done + li.done::after { background: var(--brand); }
.ui-steps li.now { color: var(--ink); font-weight: 600; }
.ui-steps li.now::before { border-color: var(--brand); box-shadow: 0 0 0 4px var(--mk-tint); }
.ui-steps small { font-weight: 400; color: var(--muted); }

/* ---------- key/value list */
.ui-kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: 14px; }
.ui-kv dt { color: var(--muted); }
.ui-kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.ui-kv .tot { font-weight: 600; font-size: 15px; padding-top: 6px; border-top: 1px solid var(--mk-hair); }

/* ---------- month stepper / segmented links */
.ui-step { display: inline-flex; align-items: center; gap: 2px; min-height: 40px; padding: 0 4px; background: #fff; border: 1px solid var(--mk-hair); border-radius: 12px; box-shadow: var(--mk-shadow); font-weight: 600; white-space: nowrap; }
.ui-step a { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.ui-step a:hover { background: var(--mk-tint); color: var(--brand); }
.ui-step span { padding: 0 8px; }
.ui2 .ol-chip small { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ui2 .ol-chip.on small { color: var(--mk-on-brand-2); }

/* ---------- folds inside pages (details) */
.ui-fold { border-top: 1px solid var(--mk-hair); }
.ui-fold > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; color: var(--accent); font-size: 14px; list-style: none; }
.ui-fold > summary::-webkit-details-marker { display: none; }
.ui-fold > summary::after { content: '›'; margin-left: auto; font-size: 18px; color: var(--muted); transition: transform .15s; }
.ui-fold[open] > summary::after { transform: rotate(90deg); }
.ui-fold > :not(summary) { margin-bottom: 12px; }

/* ---------- sticky save bar (long forms; phone and desktop) */
.ui-savebar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 12px; margin: 16px -32px -64px; padding: 12px 32px; background: rgba(255, 255, 255, .96); border-top: 1px solid var(--mk-hair); }
.ui-savebar .ui-savebar-t { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); }
.ui-savebar .ui-savebar-t b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- table -> cards on a phone: <table class="table cards-sm">, cells carry .c-title / .c-meta / .c-num / .c-hide / data-label */
@media (max-width: 767px) {
  .page-main.ui2 { padding: 12px 16px 72px; }
  .ui2 .page-head :is(h1, h2) { font-size: 20px; }
  .ui2 .page-head .crumb { display: none; } /* the tabs above name the section */
  .ui-tabs { display: flex; gap: 4px; padding: 8px 16px; background: #fff; border-bottom: 1px solid var(--mk-hair); overflow-x: auto; scrollbar-width: none; }
  .ui-tabs::-webkit-scrollbar { display: none; }
  .ui-tabs a { flex: 1 0 auto; text-align: center; padding: 6px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
  .ui-tabs a[aria-current] { background: var(--mk-tint); color: var(--brand); font-weight: 600; }
  .ui2 .mk-dash { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .ui2 .mk-dash > * { grid-column: auto !important; }
  .ui2 .mk-dash .mk-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .ui2 .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .ui2 .tile { min-height: 0; padding: 12px 14px; }
  .ui2 .tile b { font-size: 20px; }
  .ui2 .ol-chips { flex-wrap: nowrap; overflow-x: auto; margin-inline: -16px; padding: 1px 16px; scrollbar-width: none; }
  .ui2 .ol-chips::-webkit-scrollbar { display: none; }
  .ui2 .ol-chip { flex: none; }
  .ui-savebar { margin: 16px -16px -72px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .ui-savebar > button, .ui-savebar > a.button-link { flex: 1; }
  .ui-savebar .ui-savebar-t { flex: 0 1 auto; }
  .ui-now-a > *, .ui-now-a > form > button { flex: 1 1 auto; }
  .ui-steps li { font-size: 12px; }

  .ui2 .table-wrap:has(> .cards-sm) { background: none; border: 0; box-shadow: none; overflow: visible; }
  .ui2 .cards-sm, .ui2 .cards-sm tbody { display: block; }
  .ui2 .cards-sm thead { display: none; }
  .ui2 .cards-sm tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 12px 14px; margin-bottom: 10px; background: #fff; border: 1px solid var(--mk-hair); border-radius: 14px; box-shadow: var(--mk-shadow); }
  .ui2 .cards-sm tr::after { content: ''; order: 1; flex-basis: 100%; height: 0; } /* line break after title + number */
  .ui2 .cards-sm td { display: block; padding: 0; border: 0; order: 2; font-size: 14px; text-align: left; min-width: 0; }
  .ui2 .cards-sm td.c-title { order: 0; flex: 1 1 0; min-width: 55%; font-size: 15px; font-weight: 600; }
  .ui2 .cards-sm td.c-num { order: 1; flex: none; margin-left: auto; text-align: right; font-size: 15px; font-weight: 600; white-space: nowrap; }
  .ui2 .cards-sm td.c-meta { color: var(--muted); font-size: 13px; }
  .ui2 .cards-sm td.c-side { order: 3; margin-left: auto; }
  .ui2 .cards-sm td.c-hide, .ui2 .cards-sm td:empty { display: none; }
  .ui2 .cards-sm td[data-label]::before { content: attr(data-label) ' '; color: var(--muted); }
  .ui2 .cards-sm td.c-pick { order: -1; flex: none; align-self: center; }
}
.push-hint summary { cursor: pointer; } /* T91: blocked-notification hint, one line until opened */

/* T93 — stock pages: คงเหลือ head, ต้นทุน and ล็อต as cards on a phone, lot page head, opening count grid + save bar. */
.t93-unit { display: none; } /* "ชิ้น" after a bare number, only where the table header is hidden (phone cards) */
/* นับสต็อกตั้งต้น: colour column stays on the left while the sizes scroll; the right edge fades while more sizes follow
   (the white cover scrolls with the content and hides the fade at the end; CSS only). */
.ui2 .count-grid :is(thead th:first-child, tbody th) { position: sticky; left: 0; z-index: 1; background: var(--white); }
.ui2 .sc-grid:has(> .count-grid) {
  background: linear-gradient(to left, var(--white), var(--white)) right / 24px 100% no-repeat local,
    linear-gradient(to left, rgba(74, 32, 54, .16), rgba(74, 32, 54, 0)) right / 20px 100% no-repeat scroll;
}
@media (max-width: 767px) {
  /* คงเหลือ: sync time drops under the title; ซิงก์ and ⋯ stay on the title line */
  .ui2 .page-head:has(.sync-at) { flex-wrap: wrap; }
  .ui2 .page-head:has(.sync-at) h1 { flex: 1 1 auto; min-width: 0; }
  .ui2 .page-head:has(.sync-at) .ui-actions { display: contents; }
  .ui2 .page-head:has(.sync-at) .sync-at { order: 1; flex-basis: 100%; margin-top: -8px; }
  .ui2 .cards-sm .t93-unit { display: inline; }
  /* ต้นทุน: one card per model (its tbody), the "แยกต่อล็อต" fold inside the same card */
  .ui2 .cost-table > tbody { margin-bottom: 10px; background: #fff; border: 1px solid var(--mk-hair); border-radius: 14px; box-shadow: var(--mk-shadow); }
  .ui2 .cost-table > tbody > tr { margin: 0; border: 0; border-radius: 0; box-shadow: none; background: none; }
  .ui2 .cost-table > tbody > tr + tr { padding-top: 0; }
  .ui2 .cost-table td.cost-lots { flex-basis: 100%; }
  .ui2 .cost-lots table { display: block; margin-top: 4px; }
  .ui2 .cost-lots tr { margin: 0; padding: 8px 0; border: 0; border-top: 1px solid var(--mk-hair); border-radius: 0; box-shadow: none; }
  .ui2 .cards-sm .cost-model { gap: 8px; }
  .ui2 .cards-sm .cost-model .sc-thumb { width: 42px; height: 56px; flex: none; }
}
/* หน้าล็อต: picture, name, code on one line; the cost line drops below on a narrow phone so the name keeps its width */
@media (max-width: 479px) {
  .lot-model .sc-head { flex-wrap: wrap; }
  .lot-model .sc-meta { flex-basis: 100%; align-items: flex-start; white-space: normal; }
}
.ui2 .lot-sum, .ui2 .lot-model { margin-bottom: 12px; }
/* T95 expenses: month stepper + chips in the head, cards-sm list, bill count, save bar on the add form, delete in a fold */
.ui2 .x-bill { white-space: nowrap; }
.ui2 .x-bill a { color: inherit; text-decoration: none; }
.ui2 .x-bill a:hover { color: var(--brand); }
.ui2 .x-bill .mk-ic { width: 14px; height: 14px; vertical-align: -2px; }
.ui2 .x-none { color: #a8989f; }
.ui2 .x-foot { margin: 12px 0 0; text-align: right; font-size: 14px; color: var(--muted); }
.ui2 .x-form { max-width: 760px; }
.ui2 .x-form fieldset { gap: 0; }
.ui2 .x-form .card { margin: 0; }
.ui2 .x-form .bill-rows { margin-top: 16px; }
.ui2 .x-thumbs { margin-top: 12px; }
.ui2 .x-thumbs .bill img { width: 72px; height: 72px; }
.ui2 .x-form + .ui-fold { max-width: 760px; margin-top: 24px; }
@media (max-width: 767px) {
  .ui2 .page-head:has(.ui-step) .ui-actions { flex-basis: 100%; margin-left: 0; justify-content: space-between; }
  .ui2 .x-foot { text-align: center; }
}

/* T97 staff: full-width list (cards on a phone), add form folded under the head (#add), person page cards in two columns */
.ui2 #add { margin-bottom: 16px; }
.ui2 #add > .card { margin: 0; max-width: 760px; }
.ui2 .st-list tr.off .row-title { color: var(--muted); }
.ui2 .st-list td.mono { overflow-wrap: anywhere; }
.ui2 .st-grid { display: grid; gap: 16px; align-items: start; }
.ui2 .st-grid > .card { margin: 0; max-width: none; }
.ui2 .st-grid h3 { margin: 0; }
.ui2 .st-erase { max-width: 760px; }
@media (min-width: 768px) {
  .ui2 .st-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
} /* end T97 desktop */
/* T96 cases: list chips + cards, case page summary / now bar / steps, two columns */
.ui2 .cs-back { display: flex; flex-wrap: wrap; gap: 0 18px; margin: 0 0 6px; }
.ui2 .cs-back svg, .ui2 .ui-now-a .button-link svg { width: 16px; height: 16px; flex: none; }
.ui2 .ui-now-a .button-link { display: inline-flex; align-items: center; gap: 6px; }
.case-page .cs-sum > .page-head { margin-bottom: 4px; flex-wrap: wrap; align-items: center; gap: 8px; }
.case-page .cs-sum > .page-head h1 { font-size: 22px; }
.case-page .cs-sum > .page-head > .tag { align-self: center; }
.case-page .cs-sum > p { margin: 0; }
.case-page .cs-sum > .ui-now { margin-top: 12px; }
.case-page .cs-grid { margin-top: 16px; }
.case-page .cs-retry { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.case-page .cs-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 0 0 8px; width: 100%; }
.case-page .cs-inline label { flex: 1 1 240px; }
.case-page .cs-draft { white-space: pre-wrap; font: inherit; margin: 0 0 8px; padding: 12px 14px; background: var(--mk-sand); border-radius: 12px; }
.case-page .od-items li { grid-template-columns: minmax(0, 1fr) auto auto; }
.case-page .od-items li:last-child { border-bottom: 0; }
.case-page .od-item-name small { display: block; }
.case-page .ui-kv { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--mk-hair); }
.case-page .od-events + .ui-fold { margin-top: 10px; }
.case-page .ui-fold > summary { color: var(--muted); }
.case-page .ui-fold .case-stop { margin: 8px 0 0; padding-top: 0; border-top: 0; }
@media (max-width: 767px) {
  .case-page .ui-steps li small { display: none; }
  .case-page .ui-steps li { font-size: 11px; }
  .case-page .cs-sum > .page-head h1 { font-size: 18px; }
  .ui2 .cs-back .ui-back { min-height: 28px; margin-bottom: 0; }
  .case-form .table tr { margin-bottom: 10px; padding: 8px 4px; border: 1px solid var(--mk-hair); border-radius: 12px; }
} /* end T96 phone */
/* T92 dashboard (ภาพรวมขาย) + P&L. From ux-all-2026-11-19/_src/mock.css "T92". */
.d2-period { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 16px; }
.d2-period .ol-chips { margin: 0; align-items: center; }
.d2-range { display: none; order: 1; flex-basis: 100%; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin: 0; }
.d2-range:target, .d2-range.on { display: flex; }
.d2-range label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.d2-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.d2-kpis .mk-val .delta, .d2-kpis .mk-note .delta { font-size: 13px; font-weight: 500; white-space: nowrap; }
.d2-kpis .mk-note { display: block; }
.dash2 .mk-card .legend { margin: 0 0 12px; }
.d2-neg { color: var(--danger); }
.d2-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.d2-num small { display: block; font-size: 13px; color: var(--muted); }
.d2-pair { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 10px; }
.d2-pair > * { min-width: 0; color: inherit; text-decoration: none; }
.d2-pair small { display: block; font-size: 13px; color: var(--muted); }
.d2-pair b { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.d2-pair a:hover b { color: var(--brand); }
.mk-t small { display: block; font-size: 13px; color: var(--muted); }
.dash2 .mk-card .ui-fold { margin-top: 2px; }
.dash2 .mk-card .ui-fold > summary { min-height: 36px; }
.dash2 .mk-card :is(.tile, .table-wrap) { box-shadow: none; }
.dash2 .mk-card .ui-fold h3 { margin: 14px 0 8px; font-size: 15px; font-weight: 600; }
.dash2 .mk-card .ui-fold .tiles { margin: 4px 0 8px; }
.dash2 .mk-card .tile { min-height: 0; }
.dash2 .mk-card .tile b { font-size: 20px; }
.dash2 .mk-banner h1 { font-size: 24px; }
.pnl .d2-kpis { margin-bottom: 16px; }
.ui-step i.off { display: grid; place-items: center; width: 32px; height: 32px; color: #d9cbd1; }
.ui-step .mk-ic { width: 16px; height: 16px; }
@media (max-width: 767px) {
  .d2-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .d2-period { gap: 8px; }
  .d2-period .ui-sub { flex-basis: 100%; font-size: 13px; }
  .d2-range label { flex: 1 1 130px; }
  .dash2 .mk-val { font-size: 22px; }
  .dash2 .mk-banner { padding: 16px; }
  .dash2 .mk-banner h1 { font-size: 20px; }
  .dash2 .mk-banner .mk-btn { width: 100%; }
  .d2-pair b { font-size: 17px; }
  .dash2 .d2-kpis .mk-note { font-size: 12px; }
  .dash2 .d2-kpis .mk-card-h { padding: 10px 12px 0; }
  .dash2 .d2-kpis .mk-card-b { padding: 6px 12px 10px; }
  .dash2 .mk-banner { gap: 10px; }
  .dash2 .mk-banner p { font-size: 13px; }
}

/* T94 purchase orders + receive: list as cards on a phone, PO summary card + two columns + save bar, model card cost
   fields under the name on a phone, size grid fits 375 px, lot fields in one card, 40 px "นับตรงแล้ว" tap target. */
.ui2 .po-list tr { position: relative; }
.ui2 .po-list a.row-title::after { content: ''; position: absolute; inset: 0; } /* whole row opens the order */
.ui2 .po-list .status { position: relative; } /* stays above the row link for hover/selection, not a target */
.ui2 .po-sum { margin-bottom: 16px; }
.ui2 .po-sum .page-head { margin-bottom: 4px; }
.ui2 .po-sum .page-head h1 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.ui2 .po-sum .page-head h1 .status { font-size: 12px; }
.ui2 .po-sum .ui-now { margin-top: 12px; }
.ui2 .po-sum .more-list { min-width: 260px; display: flex; flex-direction: column; gap: 4px; }
.ui2 .po-sum .more-list form { margin: 0; }
.ui2 .po-sum .more-list button { width: 100%; justify-content: flex-start; }
.ui2 .po-sum .more-list .cancel-form { margin: 0; padding: 8px; }
.ui2 .po-sum .more-list .cancel-form p { white-space: normal; }
.ui2 .po-sum .more-list .op-links { width: 100%; }
.ui2 .po-sum .more-list .op-links button { flex: 1; width: auto; }
.ui2 .po-lots { margin-bottom: 16px; }
.ui2 .po-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.ui2 .po-grid > .card, .ui2 .po-form > .card, .ui2 .po-msg-col > .card { margin: 0; }
.ui2 .po-form { display: contents; }
.ui2 .po-items { order: 1; }
.ui2 .po-msg-col { order: 2; min-width: 0; }
.ui2 .po-side { order: 3; }
.ui2 .po-grid .ui-savebar { order: 4; }
.ui2 .po-items .stock-card { margin: 0; padding: 12px 0; border: 0; border-top: 1px solid var(--mk-hair); border-radius: 0; box-shadow: none; }
.ui2 .po-items .ui-card-h + .stock-card, .ui2 .po-items .po-add + .stock-card { border-top: 0; padding-top: 0; }
.ui2 .po-items h3 small { font-weight: 400; }
.ui2 .po-add { max-width: none; }
.ui2 .po-money .ui-kv dd { font-variant-numeric: tabular-nums; }
.ui2 .po-due { color: var(--mk-back); font-weight: 600; }
.ui2 .po-bills { list-style: none; margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--mk-hair); font-size: 14px; }
.ui2 .po-bills li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 4px 0; }
.ui2 .po-bills li > a { flex: 1; min-width: 0; }
.ui2 .po-bills small { flex-basis: 100%; }
.ui2 .po-wide { width: 100%; margin-top: 14px; justify-content: center; }
.ui2 .po-info .ui-fold { margin-top: 4px; }
.ui2 .po-info .ui-fold ul { margin: 0; padding-left: 18px; }
@media (min-width: 861px) {
  .ui2 .po-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); grid-template-rows: auto 1fr auto; }
  .ui2 .po-items { grid-column: 1; grid-row: 1; }
  .ui2 .po-msg-col { grid-column: 1; grid-row: 2; }
  .ui2 .po-side { grid-column: 2; grid-row: 1 / 3; }
  .ui2 .po-grid .ui-savebar { grid-column: 1 / -1; grid-row: 3; }
  .ui2 .po-grid:not(:has(.po-msg-col)) .po-side { grid-row: 1; }
} /* end T94 media 1 */
/* model card (purchase order + receive): picture, name and code on the top line; on a phone the cost fields drop below */
.ui2:is(.po-page, .rc-page) .stock-card .sc-title strong { overflow-wrap: anywhere; }
@media (max-width: 767px) {
  .ui2:is(.po-page, .rc-page) .stock-card .sc-head { flex-wrap: wrap; }
  .ui2:is(.po-page, .rc-page) .stock-card .sc-title { flex: 1 1 calc(100% - 80px); }
  .ui2:is(.po-page, .rc-page) .stock-card .rc-cost { flex: 1 1 120px; min-width: 0; align-items: stretch; }
  .ui2:is(.po-page, .rc-page) .stock-card .rc-cost input { width: 100%; }
  .ui2:is(.po-page, .rc-page) .stock-card .sc-thumb { width: 48px; height: 64px; }
  /* size grid: 5 sizes fit 375 px, cells at least 44 px */
  .ui2:is(.po-page, .rc-page) .sc-grid { overflow-x: visible; background: none; }
  .ui2:is(.po-page, .rc-page) .count-grid { table-layout: fixed; }
  .ui2:is(.po-page, .rc-page) .count-grid :is(th, td) { padding: 4px 2px; }
  .ui2:is(.po-page, .rc-page) .count-grid :is(thead th:first-child, tbody th) { width: 64px; white-space: normal; overflow-wrap: anywhere; }
  .ui2:is(.po-page, .rc-page) .count-grid input.count { width: 100%; min-width: 44px; padding: 4px 6px; height: 40px; min-height: 40px; }
  .ui2 .po-grid .ui-savebar > button { flex: 0 1 auto; }
} /* end T94 media 2 */
/* receive: GET "จากใบสั่งซื้อ" and the lot fields read as one card */
.ui2 .rc-po { margin: 0; padding-bottom: 4px; border-bottom: 0; border-radius: var(--mk-r-card) var(--mk-r-card) 0 0; box-shadow: none; }
.ui2 .rc-po label { flex: 1 1 260px; }
.ui2 .rc-po { flex-wrap: wrap; }
.ui2 .rc-po .rc-from { flex: 1 1 100%; margin: 0; }
.ui2 .rc-lot { margin: 0 0 16px; }
.ui2 .rc-po + form .rc-lot { border-top: 0; border-radius: 0 0 var(--mk-r-card) var(--mk-r-card); padding-top: 8px; }
.ui2 .rc-po + form .rc-lot > h3 { display: none; } /* the card already starts with จากใบสั่งซื้อ */
.ui2 .rc-lot .form-grid { margin-bottom: 4px; }
@media (max-width: 767px) {
  .ui2 .rc-lot .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
  .ui2 .rc-lot .form-grid:has([name="close_po"]) > label.full { grid-column: auto; } /* หมายเหตุ beside ปิดใบนี้ */
  .ui2 .rc-lot .form-grid > label:has([name="close_po"]) { justify-content: center; min-height: 40px; }
  .ui2.rc-page > p.small { margin: 0 0 8px; font-size: 13px; }
  .ui2.rc-page .page-head { margin-bottom: 8px; }
  .ui2 .rc-po { padding-top: 12px; row-gap: 6px; }
  .ui2 .rc-po .rc-from { font-size: 13px; line-height: 1.45; }
  .ui2 .rc-po + form .rc-lot { padding-top: 4px; }
  .ui2.rc-page .opening-form .rc-lot + .stock-card { margin-top: -4px; }
  .ui2.rc-page .ui-savebar { flex-wrap: wrap; row-gap: 6px; }
  .ui2.rc-page .ui-savebar .ui-savebar-t { flex-basis: 100%; }
  .ui2.rc-page .rc-lot .ui-fold > summary { min-height: 40px; }
} /* end T94 media 3 */
.ui2 .rc-lot .ui-fold p { margin: 0; }
.ui2.rc-page .opening-form .stock-card { margin-bottom: 12px; border-color: var(--mk-hair); border-radius: var(--mk-r-card); box-shadow: var(--mk-shadow); }
.ui2.rc-page .rc-qc { width: 100%; }
/* "นับตรงแล้ว": the label is a 40 px target; the visible box stays 20 px */
.ui2 .count-grid label.count-ok-hit { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin: 0; vertical-align: middle; cursor: pointer; }
.ui2 .count-grid label.count-ok-hit input.count-ok { margin: 0; }
@media (max-width: 767px) {
  .ui2.rc-page .count-grid label.count-ok-hit { display: flex; width: 100%; height: 40px; }
  .ui2.rc-page .count-grid label.count-ok-hit input.count-ok { appearance: none; -webkit-appearance: none; width: 100%; max-width: 44px; height: 36px; margin: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
  .ui2.rc-page .count-grid label.count-ok-hit input.count-ok:checked { border-color: var(--brand); background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 18px no-repeat; }
  .ui2.rc-page .count-grid label.count-ok-hit input.count-ok:required:not(:checked) { border-color: var(--accent); }
} /* end T94 media 4 */
/* T98 — vendors + reorder: vendor list as phone cards, vendor products as one card per row, reorder grouped by model, order message box. */
.ui2 .vd-title { margin: 4px 0 12px; }
.ui2 .vd-form > .card { margin-bottom: 12px; }
.ui2 .vd-form > .card > h3 { margin: 0 0 10px; }
.ui2 .vd-form .ui-fold { margin-top: 10px; }
.ui2 .vd-form .ui-fold > .form-grid { margin-bottom: 8px; }
.ui2 .vendor-products input, .ui2 .vendor-products select { width: 100%; min-width: 0; }
.ui2 .ro-set { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.ui2 .ro-set label { flex: 0 1 200px; }
.ui2 .ro-how { flex-basis: 100%; }
.ui2 .ro-n { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.ui2 .ro-model { padding: 0 !important; margin-bottom: 12px; }
.ui2 .ro-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--mk-hair); }
.ui2 .ro-head .sc-thumb { width: 44px; height: 56px; object-fit: cover; object-position: center top; border-radius: 8px; flex: none; }
.ui2 .ro-head > div { flex: 1; min-width: 0; }
.ui2 .ro-head b, .ui2 .ro-head small { display: block; }
.ui2 .ro-pick { font-size: 13px; color: var(--muted); white-space: nowrap; }
.ui2 .ro-rows { list-style: none; margin: 0; padding: 0; }
.ui2 .ro-rows li { display: grid; grid-template-columns: minmax(0, 1fr) 96px minmax(180px, 280px); gap: 8px 12px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--mk-hair); }
.ui2 .ro-rows li:first-child { border-top: 0; }
.ui2 .ro-rows li:has(input[type="checkbox"]:checked) { background: #fcf8f9; }
.ui2 .ro-rows .check { align-items: flex-start; gap: 12px; min-height: 44px; cursor: pointer; }
.ui2 .ro-rows .check input { width: 22px; height: 40px; margin: -9px 0 -9px; flex: none; } /* 40 px tall hit area, the box itself draws at 22 px */
.ui2 .ro-rows .check b, .ui2 .ro-rows .check small { display: block; }
.ui2 .ro-rows .check small { font-size: 13px; color: var(--muted); font-weight: 400; }
.ui2 .ro-q { flex-direction: row; align-items: center; gap: 6px; }
.ui2 .ro-q input { text-align: right; width: 100%; min-width: 0; }
.ui2 .ro-rows select { width: 100%; min-width: 0; }
.ui2 .ro-rest { margin: 4px 0 12px; padding-block: 0 !important; }
.ui2 .ro-rest > .ui-fold { border-top: 0; }
.ui2 .ro-rest .ro-model { box-shadow: none; }
.ui2 .po-message .ol-chips { margin: 8px 0 10px; }
.ui2 textarea.po-msg { display: block; width: 100%; margin: 0 0 12px; padding: 12px 14px; border: 0; border-radius: 12px; background: var(--mk-fog); font: inherit; font-size: 14px; resize: vertical; field-sizing: content; } /* grows with wrapped lines; rows= is the fallback */
@media (max-width: 767px) {
  .ui2 .ro-rows li { grid-template-columns: minmax(0, 1fr) 96px; }
  .ui2 .ro-rows li select { grid-column: 1 / -1; }
  .ui2 .ro-set label { flex: 1 1 130px; }
  .ui2 .vd-list td.vd-contact { flex-basis: 100%; }
  .ui2 .vd-form .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  /* vendor products: one card per row, two fields per line, model across the top */
  .ui2 .vendor-products tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 10px; }
  .ui2 .vendor-products tr::after { display: none; }
  .ui2 .vendor-products td.vp-model { grid-column: 1 / -1; }
  .ui2 .vendor-products td[data-label]::before { display: block; margin-bottom: 2px; font-size: 12px; }
  .ui2 .po-message .ol-chips { margin-inline: 0; padding-inline: 0; }
} /* end T98 phone */
/* T101 settings: cards of one sub-page side by side from 1100 px, returns fields in two columns with a dot on a default,
   tracking links as rows (logo, name, try link, tick on the right), P&L target inputs right-aligned with a sticky head on a phone */
.set-cols { display: grid; gap: var(--s4); align-items: start; }
.set-cols > .form-card, .ui2 .set-returns { max-width: none; }
.set-cols > .card + .card { margin-top: 0; }
@media (min-width: 1100px) {
  .set-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
} /* end T101 1100 */
@media (min-width: 768px) {
  .ui2 .set-returns .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
} /* end T101 768 */
.set-dot, .set-dot-key { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #d9a514; margin-right: 6px; vertical-align: 1px; flex: none; }
.set-dot-key { margin: 0 2px; }
.ui2 .track-brands { gap: 0; border-top: 1px solid var(--line); }
.ui2 .track-brands li { display: block; min-height: 0; border-bottom: 1px solid var(--line); }
.ui2 .track-brands label.trk-row { display: flex; flex-direction: row; align-items: center; gap: 12px; min-height: 56px; padding: 8px 4px; color: var(--ink); font-size: var(--fs-sm); cursor: pointer; }
.trk-mark { display: flex; flex: none; }
.trk-t { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.trk-row input[type="checkbox"] { width: 20px; height: 20px; margin-left: auto; }
.tgt-table td.num input { text-align: right; }
@media (max-width: 767px) {
  .ui2 .tgt-wrap { overflow: visible; }
  .ui2 .tgt-table thead th { position: sticky; top: 53px; z-index: 2; background: var(--white); } /* under the sticky .mobile-bar */
} /* end T101 phone */

/* T99 catalog: search + one primary button on a row, model list as cards on a phone (whole row opens the model),
   model page summary card, phone jump row, two columns from 861 px (form left, images + vendors right), vendor links as blocks */
.ui2 .pc-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.ui2 .pc-bar input { flex: 1; min-width: 0; }
.ui2 .pc-bar .button-link { flex: none; white-space: nowrap; }
.ui2 .pc-bar .mk-ic { width: 16px; height: 16px; vertical-align: -3px; }
.ui2 .pc-list tr.row-link { position: relative; }
.ui2 .pc-list a.row-title::after { content: ''; position: absolute; inset: 0; } /* the whole row is the link; no other link in the row */
.ui2 .pc-unit { display: none; }
.ui2 .pc-sum { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 10px 16px; }
.ui2 .pc-sum .sc-thumb { width: 42px; height: 56px; }
.ui2 .pc-sum b { font-size: 16px; }
.ui2 .pc-jump { display: none; }
.ui2 .pc-grid { align-items: start; }
.ui2 .pc-grid .ui-stack { gap: 12px; }
.ui2 .pc-grid .card { margin: 0; }
.ui2 .pc-np { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); margin-bottom: 8px; }
.ui2 .pc-np:has(> label:nth-child(3)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ui2 #info .table-wrap { box-shadow: none; }
.ui2 #info .stock-table :is(th, td) { padding: 6px 12px; }
.ui2 #info .row-inline { min-height: 40px; }
/* SKU codes per colour: one line per colour that wraps (no sideways scroll at any width) */
.ui2 .pc-skus, .ui2 .pc-skus tbody { display: block; }
.ui2 .pc-skus thead { display: none; }
.ui2 .pc-skus tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; padding: 10px 14px; border-top: 1px solid var(--mk-hair); }
.ui2 .pc-skus tr:first-child { border-top: 0; }
.ui2 .pc-skus :is(th, td) { display: block; padding: 0 !important; border: 0; background: none; }
.ui2 .pc-skus tbody th { flex-basis: 100%; font-weight: 600; }
.ui2 .pc-skus td.c-hide { display: none; }
.ui2 .pc-skus td[data-label]::before { content: attr(data-label) ' '; color: var(--muted); font-family: var(--font, inherit); }
.ui2 .pc-images .spec-images { margin-top: 0; }
.ui2 .pc-images .spec-list > li { border-bottom: 0; padding-bottom: 0; }
.ui2 .pc-images .role-slots { gap: 8px; }
.ui2 .pc-images .role-slot { width: calc(25% - 6px); min-width: 0; }
.ui2 .pc-vrows { list-style: none; margin: 0 0 4px; padding: 0; }
.ui2 .pc-vrow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 8px; padding: 6px 0; border-top: 1px solid var(--mk-hair); }
.ui2 .pc-vrow:first-child { border-top: 0; padding-top: 0; }
.ui2 .pc-vrow label { gap: 2px; font-size: 12px; color: var(--muted); min-width: 0; }
.ui2 .pc-vrow :is(input:not([type="checkbox"]), select) { width: 100%; min-height: 34px; height: 34px; padding-block: 4px; }
.ui2 .pc-vrow .pc-v-wide { grid-column: 1 / -1; }
.ui2 .pc-vrow .pc-v-del { align-self: end; min-height: 36px; color: var(--ink); font-size: 14px; }
.ui2 .pc-grid + .ui-fold { margin-top: 16px; }
.ui2 .pc-new .card { margin: 0; }
.ui2 .pc-new .ui-savebar { margin-top: 0; }
@media (min-width: 1101px) {
  /* 4 fields a line; the first row's labels head the columns, later rows keep them for screen readers only */
  .ui2 .pc-vrow { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ui2 .pc-vrow .pc-v-wide { grid-column: span 2; }
  .ui2 .pc-vrow + .pc-vrow .pc-vl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
} /* end T99 wide */
@media (max-width: 767px) {
  .ui2 .pc-unit { display: inline; }
  .ui2 .pc-list .sc-thumb { width: 42px; height: 56px; }
  .ui2 .pc-jump { display: flex; gap: 6px; margin: 0 0 12px; }
  .ui2 .pc-jump a { flex: 1; display: grid; place-items: center; min-height: 40px; border: 1px solid var(--mk-hair); border-radius: 10px; background: #fff; color: var(--brand); text-decoration: none; font-size: 14px; font-weight: 500; }
  .ui2 .pc-np, .ui2 .pc-np:has(> label:nth-child(3)) { grid-template-columns: minmax(0, 1fr); }
  .ui2 .pc-images .role-slot { width: calc(50% - 4px); }
  .ui2 :is(#info, #skus, #add-sku, #role-images, #vendors) { scroll-margin-top: 12px; }
} /* end T99 phone */

/* T100 defects + repairs: record form folded behind the header button (#new), totals and recent records as phone cards,
   B-grade price form inside its SKU card, repair list as cards, repair page summary + now bar */
.ui2 #new:not([open]) { border-top: 0; }
.ui2 #new:not([open]) > summary { display: none; } /* the header button opens it; once open the summary folds it again */
.ui2 #new > .card { margin: 0 0 8px; max-width: 860px; }
.ui2 #new .df-then { margin-top: 12px; }
.ui2 .df-hint { margin: -6px 0 10px; }
.ui2 .df-unit, .ui2 .df-totals .df-unit { display: none; }
.ui2 .df-price form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; min-width: 14em; }
.ui2 .df-price input { flex: 0 0 7em; width: 7em; min-width: 0; }
.ui2 .df-repairs tr.row-link { position: relative; }
.ui2 .df-repairs a.row-title::after { content: ''; position: absolute; inset: 0; }
.ui2 .df-repairs .bills { position: relative; z-index: 1; } /* bill links stay clickable above the row link */
.ui2 .df-sum p { margin: 0 0 6px; }
.ui2 .df-sum .ui-now { margin-top: 12px; }
.ui2 .df-sum + form.card, .ui2 form.card + .card { margin-top: 16px; }
@media (max-width: 767px) {
  .ui2 .df-unit, .ui2 .df-totals .df-unit { display: inline; }
  .ui2 .c-hide-sm { display: none; }
  .ui2 .df-totals td.c-meta { white-space: nowrap; }
  .ui2 .df-totals td.df-price { order: 4; flex-basis: 100%; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--mk-hair); }
  .ui2 .df-price form { min-width: 0; }
  .ui2 .df-recent td.df-desc, .ui2 .df-repairs td.df-desc { flex-basis: 100%; color: var(--ink); }
  .ui2 .df-recent td.df-date { order: 3; }
} /* end T100 phone */
/* T102: picture viewer, iPhone-app swipe back, bigger back links on phone */
.imgview { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(20, 14, 18, .95); }
.imgview::backdrop { background: rgba(20, 14, 18, .95); }
.imgview img { display: block; width: 100%; height: 100%; object-fit: contain; touch-action: pinch-zoom; }
.imgview-bar { position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 10px; }
.imgview-close { min-height: 44px; padding: 0 18px; border: 0; border-radius: 22px; background: rgba(255, 255, 255, .18); color: #fff; font-size: 16px; }
.swipe-back { position: fixed; left: 0; top: 50%; z-index: 1000; width: 44px; height: 44px; margin-top: -22px; border-radius: 50%; display: grid; place-items: center; background: var(--white); color: var(--accent); font-size: 28px; line-height: 1; box-shadow: 0 2px 10px rgba(0, 0, 0, .2); opacity: 0; pointer-events: none; transform: translateX(-48px); transition: opacity .15s; }
@media (max-width: 767px) {
  .ui2 .ui-back, .ui2 .cs-back .ui-back { min-height: 44px; margin: 4px 0 4px -8px; padding: 0 14px 0 8px; font-size: 16px; }
  .back, .back-link { min-height: 44px; font-size: 16px; }
} /* end T102 phone */
/* T102: iPhone zooms the page in when a field under 16px gets focus and leaves it zoomed (header pushed under the
   status bar, sides cut off). iOS only, so Android keeps the smaller pills. */
@supports (-webkit-touch-callout: none) {
  input, textarea, select { font-size: max(16px, 1em) !important; }
} /* end T102 iOS */
/* T103: ข้อความลัด bar: icon tile + short name, arrow on the button that opens a sheet, เลขบัญชี in the รอโอน colours with
   the amount, a tick on the button just used. Same icon tile in "ทั้งหมด", the "/" list and ตั้งค่า › แชต. */
.quick .chip { gap: 8px; border-radius: 12px; border-color: var(--mk-hair); box-shadow: 0 1px 2px rgba(91, 33, 64, .06); }
.quick .qr-all-btn { gap: 4px; padding: 0 12px 0 9px; }
.quick .qr-all-btn .sb-icon { width: 16px; height: 16px; }
.quick .qchip { padding: 0 12px 0 3px; font-weight: 500; }
.quick .qchip .ql { max-width: 12em; overflow: hidden; text-overflow: ellipsis; }
.quick .qchip small { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.quick .qup { width: 14px; height: 14px; margin: 0 -4px; }
.qi { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex: none; border-radius: 8px; background: var(--mk-tint); color: var(--brand); overflow: hidden; }
.qi .sb-icon { width: 15px; height: 15px; }
.qi-img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.qi-img[hidden], .qi-img:not([hidden]) + .sb-icon, .qi .qi-ok { display: none; }
.quick .q-due { background: var(--mk-sand); border-color: color-mix(in srgb, var(--mk-wait) 30%, var(--mk-sand)); color: var(--mk-wait); }
.quick .q-due .qi { background: var(--white); color: var(--mk-wait); }
.quick .qchip.used { border-color: var(--accent); background: var(--mk-tint); color: var(--brand); }
.quick .qchip.used .qi { background: var(--brand); color: var(--white); }
.quick .qchip.q-due.used { border-color: var(--mk-wait); background: var(--mk-sand); color: var(--mk-wait); }
.quick .qchip.q-due.used .qi { background: var(--mk-wait); }
.quick .qchip.used .qi > :not(.qi-ok) { display: none; }
.quick .qchip.used .qi .qi-ok { display: block; }
.qr-slash li { flex-direction: row; align-items: center; gap: 10px; }
.qr-slash li > div { display: flex; flex-direction: column; min-width: 0; }
.qm-icons { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 0; }
.qm-icons legend { padding: 0; margin-bottom: 6px; }
.qm-icon { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px 0 8px; border: 1px solid var(--mk-hair); border-radius: 12px; cursor: pointer; }
.qm-icon input { margin: 0; }
.qm-icon:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
@media (max-width: 767px) {
  .quick { gap: 4px; } /* 390 px: ทั้งหมด and three buttons fit without scrolling */
  .quick .qr-all-btn { padding: 0 8px 0 7px; }
  .quick .qchip { gap: 5px; padding: 0 8px 0 4px; }
  .quick .qup { width: 12px; height: 12px; margin: 0 -3px; }
} /* end T103 phone */
/* T104: "รูป + ไซซ์" sheet and the send-image sheet's รูปสินค้า tab: products as a picture grid (3 columns phone, 5 computer),
   then colour buttons with a picture and the photos that will go, numbered, with where each came from. */
.pk { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.pk[hidden] { display: none; }
#img-chooser { flex: none; overflow: visible; margin: 0 -16px; }
.pk-search { padding: 4px 16px 12px; }
.pk-search input { width: 100%; min-height: 44px; }
.pk-grid { list-style: none; margin: 0; padding: 0 16px 16px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 10px; }
.pk-cell { position: relative; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 1px; width: 100%; min-width: 0; min-height: 0; padding: 0; border: 0; background: none; color: var(--ink); font-weight: 400; line-height: 1.35; text-align: left; white-space: normal; }
.pk-cell > img, .pk-noimg { width: 100%; aspect-ratio: 3 / 4; margin-bottom: 4px; object-fit: cover; object-position: center top; border-radius: 12px; border: 1px solid var(--mk-hair); background: var(--mk-fog); }
.pk-noimg { display: flex; align-items: center; justify-content: center; border-style: dashed; font-size: 12px; color: var(--muted); }
.pk-cell b { font-size: 13px; font-weight: 600; }
.pk-cell small { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pk .cut { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-cell:disabled { opacity: .6; }
.pk-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 12px; }
.pk-dots { display: flex; align-items: center; gap: 3px; min-height: 18px; margin-top: 2px; }
.pk-dots img { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; object-position: center 22%; box-shadow: 0 0 0 1px var(--line); }
.pk-dots em { margin-left: 3px; font-style: normal; font-size: 11px; color: var(--muted); white-space: nowrap; }
.pk-flag { position: absolute; top: 6px; left: 6px; padding: 0 8px; border-radius: 999px; background: rgba(42, 32, 41, .78); color: var(--white); font-size: 11px; font-weight: 500; line-height: 20px; }
.pk-prod { display: flex; align-items: center; gap: 10px; padding: 4px 16px 10px; }
.pk-prod img { width: 42px; height: 56px; flex: none; object-fit: cover; object-position: center top; border-radius: 8px; border: 1px solid var(--mk-hair); background: var(--mk-fog); }
.pk-prod-t { flex: 1; min-width: 0; margin: 0; }
.pk-prod-t b { font-weight: 600; }
.pk-prod-t small { font-size: 13px; color: var(--muted); }
.pk-prod button { flex: none; min-height: 40px; }
.pk-sw { flex: none; display: flex; gap: 8px; padding: 1px 16px 10px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--mk-hair); }
.pk-csw { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 4px 12px 4px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); color: var(--ink); font-size: 14px; font-weight: 400; line-height: 1.25; text-align: left; white-space: nowrap; }
.pk-csw img { width: 30px; height: 36px; flex: none; border-radius: 7px; object-fit: cover; object-position: center top; background: var(--mk-fog); }
.pk-csw small { display: block; font-size: 11px; color: var(--muted); }
.pk-csw[aria-pressed='true'] { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); background: var(--mk-tint); color: var(--brand); font-weight: 500; }
.pk-body { padding: 0 16px 12px; }
.pk-grp { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 10px 0 8px; font-size: 14px; }
.pk-grp > b { font-weight: 600; }
.pk-none { margin: 12px 0; }
.pk-imgs { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.pk-imgs .img-cap { font-size: 11px; }
.pk-text { flex: none; margin: 0 16px 12px; padding: 8px 12px; border-radius: 12px; background: var(--mk-fog); font-size: 13px; line-height: 1.5; color: var(--ink); }
.pk-text[hidden] { display: none; }
.pk-text > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pk-text .k { margin-right: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.qr-picker .sheet-foot, .img-sheet .sheet-head, .img-sheet .sheet-tabs { flex: none; } /* a long product grid scrolls; these keep their height */
@media (min-width: 768px) {
  .pk-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .pk-imgs { grid-template-columns: repeat(5, minmax(0, 1fr)); }
} /* end T104 computer */
/* T105: the เลขบัญชี card waiting in the attach row (order card or the shop's account card), in the รอโอน colours */
.qr-attach .qr-card { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; height: 64px; padding: 0 16px 0 8px; border: 1px solid color-mix(in srgb, var(--mk-wait) 30%, var(--mk-sand)); border-radius: 10px; background: var(--mk-sand); color: var(--mk-wait); font-size: 12px; line-height: 1.35; }
.qr-card-qi { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: none; border-radius: 8px; background: var(--white); }
.qr-card-qi .sb-icon { width: 18px; height: 18px; }
.qr-card-t { min-width: 0; display: flex; flex-direction: column; }
.qr-card-t > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-card-t b { font-size: 13px; font-weight: 600; color: var(--ink); }
/* T108: TH / EN of the chat in the header, the same size and look as the status tag beside it; EN in the พรีออเดอร์ blue */
.lang-form { margin: 0; flex: none; }
button.lang-tag { min-height: var(--control-h-sm); height: var(--control-h-sm); padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); color: var(--muted); font-size: 13px; font-weight: 500; letter-spacing: 0.04em; }
button.lang-tag:hover { background: var(--white); border-color: var(--muted); }
button.lang-tag.on { background: #ecf0f7; border-color: #c8d3e6; color: #2f4b7a; }
/* T108: TH / EN link in the top corner of the customer order page */
.pub-in { position: relative; }
.pub-lang { position: absolute; top: 24px; right: 16px; margin: 0; font-size: 13px; }
.pub-lang a { color: var(--muted); }
