/* TPC $ (Windows and web) — three panes (categories · products · prices), light and dark themes, keyboard first. Web additions: web.css. */
:root {
  --bg: #f4f6fb; --panel: #fff; --side: #f9fafd; --ink: #14172b; --muted: #5d6280; --line: #e3e6ef; --soft: #eef1f8; --hover: #f1f4fb;
  --accent: #0f8f6b; --accent-ink: #fff; --accent-soft: #e2f5ee; --accent-text: #0b6e52;
  --warn: #9a5b00; --warn-soft: #fff4dc; --warn-line: #f2c46b;
  --bad: #b42318; --bad-soft: #fde8e7; --bad-line: #f3a29b;
  --edit: #1d5fd6; --edit-soft: #e6efff; --sel: #dbe7ff;
  --shadow: 0 12px 40px rgba(20, 23, 43, .16);
  --r: 8px; font-size: 14px;
  color-scheme: light;
}
/* dark: chosen in TPC $, or following Windows when the choice is "system" */
:root[data-theme=dark] {
    --bg: #11131d; --panel: #1a1d2a; --side: #161925; --ink: #eceefa; --muted: #a3a8c3; --line: #2c3044; --soft: #232738; --hover: #20243a;
    --accent: #2fc493; --accent-ink: #062a1f; --accent-soft: #143a2e; --accent-text: #6fe0b9;
    --warn: #f5c060; --warn-soft: #3a2d10; --warn-line: #8a6a22;
    --bad: #ff8a80; --bad-soft: #3d1715; --bad-line: #8c3a33;
    --edit: #8db4ff; --edit-soft: #1c2a48; --sel: #23365c;
    --shadow: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #11131d; --panel: #1a1d2a; --side: #161925; --ink: #eceefa; --muted: #a3a8c3; --line: #2c3044; --soft: #232738; --hover: #20243a;
    --accent: #2fc493; --accent-ink: #062a1f; --accent-soft: #143a2e; --accent-text: #6fe0b9;
    --warn: #f5c060; --warn-soft: #3a2d10; --warn-line: #8a6a22;
    --bad: #ff8a80; --bad-soft: #3d1715; --bad-line: #8c3a33;
    --edit: #8db4ff; --edit-soft: #1c2a48; --sel: #23365c;
    --shadow: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif; line-height: 1.4; overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .err { color: var(--bad); } .ok { color: var(--accent-text); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { font-family: inherit; font-size: 11.5px; padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--panel); color: var(--muted); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--edit); outline-offset: 1px; }
::-webkit-scrollbar { width: 12px; height: 12px; } ::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; } ::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }

/* buttons and fields */
.btn { height: 32px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.ghost { border-color: transparent; background: none; } .btn.ghost:hover { background: var(--hover); }
.btn.link { border: 0; background: none; color: var(--accent-text); padding: 0 6px; height: auto; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn .n { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 6px; font-size: 11.5px; }
.icon { width: 32px; height: 32px; border: 0; background: none; border-radius: var(--r); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); }
.icon:hover { background: var(--hover); color: var(--ink); }
input[type=text], input[type=search], input[type=url], select, textarea { height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); min-width: 0; }
textarea { height: auto; padding: 8px 10px; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
label { cursor: pointer; }

/* sign in */
#signin { height: 100%; display: flex; align-items: center; justify-content: center; }
.si-box { width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.si-box h1 { margin: 0; font-size: 24px; }
.logo { width: 56px; height: 56px; border-radius: 15px; background: linear-gradient(135deg, #10b981, #0ea5a4 55%, #3b82f6); display: flex; align-items: center; justify-content: center; }
.logo svg { width: 42px; height: 42px; stroke: #fff; stroke-width: 7.5; }
.logo.sm { width: 26px; height: 26px; border-radius: 7px; } .logo.sm svg { width: 20px; height: 20px; stroke-width: 9; }

/* frame */
#app { display: flex; flex-direction: column; height: 100%; }
#top { height: 48px; flex: none; } #conn { flex: none; }
#top { display: flex; align-items: center; gap: 8px; padding: 0 10px 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
#top .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; width: 238px; }
#top .search { flex: 0 1 420px; position: relative; }
#top .search input { width: 100%; padding-left: 32px; }
#top .search svg { position: absolute; left: 9px; top: 7px; color: var(--muted); }
#top .grow { flex: 1; }
#conn { padding: 6px 14px; font-weight: 600; }
.banner { padding: 8px 14px; border-bottom: 1px solid var(--line); }
.banner.warn { background: var(--warn-soft); color: var(--warn); } .banner.bad { background: var(--bad-soft); color: var(--bad); } .banner.info { background: var(--edit-soft); color: var(--edit); }
#body { flex: 1; display: grid; grid-template-columns: 250px 340px minmax(0, 1fr); min-height: 0; }
#status { flex: none; height: 26px; display: flex; align-items: center; gap: 14px; padding: 0 12px; font-size: 12px; color: var(--muted); background: var(--side); border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
#status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; margin-right: 5px; }
#status .dot.off { background: var(--bad); }

/* sidebar */
#side { background: var(--side); border-right: 1px solid var(--line); overflow-y: auto; padding: 8px 0 16px; }
.sh { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 12px 14px 4px; display: flex; justify-content: space-between; align-items: center; }
.nav { display: flex; align-items: center; gap: 8px; width: calc(100% - 12px); margin: 1px 6px; min-height: 32px; padding: 5px 10px; border: 0; background: none; border-radius: var(--r); text-align: left; cursor: pointer; }
.nav:hover { background: var(--hover); }
.nav[aria-current=true] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav .c { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav .pbar { display: block; height: 3px; border-radius: 3px; background: var(--line); margin-top: 3px; overflow: hidden; }
.nav .pbar i { display: block; height: 100%; background: var(--accent); }
.nav .two { flex: 1; min-width: 0; } .nav .two b { font-weight: inherit; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* product list */
#list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
#listHead { padding: 10px 12px 6px; border-bottom: 1px solid var(--line); }
#listHead h2 { margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#listItems { overflow-y: auto; flex: 1; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; padding: 6px 0 2px; }
.chip { height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 12.5px; white-space: nowrap; cursor: pointer; }
.chip:hover { background: var(--hover); }
.chip[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.chip .n { margin-left: 4px; font-weight: 700; }
.chip .dot { color: var(--edit); font-weight: 800; }
.li { display: block; width: 100%; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.li:hover { background: var(--hover); }
.li[aria-selected=true] { background: var(--sel); box-shadow: inset 3px 0 0 var(--edit); }
.li .name { font-weight: 600; }
.li .meta { font-size: 12px; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.b { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.b.ok { background: var(--accent-soft); color: var(--accent-text); } .b.warn { background: var(--warn-soft); color: var(--warn); } .b.bad { background: var(--bad-soft); color: var(--bad); } .b.edit { background: var(--edit-soft); color: var(--edit); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* detail pane */
#detail { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
#dHead { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 56px; }
#dHead .ttl { flex: 1; min-width: 0; }
#dHead h2 { margin: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; outline: none; }
#dHead .sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dBody { flex: 1; overflow: auto; padding-bottom: 24px; }
#dBar { display: flex; gap: 8px; align-items: center; padding: 8px 14px; background: var(--panel); border-top: 1px solid var(--line); }
#dBar .grow { flex: 1; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 14px 0; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { height: 30px; border: 0; background: var(--panel); padding: 0 12px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent-text); }
.opts { padding: 6px 14px 0; display: flex; flex-direction: column; gap: 2px; }
.opt { display: flex; align-items: center; gap: 8px; }
.opt .l { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; width: 92px; flex: none; }
.opt .chips { padding: 3px 0; }

/* the price grid */
.grid { margin: 10px 14px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); overflow: hidden; }
table.pt { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.pt th { position: sticky; top: 0; z-index: 1; background: var(--soft); color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.pt th.l, .pt td.l { text-align: left; }
.pt td { padding: 4px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; height: 40px; }
.pt tr:last-child td { border-bottom: 0; }
.pt td.k { width: 34px; padding-right: 0; text-align: left; }
.pt td.q { font-weight: 700; text-align: left; white-space: normal; }
.pt td.q small { display: block; font-weight: 400; color: var(--muted); }
.pt td.p { width: 120px; }
.pt input.price { width: 104px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.pt input.price:focus { border-color: var(--edit); outline: 2px solid var(--edit); outline-offset: 0; }
.pt tr.edited input.price, .pt td.edited input.price { border-color: var(--edit); background: var(--edit-soft); }
.pt tr.invalid input.price, .pt td.invalid input.price { border-color: var(--bad); }
.pt tr.sel td, .pt td.sel { background: var(--sel); }
.pt tr.badrow td { background: var(--bad-soft); } .pt tr.warnrow td { background: var(--warn-soft); }
.pt tr.sel.badrow td, .pt tr.sel.warnrow td { background: var(--sel); }
.pt .was { color: var(--muted); text-decoration: line-through; font-size: 12.5px; }
.pt .w { color: var(--muted); }
.pt .m.low { color: var(--warn); font-weight: 700; } .pt .m.neg { color: var(--bad); font-weight: 700; }
.pt td.note { text-align: left; white-space: normal; font-size: 12.5px; min-width: 180px; }
.pt td.note .warn { color: var(--warn); } .pt td.note .bad { color: var(--bad); }
.pin { width: 28px; height: 28px; border: 0; background: none; border-radius: 6px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.pin:hover { background: var(--hover); }
.pin[aria-pressed=true] { color: var(--accent-text); background: var(--accent-soft); }
.pin[aria-pressed=true] svg { fill: currentColor; }
.pin svg { width: 15px; height: 15px; }
/* matrix: quantities down, one option across */
.pt.mx td.cell { text-align: right; padding: 4px 8px; }
.pt.mx th { text-transform: none; letter-spacing: 0; font-size: 12px; }
.pt.mx td.cell .sm { display: block; font-size: 11.5px; color: var(--muted); }
.pt.mx td.cell.bad input.price { border-color: var(--bad); background: var(--bad-soft); }
.pt.mx td.cell.warn input.price { border-color: var(--warn-line); }
.pt.mx td.cell.pinned input.price { box-shadow: inset 3px 0 0 var(--accent); }
.pt.mx td.cell.none { color: var(--muted); }
.legend { padding: 8px 14px 0; font-size: 12px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }

/* cards, forms */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin: 12px 14px 0; overflow: hidden; }
.card > h3 { margin: 0; padding: 12px 14px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.form { padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline input[type=text] { width: 110px; }
.unit { position: relative; display: inline-flex; align-items: center; align-self: flex-start; width: max-content; }
.unit input { padding-right: 26px; text-align: right; }
.unit::after { content: attr(data-u); position: absolute; right: 9px; color: var(--muted); pointer-events: none; }
.unit.pre::after { content: none; } .unit.pre::before { content: attr(data-u); position: absolute; left: 9px; color: var(--muted); pointer-events: none; } .unit.pre input { padding-left: 20px; padding-right: 10px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 14px; }
.methods { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; padding: 4px 14px 14px; }
.method { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; }
.method:hover { background: var(--hover); }
.method.on { border-color: var(--accent); background: var(--accent-soft); }
.method .mt { font-weight: 700; } .method .md { font-size: 12.5px; color: var(--muted); }
.mf { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.tier { display: grid; grid-template-columns: 150px 120px 32px; gap: 8px; align-items: center; }
.switch { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.stat { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 12px 14px; }
.stat div { background: var(--soft); border-radius: 8px; padding: 10px 12px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.grp > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.grp > summary::-webkit-details-marker { display: none; }
.grp > summary:hover { background: var(--hover); }
.grp .name { font-weight: 700; } .grp .meta { font-size: 12.5px; color: var(--muted); }
.prow { display: grid; grid-template-columns: 26px minmax(0, 1fr) 210px 90px; align-items: center; gap: 8px; padding: 5px 14px 5px 38px; border-top: 1px solid var(--soft); }
.prow .chg { text-align: right; font-variant-numeric: tabular-nums; } .prow .chg s { color: var(--muted); margin-right: 6px; }
.prow .mg { text-align: right; font-size: 12.5px; color: var(--muted); }
.prow.off { opacity: .45; }
.rows { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; }
.card > h3 + .item { border-top: 0; }
.item .grow { flex: 1; min-width: 0; } .item .name { font-weight: 600; } .item .meta { font-size: 12.5px; color: var(--muted); }
.big { font-size: 28px; font-weight: 800; }
.pbar-l { height: 8px; border-radius: 8px; background: var(--soft); overflow: hidden; margin-top: 8px; }
.pbar-l > i { display: block; height: 100%; background: var(--accent); }
.dash { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0; }

/* dialogs, snack, busy */
.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(8, 10, 20, .42); display: flex; align-items: center; justify-content: center; }
.sheet-box { width: 480px; max-width: calc(100% - 40px); max-height: calc(100% - 60px); overflow-y: auto; background: var(--panel); border-radius: 14px; padding: 20px 22px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.sheet-box.wide { width: 640px; }
.sheet-box h2 { margin: 0 0 10px; font-size: 17px; }
.sheet-box ul { padding-left: 18px; margin: 6px 0; max-height: 260px; overflow-y: auto; }
.sheet-btns { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; }
.snack { position: fixed; left: 50%; transform: translateX(-50%); bottom: 40px; z-index: 25; background: #1e2235; color: #fff; border-radius: 10px; padding: 8px 8px 8px 16px; display: flex; align-items: center; gap: 10px; min-height: 42px; box-shadow: var(--shadow); max-width: 640px; }
.snack .btn.link { color: #6fe0b9; font-weight: 700; }
.busy { position: fixed; inset: 0; z-index: 40; background: rgba(8, 10, 20, .3); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #fff; font-weight: 600; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: sp .9s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.menu { position: fixed; z-index: 35; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); min-width: 220px; padding: 4px; }
.menu button { display: flex; width: 100%; justify-content: space-between; gap: 18px; padding: 7px 10px; border: 0; background: none; text-align: left; border-radius: 6px; cursor: pointer; }
.menu button:hover, .menu button:focus { background: var(--hover); outline: none; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.compact .pt td { height: 32px; padding-top: 2px; padding-bottom: 2px; } .compact .pt input.price { height: 26px; }
@media (max-width: 1180px) { #body { grid-template-columns: 220px 290px minmax(0, 1fr); } #top .brand { width: 208px; } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } .btn:active { transform: none; } }
.keys kbd { justify-self: start; }
