:root {
  --ink: #1a222c;
  --muted: #667283;
  --line: #dfe4ea;
  --line-soft: #eef1f5;
  --bg: #f0f2f5;
  --panel: #ffffff;

  --sidebar: #1e2732;
  --sidebar-2: #263140;
  --sidebar-ink: #c3ccd8;
  --sidebar-ink-dim: #8a95a4;

  --accent: #2f6db0;
  --accent-dark: #255c96;
  --low: #fbeecd;
  --low-ink: #8a5a12;

  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

/* Embedded (inside a workspace window): show only the document, no chrome. */
html.embedded .sidebar,
html.embedded .topbar { display: none; }
html.embedded .app { grid-template-columns: 1fr; min-height: 0; height: auto; overflow: visible; }
html.embedded .main { height: auto; overflow: visible; }
html.embedded .content { padding: 16px 18px; overflow: visible; }
html.embedded, html.embedded body { height: auto; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}

/* ---------- App frame ---------- */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  /* Fixed app shell: the frame fills the viewport and never scrolls itself, so
     the sidebar and top bar stay put while only the content area scrolls. */
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar (module list) ---------- */
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;   /* a long module list scrolls on its own, not the page */
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.sidebar-brand .mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border-radius: 6px;
  letter-spacing: .02em;
}
.sidebar-brand .co { font-weight: 600; color: #fff; font-size: 14.5px; }

.modnav { padding: 8px 0; }
.modnav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 18px;
  color: var(--sidebar-ink);
  text-decoration: none;
  border-left: 3px solid transparent;
  font-size: 13.5px;
}
.modnav-item:hover { background: var(--sidebar-2); color: #fff; }
.modnav-item.is-active {
  background: var(--sidebar-2);
  color: #fff;
  border-left-color: var(--accent);
}
.modnav-item .code {
  min-width: 26px;
  font-size: 11px;
  font-weight: 700;
  color: var(--sidebar-ink-dim);
  letter-spacing: .04em;
}
.modnav-item.is-active .code, .modnav-item:hover .code { color: #fff; }

/* ---------- Main column ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  height: 48px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
}
.crumb { font-size: 13.5px; color: var(--muted); }
.crumb a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.crumb-current { color: var(--ink); font-weight: 600; }
.crumb-sep { margin: 0 7px; color: var(--line); }
.topbar-right { display: flex; align-items: center; gap: 18px; font-size: 13px; color: var(--muted); }
.topbar-right .user { color: var(--ink); font-weight: 600; }

/* ---- Global search (top bar) ---- */
.gsearch { position: relative; flex: 0 1 380px; margin: 0 18px; display: flex; align-items: center; }
.gsearch-icon { position: absolute; left: 10px; font-size: 12px; opacity: .55; pointer-events: none; }
.gsearch input { width: 100%; height: 32px; padding: 0 10px 0 30px; border: 1px solid var(--line);
  border-radius: 16px; background: var(--bg); font-size: 13px; color: var(--ink); outline: none; }
.gsearch input:focus { background: var(--panel); border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 109, 176, .12); }
.gsearch-results { position: absolute; top: 38px; left: 0; right: 0; z-index: 60; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(20, 30, 45, .16);
  max-height: 72vh; overflow-y: auto; padding: 5px; }
.gsearch-grouphead { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 8px 10px 4px; }
.gsearch-hit { display: flex; flex-direction: column; gap: 1px; padding: 6px 10px; border-radius: 7px;
  text-decoration: none; color: var(--ink); }
.gsearch-hit:hover, .gsearch-hit.is-active { background: var(--accent); color: #fff; }
.gsearch-hit-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gsearch-hit-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gsearch-hit:hover .gsearch-hit-sub, .gsearch-hit.is-active .gsearch-hit-sub { color: rgba(255, 255, 255, .85); }
.gsearch-all { display: block; text-align: center; padding: 8px; margin-top: 4px;
  border-top: 1px solid var(--line-soft); font-size: 12px; font-weight: 600; color: var(--accent-dark);
  text-decoration: none; border-radius: 7px; }
.gsearch-all:hover, .gsearch-all.is-active { background: var(--low); }
.gsearch-none { padding: 14px 12px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---- Full search results page ---- */
.search-page-form { display: flex; gap: 8px; margin: 0 0 18px; max-width: 560px; }
.search-page-form input { flex: 1; height: 38px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; }
.search-hint { padding: 8px 0; }
.search-group { margin-bottom: 22px; }
.search-group-head { font-size: 14px; margin: 0 0 8px; color: var(--ink); }
.search-count { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; border-radius: 9px;
  background: var(--line-soft); color: var(--muted); font-size: 11px; font-weight: 700; text-align: center; }
.search-hits { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; background: var(--panel); }
.search-hits li + li { border-top: 1px solid var(--line-soft); }
.search-hits a { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px;
  text-decoration: none; color: var(--ink); }
.search-hits a:hover { background: var(--bg); }
.search-hits .hit-title { font-weight: 600; font-size: 13.5px; }
.search-hits .hit-sub { font-size: 12px; color: var(--muted); }

@media (max-width: 720px) {
  .gsearch { flex-basis: 150px; margin: 0 8px; }
}

/* ---- AI assistant ---- */
.ai-notice { background: var(--low); color: var(--low-ink); border: 1px solid #e7cf94;
  border-radius: 8px; padding: 12px 14px; margin: 0 0 16px; font-size: 13.5px; }
.ai-notice a { color: var(--accent-dark); font-weight: 600; }
.ai-ask { display: flex; gap: 8px; margin: 0 0 12px; max-width: 720px; }
.ai-ask input { flex: 1; height: 42px; padding: 0 14px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 15px; }
.ai-ask input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 109, 176, .12); }
.ai-ask .btn { height: 42px; padding: 0 22px; }
.ai-examples { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 0 0 20px; }
.ai-examples-label { font-size: 12.5px; color: var(--muted); margin-right: 2px; }
.ai-chip { background: #fff; border: 1px solid var(--line); color: var(--ink);
  border-radius: 14px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; }
.ai-chip:hover:not(:disabled) { background: var(--line-soft); border-color: var(--accent); }
.ai-chip:disabled { opacity: .5; cursor: default; }
.ai-status { padding: 10px 0; font-size: 14px; color: var(--muted); }
.ai-status.is-error { color: #c0392b; }
.ai-explain { font-size: 15px; font-weight: 600; color: var(--ink); margin: 6px 0 12px; }
.ai-sql { margin: 14px 0 0; max-width: 720px; }
.ai-sql summary { cursor: pointer; font-size: 12.5px; color: var(--accent-dark); }
.ai-sql pre { background: #0f1720; color: #d6e2f0; padding: 12px 14px; border-radius: 8px;
  overflow-x: auto; font-size: 12.5px; line-height: 1.5; margin: 8px 0 0; white-space: pre-wrap; }
.ai-footnote { margin-top: 22px; font-size: 12px; }

/* The one scroller: page content scrolls here, under a fixed top bar. */
.content { padding: 24px 26px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }

/* ---------- Page head ---------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
h1 { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--muted); margin: 4px 0 0; }
.mod-code {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 3px 8px;
  background: var(--panel);
}

/* ---------- Module landing: grouped function lists ---------- */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
  align-items: start;
}
.menu-col {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.menu-title {
  margin: 0;
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: #f7f9fb;
  border-bottom: 1px solid var(--line);
}
.menu-list { list-style: none; margin: 0; padding: 6px 0; }
.menu-list li { margin: 0; }
.menu-link {
  display: block;
  padding: 8px 16px;
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
}
.menu-link.live { color: var(--accent-dark); font-weight: 600; }
.menu-link.live:hover { background: #eef4fb; border-left-color: var(--accent); }
.menu-link.soon { color: #7b8595; }
.menu-link.soon:hover { background: var(--line-soft); color: var(--ink); }

/* ---------- Home: module cards ---------- */
.module-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.module-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
  text-decoration: none;
  color: var(--ink);
}
.module-card:hover { border-color: var(--accent); box-shadow: 0 1px 0 var(--accent); }
.module-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.module-card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.module-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border: 1px solid var(--accent-dark);
  padding: 8px 15px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--line-soft); }

/* ---------- Table (product list) ---------- */
.grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.grid th, .grid td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); }
.grid th {
  background: #f7f9fb;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 700;
}
.grid tr:last-child td { border-bottom: none; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid tbody tr:hover { background: #fafbfc; }
.grid tr.low { background: var(--low); }
.grid tr.low:hover { background: #f7e7c2; }
.tag {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--low-ink);
  color: #fff;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
}
.tag.hold { background: #b0710f; margin-left: 0; }

/* ---------- Forms ---------- */
.form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  max-width: 640px;
}
.form label { display: block; margin-bottom: 15px; font-weight: 600; font-size: 13px; }
.form input, .form textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-weight: 400;
  color: var(--ink);
}
.form input:focus, .form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 109, 176, 0.12);
}
.form .row { display: flex; gap: 16px; }
.form .row label { flex: 1; }
.form-wide { max-width: 720px; }
.form select {
  display: block; width: 100%; margin-top: 6px;
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 6px; font: inherit;
}
.form label.tight { margin-top: -8px; }
.field-hint { display: block; margin-top: 5px; font-weight: 400; font-size: 12px; color: var(--muted); }

/* Customer account rows */
.acct-main td { border-top: 1px solid var(--line); }
.acct-sub td:first-child { padding-left: 28px; color: var(--muted); }
.sub-mark { color: var(--muted); margin-right: 2px; }
.row-actions { display: flex; gap: 12px; white-space: nowrap; }

/* ---------- Tabbed account form ---------- */
.acct-form { max-width: 820px; }
.acct-key {
  display: flex; gap: 14px; align-items: flex-end;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px 8px 0 0; border-bottom: none; padding: 16px 18px;
}
.acct-key label { display: block; font-size: 12.5px; font-weight: 600; }
.acct-key label.grow { flex: 1; }
.acct-key input, .acct-key select {
  display: block; margin-top: 6px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 6px; font: inherit; font-weight: 400;
}
.acct-key label:not(.grow) input, .acct-key label:not(.grow) select { width: 150px; }
.acct-key label.grow input { width: 100%; }

.tabs {
  display: flex; gap: 2px;
  background: #eef1f5; border: 1px solid var(--line); border-bottom: none;
  padding: 6px 8px 0;
}
.tab {
  border: 1px solid transparent; border-bottom: none;
  background: transparent; padding: 9px 16px; cursor: pointer;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--muted);
  border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--panel); color: var(--accent-dark); border-color: var(--line); }

.tab-panel {
  display: none;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 0 0 8px 8px; padding: 20px 22px;
}
.tab-panel.is-active { display: block; }

.fieldset { margin-bottom: 22px; }
.fieldset:last-child { margin-bottom: 0; }
.fieldset h3 {
  margin: 0 0 14px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  border-bottom: 1px solid var(--line-soft); padding-bottom: 6px;
}
.fieldset label { display: block; margin-bottom: 13px; font-weight: 600; font-size: 13px; }
.fieldset input, .fieldset select, .fieldset textarea {
  display: block; width: 100%; margin-top: 6px;
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; font-weight: 400; color: var(--ink);
}
.fieldset input:focus, .fieldset select:focus, .fieldset textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,109,176,.12);
}
.fieldset .row { display: flex; gap: 14px; }
.fieldset .row label { flex: 1; }
.fieldset label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.fieldset label.check input { width: auto; margin: 0; }

.contact-grid { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.contact-grid th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700; padding: 0 6px 6px;
}
.contact-grid td { padding: 3px 6px 3px 0; }
.contact-grid input { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; font: inherit; }
.row-del { font-size: 13px; }

.acct-actions { display: flex; gap: 12px; margin-top: 16px; }
.btn.danger { background: #fff; color: #c0392b; border-color: #e6b0aa; }
.btn.danger:hover { background: #fdecea; }

/* ---------- Placeholder (coming soon) ---------- */
.placeholder {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 40px;
  max-width: 560px;
}
.placeholder-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 8px;
  margin-bottom: 14px;
}
.placeholder h1 { margin-bottom: 8px; }
.placeholder .btn { margin-top: 20px; }

/* ---------- Point of Sale register ---------- */
.pos { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }

.pos-catalog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.pos-search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  margin-bottom: 12px;
}
.pos-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,109,176,.12); }
.pos-products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
}
.pos-prod {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  cursor: pointer;
  font: inherit;
}
.pos-prod:hover { border-color: var(--accent); background: #f4f8fc; }
.pos-prod-name { font-weight: 600; font-size: 13.5px; }
.pos-prod-meta { font-size: 11.5px; color: var(--muted); }

.pos-cart {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  position: sticky;
  top: 16px;
}
.pos-lines { min-height: 90px; margin-bottom: 12px; }
.pos-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 22px 0; }
.pos-line {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.pos-line-info { display: flex; flex-direction: column; }
.pos-line-info strong { font-size: 13.5px; }
.pos-line-info span { font-size: 11.5px; color: var(--muted); }
.pos-qty { display: flex; align-items: center; gap: 8px; }
.qbtn {
  width: 24px; height: 24px;
  border: 1px solid var(--line);
  background: #fff; border-radius: 5px;
  cursor: pointer; font-size: 15px; line-height: 1;
}
.qbtn:hover { border-color: var(--accent); color: var(--accent); }
.qn { min-width: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.pos-line-total { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 60px; text-align: right; }
.pos-remove { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.pos-remove:hover { color: #c0392b; }

.pos-totals { border-top: 1px solid var(--line); padding-top: 12px; }
.pos-totals .row, .pos-pay .row {
  display: flex; justify-content: space-between;
  font-size: 13.5px; padding: 4px 0;
}
.pos-totals .grand { font-size: 17px; font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
.pos-totals .grand span, .pos-line-total { font-variant-numeric: tabular-nums; }

.pos-pay { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.pos-pay label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 10px; }
.pos-pay select, .pos-pay input {
  display: block; width: 100%; margin-top: 5px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-weight: 400;
}
.pos-pay .change { font-weight: 600; }
.pos-complete { width: 100%; margin-top: 14px; padding: 12px; font-size: 15px; }
.pos-complete:disabled { opacity: .5; cursor: not-allowed; }
.pos-error { color: #c0392b; font-size: 13px; margin: 8px 0 0; }

/* ---------- Receipt ---------- */
.receipt-actions { display: flex; gap: 10px; }
.receipt {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  max-width: 460px;
}
.receipt-head { display: flex; flex-direction: column; gap: 2px; text-align: center; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.receipt-head strong { font-size: 16px; }
.receipt-brand-logo { max-height: 56px; max-width: 260px; width: auto; height: auto; margin: 0 auto 4px; display: block; }
.receipt-head span { font-size: 12px; color: var(--muted); }
.receipt-lines { width: 100%; border-collapse: collapse; margin: 14px 0; }
.receipt-lines th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.receipt-lines td { padding: 6px 0; font-size: 13px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.receipt-lines .num { text-align: right; font-variant-numeric: tabular-nums; }
.receipt-lines .sku { display: block; font-size: 11px; color: var(--muted); }
.receipt-totals { border-top: 1px dashed var(--line); padding-top: 12px; }
.receipt-totals .row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.receipt-totals .grand { font-weight: 700; font-size: 15px; }
.receipt-totals .row span:last-child { font-variant-numeric: tabular-nums; }
.receipt-foot { text-align: center; color: var(--muted); margin: 16px 0 0; font-size: 13px; }

/* ---------- Sales Order entry ---------- */
.mode-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.mode-bar[hidden] { display: none; }
.po-required-tag { margin-left: 4px; padding: 0 5px; border-radius: 4px; background: #fff4e5; color: #9a5b00;
  border: 1px solid #f3d19c; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.po-required-tag[hidden] { display: none; }
input.is-required { border-color: #e0a84a !important; background: #fffaf2; }
.ship-inv-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; margin: 0 0 14px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #f7fafc; }
.ship-inv-form[hidden] { display: none; }
.ship-inv-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; }
.ship-inv-form input { padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.ship-inv-form strong { flex-basis: 100%; }
@media print { .ship-inv-form { display: none !important; } }
.cust-inactive-tag { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px;
  background: #fdecec; color: #9b1c1c; border: 1px solid #f5c2c2; font-size: 10.5px; font-weight: 700; letter-spacing: .03em; }
/* Print ▾ menu on the order page: Sales Order or Pick List */
.print-menu { position: relative; display: inline-block; }
.print-menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 50; min-width: 170px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(20,35,55,.15);
  padding: 4px; display: flex; flex-direction: column; }
.print-menu-list[hidden] { display: none; }
.print-menu-list button, .print-menu-list a { all: unset; cursor: pointer; padding: 9px 12px; border-radius: 6px;
  font-weight: 600; color: var(--ink, #1c2733); }
.print-menu-list button:hover, .print-menu-list a:hover { background: #eef4fb; }          /* opened by the ✎ Amend button */
#amend-toggle { white-space: nowrap; }
#amend-bar .lookup-input { min-width: 340px; }
#amend-toggle.is-active { background: var(--accent, #2f6db0); border-color: var(--accent, #2f6db0); color: #fff; }
.editing-line { margin: 0 0 12px; }
.mode-select {
  padding: 8px 12px; border: 1px solid var(--accent); border-radius: 6px;
  font: inherit; font-weight: 600; color: var(--accent-dark); background: #eef4fb;
}
.lookup { display: flex; align-items: center; gap: 8px; }
.lookup-input {
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 6px; font: inherit; min-width: 260px;
}
.lookup-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,109,176,.12); }
.editing-badge {
  font-size: 12px; font-weight: 700; color: var(--accent-dark);
  background: #eef4fb; border: 1px solid #cfe0f2; border-radius: 999px; padding: 4px 12px;
}
.order-form { max-width: 920px; }
.doc-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 18px; }
.doc-opt {
  padding: 9px 20px; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--muted);
  border-right: 1px solid var(--line); background: var(--panel);
}
.doc-opt:last-child { border-right: none; }
.doc-opt.is-active { background: var(--accent); color: #fff; }
.doc-opt input { display: none; }

.order-head {
  display: flex; gap: 14px 18px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid #b8c4d2; border-radius: 8px;
  padding: 15px 18px; margin-bottom: 16px;
}
.order-head label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.order-head label.grow { flex: 2 1 240px; }
.order-head label:not(.grow) { flex: 1 1 130px; }
.order-head input, .order-head select {
  display: block; width: 100%; margin-top: 6px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 6px; font: inherit; font-weight: 400;
}

/* Search-as-you-type picker (customer + line items) */
.combo { position: relative; }
.combo-input { display: block; width: 100%; }
.order-head .combo-input { margin-top: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-weight: 400; }
.combo-menu {
  display: none; position: absolute; z-index: 50; left: 0; right: 0; top: 100%; margin-top: 3px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
  box-shadow: 0 10px 26px rgba(20,35,55,.20); max-height: 280px; overflow-y: auto; padding: 4px;
}
.combo-menu.open { display: block; }
.combo-opt { padding: 7px 9px; border-radius: 5px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.combo-opt:hover, .combo-opt.active { background: #eef4fb; }
.combo-opt .opt-name { font-size: 13px; font-weight: 600; color: var(--text); }
.combo-opt .opt-meta { font-size: 11.5px; color: var(--muted); }
.combo-empty { padding: 8px 9px; font-size: 12.5px; color: var(--muted); }
.combo-head { padding: 6px 9px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #9aa6b4; }
.combo-more { margin-top: 4px; padding: 8px 9px; border-top: 1px solid var(--line-soft); text-align: center; font-size: 12.5px; font-weight: 600; color: var(--accent-dark); cursor: pointer; border-radius: 0 0 5px 5px; }
.combo-more:hover { background: #eef4fb; }

/* Read-only header field (e.g. Salesperson, which comes from the account) */
.order-head .ro-field {
  margin-top: 6px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 6px;
  background: #f7f9fb; font-weight: 400; min-height: 37px; box-sizing: border-box;
  display: flex; align-items: center;
}
.order-head .ro-field.empty { color: var(--muted); }

/* Add-item search bar above the line grid */
.line-add-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.line-add-bar .combo { flex: 1; }
.line-add-bar .combo-input { padding: 9px 11px; border: 1px solid var(--accent); border-radius: 6px; box-shadow: 0 0 0 3px rgba(47,109,176,.06); }
.line-add-bar .btn { white-space: nowrap; }
.lines-empty {
  margin: 0; padding: 16px; text-align: center; color: var(--muted); font-size: 13px;
  background: #f7f9fb; border: 1px solid var(--line); border-top: none; border-radius: 0 0 10px 10px;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }
.logout-link { font-size: 12px; color: var(--muted); text-decoration: none; }
.logout-link:hover { color: var(--accent-dark); text-decoration: underline; }

/* List search bar (inventory, etc.) */
.list-search { display: flex; gap: 8px; margin: 4px 0 6px; }
.list-search input[type=search] { flex: 1; max-width: 420px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.list-search input[type=search]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,109,176,.12); }

/* Pager — Prev / Next control shown under any long list (see app/pagination.py). */
.pager { display: flex; align-items: center; gap: 12px; margin: 12px 0 4px; }
.pager .pager-info { white-space: nowrap; }
.pager .btn.disabled { opacity: .45; pointer-events: none; }

/* Line grid — a proper AccountMate-style data grid: gridlines, blue header,
   zebra rows, an auto-numbered Seq column. */
/* Clean, modern line grid — its own look: no boxed-in gridlines or Windows-style
   header, just light row separators and an accent underline. (No `overflow:
   hidden` — that would clip the item-search dropdown below a row.) */
.order-lines { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px 10px 0 0; }
.order-lines thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 700; padding: 11px 12px;
  background: transparent; border-bottom: 2px solid var(--accent);
}
.order-lines th.num, .order-lines td.num { text-align: right; }
.order-lines tbody td { padding: 7px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.order-lines tbody tr:last-child td { border-bottom: none; }
.order-lines tbody tr:hover { background: #f6f9fc; }
.order-lines .w-seq { width: 40px; }
.order-lines td.l-seq { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.order-lines .w-item { width: 42%; }
.order-lines input, .order-lines select { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; font: inherit; background: #fff; }
.order-lines input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47,109,176,.12); }
.order-lines .l-total { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
/* Plain 1, 2, 3 line numbers, auto-renumbered as rows change. */
#line-rows { counter-reset: seq; }
#line-rows tr { counter-increment: seq; }
#line-rows td.l-seq::before { content: counter(seq); }
#add-line { margin: 10px 0 0; }

.order-totals { max-width: 300px; margin: 16px 0 0 auto; }
.order-totals .row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 6px 2px; }
.order-totals .row span:first-child { color: var(--muted); }
.order-totals .row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.order-totals .grand { font-size: 18px; font-weight: 800; color: var(--accent-dark); border-top: 2px solid var(--accent); margin-top: 6px; padding-top: 10px; }
.order-totals .grand span:first-child { color: var(--accent-dark); }
.order-notes { display: block; margin-top: 16px; font-size: 12.5px; font-weight: 600; }
.order-notes textarea { display: block; width: 100%; margin-top: 6px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-weight: 400; }

.cust-link {
  display: none; margin-top: 6px; font-size: 12px; font-weight: 600;
  color: var(--accent-dark); text-decoration: none;
}
.cust-link:hover { text-decoration: underline; }

/* ---------- Customer detail (account lookup) ---------- */
.stat-value.small { font-size: 15px; }
.fine { font-size: 12px; margin: -8px 0 20px; }
.detail-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; margin-bottom: 22px; }
.detail-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; }
.detail-card h3 { margin: 0 0 12px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.sub-list { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.sub-list li { padding: 4px 0; }
.section-h { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 6px 0 12px; }

@media (max-width: 760px) { .detail-cols { grid-template-columns: 1fr; } }

/* ---------- Sales document view ---------- */
.doc { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 26px; max-width: 640px; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--ink); padding-bottom: 12px; }
.doc-head strong { font-size: 17px; }
.doc-brand-logo { max-height: 64px; max-width: 320px; width: auto; height: auto; display: block; }
.doc-meta { text-align: right; font-size: 13px; }
.doc-meta span { color: var(--muted); display: inline-block; min-width: 78px; }
.doc-billto { margin: 16px 0; font-size: 13.5px; line-height: 1.5; }
.doc-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin-bottom: 3px; }
.doc-lines { width: 100%; border-collapse: collapse; margin: 8px 0 16px; }
.doc-lines th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.doc-lines th.num, .doc-lines td.num { text-align: right; }
.doc-lines td { padding: 8px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; vertical-align: top; }
.doc-lines .sku { display: block; font-size: 11px; color: var(--muted); }
.doc-totals { max-width: 260px; margin-left: auto; }
.doc-totals .row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 3px 0; }
.doc-totals .row span:last-child { font-variant-numeric: tabular-nums; }
.doc-totals .grand { font-weight: 700; font-size: 16px; border-top: 1px solid var(--line); margin-top: 5px; padding-top: 7px; }
.doc-notes { margin-top: 18px; font-size: 13px; }

/* ---------- AccountMate-style document (Quote / Order / Invoice) ---------- */
:root {
  --am-line: #ccd6e2;      /* hairline box borders */
  --am-line-soft: #e7edf4; /* faint row dividers inside the line table */
  --am-head: #eef2f8;      /* very light header fill */
  --am-head2: #f4f7fb;     /* lightest fill for secondary headers */
  --am-ink: #1c2b3d;
}
.am-doc {
  background: #fff; color: var(--am-ink); border: 1px solid var(--am-line);
  padding: 26px 30px 22px; max-width: 720px; margin: 0 auto 22px;
  font-size: 10.5px; line-height: 1.4;
}
/* Each printed sheet: fixed minimum height so the footer sits at the bottom and
   every page looks the same, even a short last page. */
.am-page { display: flex; flex-direction: column; min-height: 940px; }
.am-page .am-foot { margin-top: auto; }
/* Blank filler rows keep every page's grid the same height. */
.am-lines tbody tr.am-blank td { height: 24px; }
.am-continued { text-align: right; font-size: 10px; font-style: italic; color: var(--muted); margin: 6px 2px 0; }
/* Header */
.am-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 4px; }
.am-head-left { flex: 1 1 auto; min-width: 0; }
.am-logo { max-height: 88px; max-width: 320px; width: auto; height: auto; display: block; }
.am-company { font-size: 16px; font-weight: 700; letter-spacing: .01em; }
.am-head-right { flex: 0 0 auto; text-align: right; min-width: 250px; }
.am-code { font-size: 9.5px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }
.am-title { font-size: 20px; font-weight: 700; margin: 0 0 10px; letter-spacing: .04em; color: #33465c; text-transform: uppercase; }
.am-idbox { border-collapse: collapse; margin-left: auto; }
.am-idbox th, .am-idbox td { border: 1px solid var(--am-line); padding: 4px 12px; font-size: 10.5px; }
.am-idbox th { background: var(--am-head); text-align: right; font-weight: 600; white-space: nowrap; color: #4a5a6e; }
.am-idbox td { text-align: right; min-width: 96px; font-variant-numeric: tabular-nums; }
/* Bill To / Ship To */
.am-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin: 14px 0 10px; }
.am-party-label { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-bottom: 1px solid var(--am-line); padding-bottom: 3px; margin-bottom: 6px; }
.am-party-body { font-size: 10.5px; }
.am-kv { display: block; margin-top: 2px; }
.am-kv b, .am-party-body b { font-weight: 600; }
/* Info grid */
.am-info { width: 100%; border-collapse: collapse; margin-bottom: 2px; }
.am-info th, .am-info td { border: 1px solid var(--am-line); padding: 4px 8px; font-size: 9.5px; text-align: left; }
.am-info .hd th { background: var(--am-head); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: #4a5a6e; }
/* Line items */
.am-lines { width: 100%; border-collapse: collapse; margin-top: 12px; border: 1px solid var(--am-line); }
.am-lines thead th {
  background: var(--am-head); border-bottom: 1.5px solid var(--am-line); border-right: 1px solid var(--am-line);
  padding: 6px 8px; font-size: 9px; font-weight: 700; vertical-align: bottom; text-align: left;
  text-transform: uppercase; letter-spacing: .04em; line-height: 1.2; color: #4a5a6e;
}
.am-lines thead th:last-child { border-right: 0; }
.am-lines thead th.num { text-align: right; }
.am-lines thead th.ctr { text-align: center; }
.am-lines tbody td { border-bottom: 1px solid var(--am-line-soft); border-right: 1px solid var(--am-line); padding: 4px 8px; vertical-align: top; font-size: 10.5px; }
.am-lines tbody td:last-child { border-right: 0; }
.am-lines tbody tr:last-child td { border-bottom: 0; }
.am-lines tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.am-lines tbody td.ctr { text-align: center; }
.am-item { font-weight: 600; }
.am-uom { color: var(--muted); margin-left: 22px; font-size: 9.5px; }
.am-desc { margin-top: 1px; color: #566577; }
.am-notes { margin: 12px 2px; font-size: 10px; }
.am-thanks { text-align: center; font-weight: 700; font-size: 12px; margin: 14px 0 2px; }
/* Quote approval block */
.am-approve { text-align: center; margin: 22px 0 8px; }
.am-approve-sign { font-weight: 700; font-size: 11px; display: inline-block; }
.am-sign-line { display: inline-block; width: 260px; border-bottom: 1px solid var(--am-ink); margin-left: 6px; vertical-align: bottom; height: 1em; }
.am-approve-all { margin-top: 12px; font-weight: 700; font-size: 11px; }
.am-checkbox { display: inline-block; width: 11px; height: 11px; border: 1px solid var(--am-ink); vertical-align: -1px; margin-right: 5px; }
.am-approve-link { text-align: center; margin: 10px auto 4px; font-size: 11px; max-width: 90%; word-break: break-all; }
.am-approve-link a { color: #1f6fd6; }
/* Footer */
.am-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-top: 16px; }
.am-print { border-collapse: collapse; align-self: flex-start; }
.am-print th, .am-print td { padding: 2px 10px 2px 0; font-size: 9.5px; }
.am-print th { text-align: left; font-weight: 600; white-space: nowrap; color: var(--muted); }
.am-print td { text-align: left; font-variant-numeric: tabular-nums; }
.am-totals { border-collapse: collapse; min-width: 250px; border: 1px solid var(--am-line); }
.am-totals th, .am-totals td { padding: 5px 12px; font-size: 10.5px; }
.am-totals th { text-align: right; font-weight: 600; white-space: nowrap; color: #4a5a6e; border-right: 1px solid var(--am-line); }
.am-totals td { text-align: right; font-variant-numeric: tabular-nums; min-width: 96px; }
.am-totals tr th, .am-totals tr td { border-bottom: 1px solid var(--am-line-soft); }
.am-totals .grand th, .am-totals .grand td { border-top: 1.5px solid var(--am-line); border-bottom: 0; background: var(--am-head); font-weight: 700; font-size: 12.5px; color: var(--am-ink); }
.am-printedby { font-size: 9.5px; color: var(--muted); margin: 8px 2px 0; }

/* ---------- Stat tiles (reports) ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.stat-label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.stat-value { display: block; font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.total { background: #eef4fb; border-color: #cfe0f2; }
.day-picker { display: flex; gap: 8px; align-items: center; }
.day-picker input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }

/* ---------- Print (receipt) ---------- */
@media print {
  .sidebar, .topbar, .page-head, .ship-status, .doc-invoices { display: none !important; }
  .app { display: block; height: auto; overflow: visible; }
  .main { height: auto; overflow: visible; }
  .content { padding: 0; overflow: visible; }
  .receipt { border: none; max-width: 100%; }
  .am-doc { border: none; max-width: 100%; padding: 0; margin: 0; }
  /* Keep the light header fills when printing (browsers strip backgrounds by default). */
  .am-idbox th, .am-info .hd th, .am-lines thead th,
  .am-totals .grand th, .am-totals .grand td {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  /* Each document "page" prints on its own physical sheet. */
  @page { size: letter; margin: 0.5in; }
  /* Documents print on a zero-margin sheet (the 0.5in margin moves into the
     page's own padding) so the browser has no room for its date / title / URL
     header and footer — only the paper itself prints. */
  @page doc { size: letter; margin: 0; }
  html, body, .app, .main, .content { background: #fff !important; }
  /* 9.9in tall, not 10.5in: browsers WITHOUT named-page support (e.g. the
     desktop app's WebView) ignore "@page doc" and keep the 0.5in margins, which
     leave only 10in of sheet — a taller page spilled its last line ("Printed
     By") onto a second, otherwise blank, page. 9.9in fits either way. */
  .am-page { page: doc; box-sizing: border-box; min-height: 9.9in; border: none;
             padding: 0.3in 0.5in; break-after: page; page-break-after: always; }
  /* No break after the final page. A class, not :last-child — on a doc still
     syncing to AccountMate a <script> follows the last page, so :last-child
     never matched and a blank sheet came out at the end. */
  .am-page.am-page-last { break-after: auto; page-break-after: auto; }
  .am-lines tr { break-inside: avoid; page-break-inside: avoid; }
  .am-foot { break-inside: avoid; page-break-inside: avoid; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .pos { grid-template-columns: 1fr; }
  .pos-cart { position: static; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; }
  .modnav { display: flex; }
}

/* ---------- Accounts Payable (Enter Bill / Pay Bills) ---------- */
.ap-form { max-width: 820px; }
.combo-menu.is-open { display: block; }
.combo-item { padding: 8px 10px; border-radius: 5px; cursor: pointer; font-size: 13px; color: var(--ink); }
.combo-item:hover { background: #eef4fb; color: var(--accent-dark); }
.ap-grid2 {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px;
  background: var(--panel); border: 1px solid #b8c4d2; border-radius: 8px; padding: 15px 18px; margin-bottom: 18px;
}
.ap-field { display: flex; flex-direction: column; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.ap-field input, .ap-field select {
  margin-top: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-weight: 400; color: var(--ink);
}
.ap-field input:focus, .ap-field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,109,176,.12); }
.ap-field .lookup-input { min-width: 0; width: 100%; }
.ap-notes { max-width: 520px; margin-bottom: 4px; }
.ap-subhead { font-size: 14px; margin: 4px 0 10px; }
.ap-lines input { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; font: inherit; }
.ap-lines input:focus { outline: none; border-color: var(--accent); }
.ap-lines .ap-amt { text-align: right; }
.ap-del { appearance: none; border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; }
.ap-del:hover { color: #b0342a; }
.ap-add-cell { padding-top: 8px; }

/* ---------- Shipment status banner ---------- */
.ship-status { margin: 0 0 16px; padding: 10px 14px; border-radius: 8px; font-size: 13px; border: 1px solid; }
.ship-open { background: #eef4fb; border-color: #cfe0f2; color: #1f4e7a; }
.ship-partial { background: #fdf3e2; border-color: #f0dcb4; color: #8a5a12; }
.ship-shipped { background: #e9f6ec; border-color: #c2e6cb; color: #1f7a3d; }
.doc-invoices { margin: 0 0 16px; font-size: 13px; }
.doc-invoices .doc-label { display: inline; margin-right: 8px; }
.doc-invoices a { font-weight: 600; }

/* ---------- Reports ---------- */
.report-actions { display: flex; gap: 8px; align-items: center; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.table-scroll .grid { border: none; margin: 0; }
.grid tfoot .grid-total td { border-top: 2px solid var(--line); font-weight: 700; background: #f6f8fb; }
.report-note { margin-top: 10px; font-size: 12.5px; }

/* Criteria screen — AccountMate-style report selection window */
.rc-window { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; max-width: 920px; box-shadow: 0 6px 20px rgba(20,35,55,.08); }
.rc-titlebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 10px; background: #e9eef4; border-bottom: 1px solid #c2ccd8; }
.rc-title { font-weight: 600; font-size: 13.5px; color: #333f4d; padding-left: 4px; }
.rc-tools { display: flex; gap: 6px; align-items: center; }

/* Desktop-app toolbar buttons — defined edges + a subtle bevel */
.rc-tbtn {
  display: inline-flex; align-items: center; gap: 7px;
  appearance: none; font: inherit; font-size: 13px; color: #27313f; cursor: pointer; text-decoration: none;
  background: linear-gradient(#ffffff, #eef2f7);
  border: 1px solid #b4c0ce; border-radius: 5px; padding: 6px 13px; line-height: 1.4;
  box-shadow: 0 1px 1px rgba(20,35,55,.05), inset 0 1px 0 #fff;
}
.rc-tbtn:hover { background: linear-gradient(#f5f9ff, #e3edf9); border-color: #8fb0d6; }
.rc-tbtn:active { background: #e0e8f1; box-shadow: inset 0 1px 3px rgba(20,35,55,.15); }
.rc-ico { font-size: 12px; line-height: 1; }
.rc-tbtn-close .rc-ico { color: #c0392b; font-weight: 700; }

/* Export split-button (Export = PDF; arrow = format menu) */
.rc-split { position: relative; display: inline-flex; }
.rc-split-main { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: none; }
.rc-split-arrow { border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 6px 8px; font-size: 11px; }
.rc-menu { position: absolute; top: calc(100% + 3px); right: 0; min-width: 210px; background: var(--panel); border: 1px solid #b0bccb; border-radius: 5px; box-shadow: 0 10px 24px rgba(20,35,55,.20); padding: 4px; display: none; z-index: 30; }
.rc-split.is-open .rc-menu { display: block; }
.rc-menu-item { display: block; width: 100%; text-align: left; appearance: none; border: none; background: transparent; padding: 8px 12px; font: inherit; font-size: 13px; color: var(--ink); border-radius: 4px; cursor: pointer; text-decoration: none; }
.rc-menu-item:hover { background: #e8f0fb; color: var(--accent-dark); }

.rc-body { display: grid; grid-template-columns: 230px 1fr; }
.rc-side { padding: 14px; border-right: 1px solid var(--line); background: #f7f9fc; display: flex; flex-direction: column; gap: 14px; }
.rc-box { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px 12px; margin: 0; background: var(--panel); }
.rc-box legend { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 0 4px; }
.rc-box select, .rc-box input[type="text"] { width: 100%; padding: 6px 8px; border: 1px solid #c9d0d9; border-radius: 5px; font: inherit; background: #fbfcff; }
.rc-mt { margin-top: 8px; }
.rc-check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: #37414f; margin: 5px 0; }
.rc-check input { width: auto; }

.rc-criteria { padding: 14px 16px; }
.rc-crit-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }
.rc-grid { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.rc-grid-row { display: grid; grid-template-columns: 150px 46px minmax(0,1fr) minmax(0,1fr); align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line-soft); }
.rc-grid-row:last-child { border-bottom: none; }
.rc-grid-header { background: #eef3f9; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.rc-grid-header span { text-align: left; }
.rc-field { font-size: 12.5px; font-weight: 600; color: #37414f; }
.rc-all { text-align: center; }
.rc-all input { width: auto; }
.rc-cell { display: flex; align-items: center; gap: 6px; }
.rc-cell input[type="text"], .rc-cell input[type="date"], .rc-cell select { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid #c9d0d9; border-radius: 5px; font: inherit; background: #fbfcff; }
.rc-cell input:disabled { background: #eef0f3; color: #9aa4b2; }
.rc-cell input:focus, .rc-cell select:focus { outline: none; border-color: var(--accent); }
.rc-span2 { grid-column: span 2; max-width: 260px; }
.rc-year { max-width: 74px; flex: 0 0 auto !important; }
.rc-lookup { cursor: pointer; color: var(--muted); font-size: 13px; user-select: none; }
.rc-range { font-size: 11px; color: var(--muted); white-space: nowrap; }

.rc-options { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: #f7f9fc; }
.rc-opt { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: #37414f; }
.rc-opt select { padding: 6px 8px; border: 1px solid #c9d0d9; border-radius: 5px; font: inherit; background: #fbfcff; }

@media (max-width: 760px) {
  .rc-body { grid-template-columns: 1fr; }
  .rc-side { border-right: none; border-bottom: 1px solid var(--line); }
  .rc-grid-row { grid-template-columns: 110px 40px 1fr 1fr; }
}

@media print {
  .report-actions { display: none !important; }
  /* Reports keep their title on paper. Scoped to report pages only — a bare
     .page-head here would also print the title + buttons on sales orders,
     quotes and POs, which must print as just the document. */
  .page-head:has(.report-actions) { display: block !important; }
  .page-head:has(.report-actions) .muted { display: block !important; }
}

/* ---------------------------------------------------------------------------
   Customer purchase-history panel + item drill-in modal.
   Shared by the Sales Order screen and the POS register: everything an account
   has ever bought (one row per item, price paid, ×N times), search by item /
   SKU / UPC, right-click a row for every date & order.
--------------------------------------------------------------------------- */
.cust-hist { margin-top: 20px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 1px 3px rgba(20,35,55,.06); overflow: hidden; }
.ch-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: linear-gradient(#fbfcfe, #f3f6fa); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ch-title { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink); }
.ch-search { flex: 1; min-width: 220px; max-width: 540px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 7px; font: inherit; background: #fff; }
.ch-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,109,176,.12); }
.ch-search:disabled { background: #eef1f5; color: var(--muted); }
.ch-count { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--accent-dark); background: #eaf2fb; border: 1px solid #d3e2f4; border-radius: 999px; padding: 3px 11px; white-space: nowrap; }
.ch-list { max-height: 340px; overflow-y: auto; }
.ch-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ch-table thead th { position: sticky; top: 0; z-index: 1; background: #f5f8fb; text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 9px 16px; border-bottom: 1px solid var(--line); }
.ch-table td { padding: 9px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.ch-table tbody tr:last-child td { border-bottom: 0; }
.ch-table tbody tr:nth-child(even) td { background: #fafbfd; }
.ch-table tbody tr:hover td { background: #eef4fb; }
.ch-sku { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12px; color: var(--muted); white-space: nowrap; }
.ch-desc { font-weight: 500; color: var(--ink); }
.ch-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ch-doc { color: #9aa6b4; }
.ch-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ch-price { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); white-space: nowrap; }
.ch-add { padding: 4px 14px; font-size: 12px; font-weight: 600; border: 1px solid var(--accent); background: #fff; color: var(--accent-dark); border-radius: 6px; cursor: pointer; transition: background .12s, color .12s; }
.ch-add:hover { background: var(--accent); color: #fff; }
.ch-empty { padding: 22px 16px; color: var(--muted); font-size: 13px; text-align: center; }
.ch-times { border: 1px solid #d3e2f4; background: #eaf2fb; color: var(--accent-dark); font: inherit; font-size: 11px; font-weight: 700; line-height: 1; padding: 2px 7px; border-radius: 999px; cursor: pointer; vertical-align: middle; }
.ch-times:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.ch-tip { padding: 8px 16px; font-size: 11.5px; color: var(--muted); background: #fafbfd; border-top: 1px solid var(--line-soft); }
/* Item drill-in modal */
.ch-modal { position: fixed; inset: 0; z-index: 60; background: rgba(20,32,48,.44); display: flex; align-items: center; justify-content: center; padding: 20px; }
.ch-modal[hidden] { display: none; }
.ch-modal-card { width: 100%; max-width: 520px; max-height: 82vh; display: flex; flex-direction: column; background: #fff; border-radius: 12px; box-shadow: 0 18px 50px rgba(15,28,45,.32); overflow: hidden; }
.ch-modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px; background: linear-gradient(#fbfcfe, #eef3f9); border-bottom: 1px solid var(--line); }
.ch-modal-title { font-size: 15px; font-weight: 700; color: var(--ink); line-height: 1.25; }
.ch-modal-sub { margin-top: 2px; font-size: 12px; color: var(--muted); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.ch-modal-x { margin-left: auto; border: 0; background: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.ch-modal-x:hover { background: #e6ecf3; color: var(--ink); }
.ch-modal-body { overflow-y: auto; }
.chm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.chm-table thead th { position: sticky; top: 0; background: #f5f8fb; text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 9px 18px; border-bottom: 1px solid var(--line); }
.chm-table td { padding: 8px 18px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.chm-table tbody tr:nth-child(even) td { background: #fafbfd; }
.ch-modal-foot { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); background: #fafbfd; }
.ch-modal-hint { font-size: 12px; color: var(--muted); }
.ch-modal-add { margin-left: auto; padding: 8px 18px; font-size: 13px; font-weight: 600; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 7px; cursor: pointer; }
.ch-modal-add:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.ch-modal-add:disabled { background: #c7d2de; border-color: #c7d2de; cursor: default; }
