:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1d2433; --muted: #6b7385; --line: #e3e6ec;
  --brand: #1f5eff; --brand-ink: #fff; --hi: #12a150; --mid: #e0a100; --lo: #d93a3a;
  --a: #12a150; --b: #3b82f6; --c: #e0a100; --d: #9aa1ae; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11141a; --card: #1a1f28; --ink: #e8ebf1; --muted: #9aa3b4; --line: #2a3140; --brand: #5b8cff; }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'IBM Plex Sans Thai', system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; }
h2 { font-size: 18px; margin: 0 0 4px; line-height: 1.4; }
h3 { font-size: 15px; margin: 20px 0 8px; }
h4 { font-size: 13px; margin: 14px 0 4px; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 4px; }
input[type=checkbox], input[type=range] { width: auto; margin: 0; }
.btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.ghost { background: transparent; } .btn.danger { color: var(--lo); }
.btn:disabled { opacity: .6; cursor: wait; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; } .row.end { justify-content: flex-end; }
.err { color: var(--lo); min-height: 1em; }
.warn { background: color-mix(in srgb, var(--mid) 14%, transparent); border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-top: 10px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
.brand { font-weight: 600; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 25%, transparent); }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav button { font: inherit; background: none; border: 0; padding: 8px 12px; border-radius: 8px; color: var(--muted); cursor: pointer; }
.top nav button.on { background: var(--bg); color: var(--ink); font-weight: 600; }
.top-actions { display: flex; gap: 8px; }
main { padding: 16px 20px 40px; max-width: 1400px; margin: 0 auto; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 50; max-width: 90vw; font-size: 14px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile b { display: block; font-size: 22px; font-weight: 600; } .tile span { font-size: 12.5px; color: var(--muted); }
.tile.a b { color: var(--a); } .tile.b b { color: var(--b); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { flex: 1 1 260px; margin: 0; } .filters select { width: auto; margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 500; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
tbody tr { cursor: pointer; } tbody tr:hover { background: var(--bg); }
.title-cell { min-width: 320px; } .title { font-weight: 500; line-height: 1.45; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 40px; cursor: default; }
.score { display: inline-grid; place-items: center; min-width: 38px; height: 30px; border-radius: 8px; font-weight: 600; color: #fff; }
.score.big { min-width: 56px; height: 56px; font-size: 22px; border-radius: 12px; }
.gA { background: var(--a); } .gB { background: var(--b); } .gC { background: var(--c); } .gD { background: var(--d); }
.flag { display: inline-block; margin-left: 6px; font-size: 11.5px; color: var(--lo); }
.pill { display: inline-block; font: inherit; font-size: 12px; padding: 3px 10px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); color: var(--ink); white-space: nowrap; cursor: pointer; }
.pill.watching { border-color: var(--b); color: var(--b); } .pill.bidding { border-color: var(--a); color: var(--a); }
.pill.skip { color: var(--muted); } .pill.won { border-color: var(--a); color: var(--a); font-weight: 600; } .pill.lost { color: var(--lo); }
.pill.sel { outline: 2px solid var(--brand); }
.dl { font-size: 11.5px; padding: 1px 6px; border-radius: 6px; margin-left: 4px; white-space: nowrap; }
.dl.hi { color: var(--hi); } .dl.mid { color: var(--mid); background: color-mix(in srgb, var(--mid) 12%, transparent); } .dl.lo { color: var(--lo); }

.overlay { position: fixed; inset: 0; background: rgba(10, 14, 22, .45); z-index: 20; display: flex; justify-content: flex-end; }
.drawer { width: min(760px, 100vw); height: 100vh; overflow-y: auto; background: var(--card); padding: 20px 24px 40px; }
.drawer-head { display: flex; gap: 14px; align-items: flex-start; }
.drawer-head > div { flex: 1; }
.x { background: none; border: 0; font-size: 20px; color: var(--muted); cursor: pointer; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 14px 0 8px; }
.facts > div { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.facts span { display: block; font-size: 12px; color: var(--muted); } .facts b { font-weight: 600; }
.statusbar { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 4px; }
.parts { display: grid; gap: 10px; }
.part-h { display: flex; justify-content: space-between; font-size: 13.5px; }
.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 4px 0 2px; }
.bar i { display: block; height: 100%; border-radius: 99px; }
.bar i.hi { background: var(--hi); } .bar i.mid { background: var(--mid); } .bar i.lo { background: var(--lo); }
.mini { margin-top: 8px; } .mini td, .mini th { padding: 5px 6px; font-size: 13px; }
.ai-form { background: var(--bg); padding: 10px 12px; border-radius: 8px; }
.ai-form input, .ai-form textarea { background: var(--card); }
.ai { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.ai-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ai ul { margin: 4px 0; padding-left: 20px; } .ai li { margin: 3px 0; font-size: 14px; }
.rec { padding: 4px 12px; border-radius: 99px; font-weight: 600; color: #fff; background: var(--d); }
.rec.yes { background: var(--a); } .rec.maybe { background: var(--mid); } .rec.no { background: var(--lo); }
.modal { width: min(620px, 94vw); margin: auto; max-height: 92vh; overflow-y: auto; }

.settings .grid2 { align-items: start; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.settings h3 { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; gap: 6px; align-items: center; margin: 0; padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--ink); }
label.wrow { display: grid; grid-template-columns: 140px 1fr 30px; width: 100%; margin: 6px 0; }
.status-list { list-style: none; padding: 0; margin: 0; } .status-list li { padding: 4px 0; font-size: 14px; }
.status-list li.ok::before { content: '● '; color: var(--hi); } .status-list li.no::before { content: '● '; color: var(--lo); }
@media (max-width: 640px) { main { padding: 12px; } .top { padding: 10px 12px; } .top-actions .ghost { display: none; } }
.install { width: 100%; max-width: 520px; }
.install pre { background: var(--bg); padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: .92em; }

/* ===== Settings (v2) ===== */
.settings { max-width: 1180px; }
.set-layout { display: grid; grid-template-columns: 250px 1fr; gap: 20px; align-items: start; }
.set-nav { position: sticky; top: 74px; display: flex; flex-direction: column; gap: 2px; }
.set-nav button { display: grid; grid-template-columns: 34px 1fr 10px; align-items: center; gap: 10px; text-align: left; font: inherit; color: var(--ink);
  background: none; border: 0; border-radius: 10px; padding: 9px 10px; cursor: pointer; }
.set-nav button:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.set-nav button.on { background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 0 0 1px var(--line); }
.set-nav b { display: block; font-weight: 500; font-size: 14.5px; }
.set-nav small { display: block; font-size: 12px; color: var(--muted); }
.set-ico { width: 34px; height: 34px; padding: 7px; border-radius: 9px; background: color-mix(in srgb, var(--brand) 10%, transparent);
  stroke: var(--brand); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.set-nav button.on .set-ico { background: var(--brand); stroke: #fff; }
.set-dot { width: 8px; height: 8px; border-radius: 50%; }
.set-dot.ok { background: var(--hi); } .set-dot.no { background: var(--mid); }

.set-panel { padding: 0; overflow: hidden; }
.set-panel > section { padding: 24px 28px 0; }
.set-head { padding-bottom: 16px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.set-head h2 { font-size: 20px; margin: 0 0 4px; }
.set-head p { margin: 0; color: var(--muted); font-size: 14px; }
.field { display: grid; grid-template-columns: 210px 1fr; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.field:last-of-type { border-bottom: 0; }
.f-label { font-size: 14px; font-weight: 500; padding-top: 8px; }
.f-label small { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.f-ctl > input, .f-ctl > textarea, .f-ctl > select { margin-top: 0; }
.f-ctl label { margin: 0; }
.set-foot { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; margin: 8px -28px 0; padding: 14px 28px;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--line); }
.btn.sm { padding: 5px 10px; font-size: 13.5px; }
.result { margin: 10px 0 6px; padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.result.good { background: color-mix(in srgb, var(--hi) 12%, transparent); color: var(--hi); }
.result.bad { background: color-mix(in srgb, var(--lo) 10%, transparent); color: var(--lo); }
.f-ctl > small { display: block; margin-top: 6px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 42px; padding: 6px 8px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg); cursor: text; }
.tags:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 6px; font-size: 13.5px;
  background: var(--card); border: 1px solid var(--line); }
.tag button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; border-radius: 4px; }
.tag button:hover { background: var(--bg); color: var(--lo); }
.tags input { flex: 1; min-width: 140px; border: 0; background: transparent; padding: 4px; margin: 0; box-shadow: none; }
.tags input:focus { outline: none; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }

.unit { display: flex; align-items: stretch; margin-top: 4px; }
.unit input { margin: 0; border-radius: 8px 0 0 8px; min-width: 0; }
.unit span { display: grid; place-items: center; padding: 0 10px; font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-left: 0;
  border-radius: 0 8px 8px 0; background: var(--card); white-space: nowrap; }
.range2 { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.range2 .unit { margin: 0; } .range2 .full { grid-column: 1 / -1; }
.chips .chip { cursor: pointer; font-size: 13.5px; padding: 6px 12px; transition: .15s; }
.chips .chip input { display: none; }
.chips .chip.on { background: color-mix(in srgb, var(--brand) 12%, transparent); border-color: var(--brand); color: var(--brand); font-weight: 500; }

.switch { display: inline-flex !important; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--ink) !important; padding-top: 6px; }
.switch input { display: none; }
.switch span { width: 40px; height: 22px; border-radius: 99px; background: var(--line); position: relative; transition: .2s; flex: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { left: 21px; }

.url-list { display: grid; gap: 8px; margin-bottom: 8px; }
.url-row { display: grid; grid-template-columns: 90px 1fr 34px; gap: 6px; }
.url-row select, .url-row input, .url-row textarea { margin: 0; }
.url-row textarea { grid-column: 2 / 3; font-family: ui-monospace, monospace; font-size: 13px; }
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 16px; }
.icon-btn:hover { color: var(--lo); }
.help { margin-top: 10px; font-size: 13.5px; color: var(--muted); }
.help summary { cursor: pointer; color: var(--brand); }
.help ol { padding-left: 20px; margin: 8px 0; } .help li { margin: 3px 0; }

.weights { padding: 16px 0 8px; }
.w-row { display: grid; grid-template-columns: 170px 1fr 56px; align-items: center; gap: 16px; padding: 10px 0; }
.w-name { font-size: 14.5px; }
.w-row input[type=range] { width: 100%; accent-color: var(--brand); }
.w-pct { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.w-bar { display: flex; height: 10px; gap: 2px; border-radius: 99px; overflow: hidden; margin-top: 14px; }
.w-bar i { background: var(--brand); min-width: 0; }
.w-bar i:nth-child(2n) { background: color-mix(in srgb, var(--brand) 60%, var(--card)); }
.w-bar i:nth-child(3n) { background: color-mix(in srgb, var(--brand) 35%, var(--card)); }
.inline-range { display: flex; align-items: center; gap: 14px; padding-top: 6px; }
.inline-range input { flex: 1; max-width: 360px; accent-color: var(--brand); }
.inline-range b { min-width: 44px; padding: 3px 10px; border-radius: 6px; background: var(--bg); text-align: center; }
.channel { padding: 16px 0; border-bottom: 1px solid var(--line); }
.channel:last-of-type { border-bottom: 0; }
.channel h3 { margin: 0 0 4px; font-size: 15px; }
.channel label small, .grid2 label small { color: var(--hi); }

.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; padding: 18px 0 6px; }
.status-grid > div { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; border-left-width: 4px; }
.status-grid > div.ok { border-left-color: var(--hi); } .status-grid > div.no { border-left-color: var(--lo); }
.status-grid b { display: block; font-size: 14px; } .status-grid span { font-size: 13px; color: var(--muted); }
h3.sub { margin: 22px 0 8px; font-size: 15px; }
.runs { margin-bottom: 8px; }
.set-panel section[x-show="stab==='system'"] { padding-bottom: 24px; }

@media (max-width: 860px) {
  .set-layout { grid-template-columns: 1fr; gap: 12px; }
  .set-nav { position: static; flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .set-nav button { grid-template-columns: auto; padding: 8px 12px; white-space: nowrap; border: 1px solid var(--line); }
  .set-nav small, .set-nav .set-ico, .set-nav .set-dot { display: none; }
  .set-panel > section { padding: 18px 16px 0; }
  .set-foot { margin: 8px -16px 0; padding: 12px 16px; }
  .field { grid-template-columns: 1fr; gap: 8px; }
  .f-label { padding-top: 0; }
  .w-row { grid-template-columns: 110px 1fr 44px; gap: 10px; }
  .range2 { grid-template-columns: 1fr; } .range2 > .muted { display: none; }
}
.tags input:focus { border: 0; box-shadow: none; }

/* ===== Users / me menu / model picker ===== */
.me { position: relative; }
.me-btn { display: flex; align-items: center; gap: 8px; font: inherit; color: var(--ink); background: none; border: 1px solid var(--line); border-radius: 99px; padding: 3px 12px 3px 3px; cursor: pointer; }
.me-name { font-size: 14px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; padding: 6px; z-index: 30; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.me-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.me-head b { display: block; } .me-head small { color: var(--muted); }
.me-menu button { display: block; width: 100%; text-align: left; font: inherit; font-size: 14px; color: var(--ink); background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.me-menu button:hover { background: var(--bg); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; color: #fff; background: var(--d); flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 13px; }
.avatar.superadmin { background: #7c3aed; } .avatar.admin { background: var(--brand); } .avatar.user { background: #64748b; }
.head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.users { display: grid; }
.user-row { display: grid; grid-template-columns: 40px 1fr auto auto auto; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.user-row.off { opacity: .55; }
.u-main b { display: block; font-weight: 500; } .u-main small { color: var(--muted); font-size: 12.5px; }
.u-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; min-width: 120px; }
.lock { font-size: 14px; opacity: .7; padding: 0 6px; }
.role-badge { font-size: 12px; padding: 3px 10px; border-radius: 99px; white-space: nowrap; font-weight: 500; }
.role-badge.superadmin { background: color-mix(in srgb, #7c3aed 14%, transparent); color: #7c3aed; }
.role-badge.admin { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.role-badge.user { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.role-help { display: grid; gap: 8px; padding: 16px 0 24px; font-size: 13px; color: var(--muted); }
.role-help .role-badge { display: inline-block; min-width: 86px; text-align: center; margin-right: 8px; }
.overlay.center { justify-content: center; align-items: center; padding: 16px; }
.modal.sm { width: min(440px, 94vw); }
.model-pick { display: grid; grid-template-columns: 1fr 42px; gap: 6px; }
.model-pick select, .model-pick input { margin: 0; }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.note { margin-top: 6px; font-size: 13px; padding: 6px 10px; border-radius: 6px; background: color-mix(in srgb, var(--mid) 12%, transparent); }
.full2 { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .user-row { grid-template-columns: 40px 1fr auto; }
  .user-row .role-badge, .user-row > .pill { grid-column: 2; justify-self: start; }
  .u-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .me-name { display: none; } .me-btn { padding: 3px; }
}

/* ===== ระดับ 2 ===== */
main.wide { max-width: 1500px; }
.view-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.view-head h2 { margin: 0; font-size: 20px; }
.view-head .row { margin: 0; }
.icon-btn.lg { width: 34px; height: 34px; font-size: 20px; line-height: 1; }
.export { position: relative; margin-left: auto; }
.export .me-menu { right: 0; left: auto; min-width: 200px; }
.export a, .me-menu a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: 14px; }
.export a:hover { background: var(--bg); }

/* board */
.board { display: grid; grid-template-columns: repeat(5, minmax(240px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: color-mix(in srgb, var(--ink) 4%, var(--bg)); border-radius: 12px; padding: 10px; min-height: 300px; transition: .15s; border: 2px dashed transparent; }
.col.over { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, var(--bg)); }
.col header { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; }
.col header small { margin-left: auto; }
.cnt { font-size: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; }
.dot-s { width: 10px; height: 10px; border-radius: 50%; }
.dot-s.watching { background: var(--b); } .dot-s.preparing { background: var(--mid); } .dot-s.bidding { background: #7c3aed; }
.dot-s.won { background: var(--hi); } .dot-s.lost { background: var(--lo); }
.cards { display: grid; gap: 8px; }
.kcard { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.kcard:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.kcard:active { cursor: grabbing; }
.k-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.k-title { font-size: 13.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.k-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.k-meta .avatar { margin-left: auto; }
.k-ck { font-size: 11.5px; padding: 1px 7px; border-radius: 6px; background: var(--bg); color: var(--muted); }
.k-ck.full { color: var(--hi); background: color-mix(in srgb, var(--hi) 12%, transparent); }
.score.sm { min-width: 30px; height: 22px; font-size: 12px; border-radius: 6px; }
.avatar.xs { width: 24px; height: 24px; font-size: 11px; }
.avatar.none { background: var(--line); color: var(--muted); }
.empty-col { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 8px; border: 1px dashed var(--line); border-radius: 10px; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); margin-top: 10px; }
.cal-h { padding: 8px; font-size: 12.5px; color: var(--muted); text-align: center; border-bottom: 1px solid var(--line); background: var(--bg); }
.cal-d { min-height: 112px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-d:nth-child(7n) { border-right: 0; }
.cal-d.other { background: color-mix(in srgb, var(--bg) 60%, var(--card)); } .cal-d.other .cal-n { opacity: .45; }
.cal-n { font-size: 12.5px; font-weight: 500; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-d.today .cal-n { background: var(--brand); color: #fff; }
.cal-e { display: block; width: 100%; text-align: left; font: inherit; font-size: 11.5px; padding: 2px 6px; border-radius: 4px; border: 0; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: color-mix(in srgb, var(--b) 14%, transparent); color: var(--ink); }
.cal-e.preparing { background: color-mix(in srgb, var(--mid) 20%, transparent); }
.cal-e.bidding { background: color-mix(in srgb, #7c3aed 16%, transparent); }
.cal-e.won { background: color-mix(in srgb, var(--hi) 16%, transparent); } .cal-e.lost, .cal-e.new { background: var(--bg); color: var(--muted); }
.cal-e.task { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.legend { display: flex; gap: 14px; margin-top: 10px; align-items: center; }
.legend .cal-e { display: inline-block; width: auto; }

/* analytics */
.an-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
.an-grid h3 { margin-top: 0; }
.mchart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 8px; }
.mcol { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 18px; }
.mcol small { font-size: 10.5px; color: var(--muted); }
.stack { width: 70%; max-width: 34px; display: flex; flex-direction: column; border-radius: 4px 4px 0 0; overflow: hidden; min-height: 2px; }
.stack i, .legend i { display: block; }
.legend span { display: inline-flex; align-items: center; gap: 5px; } .legend i { width: 10px; height: 10px; border-radius: 2px; }
i.w { background: var(--hi); } i.l { background: var(--lo); } i.p { background: color-mix(in srgb, #7c3aed 55%, var(--card)); }
.rbar { position: relative; height: 18px; background: var(--bg); border-radius: 4px; overflow: hidden; min-width: 90px; }
.rbar i { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--hi) 35%, transparent); }
.rbar span { position: relative; font-size: 12px; padding-left: 6px; font-variant-numeric: tabular-nums; }
.mini.rate td:first-child { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* drawer v2 */
.assign { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; }
.assign select { width: auto; margin: 0; padding: 5px 8px; }
.dtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 16px 0 4px; position: sticky; top: -20px; background: var(--card); z-index: 2; }
.dtabs button { font: inherit; font-size: 14.5px; background: none; border: 0; padding: 10px 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.dtabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }
.dtabs small { margin-left: 4px; font-size: 11px; background: var(--bg); padding: 1px 6px; border-radius: 99px; }
.bonds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.bonds > div { background: var(--bg); border-radius: 8px; padding: 10px 12px; }
.bonds > div > span { display: block; font-size: 12px; color: var(--muted); }
.ck-head { display: flex; align-items: center; gap: 12px; } .ck-head h3 { flex: none; }
.ck-prog { flex: 1; height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; } .ck-prog i { display: block; height: 100%; background: var(--hi); }
.ck { list-style: none; padding: 0; margin: 0 0 10px; }
.ck li { display: grid; grid-template-columns: 1fr auto 130px 30px; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.ck-box { display: flex; gap: 10px; align-items: flex-start; margin: 0; color: var(--ink); font-size: 14px; cursor: pointer; }
.ck-box input { margin-top: 4px; accent-color: var(--hi); width: 16px; height: 16px; }
.ck li.done .ck-box span { text-decoration: line-through; color: var(--muted); }
.ck-due { margin: 0; padding: 4px 6px; font-size: 12.5px; }
.ck .icon-btn { height: 28px; }
.empty-ck { text-align: center; padding: 18px; border: 1px dashed var(--line); border-radius: 10px; margin-bottom: 10px; }
.price-viz { margin: 26px 8px 8px; }
.pv-track { position: relative; height: 10px; background: linear-gradient(90deg, var(--bg), color-mix(in srgb, var(--brand) 18%, var(--bg))); border-radius: 99px; }
.pv-zone { position: absolute; top: -3px; bottom: -3px; background: color-mix(in srgb, var(--hi) 30%, transparent); border: 1px solid var(--hi); border-radius: 6px; }
.pv-mark { position: absolute; top: -6px; width: 2px; height: 22px; background: var(--ink); transform: translateX(-1px); }
.pv-mark b { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; white-space: nowrap; font-weight: 500; }
.pv-mark.cost { background: var(--mid); } .pv-mark.bid { background: var(--brand); width: 3px; } .pv-mark.budget { background: var(--muted); }
b.neg { color: var(--lo); }
.tor-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 14px; }
.tor-box .ai-form { margin-top: 8px; }
.ai details summary { cursor: pointer; color: var(--brand); font-size: 14px; margin-top: 6px; }
.chat { max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 10px; background: var(--bg); border-radius: 10px; margin-bottom: 8px; }
.msg { display: flex; flex-direction: column; max-width: 88%; } .msg.m-user { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 9px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); white-space: pre-wrap; font-size: 14px; line-height: 1.55; }
.msg.m-user .bubble { background: var(--brand); color: #fff; border-color: var(--brand); }
.typing { color: var(--muted); font-style: italic; }
.chips.sm .chip { font-size: 12.5px; padding: 4px 10px; background: var(--card); cursor: pointer; font: inherit; font-size: 12.5px; }
.cm-sum { display: flex; gap: 6px; margin: 6px 0; }
.cm-st { font-size: 12px; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.cm-st.ok { background: color-mix(in srgb, var(--hi) 15%, transparent); color: var(--hi); }
.cm-st.no { background: color-mix(in srgb, var(--lo) 12%, transparent); color: var(--lo); }
.cm-st.chk { background: color-mix(in srgb, var(--mid) 16%, transparent); color: #9a6b00; }
.mini.cm td { font-size: 12.5px; vertical-align: top; }
.letter { white-space: pre-wrap; font-family: inherit; font-size: 14px; line-height: 1.7; background: var(--bg); padding: 14px 16px; border-radius: 10px; max-height: 420px; overflow-y: auto; }
.tpl { padding-left: 22px; margin: 0 0 8px; } .tpl li { margin-bottom: 6px; }
.tpl li { display: list-item; } .tpl li input { width: calc(100% - 40px); margin: 0; display: inline-block; } .tpl li .icon-btn { height: 34px; width: 32px; margin-left: 4px; vertical-align: middle; }
.pill.preparing { border-color: var(--mid); color: #9a6b00; }
@media (max-width: 860px) {
  .board { grid-template-columns: repeat(5, 78vw); scroll-snap-type: x mandatory; } .col { scroll-snap-align: start; }
  .cal-d { min-height: 70px; } .cal-e { font-size: 0; height: 6px; padding: 0; } .cal-h { font-size: 11px; padding: 6px 2px; }
  .bonds { grid-template-columns: 1fr; } .ck li { grid-template-columns: 1fr 30px; } .ck li small, .ck-due { grid-column: 1; }
  .top nav { overflow-x: auto; }
}
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.tpl li { display: flex; gap: 6px; align-items: center; } .tpl li input { flex: 1; width: auto; }
.chips { align-items: center; } .chips .chip { line-height: 1.35; }
.top nav button { white-space: nowrap; }
@media (max-width: 860px) {
  .top { gap: 8px; } .top nav { order: 3; flex: 1 1 100%; overflow-x: auto; }
  .top-actions { margin-left: auto; }
}

/* ===== งาน AI เบื้องหลัง ===== */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid color-mix(in srgb, var(--brand) 25%, transparent);
  border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; flex: none; }
.jobs-ind { position: relative; }
.jobs-ind .btn { display: inline-flex; gap: 6px; align-items: center; border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.jobs-ind .me-menu { min-width: 280px; }
.job-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; margin-top: 14px;
  background: color-mix(in srgb, var(--brand) 8%, transparent); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); font-size: 14px; }
.job-banner small { flex-basis: 100%; padding-left: 22px; }
.job-banner .btn { margin-left: auto; }

/* ===== จับคู่ข้อมูล ===== */
.mp-add { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 14px 0 0; background: var(--bg); }
.mp-add input, .mp-add textarea, .mp-add select { background: var(--card); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 10px; }
.seg button { font: inherit; font-size: 13.5px; padding: 6px 12px; border: 0; background: var(--card); color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; }
.mp-layout { display: grid; grid-template-columns: 260px 1fr; gap: 18px; padding: 16px 0 24px; }
.mp-caps h4 { margin: 4px 0 8px; }
.mp-cap { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; width: 100%; text-align: left; font: inherit; color: var(--ink);
  background: none; border: 1px solid transparent; border-radius: 8px; padding: 8px; cursor: pointer; }
.mp-cap:hover { background: var(--bg); } .mp-cap.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, transparent); }
.mp-cap small { grid-column: 2; font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.mp-url { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, monospace; }
.mp-type { font-size: 10px; font-weight: 600; padding: 2px 5px; border-radius: 4px; background: var(--bg); align-self: start; margin-top: 2px; }
.mp-type.json { color: #7c3aed; } .mp-type.html { color: #c2410c; }
.mp-badge { color: var(--hi); }
.mp-saved { display: flex; justify-content: space-between; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.mp-saved b { display: block; font-size: 13.5px; font-weight: 500; } .mp-saved small { font-size: 11.5px; word-break: break-all; }
.mp-saved .icon-btn { height: 28px; width: 28px; flex: none; }
.mp-step { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; }
.mp-step:first-child { margin-top: 0; }
.mp-step span { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.mp-step small { margin-left: 4px; }
.mp-main > div > select, .mp-main select { margin: 0; }
.mp-fields td { padding: 4px 6px; } .mp-fields td:first-child { width: 170px; font-size: 13.5px; }
.mp-fields select { padding: 5px 8px; font-size: 13px; }
.mp-sample { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-prev td { font-size: 12.5px; }
@media (max-width: 960px) { .mp-layout { grid-template-columns: 1fr; } .mp-sample { display: none; } }
