/* ============ Chokdee Quotation — UI ============ */
:root {
  --red: #d0112b; --red-d: #a50d22; --red-dd: #7d0a1a; --red-l: #fff0f2; --red-m: #ffd9de;
  --gold: #ffc531; --gold-d: #e0a400; --gold-l: #fff7df;
  --ink: #1c1917; --ink-2: #44403c; --muted: #78716c; --faint: #a8a29e;
  --line: #ece7e4; --line-2: #f5f2f0; --bg: #f8f5f2; --card: #fff;
  --ok: #15803d; --ok-l: #e9f7ee; --warn: #b45309; --warn-l: #fff6e5; --bad: #c81e1e; --bad-l: #fdecec;
  --info: #1d4ed8; --info-l: #eef3ff;
  --r: 14px; --r-sm: 10px;
  --sh-1: 0 1px 2px rgba(28,25,23,.04), 0 1px 3px rgba(28,25,23,.06);
  --sh-2: 0 4px 16px rgba(28,25,23,.07), 0 1px 3px rgba(28,25,23,.05);
  --sh-3: 0 18px 50px rgba(28,25,23,.18);
  --side: 248px;
  --font: 'IBM Plex Sans Thai', 'Sarabun', 'Leelawadee UI', Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--red); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { width: 18px; height: 18px; flex: none; }
.center-msg { padding: 90px 20px; text-align: center; color: var(--muted); }
.center-msg::before { content: ''; display: block; width: 34px; height: 34px; margin: 0 auto 14px; border: 3px solid var(--red-m); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- layout ---------- */
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side); z-index: 30;
  background: linear-gradient(180deg, #c80f28 0%, #a30c21 100%); color: #fff;
  display: flex; flex-direction: column; padding: 18px 14px; gap: 6px;
}
.side::after { content: ''; position: absolute; inset: auto 0 0 0; height: 220px; pointer-events: none;
  background: radial-gradient(120% 80% at 20% 120%, rgba(255,197,49,.22), transparent 60%); }
.brand { display: flex; align-items: center; gap: 11px; color: #fff; padding: 4px 6px 16px; }
.brand img { width: 44px; height: 44px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
.brand b { display: block; font-size: 16px; line-height: 1.2; }
.brand small { display: block; font-size: 12.5px; opacity: .78; }
.cta {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin: 2px 2px 14px;
  background: var(--gold); color: #3a2500; font-weight: 700; padding: 11px 12px; border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.18), inset 0 -2px 0 rgba(0,0,0,.08); transition: transform .15s, box-shadow .15s;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(0,0,0,.22), inset 0 -2px 0 rgba(0,0,0,.08); }
.cta.on { outline: 2px solid #fff; outline-offset: 2px; }
.snav { display: flex; flex-direction: column; gap: 2px; }
.snav .sep { font-size: 11.5px; letter-spacing: .06em; opacity: .6; padding: 14px 12px 4px; }
.snav a { display: flex; align-items: center; gap: 11px; color: rgba(255,255,255,.86); padding: 9px 12px; border-radius: 10px; font-weight: 500; transition: background .15s; }
.snav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.snav a.on { background: #fff; color: var(--red); font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.me { margin-top: auto; position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: rgba(0,0,0,.16); border: 1px solid rgba(255,255,255,.12); color: #fff; border-radius: 12px; padding: 9px 10px; cursor: pointer; }
.me:hover { background: rgba(0,0,0,.24); }
.me b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.me small { display: block; font-size: 12px; opacity: .75; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: #3a2500; display: grid; place-items: center; font-weight: 700; flex: none; }
.mtop, .bnav { display: none; }

.page { margin-left: var(--side); max-width: calc(1240px + var(--side)); padding: 26px 32px 80px; animation: fade .25s ease; }
.page h2 { margin: 0; font-size: 25px; font-weight: 700; letter-spacing: -.01em; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hint { color: var(--muted); font-size: 13px; }
.muted { color: var(--faint); }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--sh-1); }
.card h3 { margin: 0 0 16px; font-size: 16.5px; display: flex; align-items: center; gap: 10px; font-weight: 700; }
.card h3 .n { background: var(--red-l); color: var(--red); width: 28px; height: 28px; border-radius: 9px; display: inline-grid; place-items: center; font-size: 14px; font-weight: 700; }
.card h3 .hint { font-weight: 400; }

/* ---------- forms ---------- */
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-size: 13px; color: var(--ink-2); font-weight: 500; margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input[type=email], input[type=tel], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #ddd6d2; border-radius: var(--r-sm); background: #fff; min-height: 42px;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
input:hover, select:hover, textarea:hover { border-color: #cbc2bd; }
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 4px rgba(208,17,43,.12); }
input[readonly] { background: var(--line-2); color: var(--ink-2); border-color: var(--line); }
input::placeholder, textarea::placeholder { color: var(--faint); }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; }
textarea { resize: vertical; min-height: 64px; line-height: 1.55; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }

.btn { border: 1px solid #ddd6d2; background: #fff; padding: 9px 16px; border-radius: var(--r-sm); cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; color: var(--ink); font-weight: 500; min-height: 42px;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s; }
.btn:hover { background: var(--line-2); border-color: #cbc2bd; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; box-shadow: 0 4px 12px rgba(208,17,43,.25); }
.btn.primary:hover { background: var(--red-d); border-color: var(--red-d); }
.btn.primary:disabled { background: #e8a9b2; border-color: #e8a9b2; box-shadow: none; cursor: not-allowed; }
.btn.line { background: #06c755; border-color: #06c755; color: #fff; font-weight: 700; }
.btn.line:hover { background: #05b04b; }
.btn.small { padding: 5px 11px; font-size: 13.5px; min-height: 34px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.danger { color: var(--bad); }
.toggle { display: inline-flex; background: var(--line-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.toggle button { border: 0; background: transparent; padding: 7px 18px; cursor: pointer; border-radius: 9px; font-weight: 500; color: var(--muted); }
.toggle button.on { background: #fff; color: var(--red); font-weight: 700; box-shadow: var(--sh-1); }
.checkbox { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--red); }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 22px; align-items: start; }
.preview-col { position: sticky; top: 20px; }
.preview-col .phead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.preview-col .phead .live { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.18); }
.preview { background: linear-gradient(180deg, #ece6e2, #e4ddd8); border-radius: var(--r); padding: 12px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,.05); }
.preview .scaler { transform-origin: top left; }
.preview .qdoc { box-shadow: 0 8px 26px rgba(0,0,0,.14); margin: 0; border-radius: 3px; }
.cust-box { display: flex; gap: 10px; align-items: flex-start; background: var(--line-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; font-size: 13.5px; color: var(--ink-2); margin: -4px 0 14px; }
.cust-box::before { content: '🏢'; }
.items { width: 100%; display: block; }
.items thead, .items tbody { display: block; }
.items tr { display: grid; grid-template-columns: minmax(0, 2.3fr) minmax(70px, .9fr) minmax(80px, 1fr) minmax(96px, auto) 76px; gap: 0 8px; align-items: start; }
.items th:nth-child(4) { display: none; }
.items td:nth-child(4) { order: 10; grid-column: 1 / -1; padding-top: 0; border-top: 0; }
.items td:nth-child(4) textarea { min-height: 38px; height: 38px; background: #fcfaf9; }
.items tbody tr { border-top: 1px solid var(--line-2); padding: 4px 0; }
.items tbody tr:hover { background: #fffbfb; border-radius: 10px; }
.items th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 0 0 8px; text-transform: uppercase; letter-spacing: .02em; }
.items td { padding: 8px 0; vertical-align: top; }
.items td.amt { text-align: right; padding-top: 17px; white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.items .chk { font-size: 12.5px; margin-top: 5px; font-weight: 500; }
.items .chk.muted { color: var(--faint); }
.items textarea { min-height: 42px; height: 42px; font-size: 13.5px; }
.items .acts { white-space: nowrap; padding-top: 12px; text-align: right; }
.items .acts button { border: 0; background: none; cursor: pointer; padding: 4px 6px; color: var(--faint); font-size: 15px; border-radius: 6px; }
.items .acts button:hover { color: var(--red); background: var(--red-l); }
.totals { margin-left: auto; max-width: 380px; margin-top: 14px; background: var(--line-2); border-radius: 12px; padding: 12px 16px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.totals .g { font-weight: 700; font-size: 19px; color: var(--ink); border-top: 1px dashed #d6ccc6; margin-top: 6px; padding-top: 9px; }
.totals .g span:last-child { color: var(--red); }
.status-box { border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; border: 1px solid transparent; }
.status-box.ok { background: var(--ok-l); color: var(--ok); border-color: #c9ebd5; }
.status-box.bad { background: var(--bad-l); color: var(--bad); border-color: #f6cdcd; }
.status-box.warnbox { background: var(--warn-l); color: var(--warn); border-color: #f5ddb0; }
.status-box ul { margin: 6px 0 0; padding-left: 20px; }
.savebar { position: sticky; bottom: 14px; z-index: 5; display: flex; gap: 10px; align-items: center; padding: 10px 12px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh-2); }
.savebar .btn.primary { padding: 10px 22px; }

/* ---------- tables ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin-bottom: 14px; box-shadow: var(--sh-1); }
.toolbar select, .toolbar input { min-height: 38px; width: auto; }
.toolbar .search { position: relative; flex: 1; min-width: 180px; }
.toolbar .search input { width: 100%; padding-left: 36px; }
.toolbar .search .ic { position: absolute; left: 11px; top: 10px; color: var(--faint); }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.ms { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; box-shadow: var(--sh-1); position: relative; overflow: hidden; }
.ms::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--red)); }
.ms .l { font-size: 12.5px; color: var(--muted); }
.ms .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ms .s { font-size: 12px; color: var(--muted); }
.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-1); }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; background: #fcfaf9; padding: 11px 14px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 12.5px; text-transform: uppercase; letter-spacing: .02em; }
table.list td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; transition: background .12s; }
table.list tr.click:hover td { background: #fff8f8; }
table.list .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.list tr.off td { color: var(--faint); }
table.list .qno { font-weight: 700; color: var(--ink); letter-spacing: .01em; }
table.list .sub2 { display: block; font-size: 12.5px; color: var(--muted); }
table.list tr.total td { font-weight: 700; background: #fcfaf9; }
.empty { text-align: center; padding: 50px 20px !important; color: var(--muted); }
.empty .big { font-size: 40px; display: block; margin-bottom: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.st-รอตอบกลับ { background: var(--warn-l); color: #92400e; }
.st-ได้งาน { background: var(--ok-l); color: var(--ok); }
.st-ไม่ได้งาน { background: #f1efed; color: #57534e; }
.st-ยกเลิก { background: var(--bad-l); color: var(--bad); }
select.st { min-height: 30px; padding: 3px 28px 3px 12px; width: auto; border-radius: 999px; font-size: 13px; font-weight: 600; border-color: transparent; background-position: right 9px center; }
select.st:hover { border-color: rgba(0,0,0,.1); }
.eye { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ok); background: var(--ok-l); padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.tag-exp { display: inline-block; font-size: 11.5px; color: var(--bad); background: var(--bad-l); padding: 1px 7px; border-radius: 6px; margin-left: 4px; font-weight: 600; }

/* ---------- view page ---------- */
.viewbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.viewbar h2 { margin: 0 4px; }
.share { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center;
  background: linear-gradient(120deg, #fff 0%, #fff 60%, var(--red-l) 100%); }
.share .qr { width: 52px; height: 52px; border-radius: 14px; background: var(--red-l); color: var(--red); display: grid; place-items: center; font-size: 26px; }
.sharebox { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.sharebox input { flex: 1; min-width: 220px; font-size: 13px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.notebar { display: flex; gap: 8px; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.notebar input { flex: 1; min-width: 200px; min-height: 36px; }
.doc-wrap { background: linear-gradient(180deg, #ece6e2, #e4ddd8); padding: 26px; border-radius: var(--r); overflow-x: auto; }
.doc-wrap .qdoc { box-shadow: 0 12px 40px rgba(0,0,0,.15); border-radius: 3px; }

/* ---------- summary ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--sh-1); display: flex; gap: 14px; align-items: flex-start; }
.kpi .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: none; background: var(--red-l); }
.kpi.k2 .ico { background: var(--ok-l); } .kpi.k3 .ico { background: var(--warn-l); } .kpi.k4 .ico { background: var(--info-l); }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 1px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .s { color: var(--muted); font-size: 12.5px; }
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; align-items: end; height: 220px; padding: 14px 4px 0; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(0deg, transparent 0 54px, var(--line-2) 54px 55px); }
.bars .col { display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .b { width: 40%; max-width: 20px; border-radius: 6px 6px 0 0; min-height: 2px; transition: height .5s ease; }
.bars .b.o { background: linear-gradient(180deg, #f6a7b3, #ee7f90); } .bars .b.w { background: linear-gradient(180deg, #34c06a, #15803d); }
.bars .col:hover .b { filter: brightness(1.05); }
.mlabels { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; padding: 6px 4px 0; text-align: center; font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 6px; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-hero { position: relative; overflow: hidden; color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(90% 70% at 10% 110%, rgba(255,197,49,.35), transparent 60%), linear-gradient(150deg, #d61330 0%, #a30c21 70%, #7d0a1a 100%); }
.auth-hero::before { content: ''; position: absolute; width: 520px; height: 520px; right: -160px; top: -160px; border-radius: 50%; border: 70px solid rgba(255,255,255,.06); }
.auth-hero img { width: 76px; height: 76px; border-radius: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.auth-hero h2 { font-size: 38px; line-height: 1.2; margin: 26px 0 10px; letter-spacing: -.01em; }
.auth-hero p { opacity: .85; font-size: 16px; max-width: 420px; margin: 0; }
.auth-hero ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; }
.auth-hero li { display: flex; gap: 10px; align-items: center; opacity: .92; }
.auth-hero li b { width: 28px; height: 28px; border-radius: 8px; background: rgba(255,255,255,.15); display: grid; place-items: center; font-size: 14px; }
.auth-hero .foot { font-size: 13px; opacity: .6; }
.auth-side { display: grid; place-items: center; padding: 30px; }
.auth { width: 100%; max-width: 380px; animation: pop .35s ease; }
.auth .logo { display: none; width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 16px; }
.auth h1 { font-size: 26px; margin: 0 0 4px; }
.auth .lead { color: var(--muted); margin: 0 0 24px; }
.auth .btn { width: 100%; padding: 12px; margin-top: 4px; }
.err { color: var(--bad); font-size: 14px; min-height: 22px; margin: 10px 0 0; }

/* ---------- modal + toast ---------- */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; background: rgba(28,25,23,.45); backdrop-filter: blur(3px); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s ease; }
.modal-box { background: #fff; border-radius: 18px; padding: 24px; width: 100%; max-width: 580px; max-height: 92vh; overflow: auto; box-shadow: var(--sh-3); animation: pop .2s ease; }
.modal-box h3 { margin: 0 0 18px; font-size: 19px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.menu-links { display: grid; gap: 6px; margin-bottom: 16px; }
.menu-links a { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px; background: var(--line-2); color: var(--ink); font-weight: 500; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(30px); background: #1c1917; color: #fff; padding: 12px 20px; border-radius: 12px;
  opacity: 0; transition: .25s; z-index: 60; pointer-events: none; max-width: 90vw; box-shadow: var(--sh-3); display: flex; gap: 9px; align-items: center; font-weight: 500; }
.toast::before { content: '✓'; width: 22px; height: 22px; border-radius: 50%; background: #22c55e; display: grid; place-items: center; font-size: 13px; flex: none; }
.toast.bad::before { content: '!'; background: #ef4444; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .preview-col { position: static; }
}
@media (max-width: 900px) {
  .side { display: none; }
  .mtop { display: flex; position: sticky; top: 0; z-index: 30; align-items: center; gap: 10px; height: 58px; padding: 0 14px;
    background: linear-gradient(90deg, #d0112b, #a50d22); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
  .mtop .brand { padding: 0; flex: 1; } .mtop .brand img { width: 36px; height: 36px; border-radius: 10px; }
  .mtop .js-user { border: 0; background: none; padding: 0; cursor: pointer; }
  .bnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; font-weight: 500; }
  .bnav a.on { color: var(--red); font-weight: 700; }
  .bnav a .ic { width: 22px; height: 22px; }
  .bnav a.plus .ic { width: 46px; height: 46px; padding: 12px; margin-top: -22px; border-radius: 50%; background: var(--red); color: #fff; box-shadow: 0 6px 16px rgba(208,17,43,.4); border: 3px solid #fff; }
  .page { margin-left: 0; padding: 16px 14px 110px; }
  .page h2 { font-size: 21px; }
  .savebar { bottom: 80px; }
  .mini-stats, .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; min-width: 0; } .kpi .ico { display: none; } .kpi .v, .ms .v { font-size: 18px; } .ms { min-width: 0; padding: 10px 12px; }
  .toast { bottom: 90px; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth .logo { display: block; }
  .auth h1, .auth .lead { text-align: center; }
}
@media (max-width: 700px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .items thead { display: none; }
  .items tr { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; border-top: 1px solid var(--line); padding: 10px 0; }
  .items td { border: 0; padding: 0; }
  .items td:nth-child(4) { order: 0; }
  .items td.full { grid-column: 1 / -1; }
  .items td.amt { text-align: left; padding-top: 4px; }
  .items td.amt::before { content: 'จำนวนเงิน '; font-weight: 400; color: var(--muted); }
  .items td.acts { text-align: right; padding-top: 0; }
  .doc-wrap { padding: 0; background: none; }
  .share { grid-template-columns: 1fr; } .share .qr { display: none; }
  /* table → cards */
  table.list.cards thead { display: none; }
  table.list.cards, table.list.cards tbody, table.list.cards tr, table.list.cards td { display: block; width: 100%; }
  table.list.cards tr { padding: 12px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
  table.list.cards td { border: 0; padding: 0; }
  table.list.cards td[data-k=no] { grid-column: 1; }
  table.list.cards td[data-k=amt] { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 700; }
  table.list.cards td[data-k=cust] { grid-column: 1 / -1; }
  table.list.cards td[data-k=date], table.list.cards td[data-k=valid] { display: inline; font-size: 12.5px; color: var(--muted); }
  table.list.cards td[data-k=date]::before { content: 'เสนอ '; } table.list.cards td[data-k=valid]::before { content: 'ยืนราคาถึง '; }
  table.list.cards td[data-k=st] { grid-column: 2; grid-row: 2 / span 2; align-self: center; }
  table.list.cards td[data-k=by], table.list.cards td[data-k=eye] { font-size: 12.5px; color: var(--muted); }
  .bars { height: 160px; gap: 4px; } .mlabels { gap: 4px; font-size: 10.5px; }
}
@media print {
  .side, .mtop, .bnav, .viewbar, .no-print { display: none !important; }
  .page { padding: 0; margin: 0; max-width: none; }
  .doc-wrap { padding: 0; background: none; }
  body { background: #fff; }
}
