/* SPDX-License-Identifier: Apache-2.0 */
/* MonzFurn — light and dark from the system */
:root {
  --bg: #f4f2ef; --panel: #ffffff; --ink: #24201c; --ink-2: #6b635b; --line: #ddd7cf; --accent: #9a5b1e; --accent-ink: #fff; --sel: #1e5bd8;
  --warn: #9a5800; --warn-bg: #fff3df;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16181c; --panel: #1f2227; --ink: #ece8e2; --ink-2: #a39a90; --line: #33373e; --accent: #e0a060; --accent-ink: #1a1208; --sel: #6b9bff; --warn: #ffbe5c; --warn-bg: #3a2a10; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: grid; grid-template-rows: auto 1fr auto; background: var(--bg); color: var(--ink); font: 14px/1.45 "Sarabun", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--ink-2); }
.pad { padding: 6px 10px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { letter-spacing: .02em; }
#title { margin-right: 8px; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-group { display: flex; gap: 2px; padding-right: 6px; border-right: 1px solid var(--line); }
.tb-group:last-child { border-right: 0; }
.tb { border: 1px solid transparent; background: none; border-radius: 6px; padding: 4px 8px; cursor: pointer; white-space: nowrap; }
.tb:hover { background: var(--bg); border-color: var(--line); }
.tb.on { background: var(--accent); color: var(--accent-ink); }
.tb:focus-visible, .btn:focus-visible, .tab:focus-visible { outline: 2px solid var(--sel); outline-offset: 2px; }

.work { display: grid; grid-template-columns: 220px minmax(0, 1fr) 330px; min-height: 0; }
.side { background: var(--panel); overflow: auto; padding: 8px 12px 16px; min-height: 0; }
.side.left { border-right: 1px solid var(--line); }
.side.right { border-left: 1px solid var(--line); }
.side h2 { font-size: 15px; margin: 4px 0 8px; }
.side h3 { font-size: 13px; margin: 14px 0 6px; color: var(--ink-2); font-weight: 600; }
.center { display: grid; grid-template-rows: minmax(0, 1fr) 230px; min-height: 0; min-width: 0; }
#cv { width: 100%; height: 100%; display: block; touch-action: none; }

ul.cabs { list-style: none; margin: 0; padding: 0; }
ul.cabs li { padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; flex-wrap: wrap; gap: 0 6px; align-items: baseline; }
ul.cabs li:hover { background: var(--bg); }
ul.cabs li.on { background: color-mix(in srgb, var(--sel) 14%, transparent); }
ul.cabs small { width: 100%; color: var(--ink-2); }
.dot { color: var(--warn); font-weight: 700; }

.fld { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.fld > span { font-size: 12px; color: var(--ink-2); }
.fld small { font-size: 11px; color: var(--ink-2); }
.fld.wide input { width: 100%; }
input[type=number], input[type=text], select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); min-width: 0; width: 100%; }
input.n { width: 90px; }
.row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chk { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 8px; align-items: end; }
.warn { background: var(--warn-bg); color: var(--warn); padding: 6px 8px; border-radius: 6px; margin-bottom: 8px; font-size: 13px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 12px; }
table.mini td { padding: 2px 4px; border-top: 1px solid var(--line); }
table.open input.n4 { width: 62px; padding: 2px 4px; }
table.open select { width: 92px; padding: 2px 4px; }
table.open th { font-weight: 500; color: var(--ink-2); text-align: left; padding: 2px; }
table.open td { padding: 2px; }
.mini { border: 1px solid var(--line); background: var(--bg); border-radius: 4px; padding: 0 6px; cursor: pointer; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }

.bottom { background: var(--panel); border-top: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tab { padding: 6px 12px; border: 0; background: none; cursor: pointer; border-bottom: 2px solid transparent; }
.tab.on { border-bottom-color: var(--accent); font-weight: 600; }
.bottom-body { overflow: auto; flex: 1; padding: 0 10px 10px; }
table.list { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.list th { text-align: left; font-weight: 500; color: var(--ink-2); padding: 4px 6px; position: sticky; top: 0; background: var(--panel); border-bottom: 1px solid var(--line); }
table.list td { padding: 3px 6px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.list td, table.list th { white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink-2); }

.foot { padding: 4px 10px; background: var(--panel); border-top: 1px solid var(--line); min-width: 0; }
#msg { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn { border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 5px 12px; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.dlg { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); max-width: min(720px, 94vw); max-height: 90vh; padding: 16px 18px; }
.dlg::backdrop { background: #0006; }
.dlg h2 { margin: 0 0 8px; font-size: 17px; }
.dlg h3 { font-size: 13px; margin: 12px 0 4px; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.libform input[type=text] { width: 160px; }
.libform .grid2 input[type=text] { width: 100%; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 8px; }
.grid2 .wide { grid-column: 1 / -1; }
textarea { font: inherit; color: inherit; width: 100%; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
/* products */
.picker { display: flex; gap: 6px; align-items: center; }
.swatch-img { width: 34px; height: 34px; border-radius: 4px; flex: none; object-fit: cover; border: 1px solid var(--line); }
.swatch-img.none { display: inline-block; background: repeating-linear-gradient(45deg, var(--bg) 0 4px, var(--line) 4px 6px); }
.warn-t { color: var(--warn); font-size: 12px; }
.dlg:has(.catalog) { width: min(1000px, 96vw); }
.catalog .tabs { flex-wrap: wrap; margin-bottom: 6px; }
.catalog input[type=search] { flex: 1; min-width: 180px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.clist { max-height: 56vh; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.crow { display: flex; gap: 8px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; }
.crow.generic { border-style: dashed; }
.cimg { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.cimg img { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; border: 1px solid var(--line); }
.cmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.chead { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chead .brand { width: 110px; } .chead .code { width: 120px; } .chead .name { flex: 1; min-width: 160px; }
.chead .price { white-space: nowrap; font-size: 12px; color: var(--ink-2); }
.chead input.n { width: 80px; }
.cfields { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.cf { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-2); }
.cf input.n { width: 64px; padding: 2px 4px; } .cf select { width: auto; padding: 2px 4px; } .cf input.short { width: 90px; }
.cf input[type=color] { width: 32px; height: 22px; padding: 0; border: 1px solid var(--line); }
.cf .pair { display: inline-flex; gap: 2px; align-items: center; }
.cf.todo span:first-child, input.todo { color: var(--warn); }
.cf.todo input, .cf.todo select, input.todo { border-color: var(--warn); }
.cmeta { font-size: 11.5px; color: var(--ink-2); }
.todo-list { color: var(--warn); }
.nests h4 { margin: 8px 0 4px; font-size: 13px; }
.sheets { display: flex; flex-wrap: wrap; gap: 10px; }
.sheets figure { margin: 0; width: 220px; }
.sheets figcaption { font-size: 12px; color: var(--ink-2); }
svg.sheet { width: 100%; height: auto; display: block; }
svg.sheet .board { fill: color-mix(in srgb, var(--ink-2) 18%, transparent); stroke: var(--ink-2); stroke-width: 6; }
svg.sheet .pc { fill: var(--panel); stroke: var(--accent); stroke-width: 5; }
svg.sheet .pt { fill: var(--ink); font-size: 70px; text-anchor: middle; dominant-baseline: central; }

@media (max-width: 980px) {
  body { overflow: auto; }
  .work { grid-template-columns: 1fr; grid-template-rows: auto 70vh auto; }
  .side.left, .side.right { border: 0; border-bottom: 1px solid var(--line); }
  .center { grid-template-rows: 1fr 240px; }
}
