/* Layout and look modelled on the Salesgent screens the team already knows:
   navy icon rail, light-grey header with quick links, compact 13px tables, 6px corners, blue #0137fc. */
:root {
  --brand: #0137fc;
  --brand-rgb: 1, 55, 252;
  --brand-hover: #2b5bff;
  --brand-active: #0029c4;
  --brand-soft: #e6ebff;
  --sider-bg: #030b25;
  --sider-w: 80px;
  --sider-w-wide: 220px;
  --header-bg: #f7f7f7;
  --head-bg: #f9f9f9;
  --line: #f0f0f0;
  --line-strong: #d9d9d9;
  --text: rgba(0, 0, 0, .88);
  --text-2: rgba(0, 0, 0, .65);
  --text-3: rgba(0, 0, 0, .45);
  --th-bg: #fafafa;
  --row-hover: #fafafa;
  --surface: #fff;
  --series-1: #2a78d6;
  --grid: #e7e6e2;

  --bs-primary: var(--brand);
  --bs-primary-rgb: var(--brand-rgb);
  --bs-primary-bg-subtle: var(--brand-soft);
  --bs-primary-text-emphasis: var(--brand-active);
  --bs-primary-border-subtle: #99adfe;
  --bs-link-color: var(--brand);
  --bs-link-color-rgb: var(--brand-rgb);
  --bs-link-hover-color: var(--brand-hover);
  --bs-link-hover-color-rgb: 43, 91, 255;
  --bs-body-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: 14px;
  --bs-body-color: var(--text);
  --bs-border-color: var(--line-strong);
  --bs-border-radius: 6px;
  --bs-border-radius-sm: 4px;
  --bs-border-radius-lg: 8px;
  --bs-focus-ring-color: rgba(5, 145, 255, .1);
}
[data-bs-theme="dark"] {
  --brand-soft: #111d4a;
  --header-bg: #141414;
  --head-bg: #1a1a1a;
  --line: #303030;
  --line-strong: #424242;
  --text: rgba(255, 255, 255, .85);
  --text-2: rgba(255, 255, 255, .65);
  --text-3: rgba(255, 255, 255, .45);
  --th-bg: #1d1d1d;
  --row-hover: #1f1f1f;
  --surface: #141414;
  --series-1: #3987e5;
  --grid: #34332f;
  --bs-body-bg: #141414;
  --bs-body-color: var(--text);
  --bs-primary-text-emphasis: #8ea4ff;
  --bs-link-color: #4d74ff;
  --bs-link-color-rgb: 77, 116, 255;
  --bs-link-hover-color: #7a97ff;
}

body { background: var(--surface); color: var(--text); }
a { text-decoration: none; }
a:hover { text-decoration: none; }
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
.content { padding: 0 16px 24px; flex: 1; }

/* ---------- sidebar: icon rail, hover flyouts, optional wide mode ---------- */
.sider { width: var(--sider-w); flex: 0 0 var(--sider-w); background: var(--sider-bg); position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column; z-index: 1030; transition: width .15s, flex-basis .15s; }
.sider-logo { height: 60px; flex: 0 0 60px; display: flex; align-items: center; justify-content: center; gap: 10px;
  color: #fff; text-decoration: none; padding: 0 12px; }
.sider-logo img { max-height: 36px; max-width: 56px; }
.logo-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); display: grid; place-items: center;
  font-weight: 700; font-size: 18px; color: #fff; flex: 0 0 36px; }
.logo-name { display: none; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sider-menu { flex: 1; overflow-y: auto; padding: 4px; scrollbar-width: none; }
.sider-menu::-webkit-scrollbar { display: none; }
.sider-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 56px; margin-bottom: 6px; border-radius: 8px; color: #fff; text-decoration: none; font-size: 12px;
  line-height: 1.2; text-align: center; }
.sider-item i:first-child { font-size: 20px; line-height: 1; }
.sider-item .caret { display: none; }
.sider-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sider-group.active > .sider-item { background: var(--brand); }
.sider-sub { display: none; position: fixed; left: var(--sider-w); min-width: 210px; background: var(--sider-bg);
  border-radius: 0 8px 8px 0; padding: 6px; box-shadow: 6px 6px 24px rgba(0, 0, 0, .25); z-index: 1040; }
.sider-group:not(.single):hover > .sider-sub, .sider-group:not(.single):focus-within > .sider-sub { display: block; }
.sider-sub-title { color: rgba(255, 255, 255, .55); font-size: 12px; padding: 6px 12px 4px; }
.sider-link { display: flex; align-items: center; border-radius: 6px; margin: 2px 0; }
.sider-link a { color: #fff; text-decoration: none; padding: 8px 12px; flex: 1; font-size: 14px; white-space: nowrap; }
.sider-link a.add { flex: 0; padding: 8px 10px; color: rgba(255, 255, 255, .6); }
.sider-link a.add:hover { color: #fff; }
.sider-link:hover { background: rgba(255, 255, 255, .08); }
.sider-link.active { background: var(--brand); }
.sider-trigger { height: 48px; flex: 0 0 48px; background: var(--brand); border: 0; color: #fff; width: 100%; font-size: 16px; }
.sider-trigger:hover { background: var(--brand-hover); }

/* Wide menu: labels beside icons, groups open inline. Also used for the phone drawer. */
.nav-wide .sider { width: var(--sider-w-wide); flex-basis: var(--sider-w-wide); }
.nav-wide .sider-logo { justify-content: flex-start; padding: 0 20px; }
.nav-wide .logo-name { display: block; }
.nav-wide .sider-item { flex-direction: row; justify-content: flex-start; gap: 12px; height: 42px; padding: 0 14px;
  font-size: 14px; margin-bottom: 2px; }
.nav-wide .sider-item i:first-child { font-size: 17px; }
.nav-wide .sider-item .caret { display: block; margin-left: auto; font-size: 11px; transition: transform .15s; }
.nav-wide .sider-group.open > .sider-item .caret { transform: rotate(180deg); }
.nav-wide .sider-group.active:not(.single) > .sider-item { background: transparent; }
.nav-wide .sider-sub, .nav-wide .sider-group:hover > .sider-sub { display: none; position: static; box-shadow: none;
  padding: 0 0 6px 30px; min-width: 0; background: transparent; border-radius: 0; }
.nav-wide .sider-group.open > .sider-sub { display: block; }
.nav-wide .sider-sub-title { display: none; }
.nav-wide .sider-trigger i { transform: rotate(180deg); }

/* ---------- header: search row + quick links ---------- */
.topbar { background: var(--header-bg); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1020; }
.topbar-row { display: flex; align-items: center; gap: 10px; padding: 8px 16px 2px; }
.create-btn { width: 26px; height: 26px; border-radius: 50%; border: 0; background: #3f3f46; color: #fff; display: grid;
  place-items: center; font-size: 14px; }
.create-btn:hover { background: var(--brand); }
.search { display: flex; align-items: center; flex: 1; max-width: 620px; height: 34px; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 6px; position: relative; }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(5, 145, 255, .1); }
.search select { border: 0; background: transparent; color: var(--text); padding: 0 6px 0 10px; height: 100%; width: 96px;
  font-size: 14px; outline: none; cursor: pointer; }
.search .divider { width: 1px; align-self: stretch; background: var(--line-strong); }
.search i { color: var(--text-3); padding: 0 6px 0 10px; }
.search input { border: 0; outline: none; flex: 1; min-width: 0; height: 100%; background: transparent; color: var(--text); }
.search kbd { background: transparent; color: var(--text-3); font-size: 12px; margin-right: 8px; padding: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 34px; height: 34px; border-radius: 6px; border: 0; background: transparent; color: var(--text-2);
  display: grid; place-items: center; font-size: 18px; text-decoration: none; }
.icon-btn:hover { background: rgba(0, 0, 0, .06); color: var(--text); }
[data-bs-theme="dark"] .icon-btn:hover { background: rgba(255, 255, 255, .08); }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-weight: 600;
  font-size: 14px; text-transform: uppercase; }
.quick-links { display: flex; gap: 20px; padding: 4px 16px 8px; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.quick-links::-webkit-scrollbar { display: none; }
.quick-links a { color: var(--text); text-decoration: none; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.quick-links a i { font-size: 13px; color: var(--text-2); }
.quick-links a:hover, .quick-links a:hover i { color: var(--brand); }

/* ---------- page header bar with breadcrumb ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: var(--head-bg);
  margin: 0 -16px 16px; padding: 8px 16px; min-height: 49px; border-bottom: 1px solid var(--line); }
.page-head h1 { font-size: 16px; margin: 0; font-weight: 500; color: var(--text); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-head .btn-sm { --bs-btn-padding-y: 4px; --bs-btn-padding-x: 15px; --bs-btn-font-size: 14px; min-height: 32px; }
.crumbs { display: inline-flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 16px; }
.crumbs a { color: var(--text-3); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs .bi-chevron-right { font-size: 11px; }
.page-head > a.btn-link { padding: 0; color: var(--text-3); text-decoration: none; }
.page-head > a.btn-link:hover { color: var(--text); }
.page-head > a.btn-link .bi-arrow-left::before { content: "\F284"; font-size: 12px; } /* chevron-left */

/* ---------- buttons & inputs ---------- */
.btn { --bs-btn-border-radius: 6px; --bs-btn-font-weight: 400; }
.btn-sm { --bs-btn-border-radius: 4px; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-hover);
  --bs-btn-hover-border-color: var(--brand-hover); --bs-btn-active-bg: var(--brand-active);
  --bs-btn-active-border-color: var(--brand-active); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
  box-shadow: 0 2px 0 rgba(5, 95, 255, .1); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand);
  --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand-active); --bs-btn-active-border-color: var(--brand-active); }
.btn-outline-secondary { --bs-btn-color: var(--text); --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--line-strong);
  --bs-btn-hover-color: var(--brand-hover); --bs-btn-hover-bg: var(--surface); --bs-btn-hover-border-color: var(--brand-hover);
  --bs-btn-active-color: var(--brand-active); --bs-btn-active-bg: var(--surface); --bs-btn-active-border-color: var(--brand-active);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .02); }
.form-control, .form-select { border-color: var(--line-strong); border-radius: 6px; min-height: 32px; padding: 4px 11px;
  font-size: 14px; background-color: var(--surface); }
.form-select { padding-right: 32px; }
.form-control-sm, .form-select-sm { min-height: 24px; padding: 0 7px; font-size: 14px; border-radius: 4px; }
.form-select-sm { padding-right: 28px; }
.form-control:hover, .form-select:hover { border-color: var(--brand-hover); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(5, 145, 255, .1); }
.form-control-plaintext { color: var(--text); }
.form-label { color: var(--text); margin-bottom: 4px; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-text { color: var(--text-3); }
.form-section { font-size: 14px; font-weight: 600; color: var(--text); margin: 8px 0 12px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line); }
.form-section:not(:first-of-type) { margin-top: 20px; }

/* ---------- cards, descriptions ---------- */
.card { --bs-card-border-color: var(--line); --bs-card-border-radius: 8px; --bs-card-bg: var(--surface); box-shadow: none; }
.card-header { background: transparent; font-weight: 600; border-bottom-color: var(--line); padding: 10px 16px; }
.card-footer { background: transparent; border-top-color: var(--line); }
.dl { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; margin-bottom: 0; }
.dl dt { background: var(--th-bg); padding: 8px 12px; margin: 0; border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line); font-weight: 500; font-size: 13px; color: var(--text); }
.dl dd { padding: 8px 12px; margin: 0; border-bottom: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.dl dt:last-of-type, .dl dd:last-of-type { border-bottom: 0; }
.card-body > .dl { margin: -4px; }
.dl dt i { color: var(--text-2); margin-right: 4px; }
.dl-2 { grid-template-columns: max-content 1fr max-content 1fr; }
.dl-2 dd.span-3 { grid-column: span 3; }
.dl-2 dt:nth-last-of-type(-n+2), .dl-2 dd:nth-last-of-type(-n+2) { border-bottom: 0; }
@media (max-width: 767.98px) { .dl-2 { grid-template-columns: max-content 1fr; } .dl-2 dd.span-3 { grid-column: auto; } }
.balance-card { overflow: hidden; }
/* Due invoices: about five rows, then the box scrolls on its own with the header kept in view (as Salesgent). */
.due-scroll { max-height: 200px; overflow-y: auto; }
.due-scroll .table thead th { position: sticky; top: 0; z-index: 1; background: var(--th-bg, var(--bs-body-bg)); }
.balance-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px;
  font-size: 20px; border-bottom: 1px solid var(--line); }
.balance-head strong { font-weight: 600; }
.balance-card .nav-tabs { --bs-nav-tabs-border-color: var(--line); }
.balance-card .nav-link { color: var(--text-2); border: 0; border-bottom: 2px solid transparent; font-size: 13px; font-weight: 600;
  text-transform: uppercase; padding: 10px 12px; }
.balance-card .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); background: transparent; }
.balance-sum { margin: 0; }
.balance-sum td { padding: 4px 16px; }
.balance-sum tr:first-child td { padding-top: 10px; }
.balance-sum tr:last-child td { padding-bottom: 10px; }

/* ---------- document tabs (invoice page, like Salesgent) ---------- */
.doc-tabs { overflow: hidden; }
.doc-tabs > .nav-tabs { padding: 0 8px; border-bottom: 1px solid var(--line); flex-wrap: nowrap; overflow-x: auto;
  scrollbar-width: none; }
.doc-tabs > .nav-tabs::-webkit-scrollbar { display: none; }
.doc-tabs > .nav-tabs .nav-link, .balance-card .nav-link { white-space: nowrap; }
.doc-tabs > .nav-tabs .nav-link { color: var(--text); border: 0; border-bottom: 2px solid transparent; font-size: 13px;
  font-weight: 500; text-transform: uppercase; padding: 12px 12px 10px; }
.doc-tabs > .nav-tabs .nav-link:hover { color: var(--brand); }
.doc-tabs > .nav-tabs .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); background: transparent; }
.tab-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 8px; }
.tab-head h2 { font-size: 16px; font-weight: 500; margin: 0; }
.summary-bar { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line); }
.summary-bar > div { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px;
  border-right: 1px solid var(--line); }
.summary-bar > div:last-child { border-right: 0; }
.summary-bar span { color: var(--text-2); font-size: 13px; }
.summary-bar strong { font-size: 18px; font-weight: 500; }
.mini-stat { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; position: relative; }
.mini-stat span { display: block; font-size: 13px; color: var(--text-2); }
.mini-stat strong { font-size: 18px; font-weight: 600; }
.mini-stat i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--brand);
  background: var(--brand-soft); border-radius: 50%; width: 30px; height: 30px; display: grid; place-items: center; }
.addr-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--th-bg); }
.timeline { list-style: none; margin: 0; padding: 12px 16px 4px 16px; }
.timeline li { position: relative; padding: 0 0 12px 18px; font-size: 13px; border-left: 2px solid var(--line); margin-left: 4px; }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--brand); background: var(--surface); }
.timeline li span { display: block; font-size: 12px; }
.btn.icon-only { width: 32px; padding-left: 0; padding-right: 0; }
@media (max-width: 575.98px) { .summary-bar { grid-template-columns: 1fr; } .summary-bar > div { border-right: 0; border-bottom: 1px solid var(--line); } }

/* ---------- tables ---------- */
.table { margin-bottom: 0; --bs-table-bg: transparent; --bs-table-hover-bg: var(--row-hover); --bs-table-border-color: var(--line);
  font-size: 13px; color: var(--text); }
.table > :not(caption) > * > * { padding: 7px 8px; border-bottom-color: var(--line); }
.table thead th { background: var(--th-bg); color: var(--text); font-weight: 600; font-size: 13px; padding: 12px 8px;
  white-space: nowrap; position: relative; text-transform: none; letter-spacing: 0; }
.table thead th + th::before { content: ""; position: absolute; left: 0; top: 50%; height: 1.6em; width: 1px;
  background: var(--line); transform: translateY(-50%); }
.table thead th a { color: inherit; text-decoration: none; }
.table thead th a:hover { color: var(--brand); }
.table-sm > :not(caption) > * > * { padding: 4px 8px; }
.card > .table-responsive > .table thead th:first-child, .card > .table thead th:first-child { border-top-left-radius: 8px; }
.card > .table-responsive > .table thead th:last-child, .card > .table thead th:last-child { border-top-right-radius: 8px; }
.num, .table td.text-end { font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
.list-tools { padding: 8px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.list-tools .search-box { position: relative; flex: 0 1 450px; }
.list-tools .search-box i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.list-tools .search-box input { padding-left: 32px; }

/* ---------- status tags ---------- */
.tag { display: inline-block; font-size: 12px; line-height: 20px; padding: 0 7px; border-radius: 4px; border: 1px solid;
  white-space: nowrap; font-weight: 400; vertical-align: middle; }
.tag-default { background: #fafafa; border-color: #d9d9d9; color: rgba(0, 0, 0, .88); }
.tag-green { background: #f6ffed; border-color: #b7eb8f; color: #389e0d; }
.tag-blue { background: #e6f4ff; border-color: #91caff; color: #0958d9; }
.tag-cyan { background: #e6fffb; border-color: #87e8de; color: #08979c; }
.tag-gold { background: #fffbe6; border-color: #ffe58f; color: #d48806; }
.tag-volcano { background: #fff2e8; border-color: #ffbb96; color: #d4380d; }
.tag-red { background: #fff1f0; border-color: #ffa39e; color: #cf1322; }
.tag-orange { background: #fff7e6; border-color: #ffd591; color: #d46b08; }
.tag-purple { background: #f9f0ff; border-color: #d3adf7; color: #531dab; }
[data-bs-theme="dark"] .tag-orange { background: #2b1d11; border-color: #593815; color: #ffa940; }
[data-bs-theme="dark"] .tag-purple { background: #1a1325; border-color: #301c4d; color: #9254de; }
[data-bs-theme="dark"] .tag-default { background: #1d1d1d; border-color: #424242; color: rgba(255, 255, 255, .85); }
[data-bs-theme="dark"] .tag-green { background: #162312; border-color: #274916; color: #73d13d; }
[data-bs-theme="dark"] .tag-blue { background: #111a2c; border-color: #15325b; color: #4096ff; }
[data-bs-theme="dark"] .tag-cyan { background: #112123; border-color: #144848; color: #36cfc9; }
[data-bs-theme="dark"] .tag-gold { background: #2b2111; border-color: #594214; color: #faad14; }
[data-bs-theme="dark"] .tag-volcano { background: #2b1611; border-color: #592716; color: #ff7a45; }
[data-bs-theme="dark"] .tag-red { background: #2a1215; border-color: #58181c; color: #ff4d4f; }

/* ---------- pagination ---------- */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 0; flex-wrap: wrap; }
.pager .info { margin-right: auto; color: var(--text-3); font-size: 13px; }
.pager a, .pager span.page { min-width: 32px; height: 32px; padding: 0 6px; border-radius: 6px; display: grid; place-items: center;
  color: var(--text); text-decoration: none; border: 1px solid transparent; font-size: 14px; }
.pager a:hover { background: rgba(0, 0, 0, .06); }
.pager span.page.current { border-color: var(--brand); color: var(--brand); font-weight: 500; }
.pager span.page.gap { color: var(--text-3); letter-spacing: 2px; }
.pager span.page.disabled { color: var(--text-3); opacity: .5; }
.pager select { width: auto; }

/* ---------- menus, modals, toasts ---------- */
.dropdown-menu { --bs-dropdown-border-radius: 8px; --bs-dropdown-border-color: transparent; --bs-dropdown-font-size: 14px;
  --bs-dropdown-link-active-bg: var(--brand-soft); --bs-dropdown-link-active-color: var(--text);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .08), 0 3px 6px -4px rgba(0, 0, 0, .12), 0 9px 28px 8px rgba(0, 0, 0, .05); padding: 4px; }
.dropdown-item { border-radius: 4px; padding: 5px 12px; }
.modal-content { border-radius: 8px; border: 0; overflow: hidden; }
.modal-header { background: var(--brand); color: #fff; padding: 12px 16px; }
.modal-header .btn-close { filter: invert(1) grayscale(1) brightness(2); }
.toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column;
  gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast-msg { pointer-events: auto; display: flex; align-items: center; gap: 8px; background: var(--surface); color: var(--text);
  padding: 9px 12px; border-radius: 8px; font-size: 14px; transition: opacity .3s, transform .3s;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .08), 0 3px 6px -4px rgba(0, 0, 0, .12), 0 9px 28px 8px rgba(0, 0, 0, .05); }
.toast-msg.hide { opacity: 0; transform: translateY(-8px); }
.toast-msg .btn-close { font-size: 10px; margin-left: 4px; }
.toast-msg.success i { color: #52c41a; } .toast-msg.danger i { color: #ff4d4f; }
.toast-msg.warning i { color: #faad14; } .toast-msg.info i { color: var(--brand); }
.alert { border-radius: 8px; }
.alert-warning { --bs-alert-bg: #fffbe6; --bs-alert-border-color: #ffe58f; --bs-alert-color: rgba(0, 0, 0, .88); }
[data-bs-theme="dark"] .alert-warning { --bs-alert-bg: #2b2111; --bs-alert-border-color: #594214; --bs-alert-color: var(--text); }

/* ---------- dashboard & charts ---------- */
.stat .label { font-size: 13px; color: var(--text-2); }
.stat .value { font-size: 24px; font-weight: 600; line-height: 1.3; margin-top: 4px; }
.stat .sub { font-size: 12px; color: var(--text-3); }
.hero .value { font-size: 34px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .bar { fill: var(--series-1); }
.chart .bar.dim { opacity: .45; }
.chart text { fill: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 8px; font-size: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
  white-space: nowrap; display: none; transform: translate(-50%, -110%); }

/* ---------- line editor & pickers ---------- */
.lines-table input.form-control, .lines-table .form-check-input { min-width: 0; }
.lines-table td { vertical-align: middle; }
.product-cell .sku { font-size: 12px; color: var(--text-3); }
.picker { position: relative; }
.picker-results { position: absolute; z-index: 1050; left: 0; right: 0; top: calc(100% + 4px); max-height: 360px; overflow-y: auto;
  background: var(--surface); border-radius: 8px; padding: 4px; display: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .08), 0 3px 6px -4px rgba(0, 0, 0, .12), 0 9px 28px 8px rgba(0, 0, 0, .05); }
.picker-results.show { display: block; }
.picker-results button { display: flex; width: 100%; text-align: left; gap: 12px; border: 0; background: none; border-radius: 4px;
  padding: 6px 12px; color: var(--text); align-items: baseline; font-size: 14px; }
.picker-results button:hover, .picker-results button.hl { background: var(--brand-soft); }
.picker-results .meta { margin-left: auto; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.totals td { padding: 3px 12px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--sider-bg); }

/* ---------- phones & tablets: menu becomes a drawer ---------- */
@media (max-width: 991.98px) {
  .sider { position: fixed; left: 0; top: 0; width: var(--sider-w-wide); transform: translateX(-100%); transition: transform .2s; }
  .sider.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  .sider-logo { justify-content: flex-start; padding: 0 20px; }
  .logo-name { display: block; }
  .sider-item { flex-direction: row; justify-content: flex-start; gap: 12px; height: 42px; padding: 0 14px; font-size: 14px; margin-bottom: 2px; }
  .sider-item .caret { display: block; margin-left: auto; font-size: 11px; }
  .sider-group.active:not(.single) > .sider-item { background: transparent; }
  .sider-sub, .sider-group:hover > .sider-sub { display: none; position: static; box-shadow: none; padding: 0 0 6px 30px;
    background: transparent; min-width: 0; }
  .sider-group.open > .sider-sub { display: block; }
  .sider-sub-title, .sider-trigger { display: none; }
  .topbar-row { padding: 8px 12px 2px; gap: 6px; }
  .search select, .search .divider { display: none; }
  .quick-links { padding: 4px 12px 8px; }
  .content { padding: 0 12px 16px; }
  .page-head { margin: 0 -12px 12px; padding: 8px 12px; }
}
@media print {
  .sider, .topbar, .no-print, .alert, .toasts { display: none !important; }
  body, .main { background: #fff; }
  .content { padding: 0; }
  .page-head { background: none; border: 0; margin: 0 0 12px; padding: 0; }
  .card { border: 0; }
}
.is-invalid-wrap .form-control, .is-invalid-wrap .form-select { border-color: var(--bs-danger); }

/* Compact document header while editing (Salesgent's edit screen): label | field pairs, two per row. */
.form-grid { display: grid; grid-template-columns: max-content 1fr max-content 1fr; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bs-body-bg); overflow: hidden; }
.form-grid > .fg-label { display: flex; align-items: center; gap: 6px; padding: 6px 12px; background: var(--th-bg, #fafafa);
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); font-weight: 500; white-space: nowrap; margin: 0; }
.form-grid > .fg-label i { color: var(--text-2); }
.form-grid > .fg-value { padding: 4px 8px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); min-width: 0; }
.form-grid > .fg-end { border-right: 0; }
.form-grid > .fg-wide { grid-column: span 3; border-right: 0; }
.form-grid .form-control, .form-grid .form-select { padding-top: 3px; padding-bottom: 3px; font-size: 13px; min-height: 30px; }
.form-grid .form-text { margin-top: 2px; }
.form-grid .fg-static { display: flex; align-items: center; min-height: 30px; }
@media (max-width: 767.98px) {
  .form-grid { grid-template-columns: max-content 1fr; }
  .form-grid > .fg-value { border-right: 0; }
  .form-grid > .fg-wide { grid-column: auto; }
}
.totals-edit td { padding: 3px 0; }
.totals-edit td:first-child { padding-right: 16px; color: var(--text-2); }
.totals-edit input { max-width: 7.5rem; margin-left: auto; text-align: right; }

/* Product page */
.product-thumb { width: 150px; margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: 6px; text-align: center; }
.product-thumb img { width: 100%; height: 120px; object-fit: contain; }
.product-thumb.main { border-color: var(--brand, #0137fc); }
.product-thumb figcaption { font-size: 12px; margin-top: 4px; color: var(--text-2); }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.picker-item { display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 2px solid var(--line); border-radius: 8px;
  background: var(--bs-body-bg); color: var(--text-2); font-size: 12px; overflow: hidden; }
.picker-item img { width: 100%; height: 120px; object-fit: contain; background: #fff; border-radius: 4px; }
.picker-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-item:hover { border-color: var(--bs-secondary-border-subtle, #adb5bd); }
.picker-item.active { border-color: var(--brand, #0137fc); }
.price-grid input { text-align: right; }
.product-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 28px; padding: 10px 16px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bs-body-bg); }
.product-strip span { display: block; font-size: 12px; color: var(--text-2); }
.product-strip strong { font-size: 16px; font-weight: 600; }
.product-strip-img { width: 44px; height: 44px; object-fit: contain; border-radius: 6px; }

/* Product categories tree (like Salesgent's Categories tab) */
.cat-tree-list { list-style: none; margin: 0; padding-left: 22px; }
.cat-tree-row { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.cat-tree-row .form-check-input { margin: 0; flex: none; }
.cat-tree-row > .form-check-label { cursor: pointer; }
.cat-tree-toggle { width: 20px; height: 20px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: none; padding: 0; color: var(--text-2); font-size: 11px; }
.cat-tree-toggle i { transition: transform .15s; }
li[aria-expanded=true] > .cat-tree-row .cat-tree-toggle i { transform: rotate(90deg); }
.cat-tree-main { display: none; align-items: center; gap: 4px; margin-left: 4px; color: var(--text-2); cursor: pointer; }
.cat-tree-row:has(> input:checked) .cat-tree-main { display: inline-flex; }
.cat-tree-main:has(input:checked) { color: var(--bs-primary); font-weight: 600; }
.cat-tree li.cat-hidden { display: none; }

/* Row selection + Actions menu on lists (products) */
.d-contents { display: contents; }
.select-col { width: 36px; padding-right: 0 !important; }
.select-hit { display: flex; align-items: center; justify-content: center; margin: -8px; padding: 8px; cursor: pointer; }
.bulk-toast { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1090; box-shadow: 0 4px 12px rgba(0,0,0,.15); }

/* Advance Search ("Select Products") dialog on order / invoice / PO forms */
.btn-advance { color: #fff; background: linear-gradient(90deg, #7b2ff7, #4f46e5); border: 0; }
.btn-advance:hover, .btn-advance:focus { color: #fff; filter: brightness(1.08); }
.adv-head { background: var(--bs-primary); color: #fff; }
.adv-table-wrap { max-height: calc(100vh - 380px); overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.adv-table-wrap thead th { position: sticky; top: 0; background: var(--th-bg); z-index: 1; }
.adv-added .adv-table-wrap { border: 0; border-radius: 0; }
.adv-added tfoot td { position: sticky; bottom: 0; background: var(--th-bg); }
.adv-img { width: 40px; height: 40px; object-fit: contain; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; }
.adv-noimg { background: var(--th-bg); color: var(--text-2); }
.adv-pager { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 8px; }
.adv-pager .page-link { min-width: 2rem; text-align: center; }

/* Invoice / order line editor: info popover with recent invoices, row actions */
.line-info-popover { max-width: 440px; }
.line-info-popover .table { --bs-table-bg: transparent; }
.lines-table .icon-only { padding: .15rem .4rem; }

/* Column-header filters on lists (as Salesgent): magnifier / calendar / funnel next to the column name */
.th-wrap { display: inline-flex; align-items: center; gap: 6px; }
.col-filter-btn { color: var(--text-2); font-size: 12px; line-height: 1; text-decoration: none; }
.col-filter-btn:hover, .col-filter-btn.active { color: var(--bs-primary); }
.col-filter-menu { min-width: 220px; font-weight: normal; text-align: left; }
.col-filter-list { max-height: 260px; overflow: auto; }

/* Financial statements */
.report .report-group th { font-size: 15px; padding-top: 14px; border-bottom: 1px solid var(--line); }
.report .report-section th { font-weight: 600; color: var(--text-2); padding-top: 10px; }
.report .report-total td { font-weight: 600; border-top: 1px solid var(--line); }
.report .report-grand td { font-size: 16px; border-top: 2px solid var(--text); }
@media print { .sider, .topbar, .quick-links { display: none !important; } .report { max-width: none !important; border: 0; } }
