/* Palette and type from mockup/mockup-option-c-filtered-sidebar.html */
:root {
  --bg: #F4F2EC;
  --surface: #FFFFFF;
  --surface-2: #FAF9F5;
  --row-hl: #FBFAF6;
  --band: #EAE6DA;             /* every other product in the results (checkered by product) */
  --border: #E4E0D6;
  --border-soft: #EFECE3;
  --input-border: #D8D3C6;
  --text: #1C1B19;
  --text-2: #4A4636;
  --muted: #8A857A;
  --muted-2: #6B6656;
  --disabled: #B0AC9E;
  --accent: #2A5DB0;
  --accent-hover: #1E4685;
  --chip-bg: #EAF0FA;
  --chip-border: #C7D7EF;
  --chip-text: #1C3A6B;
  --ok: #205C41;
  --ok-dot: #2E7D5B;
  --ok-bg: #E6F2EC;
  --warn: #8A4B10;
  --warn-bg: #FBF0E2;
  --bad: #963A2F;
  --bad-bg: #F8E7E4;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --grid: 34px minmax(120px, 170px) minmax(200px, 1fr) 118px 150px 150px 64px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: 'IBM Plex Sans', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 13px; }
a { color: var(--accent); } a:hover { color: var(--accent-hover); }
button, input, select { font: inherit; color: inherit; }
input::placeholder { color: var(--muted); }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); }
.grow { flex-grow: 1; }
.hint { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.45; }

.app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* Top bar */
.topbar { flex-shrink: 0; display: flex; align-items: center; gap: 24px; padding: 16px 32px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.search { flex-grow: 1; max-width: 640px; display: flex; gap: 12px; }
.search input { flex-grow: 1; padding: 11px 16px; border: 1px solid var(--input-border); border-radius: 8px; font-size: 14px; background: var(--surface-2); }
.search input:focus { outline: 2px solid var(--chip-border); border-color: var(--accent); }
.btn-primary { display: inline-flex; align-items: center; padding: 10px 18px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { display: inline-flex; align-items: center; justify-content: center; padding: 9px 14px; background: var(--bg); border: 1px solid var(--input-border); border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text); text-decoration: none; }
.btn-secondary:hover { background: #ECE9E0; color: var(--text); }
.btn-secondary.small { padding: 5px 10px; font-size: 12px; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 12px; }
.btn-link.danger { color: var(--bad); }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 15px; font-weight: 700; cursor: pointer; padding: 2px 6px; }
.icon-btn:hover { color: var(--text); }
.basket-pill { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--bg); border: none; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.basket-pill:hover { background: #ECE9E0; }
.basket-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--disabled); }
.basket-pill.has-items .dot { background: var(--ok-dot); }
.user-box { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 12px; white-space: nowrap; }
.user-name { color: var(--muted-2); font-weight: 600; }
.user-links { display: flex; gap: 12px; }
.user-links a.btn-link { text-decoration: none; }
.dialog { width: min(380px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); }
.dialog::backdrop { background: rgba(28, 27, 25, 0.35); }
.dialog h2 { margin: 0 0 6px; font-size: 16px; }
.dialog p { margin: 0 0 4px; font-size: 12px; line-height: 1.5; color: var(--muted-2); }
.dialog label { display: block; margin: 14px 0 6px; font-size: 12px; font-weight: 600; color: var(--muted-2); }
.dialog input { width: 100%; padding: 9px 12px; border: 1px solid var(--input-border); border-radius: 8px; font-size: 14px; background: var(--surface-2); }
.dialog input:focus { outline: 2px solid var(--chip-border); border-color: var(--accent); }
.dialog .err { margin-top: 14px; padding: 8px 10px; border-radius: 6px; background: var(--bad-bg); color: var(--bad); font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.demo-badge { padding: 4px 10px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }

.body { flex-grow: 1; display: flex; overflow: hidden; }

/* Sidebar */
.sidebar { width: 336px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }
.sidebar .block { border-top: 1px solid var(--border-soft); padding-top: 16px; display: flex; flex-direction: column; gap: 18px; }
.sidebar > [hidden] + .block { border-top: none; padding-top: 0; }  /* no divider above the first visible section */
.sidebar .block.tight { gap: 0; }
.label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 10px; }
.check { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; padding: 4px 0; cursor: pointer; }
.check > span:first-child { display: flex; align-items: center; gap: 8px; }
.check input { margin: 0; }
.check .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.check.disabled { color: var(--disabled); cursor: default; }
.check.zero { color: var(--disabled); }
#facets { display: flex; flex-direction: column; gap: 18px; }
.brand-list { margin-top: 6px; max-height: 320px; overflow-y: auto; }
.more-btn { margin-top: 4px; }
.price-range { display: flex; align-items: center; gap: 8px; }
.price-range input, .sidebar select { width: 100%; padding: 8px 10px; border: 1px solid var(--input-border); border-radius: 6px; font-size: 13px; background: var(--surface); }
.price-range span { color: var(--muted); }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.crumbs button { background: none; border: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 12px; }
.cat-selected { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; background: var(--chip-bg); border: 1px solid var(--chip-border); border-radius: 8px; }
.cat-selected .name { font-size: 13px; font-weight: 600; color: var(--chip-text); }
.cat-selected .dist { font-size: 11px; color: #4A6FA5; }
.cat-selected button { background: none; border: none; color: #4A6FA5; font-size: 14px; font-weight: 700; cursor: pointer; padding: 0 2px; }
.cat-filter { width: 100%; padding: 8px 10px; border: 1px solid var(--input-border); border-radius: 6px; font-size: 13px; background: var(--surface-2); }
.cat-list { margin-top: 8px; max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; }
.cat-list button { display: flex; justify-content: space-between; gap: 8px; text-align: left; background: none; border: none; border-radius: 6px; padding: 6px 8px; cursor: pointer; font-size: 12px; }
.cat-list button:hover { background: var(--bg); }
.cat-list .path { color: var(--muted); font-size: 11px; }
.cat-list .dist-tag { font-size: 10px; font-weight: 700; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.cat-group { font-size: 11px; font-weight: 700; color: var(--chip-text); background: var(--chip-bg); border-radius: 6px; text-transform: uppercase; letter-spacing: 0.05em; padding: 5px 8px; margin-top: 8px; position: sticky; top: 0; z-index: 1; }
.cat-group:first-child { margin-top: 0; }

.freshness { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border-soft); font-size: 11px; color: var(--muted); line-height: 1.5; }
.freshness .bad { color: var(--bad); }
.freshness ul { margin: 4px 0; padding-left: 14px; }

/* Results */
.results { flex-grow: 1; min-width: 0; overflow: hidden; padding: 20px 28px; display: flex; flex-direction: column; }
.tabs { flex-shrink: 0; display: flex; align-items: flex-end; gap: 4px; margin: -6px 0 12px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 7px; max-width: 260px; margin-bottom: -1px; padding: 6px 8px 6px 12px; border: 1px solid var(--border); border-radius: 8px 8px 0 0; background: var(--surface-2); color: var(--muted-2); font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); border-bottom-color: var(--surface); color: var(--text); font-weight: 600; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tab-label { overflow: hidden; text-overflow: ellipsis; }
.tab-count { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--muted); }
.tab-close { border: none; background: none; padding: 0 3px; border-radius: 4px; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; }
.tab-close:hover { background: var(--border-soft); color: var(--text); }
.tab-new { margin: 0 0 3px 2px; padding: 3px 10px; border: 1px dashed var(--input-border); border-radius: 6px; background: none; color: var(--muted-2); font-size: 15px; line-height: 1.2; cursor: pointer; }
.tab-new:hover { border-style: solid; color: var(--text); }
.results-head { flex-shrink: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; min-height: 26px; }
.summary { font-size: 13px; color: var(--muted-2); }
.summary .hidden-note { color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; background: var(--chip-bg); border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--chip-text); }
.chip button { background: none; border: none; padding: 0; color: #4A6FA5; cursor: pointer; font-weight: 700; font-size: 11px; }

.status-strip { flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.status-strip:empty { display: none; }
.st { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 6px; font-size: 12px; background: var(--surface); border: 1px solid var(--border); max-width: 100%; }
.st b { font-weight: 600; }
.st .msg { color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 520px; }
.st.ok { border-color: #CFE3D8; }
.st.ok::before, .st.partial::before, .st.error::before, .st.off::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.st.ok::before { background: var(--ok-dot); }
.st.partial { background: var(--warn-bg); border-color: #EBD3B3; }
.st.partial::before { background: #C77A2A; }
.st.error { background: var(--bad-bg); border-color: #E8C5BF; }
.st.error::before { background: var(--bad); }
.st.error .msg { color: var(--bad); white-space: normal; }
.st.off { color: var(--muted); }
.st.off::before { background: var(--disabled); }

.table { flex-grow: 1; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.row { display: grid; grid-template-columns: var(--grid); align-items: center; gap: 0 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.row.head { padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.row.head button { background: none; border: none; padding: 0; text-align: left; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.row.head button.sorted { color: var(--text); }
.row.head button.sorted::after { content: " ↑"; }
.row.head button.sorted.desc::after { content: " ↓"; }
.row.item { cursor: pointer; }
.row.item.band { background: var(--band); }
.row.cur-divider { display: block; padding: 14px 16px 6px; border-bottom: 2px solid var(--text-2); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); cursor: default; }
.row.cur-divider .n { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }
.row.item:hover { background: var(--row-hl); }
.row.item.best { background: var(--row-hl); }
/* out of stock: hatched and pale, with the stock shown as a red pill at full strength, so it stands
   apart from the checkered shades */
.row.item.dim { background-image: repeating-linear-gradient(135deg, transparent 0 7px, rgba(150, 58, 47, 0.07) 7px 14px); }
.row.item.dim > * { opacity: 0.5; }
.row.item.dim > .stock { opacity: 1; justify-self: start; margin-left: -9px; padding: 2px 9px; border-radius: 999px; background: var(--bad-bg); color: var(--bad); }
.row.item.failed { background: #FDF8F6; }
.row .code { font-family: var(--mono); font-weight: 600; overflow-wrap: anywhere; }
.row .code .sub { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.row .code .same { display: block; margin-top: 2px; font-family: 'IBM Plex Sans', system-ui, sans-serif; font-weight: 600; font-size: 11px; }
/* the lowest-price mark goes on its own line under the price, so the cell doesn't grow into the stock column */
.price .lowest { font-family: 'IBM Plex Sans', sans-serif; font-size: 10px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
/* twins kept together: one block per product, dashed lines inside it */
.row.in-group:not(.group-last) { border-bottom-style: dashed; }
/* between products: a firmer line than inside a block */
.row.item:not(.in-group), .row.item.group-last { border-bottom-color: #D6D0C1; }
.view-opts { display: inline-flex; align-items: center; gap: 6px; margin-left: 12px; font-size: 12px; color: var(--muted); cursor: pointer; }
.row.lowest-row { box-shadow: inset 3px 0 0 var(--accent); }
.summary .compare-bar { margin-bottom: 6px; padding: 6px 10px; border: 1px solid var(--chip-border); border-radius: 6px; background: var(--chip-bg); font-size: 13px; }
.row .desc { min-width: 0; }
.row .desc .vendor { font-size: 11px; color: var(--muted); }
.row .num { text-align: right; justify-self: end; }
.stock { font-weight: 600; font-size: 12px; }
.stock .lead { font-weight: 400; color: var(--muted-2); }
.s-in_stock { color: var(--ok); }
.s-low_stock { color: var(--warn); }
.s-out_of_stock { color: var(--bad); }
.s-on_demand { color: var(--text-2); }
.s-unknown { color: var(--muted-2); }
.s-failed { color: var(--bad); }
/* the price line (stale badge, amount, currency) never wraps; the lowest-price mark goes under it */
.price { font-family: var(--mono); display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 2px; white-space: nowrap; }
.price .price-line { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.price .amount { font-weight: 600; }
.cur { font-family: 'IBM Plex Sans', sans-serif; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: var(--bg); color: var(--muted-2); letter-spacing: 0.03em; }
.cur.foreign { background: var(--warn-bg); color: var(--warn); }
.stale { font-family: 'IBM Plex Sans', sans-serif; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: var(--warn-bg); color: var(--warn); }
.add-btn { padding: 6px 10px; background: var(--surface); border: 1px solid var(--input-border); border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; }
.add-btn:hover:not(:disabled) { background: var(--bg); }
.add-btn:disabled { background: var(--bg); border-color: var(--border); color: var(--disabled); cursor: not-allowed; }
.add-btn.added { color: var(--ok); border-color: #CFE3D8; }

.detail { padding: 10px 16px 14px 62px; border-bottom: 1px solid var(--border-soft); background: var(--surface-2); font-size: 12px; }
.detail dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
.detail table { border-collapse: collapse; margin-top: 2px; }
.detail td, .detail th { padding: 2px 12px 2px 0; text-align: left; font-weight: 400; }
.detail th { color: var(--muted); }

.empty { padding: 48px 24px; text-align: center; color: var(--muted-2); line-height: 1.6; }
.empty code { font-family: var(--mono); background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.loading { padding: 48px 24px; text-align: center; color: var(--muted); }

/* Basket drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: -12px 0 32px rgba(28, 27, 25, 0.10); display: flex; flex-direction: column; z-index: 10; }
.drawer-head { position: relative; padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
.drawer-title { font-size: 16px; font-weight: 700; }
.drawer-head .icon-btn { position: absolute; top: 14px; right: 14px; }
.basket-errors { margin: 12px 20px 0; padding: 8px 10px; background: var(--bad-bg); color: var(--bad); border-radius: 6px; font-size: 12px; }
.basket-lines { flex-grow: 1; overflow-y: auto; padding: 4px 20px; }
.bl { display: grid; grid-template-columns: 1fr 70px 120px 24px; gap: 4px 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.bl .what { min-width: 0; }
.bl .what .code { font-family: var(--mono); font-weight: 600; font-size: 12px; }
.bl .what .name { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bl .what .meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bl input { width: 100%; padding: 6px 8px; border: 1px solid var(--input-border); border-radius: 6px; font-family: var(--mono); text-align: right; }
.bl .money { text-align: right; font-family: var(--mono); font-size: 12px; }
.bl .money .unit { color: var(--muted); font-size: 11px; }
.bl .warn { grid-column: 1 / -1; font-size: 11px; color: var(--warn); }
.bl .alt { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 5px 8px; border-radius: 6px; background: var(--chip-bg); font-size: 11px; color: var(--text-2); }
.bl .alt .alt-actions { display: flex; gap: 12px; }
.drawer-foot { border-top: 1px solid var(--border); padding: 14px 20px 18px; }
.totals { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 14px; }
.totals .t { display: flex; justify-content: space-between; font-family: var(--mono); font-weight: 700; }
.totals .t span:first-child { font-family: 'IBM Plex Sans', sans-serif; font-weight: 600; color: var(--muted-2); font-size: 13px; }
.drawer-actions { display: flex; gap: 8px; align-items: center; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 20; max-width: 80vw; }
.toast.error { background: var(--bad); }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .search { order: 3; max-width: none; width: 100%; }
  .body { flex-direction: column; overflow-y: auto; }
  .app { height: auto; min-height: 100vh; overflow: visible; }
  .sidebar { width: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .results { padding: 16px; overflow: visible; }
  .table { overflow-x: auto; }
  .row { min-width: 820px; }
}
.cat-list .count { color: var(--muted); font-size: 11px; }

#freshness .searching { font-weight: 600; color: var(--text); margin-bottom: 6px; }
#freshness li { margin-bottom: 4px; }
#freshness li b { color: var(--text-2); font-weight: 600; }
#freshness li .sub { color: var(--muted); }
#freshness li.off { color: var(--disabled); }
.cat-group.shared { background: var(--accent); color: #fff; }
.cat-section { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 6px 8px 2px; }
.summary .notice { margin-bottom: 6px; padding: 7px 10px; border-radius: 6px; background: var(--warn-bg); color: var(--warn); font-size: 12px; line-height: 1.45; }
#basket-errors .note { color: var(--warn); }
.basket-errors.only-notes { background: var(--warn-bg); color: var(--warn); }
.cat-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.cat-tabs button { font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted-2); cursor: pointer; }
.cat-tabs button.on { background: var(--chip-bg); border-color: var(--chip-border); color: var(--chip-text); font-weight: 600; }
.summary .suggest { margin-top: 6px; font-size: 12px; color: var(--muted-2); }
.summary .suggest .chip-btn { font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--chip-border); background: var(--chip-bg); color: var(--chip-text); font-weight: 600; cursor: pointer; }
.summary .suggest .muted { color: var(--muted); }
.reset-block { display: flex; flex-direction: column; gap: 6px; }
.reset-block .hint { margin-top: 0; }
