:root {
  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #f0ede8;
  --text: #1f1d1b;
  --muted: #6f6a64;
  --line: #e2ddd6;
  --accent: #2f2a26; /* charcoal main buttons (แบบ ก., 2026-10-26); orange now means ซ้อนุ้ย */
  --accent-ink: #ffffff;
  --accent-soft: #e9e4de;
  --good: #1f7a4d;
  --good-soft: #e1f3e9;
  --warn: #9a6200;
  --warn-soft: #fdf1d6;
  --bad: #b3261e;
  --bad-soft: #fbe3e1;
  /* dashboard bars (user is colour-blind, 2026-10-21): dark blue = done, dark orange + stripes = still missing */
  --duo-l: #1d4e9e; --duo-r: #c9580a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --font: 'Sarabun', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161514; --surface: #201f1d; --surface-2: #2a2826; --text: #f1eee9; --muted: #a39d95;
    --line: #36332f; --accent: #6a625a; --accent-ink: #ffffff; --accent-soft: #2e2a27;
    --good: #5cc28d; --good-soft: #17301f; --warn: #e2b34f; --warn-soft: #33290f; --bad: #f08a82; --bad-soft: #3a1c1a;
    --duo-l: #5b93e6; --duo-r: #e07a2e;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161514; --surface: #201f1d; --surface-2: #2a2826; --text: #f1eee9; --muted: #a39d95;
  --line: #36332f; --accent: #6a625a; --accent-ink: #ffffff; --accent-soft: #2e2a27;
  --good: #5cc28d; --good-soft: #17301f; --warn: #e2b34f; --warn-soft: #33290f; --bad: #f08a82; --bad-soft: #3a1c1a;
  --duo-l: #5b93e6; --duo-r: #e07a2e;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); }
a { color: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.4rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.right { text-align: right; }
.hidden { display: none !important; }

/* layout */
#app { min-height: 100vh; }
main { min-width: 0; }
.view { padding: 16px; padding-bottom: calc(100px + env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #1f1d1b; color: #f7f5f2; }
.topbar .icon-btn { text-decoration: none; font-size: 1.3rem; padding: 4px 8px; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand-mark { color: #c9a24a; }
.sidebar { display: none; }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px; text-decoration: none;
  font-size: .8rem; color: var(--muted); white-space: nowrap; }
.bottomnav a .ico { font-size: 1.9rem; line-height: 1; position: relative; }
.nav-badge { display: inline-block; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff;
  font-size: .75rem; font-weight: 700; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.bottomnav a .ico img { width: 38px; height: 38px; }
.bottomnav .nav-badge { position: absolute; top: -6px; right: -14px; border: 2px solid var(--surface); line-height: 16px; height: 22px; }
.nav a .nav-badge { margin-left: 8px; }
.more-menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more-menu a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 6px; border-radius: 12px;
  background: var(--surface-2); text-decoration: none; color: var(--text); font-size: .9rem; }
.more-menu a .ico { font-size: 2rem; line-height: 1; }
.more-menu a .ico img { width: 52px; height: 52px; }
.more-menu a.active { color: var(--text); font-weight: 700; }
.bottomnav a.active { color: var(--accent); font-weight: 600; }
/* Selling menus before the first round: greyed out, not tappable. */
.nav a.nav-off, .bottomnav a.nav-off { opacity: .35 !important; pointer-events: none; filter: grayscale(1); }

@media (min-width: 900px) {
  #app { display: grid; grid-template-columns: 220px 1fr; }
  .sidebar { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 20px 12px;
    overflow-y: auto; scrollbar-width: none; background: #1f1d1b; color: #f7f5f2; } /* charcoal in both themes */
  .sidebar .brand { padding: 0 8px 12px; font-size: 1.1rem; }
  .nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .nav a { padding: 10px 12px; border-radius: 8px; text-decoration: none; opacity: .8; }
  .nav a:hover { background: rgba(255,255,255,.08); opacity: 1; }
  .nav a.active { background: var(--accent); color: var(--accent-ink); opacity: 1; font-weight: 600; }
  .topbar, .bottomnav { display: none; }
  .view { padding: 28px 32px 48px; }
}

/* page header */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* round page head (user, 2026-10-31): glossy capsule name, date and average as text under it; light แก้ไข and
   รายงานรอบ stacked at the right, no lower than the average line */
.page-head.round-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: nowrap; }
.round-btns { display: flex; flex-direction: column; gap: 6px; }
.round-btns .btn { justify-content: center; }
.round-head .cap { display: inline-block; margin: 0 0 6px; color: #fff; font-weight: 700; font-size: 1.15rem; line-height: 1.3; padding: 8px 22px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,.05) 48%, rgba(255,255,255,0) 52%), linear-gradient(180deg, #4a4540, #23201d);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 3px 7px rgba(0,0,0,.3); }
.back { display: inline-block; margin-bottom: 8px; color: var(--muted); text-decoration: none; font-size: .9rem; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: 1fr; }
.grid.two > * { min-width: 0; } /* a wide table scrolls inside its card, not the page */
@media (min-width: 700px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }
.section { margin-top: 20px; }
.section > h2 { margin-bottom: 10px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { font-size: .8rem; color: var(--muted); }
.stat .value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .8rem; color: var(--muted); }
.stat.accent { background: var(--accent-soft); border-color: transparent; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

.stock-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (min-width: 700px) { .stock-chips { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); } }
.chip-stat { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; text-align: center; }
.chip-stat .v { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.chip-stat .l { font-size: .78rem; color: var(--muted); }
.chip-stat.low .v { color: var(--bad); }

/* forms */
label.field { display: block; }
/* round / purchase forms: เฮียนาจ | ซ้อนุ้ย boxes in the cell beside the total, inputs level with the total's (2026-10-27) */
.sack-split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-self: end; }
.form-grid > label.field:has(+ .sack-split) { align-self: end; }
label.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; }
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
/* No square focus frame over round choices (user, 2026-10-22): the coloured choice box already shows what is picked. */
input[type=checkbox]:focus, input[type=radio]:focus { outline: none; }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
@media (min-width: 700px) { .form-grid.wide { grid-template-columns: repeat(4, 1fr); } }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 10px; padding: 10px 16px; min-height: 44px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.danger-solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: .875rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* segmented / tabs */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button, .seg a { font: inherit; border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; cursor: pointer;
  color: var(--muted); text-decoration: none; font-size: .9rem; }
.seg .on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* badges */
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; border: 0; font-family: inherit; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.neutral { background: var(--surface-2); color: var(--muted); }
button.badge { cursor: pointer; padding: 4px 10px; }

/* lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.row-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; }
.row-card:hover { border-color: var(--muted); }
.row-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.row-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--text); border-bottom: 0; }
tr.sub td { color: var(--muted); font-size: .9rem; }
.tight th, .tight td { padding: 8px 5px; } /* narrow tables in dialogs on phones */
.roomy th, .roomy td { padding: 14px 10px; } /* short lists that should not look cramped */
table input { min-height: 38px; padding: 6px 8px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; }
.kv > div:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }
.kv .strong { font-weight: 700; }
.kv .line { grid-column: 1 / -1; border-top: 1px solid var(--line); }

/* order form */
.pkg-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 700px) { .pkg-grid { grid-template-columns: 1fr 1fr; } }
.pkg { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.pkg.on { border-color: var(--accent); background: var(--accent-soft); }
.pkg .info { flex: 1; min-width: 0; }
.pkg .name { font-weight: 700; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font: inherit; font-size: 1.2rem; cursor: pointer; color: var(--text); }
.stepper input { width: 56px; text-align: center; padding: 6px; min-height: 40px; }
.stepper button:disabled { opacity: .35; cursor: not-allowed; }
/* The − / + buttons do the counting: no browser up/down arrows inside the box. */
.stepper input { -moz-appearance: textfield; appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.summary-bar { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 5; margin-top: 16px; }
@media (min-width: 900px) { .summary-bar { bottom: 12px; } }
.suggest { position: relative; }
.suggest-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; margin-top: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 280px; overflow-y: auto; }
.suggest-list button { display: block; width: 100%; text-align: left; font: inherit; color: var(--text); background: none; border: 0; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.suggest-list button:hover { background: var(--surface-2); }
.picked { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-row label { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; background: var(--surface); }
.radio-row label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal-back { align-items: center; } .modal { border-radius: 16px; padding: 24px; } }
.modal h2 { margin-bottom: 14px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 100; transition: .2s; pointer-events: none; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.error { background: var(--bad); color: #fff; }

/* login */
/* The picture carries the shop's logo and name (user, 2026-11-04). Phone: the picture fills the width from the top, so
   its height is --h; the box sits in the empty part between the logo (ends at 20%) and the person (starts at 48%). */
.login { --h: max(100dvh, 200vw); position: fixed; inset: 0; overflow: auto; padding: calc(var(--h) * .215) 16px 16px;
  background: #f1e6d3 url(/img/login-phone.jpg) top center / cover no-repeat; }
.login.test { background-image: url(/img/login-test-phone.jpg); }
.login .card { width: 100%; max-width: 380px; margin: 0 auto; padding: 14px 16px; color: #2b2622;
  background: rgba(255,255,255,.62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.75); }
.login .field > span { color: #4a423b; }
.login input { background: #fff; color: #2b2622; }
.login .stack > * + * { margin-top: 8px; }
/* Sideways screens: the empty part left of the grill and the person. */
@media (orientation: landscape) {
  .login { display: grid; align-items: center; justify-items: start; padding: 18vh 16px 16px max(16px, calc(29vw - 190px));
    background-image: url(/img/login-pc.jpg); background-position: center; }
  .login.test { background-image: url(/img/login-test-pc.jpg); }
  .login .card { margin: 0; }
}

/* report */
.report h1 { margin-bottom: 2px; }
.report .card h2 { margin-bottom: 10px; }
.print-only { display: none; }

@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #f3f3f3; --text: #000; --muted: #555; --line: #ccc; color-scheme: light; }
  body { font-size: 12px; background: #fff; }
  #app { display: block; }
  .no-print, .sidebar, .topbar, .bottomnav, .toast { display: none !important; }
  .print-only { display: block; }
  .view { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; padding: 10px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .grid.two { grid-template-columns: 1fr 1fr; }
  th, td { padding: 4px 6px; }
  @page { size: A4; margin: 12mm; }
}
.stock-note { background: var(--accent-soft); color: var(--text); border-radius: 8px; padding: 8px 12px; font-size: .95rem; }
.profit-table td, .profit-table th { padding: 6px 8px; }
.profit-table tr.sub-profit td { border-bottom-width: 2px; }
.stat.wide { grid-column: span 2; }
.stat-split { display: grid; grid-template-columns: 1fr 1fr; }
.stat-split > div + div { border-left: 1px solid var(--accent); padding-left: 14px; margin-left: 14px; }
.stat-head { font-size: .85rem; font-weight: 600; padding-bottom: 6px; margin-bottom: 8px; border-bottom: 1px solid var(--accent); }
.profit-table .row-note { display: block; white-space: nowrap; font-size: .85em; color: var(--muted); }
.nowrap { white-space: nowrap; }
.profit-table .row-note.wrap { white-space: normal; }
.ship-amount { text-align: right; flex-shrink: 0; line-height: 1.2; }
.ship-amount .price { font-size: 1.4rem; font-weight: 700; margin-top: 4px; white-space: nowrap; }

/* dashboard: sales − cost = profit, and the charcoal-buying fund bars */
.stat-eq { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: start; gap: 6px; max-width: 640px; }
.stat-eq > div { min-width: 0; }
.stat-eq .sub { line-height: 1.3; }
.stat-eq .op { font-size: 1.2rem; color: var(--muted); padding-top: 20px; }
.stat-eq .value { font-size: clamp(.9rem, 4.1vw, 1.15rem); white-space: nowrap; }
.stat-eq .value.muted { color: var(--muted); }
@media (min-width: 700px) { .stat-eq .value { font-size: 1.35rem; } }
.duo-head { display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
.duo-bar { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.duo-bar .l { background: var(--duo-l); }
.duo-bar .r { background: repeating-linear-gradient(135deg, var(--duo-r) 0 7px, rgba(255,255,255,.35) 7px 10px), var(--duo-r); }
.duo-bar .l + .r { border-left: 2px solid var(--surface); }
.duo .lc { color: var(--duo-l); }
.duo .rc { color: var(--duo-r); }
.duo-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; }
.duo-foot .right { text-align: right; margin-left: auto; }
.loan-calc { align-self: end; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); line-height: 1.35; }
.loan-calc:empty { display: none; }
@media (max-width: 699px) { .loan-calc { grid-column: 1 / -1; } } /* phones: too narrow beside the field */
#loan-auto, input.ro { cursor: default; } /* read-only, filled by the system; looks like the other fields (user, 2026-10-22) */
.keep-warn { color: var(--duo-r); font-weight: 600; } /* fewer sacks left than the 2 kept for custom weights */
.keep-warn:empty { display: none; }
.loan-calc .kv { gap: 2px 8px; }
.loan-calc .rc, .borrow-list .rc { color: var(--duo-r); }
.kv .total-row { border-top: 1px solid var(--line); padding-top: 6px; }
.fund-loan { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
/* orange striped alert: the system cut a repayment to ซ้อนุ้ย (stays until รับทราบ) */
.strike { text-decoration: line-through; color: var(--muted); }

/* live updates: bar shown when another screen changed something while this one is typing; "ใหม่" label on new bills */
.live-banner { position: fixed; left: 50%; transform: translateX(-50%); top: calc(54px + env(safe-area-inset-top)); z-index: 40;
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: 14px; max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg); box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 600; white-space: nowrap; }
@media (min-width: 900px) { .live-banner { top: 16px; left: calc(50% + 120px); } }
.badge.new { background: var(--accent); color: var(--accent-ink); }

/* KEX tracking numbers on เตรียมส่ง: one slot per box (phase 2) */
.tracks { margin-top: 8px; display: grid; gap: 6px; }
.track-head { display: flex; align-items: center; gap: 8px; }
.track-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; }
.track-row .track-box { font-weight: 600; font-size: .9rem; min-width: 3.6rem; }
.track-row input { min-width: 0; font-family: ui-monospace, Consolas, monospace; letter-spacing: .02em; text-transform: uppercase; }
.track-row input:placeholder-shown { text-transform: none; font-family: inherit; letter-spacing: 0; }
.track-row .btn { padding: 6px 10px; font-size: 1.1rem; line-height: 1; }
.track-who { margin-top: 4px; font-size: .85rem; }
.track-list { margin-top: 8px; display: grid; gap: 2px; }
.track-list .t { font-family: ui-monospace, Consolas, monospace; }
/* เตรียมส่ง: one tab per group, red count badge like the bottom bar (agreed 2026-10-23) */
.ship-tabs { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; margin: 14px 0 12px; }
.ship-tabs a { position: relative; text-align: center; padding: 9px 2px; white-space: nowrap; }
.ship-tabs .nav-badge { position: absolute; top: -15px; right: -3px; border: 2px solid var(--surface); line-height: 16px; height: 22px; }
.day-head { display: flex; align-items: center; gap: 10px; margin: 16px 0 8px; font-weight: 700; font-size: .95rem; }
.day-head::after { content: ''; flex: 1; border-top: 2px solid var(--line); }
.day-head:first-child { margin-top: 0; }
/* ⓧ inside a tracking slot: empty it at once to scan again */
.track-in { position: relative; min-width: 0; display: block; }
.track-in input { width: 100%; padding-right: 40px; }
/* raised orange ball, the app's main button colour (user chose "ส้มนูน", 2026-10-23), kept clear of the 📷 button */
.track-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; padding: 0; border: 0;
  border-radius: 50%; color: #fff; font-family: inherit; font-size: 1.35rem; font-weight: 700; line-height: 26px; text-align: center; cursor: pointer;
  background: radial-gradient(circle at 35% 28%, rgba(255,255,255,.85) 0 7%, transparent 38%), linear-gradient(180deg, #f08a4b, #c2410c);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), inset 0 -2px 3px rgba(0,0,0,.22), 0 2px 6px rgba(194,65,12,.45);
  text-shadow: 0 1px 1px rgba(0,0,0,.3); }
.track-clear:active { transform: translateY(-50%) scale(.9); }
.track-clear[hidden] { display: none; }
.track-row .track-in + .btn { margin-left: 8px; }
/* เตรียมส่ง: card of names under the tabs — equal buttons, five a row (ปิดแล้ว: month + 7 days, eight a row) */
.jump-card { padding: 10px; margin-bottom: 12px; }
.jump-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.jump-grid.days { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.btn.jump { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 44px; padding: 6px 4px;
  font-size: .8rem; font-weight: 600; line-height: 1.25; text-align: center; white-space: normal; color: #fff; border: 0;
  /* glossy charcoal, like the top bar (user chose "ถ่านเข้ม", 2026-10-23): stands out from the white cards */
  background: linear-gradient(180deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,.05) 48%, rgba(255,255,255,0) 52%), linear-gradient(180deg, #4a4540, #23201d);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 3px 7px rgba(0,0,0,.3); }
.btn.jump > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.days .btn.jump { font-size: .95rem; padding: 6px 0; }
.btn.jump:disabled { opacity: .3; box-shadow: none; cursor: default; }
.btn.jump-month { pointer-events: none; font-size: .78rem; color: #f6a26b; }
/* the bill (or day) a name button jumped to: a soft orange glow swells and fades twice (user, 2026-10-23) */
.flash { animation: glow2 1.8s ease-in-out; }
@keyframes glow2 {
  0%, 50%, 100% { box-shadow: var(--edge), var(--drop), 0 0 0 0 rgba(234,108,46,0); }
  22%, 72% { box-shadow: var(--edge), var(--drop), 0 0 0 2px rgba(234,108,46,.35), 0 0 22px 8px rgba(234,108,46,.55); } }
/* purchase-order card: "ยอดสั่ง 100 กระสอบ" centred, glossy charcoal like the name buttons, not tappable (user, 2026-10-27) */
.po-total { text-align: center; margin: 4px 0 6px; }
.po-total > span { display: inline-block; padding: 8px 22px; border-radius: 999px; color: #fff; font-weight: 700;
  background: linear-gradient(180deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,.05) 48%, rgba(255,255,255,0) 52%), linear-gradient(180deg, #4a4540, #23201d);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 3px 7px rgba(0,0,0,.3); }
/* ↑ back to the very top: glossy charcoal ball with a thick arrow, above the bottom bar (and the sticky ship bar on พร้อมส่ง) */
.to-top { position: fixed; right: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 9; width: 54px; height: 54px; padding: 0; border: 0;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: radial-gradient(circle at 35% 28%, rgba(255,255,255,.6) 0 7%, transparent 36%), linear-gradient(180deg, #57514b, #1f1c19);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), inset 0 -3px 4px rgba(0,0,0,.35), 0 4px 12px rgba(0,0,0,.4); }
.to-top svg { width: 28px; height: 28px; }
.to-top.lift { bottom: calc(160px + env(safe-area-inset-bottom)); }
.to-top:active { transform: scale(.92); }
.to-top[hidden] { display: none; }
@media (min-width: 900px) { .to-top { bottom: 24px; } .to-top.lift { bottom: 96px; } }
/* stock and box-count tiles everywhere: glossy charcoal like the name buttons, "10 กก. / 2 / กล่อง" top to bottom (user, 2026-10-23) */
.stock-chips .chip-stat { border: 0; color: #fff; padding: 8px 6px;
  background: linear-gradient(180deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,.05) 48%, rgba(255,255,255,0) 52%), linear-gradient(180deg, #4a4540, #23201d);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 3px 7px rgba(0,0,0,.3); }
.stock-chips .chip-stat .l { color: rgba(255,255,255,.85); font-weight: 600; line-height: 1.25; }
.stock-chips .chip-stat .v { line-height: 1.2; margin: 2px 0; }
.stock-chips .chip-stat .u { font-size: .72rem; color: rgba(255,255,255,.6); }
.stock-chips .chip-stat.low .v { color: #ff9a85; } /* low stock: light red on charcoal */
/* the total on เตรียมส่ง sits in a charcoal ball, like the number on a snooker ball */
.ball-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.num-ball { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 999px;
  color: #fff; font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums;
  background: radial-gradient(circle at 35% 28%, rgba(255,255,255,.6) 0 7%, transparent 36%), linear-gradient(180deg, #57514b, #1f1c19);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), inset 0 -3px 4px rgba(0,0,0,.35), 0 3px 8px rgba(0,0,0,.35); }
.ball-pair { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
/* bottom row of a เตรียมส่ง card: "ลบบิลนี้" left, the next step right */
.bill-actions { justify-content: space-between; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
/* "ลบบิลนี้": raised glossy red (user, 2026-10-23), on the bill page and every เตรียมส่ง card */
.btn.del-btn { color: #fff; border: 0; text-shadow: 0 1px 1px rgba(0,0,0,.3);
  background: linear-gradient(180deg, rgba(255,255,255,.35) 0%, rgba(255,255,255,.08) 48%, rgba(255,255,255,0) 52%), linear-gradient(180deg, #e0574a, #a61f17);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), inset 0 -2px 3px rgba(0,0,0,.2), 0 3px 8px rgba(166,31,23,.4); }
.btn.del-btn:active { transform: translateY(2px); box-shadow: inset 0 2px 4px rgba(0,0,0,.3); }
/* ทดลอง.bat: striped label and the two reset buttons — a second row of the black top bar (phone), top of the sidebar (PC) */
.topbar { flex-wrap: wrap; }
.test-tools { display: flex; gap: 6px; }
.test-tools .btn { padding: 5px 9px; font-size: .78rem; }
.test-label { color: #fff; font-size: .75rem; font-weight: 700; text-align: center; padding: 3px 8px; white-space: nowrap;
  background: repeating-linear-gradient(135deg, #1f3c88 0 10px, #2c55b8 10px 20px); }
/* Phone: icons and date, then the two buttons side by side, then the label edge to edge. */
.topbar .test-tools { flex: 0 0 100%; margin-top: 10px; }
.topbar .test-tools .btn { flex: 1; }
.topbar .test-label { flex: 0 0 calc(100% + 32px); margin: 8px -16px -10px; }
.sidebar .test-label { border-radius: 8px; margin: 0 0 8px; }
.sidebar .test-tools { margin-bottom: 14px; flex-wrap: wrap; }
/* เตรียมส่ง tick: comes by itself once every box has its tracking number (user, 2026-10-23); not tappable */
.ship-tick { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: transparent; border: 2px dashed var(--line); }
.ship-tick.on { color: #fff; border: 0;
  background: radial-gradient(circle at 35% 28%, rgba(255,255,255,.6) 0 7%, transparent 36%), linear-gradient(180deg, #57514b, #1f1c19);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), inset 0 -3px 4px rgba(0,0,0,.35), 0 3px 8px rgba(0,0,0,.35); }
/* ปิดแล้ว: numbers sent (dark blue) vs not yet (orange stripes) — the user is colour-blind, so the label and pattern carry it */
.badge.sent { background: var(--duo-l); color: #fff; }
.badge.unsent { color: #fff; background: repeating-linear-gradient(135deg, var(--duo-r) 0 6px, rgba(255,255,255,.3) 6px 9px), var(--duo-r); }
.row-card.is-sent { opacity: .82; }
.btn.resend-btn { font-weight: 600; }
/* share dialog: the picture cards side by side, scroll sideways when there are several */
.share-cards { display: flex; gap: 10px; overflow-x: auto; margin: 10px 0; padding-bottom: 4px; }
.share-cards img { flex: 0 0 auto; width: min(240px, 70vw); height: auto; border-radius: 12px; box-shadow: 0 3px 10px rgba(0,0,0,.25); }
.share-cards img:only-child { width: min(300px, 100%); margin: 0 auto; }
.share-msg { white-space: pre-wrap; font-family: inherit; font-size: .85rem; background: var(--bg, #f5f2ee); padding: 8px 10px; border-radius: 8px; margin: 6px 0 0; }
/* "ตั้งค่าใน Chrome" help: steps as bullets, each address in a box with a white copy button */
.help-steps { margin: 10px 0; padding-left: 20px; display: grid; gap: 10px; line-height: 1.5; }
.copy-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.copy-row code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .82rem; padding: 6px 8px; border-radius: 8px;
  background: var(--accent-soft); color: var(--text, inherit); }
.copy-row .btn { flex-shrink: 0; }
.copy-row .btn { background: #fff; color: #23201d; border: 1px solid #e2dcd3; } /* white copy buttons, light or dark theme */
/* สต๊อกวัสดุแพ็ค (2026-10-24): two tabs on สต๊อก; low or below zero = orange striped flag (the user is colour-blind) */
.ship-tabs.two { grid-template-columns: repeat(2, 1fr); }
.mat-chips .chip-stat { position: relative; overflow: hidden; }
.mat-chips .chip-stat.mat-warn { padding-bottom: 26px; }
.mat-flag { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 0; font-size: .72rem; font-weight: 700; color: #fff;
  background: repeating-linear-gradient(135deg, var(--duo-r) 0 6px, rgba(255,255,255,.3) 6px 9px), var(--duo-r); }
.mat-note { margin-top: 8px; color: var(--duo-r); }
.mat-fund-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mat-fund-two > div + div { border-left: 1px solid var(--line); padding-left: 12px; }
.mat-fund-v { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.mat-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.mat-row:last-child { border-bottom: 0; }
.mat-own { color: var(--duo-r); font-weight: 600; }
.mat-count input { width: 100%; min-width: 80px; }
.mat-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.mat-count td:first-child { white-space: nowrap; }
.mat-line-btns { display: flex; gap: 6px; flex-shrink: 0; }
/* Owner of the charcoal (2026-10-26): เฮียนาจ dark blue, ซ้อนุ้ย plain orange, large; the name is always written */
.badge.own-naj, .badge.own-nui { font-size: 1rem; padding: 4px 13px; color: #fff; }
.badge.own-naj { background: var(--duo-l); }
.badge.own-nui { background: var(--duo-r); }
.owner-seg { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin-bottom: 4px; }
.owner-seg button, .owner-seg a { text-align: center; padding: 10px 4px; font-size: 1rem; }
.owner-seg .on.nui { color: #fff; background: var(--duo-r); }
.owner-seg .on.naj { color: #fff; background: var(--duo-l); }
.owner-seg.three { grid-template-columns: 1fr 1fr 1fr; }
.owner-seg .on.all { color: #fff; background: var(--accent, #2f2a26); }
.owner-stock + .owner-stock { margin-top: 14px; }
.pack-goal { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.unit { font-size: .55em; font-weight: 500; opacity: .8; } /* unit after a big number (user, 2026-10-26) */
/* sale form: packaging the bill takes that the shelf lacks (2026-10-27) — orange stripes on the left, warn only */
.sale-mat-warn { border-left: 10px solid transparent; border-image: repeating-linear-gradient(135deg, var(--duo-r) 0 6px, rgba(255,255,255,.4) 6px 9px) 10; }
.sale-mat-warn > div + div { margin-top: 4px; }
.sale-mat-warn b { color: var(--duo-r); }
/* a pack card selling boxes packed from loose charcoal */
.loose-tag { color: var(--duo-r); font-weight: 600; }

/* Date on the black top bar / sidebar and its calendar (user, 2026-10-28) */
.top-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
/* room between the quote and calculator icons for a big finger (user, 2026-10-30) */
.top-calc[data-quote], .top-calc[data-brochure] { margin-right: 12px; }
/* PC: today's date on its own row under the shop name, the two icons under it (user, 2026-11-03). */
.sidebar .top-tools { margin: 0 8px 10px; flex-wrap: wrap; justify-content: center; }
.top-date { white-space: nowrap; }
.sidebar .top-date { order: -1; width: 100%; justify-content: center; padding: 5px 10px; font-size: .85rem; }
.top-calc { display: grid; place-items: center; padding: 0 2px; cursor: pointer; line-height: 0; background: none; border: 0; }
.top-calc svg, .top-calc img { filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.top-date { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: .9rem; font-weight: 600; color: #fff; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.28); }
.top-date .ico { font-size: 1.05rem; line-height: 1; }

.modal-back.center { align-items: center; padding: 16px; }
.modal-back.center .modal { border-radius: 16px; max-width: 380px; padding: 18px 16px; }
.modal-back.center.mini .modal { max-width: 320px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.cal-head .btn { min-width: 44px; font-size: 1.3rem; line-height: 1; }
.cal-title { font-size: 1.15rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-grid .wd { font-size: .8rem; font-weight: 700; color: var(--muted); padding-bottom: 4px; }
.cal-grid .d { padding: 9px 0; border-radius: 10px; font-variant-numeric: tabular-nums; }
.cal-grid .d.today { color: #fff; font-weight: 700; background: linear-gradient(180deg, rgba(255,255,255,.3), rgba(255,255,255,0) 55%), linear-gradient(180deg, #4a4642, #1f1c1a);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 2px 6px rgba(0,0,0,.35); }
.cal-foot { margin-top: 14px; }
.cal-foot .btn { flex: 1; }
/* Calendar memos (user, 2026-10-28): a day with memos is a snooker ball (dark blue, white circle, black number);
   today stays the charcoal square, with the white circle when it has memos. */
.cal-grid .d { display: flex; align-items: center; justify-content: center; height: 42px; padding: 0; cursor: pointer;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.cal-grid .d.sel { box-shadow: inset 0 0 0 2px var(--text); }
.cal-grid .d.today.sel { box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 2px 6px rgba(0,0,0,.35), 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.cal-grid .ball { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, rgba(255,255,255,.55), rgba(255,255,255,0) 38%), radial-gradient(circle at 50% 55%, #2c55b8, #12285e 75%);
  box-shadow: 0 2px 5px rgba(0,0,0,.35); }
.cal-grid .chip { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #fff; color: #111;
  font-size: .85rem; font-weight: 700; box-shadow: inset 0 -1px 2px rgba(0,0,0,.2); }
.cal-memos { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.memo-row { display: flex; align-items: baseline; gap: 10px; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.memo-row .memo-time { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.memo-row .memo-text { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; }
#memo-form textarea { width: 100%; resize: vertical; }
/* Dashboard memo alerts: beside "ภาพรวม" on PC, under it on phones; one striped orange banner each, รับทราบ at the end. */
.memo-alerts { display: flex; flex-direction: column; gap: 8px; flex: 1 1 100%; order: 3; }
.memo-alerts:empty { display: none; }
@media (min-width: 900px) { .memo-alerts { flex: 1 1 320px; order: 0; max-width: 620px; } }
.memo-alert { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 24px; border-radius: 12px;
  border: 2px solid var(--duo-r); background: var(--surface); box-shadow: var(--shadow); }
.memo-alert::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 12px; border-radius: 10px 0 0 10px;
  background: repeating-linear-gradient(135deg, var(--duo-r) 0 7px, rgba(255,255,255,.35) 7px 10px), var(--duo-r); }
.memo-alert .memo-body { flex: 1; min-width: 0; }
.memo-alert .memo-text { font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.memo-alert.due { border-width: 3px; }
.memo-alert.due .small { color: var(--duo-r); }
.memo-alert .btn { flex: none; }
/* when its time comes: the soft orange glow, three times */
.flash-memo { animation: glow2 1.8s ease-in-out 3; }
/* Calculator (user, 2026-10-28): floats in the middle like the calendar; digits light, operators charcoal.
   One mocha theme (user, 2026-10-29, their palette): every colour has one job and stays the same in dark mode. */
.modal:has(> .calc) { --c-bg: #F7F0E5; --c-card: #FFFCF7; --c-head: #F2E8DC; --c-text: #352B26; --c-muted: #8B796A; --c-line: #D4BCA3;
  --c-div: #E6D7C5; --c-btn: #E8D9C7; --c-sel: #745944; --c-weight: #624B3A; --c-special: #5E7358; --c-share: #694E39;
  --c-danger: #B65343; --c-close: #352B26; --c-area: #EFE3D3;
  --c-gloss: linear-gradient(180deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,.05) 50%, rgba(0,0,0,.06) 100%);
  background: var(--c-bg); color: var(--c-text); }
.calc .btn { background: var(--c-gloss), var(--c-btn); color: var(--c-text); border: 1px solid var(--c-line);
  box-shadow: 0 2px 0 #cdb79d, 0 4px 8px rgba(80,55,35,.15); }
.calc .btn.primary, .calc .calc-kg .btn { background: var(--c-gloss), var(--c-weight); color: #fff; border-color: var(--c-weight);
  box-shadow: 0 3px 0 #4a382b, 0 5px 10px rgba(60,40,25,.3); }
.calc .btn-row [data-close] { background: var(--c-gloss), var(--c-close); border-color: var(--c-close); box-shadow: 0 3px 0 #1f1916, 0 5px 10px rgba(0,0,0,.3); }
.calc .btn:active { transform: translateY(2px); box-shadow: inset 0 2px 4px rgba(0,0,0,.25); }
.calc-screen { text-align: right; padding: 10px 14px; border-radius: 12px; background: var(--c-head); border: 1px solid var(--c-div);
  margin-bottom: 12px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calc-expr { min-height: 1.4em; color: var(--c-muted); font-size: 1rem; }
.calc-result { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.calc-keys .btn { height: 54px; padding: 0; font-size: 1.35rem; font-weight: 700; touch-action: manipulation; }
.calc-keys .btn.wide { grid-column: span 2; }
.calc-keys .btn svg { display: block; margin: auto; }
.calc-kg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.calc-kg .btn { padding: 10px 0; font-weight: 700; }
.calc-area { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.calc-area .btn { padding: 10px 4px; font-weight: 700; background: var(--c-gloss), var(--c-area); }
.calc .btn-row { margin-top: 10px; }
.calc-keys .btn.primary { font-size: 1.7rem; }
.qp-found { display: grid; gap: 4px; max-height: 40vh; overflow-y: auto; }
.qp-pick { display: block; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer; }
.calc-area .btn.on { color: #fff; border-color: var(--c-special); background: var(--c-gloss), var(--c-special); box-shadow: 0 3px 0 #48593f, 0 5px 10px rgba(50,70,45,.3); }
.calc-area .btn.on::before { content: '✓ '; }
/* Quote page (user, 2026-10-30, quotepage.js): heading ใบเสนอราคา / name / switch, date and number on the right; a
   paper as wide as the page (ลูกค้าทั่วไป), four recipient buttons over it (ตัวแทน). Paper-coloured in dark mode too. */
.qpage .qh { text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: baseline; overflow-wrap: normal; }
.qh-title { font-size: 1.45rem; font-weight: 800; line-height: 1.2; }
.qh-date { justify-self: end; font: inherit; font-weight: 700; font-size: .9rem; color: var(--c-text); background: var(--c-card); border: 1px solid var(--c-line);
  border-radius: 999px; padding: 3px 8px; box-shadow: 0 2px 0 #cdb79d; cursor: pointer; white-space: nowrap; }
.qh-name { justify-self: start; min-width: 0; max-width: 100%; text-align: left; font: inherit; font-size: .98rem; font-weight: 700; color: var(--c-text);
  background: none; border: 0; padding: 0; cursor: pointer; display: flex; gap: 6px; white-space: nowrap; }
.qh-name span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.qh-name small { color: var(--c-muted); font-weight: 600; font-size: .85rem; }
.qh-no { justify-self: end; align-self: start; padding-top: 3px; color: var(--c-muted); font-size: .78rem; font-weight: 600; white-space: nowrap; }
.qh-seg { grid-column: 1 / 3; display: grid; grid-template-columns: 1fr 1fr; margin-top: 8px; border-radius: 12px; padding: 3px; background: #e3d3bf;
  box-shadow: inset 0 2px 4px rgba(80,55,35,.25); }
.qh-seg button { font: inherit; font-weight: 700; font-size: .92rem; color: var(--c-muted); background: none; border: 0; border-radius: 9px; padding: 6px 4px; cursor: pointer; }
.qh-seg button.on { color: #fff; background: var(--c-gloss), var(--c-sel); box-shadow: 0 2px 0 #5a4433, 0 3px 6px rgba(60,40,25,.3); }
.qh-seg button.on::before { content: '✓ '; }
.q-sets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.q-sets[hidden] { display: none; }
.q-set { position: relative; height: 52px; min-width: 0; border-radius: 14px; display: grid; place-items: center; align-content: center; padding: 0 4px; cursor: pointer;
  font: inherit; font-weight: 700; font-size: .9rem; line-height: 1.15; color: var(--c-text); background: var(--c-gloss), var(--c-btn); border: 1px solid var(--c-line);
  box-shadow: 0 2px 0 #cdb79d, 0 4px 8px rgba(80,55,35,.15); }
.q-set span:first-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-set small { font-weight: 600; font-size: .72rem; opacity: .8; }
.q-set.on { color: #fff; border-color: var(--c-sel); background: var(--c-gloss), var(--c-sel); box-shadow: 0 3px 0 #5a4433, 0 5px 10px rgba(60,40,25,.3); }
.q-set.add { background: var(--c-card); border: 2px dashed var(--c-line); box-shadow: none; color: var(--c-sel); }
.q-set.add:disabled { opacity: .35; cursor: default; }
.q-del { position: absolute; top: -7px; right: -6px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 900;
  color: #fff; background: linear-gradient(180deg, rgba(255,255,255,.3), rgba(255,255,255,0) 60%), var(--c-danger); border: 2px solid var(--c-bg); box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.q-paper { min-height: 300px; display: flex; flex-direction: column; background: var(--c-card); color: var(--c-text); border: 1px solid var(--c-div); border-radius: 14px;
  box-shadow: 0 4px 12px rgba(80,55,35,.18); font-variant-numeric: tabular-nums; }
.q-bar { display: flex; justify-content: space-between; align-items: baseline; margin: 7px 7px 4px; border-radius: 8px; padding: 5px 3px 5px 10px; color: #fff; font-weight: 800;
  background: linear-gradient(180deg, rgba(255,255,255,.18) 0%, rgba(255,255,255,0) 55%), linear-gradient(180deg, #4a4540, #23201d); }
.q-bar small { font-weight: 600; opacity: .85; width: 76px; text-align: center; }
.q-body { padding: 0 10px; }
.q-group { padding-bottom: 4px; cursor: pointer; }
.q-group + .q-group { border-top: 2px solid var(--c-line); }
.q-head { display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left; margin: 6px 0 2px; border: 0; border-radius: 8px; padding: 3px 9px; font: inherit; font-weight: 700; font-size: .9rem;
  color: var(--c-text); background: var(--c-btn); cursor: pointer; }
.q-group.cur .q-head { color: #fff; background: var(--c-sel); }
.q-line { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--c-div); font-size: .92rem; }
.q-kg { width: 48px; font-weight: 700; }
.q-unit { flex: 1; color: var(--c-muted); }
.q-amt { margin-left: auto; width: 76px; flex: none; text-align: center; font-weight: 700; }
.q-fee span:first-child, .q-sub span:first-child { flex: 1; }
.q-sub { font-weight: 800; border-bottom: 0; }
.q-step { display: inline-flex; align-items: stretch; border-radius: 999px; overflow: hidden; background: var(--c-btn); border: 1px solid var(--c-line); box-shadow: 0 2px 0 #cdb79d; }
.q-step button { width: 34px; height: 30px; border: 0; background: none; font: inherit; font-weight: 800; font-size: 1.15rem; color: var(--c-sel); cursor: pointer; touch-action: manipulation; }
.q-step button:active { background: rgba(0,0,0,.08); }
.q-step b { min-width: 28px; display: grid; place-items: center; background: var(--c-card); }
.q-hint { font-size: .82rem; color: var(--c-muted); padding: 6px 0; }
.q-foot { margin-top: auto; padding: 6px 10px 8px; border-top: 1px solid var(--c-div); display: grid; gap: 6px; }
.q-disc { justify-self: start; display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 4px 12px; font: inherit; font-weight: 800; font-size: .82rem;
  color: var(--c-sel); cursor: pointer; background: linear-gradient(180deg, rgba(255,255,255,.7) 0%, rgba(255,255,255,0) 55%), var(--c-btn); border: 1px solid var(--c-line);
  box-shadow: 0 2px 0 #cdb79d, 0 3px 6px rgba(80,55,35,.2); }
.q-disc:active { transform: translateY(2px); box-shadow: none; }
/* with a discount: รวมทั้งหมด and ส่วนลด above ยอดรวมทั้งสิ้น, as on the picture */
.q-less { display: flex; justify-content: space-between; font-size: .95rem; }
.q-less.q-off { color: #c9580a; font-weight: 800; }
/* ยอดรวมทั้งสิ้น on a charcoal bar like the picture (user, 2026-10-30) */
.q-grand { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 7px 14px; border-radius: 999px; color: #fff; font-size: 1.1rem; font-weight: 800;
  line-height: 1.2; background: linear-gradient(180deg, rgba(255,255,255,.18) 0%, rgba(255,255,255,0) 55%), linear-gradient(180deg, #4a4540, #23201d); box-shadow: 0 3px 6px rgba(0,0,0,.25); }
.q-grand span:last-child { font-size: 1.3rem; }
.q-grand small { font-size: .85rem; font-weight: 700; }
.qpage .calc-kg { margin-top: 12px; }
.qpage .calc-kg .btn { transition: transform .08s, box-shadow .08s, filter .08s; touch-action: manipulation; }
.qpage .calc-kg .btn:active { transform: translateY(3px); box-shadow: 0 0 0 #4a382b, 0 1px 3px rgba(60,40,25,.3); filter: brightness(1.15); }
.q-act { margin-top: 8px; }
.q-act .btn { display: flex; align-items: center; justify-content: center; gap: 8px; }
.calc .q-act .q-clear { color: #fff; border-color: var(--c-danger); background: var(--c-gloss), var(--c-danger); box-shadow: 0 3px 0 #8f3f32, 0 5px 10px rgba(120,50,35,.3); }
/* the quote page's ✕ (on the backdrop, set beside the page's top-right corner) and its middle-of-the-screen warning */
.q-x { position: fixed; z-index: 2; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; font-size: 1.05rem; font-weight: 800;
  color: #fff; border: 2px solid #F7F0E5; background: linear-gradient(180deg, rgba(255,255,255,.2) 0%, rgba(255,255,255,0) 55%), linear-gradient(180deg, #4a4540, #23201d);
  box-shadow: 0 3px 8px rgba(0,0,0,.4); }
.q-alert { position: fixed; z-index: 3; left: 50%; top: 30%; transform: translateX(-50%); width: min(300px, calc(100vw - 48px)); display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 16px; background: #FFFCF7; color: #352B26; border: 2px solid #B65343; box-shadow: 0 10px 28px rgba(0,0,0,.35);
  animation: qalert .25s ease-out; transition: opacity .4s; }
.q-alert.out { opacity: 0; }
.q-alert i { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 900; font-size: 1.2rem; color: #fff; background: #B65343; }
.q-alert b { display: block; font-size: 1.05rem; }
.q-alert span { display: block; font-size: .92rem; }
@keyframes qalert { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.calc .q-act .q-share { color: #fff; border-color: var(--c-share); background: var(--c-gloss), var(--c-share); box-shadow: 0 3px 0 #523c2c, 0 5px 10px rgba(60,40,25,.3); }

/* Settings → พร้อมเพย์: the bank logo picker (user, 2026-10-29) */
.pp-logo { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pp-logo-img { width: 76px; height: 76px; border: 1px solid var(--line, #e7e0d6); border-radius: 12px; background: #fff;
  display: grid; place-items: center; flex: none; text-align: center; }
.pp-logo-img img { width: 64px; height: 64px; object-fit: contain; }
.pp-logo-img img[hidden], .pp-logo-img span[hidden] { display: none; }

/* Share dialog (user, 2026-10-30): บันทึกรูป left and ปิด right on one row, with room below the share button */
.share-row { margin: 6px 0 0; gap: 12px; }
.share-row .btn { flex: 1; }

/* Owner tags on bill lines (stage 2, 2026-11-01): the same blue / orange as the packing pills, smaller. */
.badge.own-naj.mini, .badge.own-nui.mini { font-size: .78rem; padding: 1px 8px; vertical-align: 1px; }
.pkg-two { flex-direction: column; align-items: stretch; gap: 8px; }
.pkg-two .two-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sale-owner .owner-seg { grid-template-columns: 1fr 1fr 1fr; }
.sale-owner .owner-seg .on.joint { color: #fff; background: var(--accent, #2f2a26); }
.by-row { display: flex; gap: 10px; flex-wrap: wrap; }
.by-row label { display: flex; align-items: center; gap: 6px; }
/* Delivery area: the three choices on one line, equal and centred, phone and PC (user, 2026-11-01). */
.radio-row.area-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.radio-row.area-row label { justify-content: center; padding: 8px 4px; gap: 4px; font-size: .9rem; white-space: nowrap; }

/* Bank accounts (stage 3) */
.bank-head { display: flex; gap: 12px; align-items: center; }
.bank-logo { width: 48px; height: 48px; border-radius: 12px; object-fit: contain; flex: none; }
.bank-amt { font-size: 1.6rem; font-weight: 700; margin-top: 10px; }
.bank-neg { font-size: .85rem; padding: 2px 10px; border-radius: 8px; color: #fff; vertical-align: middle;
  background: repeating-linear-gradient(45deg, #c2570c, #c2570c 6px, #8a3d08 6px, #8a3d08 12px); }
.bank-btns { flex-wrap: wrap; margin-top: 12px; }
.ico img { width: 1.2em; height: 1.2em; object-fit: contain; vertical-align: middle; }
html:root .btn.btn-kex { color: #fff; border-color: #8a3d08; background: linear-gradient(180deg, #e8782a, #c2570c 55%, #a64a0a);
  box-shadow: 0 3px 6px rgba(138, 61, 8, .45), inset 0 1px 0 rgba(255, 255, 255, .35); }
.bank-card { scroll-margin-top: 66px; }

/* The warning blind (user, 2026-11-03, public/js/warnings.js): a card that comes down from under the black bar. The bar and its
   tab are one piece: a 16 px tile anchored on the centre, so the stripes run on from the bar into the tab (the tab's width is a
   multiple of 16; its tile starts one tab-offset lower). */
.warn-dock { --bar: 14px; position: sticky; top: var(--top-h, 0px); z-index: 9; height: 0; }
.warn-scrim { position: fixed; inset: 0 0 0 var(--main-left, 0px); background: rgba(0,0,0,.28); opacity: 0; pointer-events: none; transition: opacity .28s; }
.warn-dock.open .warn-scrim { opacity: 1; pointer-events: auto; }
.warn-blind { position: absolute; top: 0; left: 8px; right: 8px; transform: translateY(calc(-100% + var(--bar))); transition: transform .3s ease; }
.warn-dock.open .warn-blind { transform: none; }
.warn-blind.drag { transition: none; }
.warn-sheet { background: var(--surface); color: var(--text); border: 2px solid var(--duo-r); border-top: 0; border-bottom: 0; }
.warn-rows { max-height: calc(100dvh - var(--top-h, 0px) - 160px); overflow: auto; padding: 12px 14px 8px; }
.warn-rows h2 { color: var(--duo-r); margin: 0 0 4px; }
.warn-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px dashed var(--line); }
.warn-row:first-of-type { border-top: 0; }
.warn-text { min-width: 0; }
.warn-text strong { display: block; line-height: 1.35; }
.warn-text small { color: var(--muted); }
.warn-new { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 99px; font-size: .7rem; font-weight: 700; color: #fff; background: var(--duo-r); vertical-align: 2px; }
.warn-row .btn { flex: none; width: 112px; padding-left: 4px; padding-right: 4px; white-space: nowrap; }
.warn-latin { font-size: .88em; }
.warn-pull { --s1: #d0620f; --s2: #f3a765; position: relative; height: var(--bar); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
.warn-bar, .warn-knob { background: repeating-linear-gradient(135deg, var(--s1) 0 7.92px, var(--s2) 7.92px 11.314px) center top / 16px 16px; transition: filter .15s; }
.warn-bar { height: var(--bar); border-radius: 0 0 12px 12px; }
.warn-knob { position: absolute; top: calc(var(--bar) - 1px); left: calc(50% - 80px); width: 160px; height: 38px; padding: 0 6px 2px; border: 0; border-radius: 0 0 14px 14px; cursor: pointer;
  background-position: center -13px; font: inherit; font-weight: 700; color: #fff; white-space: nowrap; touch-action: none; user-select: none; -webkit-user-select: none;
  text-shadow: 0 0 3px rgba(60,25,0,.95), 0 1px 2px rgba(60,25,0,.95), 0 0 6px rgba(60,25,0,.7); }
.warn-pull:active .warn-bar, .warn-pull:active .warn-knob { filter: brightness(.92); }
@keyframes warn-glow { 0%, 100% { filter: drop-shadow(0 0 2px rgba(230,120,30,.5)); } 50% { filter: drop-shadow(0 0 9px rgba(240,130,30,.95)); } }
.warn-dock.unread:not(.open) .warn-pull { animation: warn-glow 1.9s ease-in-out infinite; }
/* Open: smoke grey, the colour of this app's cancel buttons, means "close". */
.warn-dock.open .warn-pull { --s1: #7d756b; --s2: #b3aba0; }
.warn-dock.open .warn-knob { font-size: 1.3rem; text-shadow: 0 0 3px rgba(30,25,20,.95), 0 1px 2px rgba(30,25,20,.95), 0 0 6px rgba(30,25,20,.7); }
/* Room for the tab while there are warnings, so it never covers a page's heading. */
body.has-warn .view { padding-top: 54px; }
@media (min-width: 900px) { body.has-warn .view { padding-top: 56px; } }
@media print { .warn-dock { display: none !important; } body.has-warn .view { padding-top: 0; } }

/* A backup the user made: a charcoal label; the system's own stay plain text. */
.bk-mine { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: .85rem; font-weight: 700; color: #fff; background: linear-gradient(180deg, #4a443e, #1f1d1b); }
