.crm-purchases-page{padding-top:18px}.purchase-page-heading{align-items:end;gap:20px}.purchase-toolbar{display:flex;align-items:end;gap:12px;margin-left:auto}.purchase-actions,.purchase-actions form,.purchase-filters{display:flex;gap:10px}.purchase-actions{align-items:center}.purchase-actions .button{height:44px;white-space:nowrap}.purchase-result{max-width:300px;padding:9px 12px;border-radius:10px;background:#eff6ff;color:#1d4ed8;font-size:13px;font-weight:700}.purchase-result.error{background:#fff1f2;color:#be123c}.purchase-filters label{display:grid;gap:5px;color:var(--muted);font-size:12px;font-weight:700}.purchase-filters select{min-width:180px;height:44px;border:1px solid var(--line);border-radius:12px;background:var(--card);color:var(--text);padding:0 36px 0 12px}.purchase-counters{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px;margin:14px 0}.purchase-counters>span{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:13px 15px;border:1px solid var(--line);border-radius:14px;background:var(--card)}.purchase-counters small{color:var(--muted);font-weight:700}.purchase-counters strong{font-size:22px}.purchase-counters .attention strong{color:#b45309}.purchase-layout{display:grid;grid-template-columns:minmax(310px,390px) minmax(0,1fr);gap:14px;align-items:start}.purchase-list{padding:0;overflow:hidden}.purchase-list-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:5px 10px;padding:13px 15px;border-bottom:1px solid var(--line);color:var(--text);text-decoration:none;transition:background .18s ease}.purchase-list-row:hover,.purchase-list-row.selected{background:#eff6ff}.purchase-list-row>span:first-child{min-width:0}.purchase-list-row strong,.purchase-list-row small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.purchase-list-row small,.purchase-list-row time{color:var(--muted);font-size:12px}.purchase-list-row time{grid-column:2}.purchase-status{align-self:start;border-radius:999px;background:#eef2f7;color:#475569;padding:4px 8px;font-size:12px;font-style:normal;font-weight:800}.purchase-status.transit{background:#e0f2fe;color:#0369a1}.purchase-status.production{background:#ede9fe;color:#6d28d9}.purchase-status.arrived{background:#dcfce7;color:#15803d}.purchase-status.attention{background:#fff7ed;color:#c2410c}.purchase-detail{padding:20px}.purchase-detail-header{display:flex;align-items:flex-start;justify-content:space-between;gap:20px}.purchase-detail-header h2{margin:5px 0 10px}.purchase-detail-links{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}.purchase-facts{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:1px;margin:18px 0;background:var(--line);border:1px solid var(--line);border-radius:14px;overflow:hidden}.purchase-facts div{padding:12px;background:var(--card)}.purchase-facts dt,.purchase-totals small{color:var(--muted);font-size:11px;font-weight:800;text-transform:uppercase}.purchase-facts dd{margin:4px 0 0;font-weight:700}.purchase-totals{display:flex;gap:10px;margin:14px 0}.purchase-totals span{min-width:160px;padding:12px 14px;border-radius:12px;background:#f1f5f9}.purchase-totals small,.purchase-totals strong{display:block}.purchase-totals strong{margin-top:4px;font-size:20px}.purchase-detail table{width:100%;border-collapse:collapse}.purchase-detail th,.purchase-detail td{padding:9px;border:1px solid var(--line);text-align:left}.purchase-detail th:nth-child(n+3),.purchase-detail td:nth-child(n+3){text-align:center}.purchase-issues{margin:14px 0;padding:12px 14px;border:1px solid #fed7aa;border-radius:12px;background:#fff7ed}.purchase-issues ul{margin:7px 0 0;padding-left:20px}.purchase-empty{display:grid;place-content:center;gap:6px;min-height:160px;padding:24px;text-align:center;color:var(--muted)}.purchase-empty strong{color:var(--text);font-size:18px}
@media(max-width:900px){.crm-purchases-page{padding:12px}.purchase-page-heading{display:block}.purchase-page-heading h1{margin-bottom:10px}.purchase-toolbar{display:grid;margin:0}.purchase-actions{flex-wrap:wrap}.purchase-filters{display:grid;grid-template-columns:1fr 1fr}.purchase-filters select{width:100%;min-width:0}.purchase-counters{display:flex;overflow-x:auto;scrollbar-width:none}.purchase-counters>span{min-width:145px}.purchase-layout{grid-template-columns:1fr}.purchase-detail-header{display:block}.purchase-detail-links{justify-content:flex-start;margin-top:12px}.purchase-facts{grid-template-columns:1fr 1fr}.purchase-list-row{min-height:58px}.purchase-detail{padding:15px}}
@media(max-width:540px){.purchase-filters{grid-template-columns:1fr}.purchase-facts{grid-template-columns:1fr 1fr}.purchase-totals{display:grid;grid-template-columns:1fr 1fr}.purchase-totals span{min-width:0}.purchase-detail-links .button{flex:1;text-align:center}.purchase-detail h2{font-size:20px}}
:root[data-theme="dark"] .purchase-list-row:hover,:root[data-theme="dark"] .purchase-list-row.selected,:root[data-theme="dark"] .purchase-totals span{background:#171717}:root[data-theme="dark"] .purchase-issues{border-color:#713f12;background:#1c1208}:root[data-theme="dark"] .purchase-status{background:#202020;color:#fff}:root[data-theme="dark"] .purchase-status.transit{background:#082f49}:root[data-theme="dark"] .purchase-status.production{background:#2e1065}:root[data-theme="dark"] .purchase-status.arrived{background:#052e16}:root[data-theme="dark"] .purchase-status.attention{background:#431407}
.purchase-sync-badge{display:inline-flex;margin-top:6px;padding:2px 7px;border:1px solid #86efac;border-radius:999px;color:#15803d;font-size:11px;font-style:normal;font-weight:800}.purchase-detail-action{display:flex}.purchase-detail-action .button.danger{border-color:#fecaca;background:#fff;color:#b91c1c}:root[data-theme="dark"] .purchase-sync-badge{border-color:#166534;color:#86efac}:root[data-theme="dark"] .purchase-detail-action .button.danger{background:#2b1015;color:#fecdd3}
.receipt-source-tabs { margin-bottom:18px; }
.receipt-source-tabs b { font-size:12px; font-variant-numeric:tabular-nums; }
.receipt-guide-steps { padding-left:24px; }
.receipt-guide-steps li { margin:20px 0; padding-left:6px; }
.receipt-guide-steps h3 { margin:0 0 6px; }
.receipt-guide-steps p { margin:0; }
.receipt-help p { max-width:75ch; }
.supplier-help-links { justify-content:flex-start; }
.supplier-help h2:not(:first-child) { margin-top:24px; }
.supplier-help-table { width:100%; min-width:550px; border-collapse:collapse; }
.supplier-help-table :is(th,td) { padding:9px; border-bottom:1px solid var(--line); text-align:left; vertical-align:top; }
.receipt-list .receipt-source { max-width:100%; width:auto; white-space:normal; }
.receipt-list .receipt-state-tabs a { white-space:normal; min-height:44px; }
.roll-cut-toolbar {
  display:flex;
  justify-content:flex-end;
  margin:0 0 16px;
}
.roll-cut-toolbar .receipt-expense-action {
  display:inline-flex;
  align-items:center;
  min-height:44px;
}
.roll-cut-history:not(.has-selection) { grid-template-columns:minmax(0, 1fr); }
.cut-history-list > .crm-heading {
  flex-direction:row;
  align-items:baseline;
  justify-content:flex-start;
  gap:12px;
  margin-bottom:12px;
}
.cut-history-list .crm-heading h2 { margin:0; }
.cut-history-list .crm-heading > span {
  color:var(--muted);
  font-weight:700;
  font-variant-numeric:tabular-nums;
}
.cut-history-table-wrap {
  container-type:inline-size;
  overflow:hidden;
  border:1px solid var(--line);
  border-radius:12px;
}
.cut-history-table {
  table-layout:fixed;
  border-collapse:separate;
  border-spacing:0;
  font-size:14px;
  line-height:1.3;
  overflow-wrap:anywhere;
}
.cut-history-table :is(th, td) {
  padding:8px 12px;
  vertical-align:middle;
}
.cut-history-table :is(th, td) + :is(th, td) { border-inline-start:1px solid var(--line); }
.cut-history-table th {
  background:color-mix(in srgb, var(--bg) 72%, var(--card));
  font-size:13px;
}
.cut-history-table th:first-child { width:20%; }
.cut-history-table th:nth-child(3) { width:42px; }
.cut-history-table th:last-child { width:15%; }
.cut-history-table tbody tr { position:relative; }
.cut-history-table tbody tr:last-child td { border-bottom:0; }
.cut-history-table tbody tr:is(:hover, :has(a[aria-current])) {
  background:color-mix(in srgb, var(--blue) 7%, var(--card));
}
.cut-history-who a { color:inherit; }
.cut-history-who a:hover { text-decoration:none; }
.cut-history-who a::after {
  position:absolute;
  inset:0;
  content:"";
}
.cut-history-who a:focus-visible { outline:0; }
.cut-history-who a:focus-visible::after {
  outline:2px solid var(--blue);
  outline-offset:-2px;
}
.cut-history-who strong { font-variant-numeric:tabular-nums; }
.cut-history-manager, .cut-history-product small {
  display:block;
  margin-top:2px;
  color:var(--muted);
  font-size:12px;
}
.cut-history-label { display:none; }
.cut-history-product {
  display:grid;
  grid-template-columns:fit-content(50%) minmax(0, 1fr);
  align-items:center;
  gap:8px;
}
.cut-history-product + .cut-history-product { margin-top:5px; }
.cut-history-product > b {
  min-width:3ch;
  font-size:21px;
  font-variant-numeric:tabular-nums;
}
.cut-history-spent .cut-history-product > b { color:#a74c2b; }
.cut-history-received .cut-history-product > b { color:#12487c; }
:root[data-theme="dark"] .cut-history-spent .cut-history-product > b { color:#f5a481; }
:root[data-theme="dark"] .cut-history-received .cut-history-product > b { color:#91c5ff; }
:root[data-theme="dark"] .cut-history-manager,
:root[data-theme="dark"] .cut-history-product small { color:#aeb8c6; }
.cut-history-table .cut-history-arrow {
  padding-inline:0;
  color:var(--muted);
  font-size:19px;
  text-align:center;
}
.cut-history-state .receipt-status {
  width:auto;
  max-width:100%;
}
.cut-history-state .receipt-status.done {
  align-items:center;
  gap:7px;
  padding:0;
  background:none;
  color:var(--text);
  font-size:13px;
  font-weight:500;
}
.cut-history-state .receipt-status.done::before {
  flex:none;
  width:8px;
  height:8px;
  border-radius:50%;
  background:var(--green);
  content:"";
}
@container (max-width:39rem) {
  .cut-history-table, .cut-history-table tbody { display:block; }
  .cut-history-table thead {
    position:absolute;
    width:1px;
    height:1px;
    overflow:hidden;
    clip-path:inset(50%);
  }
  .cut-history-table tbody tr {
    display:grid;
    grid-template-columns:minmax(0, 1fr) minmax(0, 40%);
    gap:6px 10px;
    padding:9px 10px;
    border-bottom:1px solid var(--line);
  }
  .cut-history-table tbody tr:last-child { border-bottom:0; }
  .cut-history-table tbody td {
    min-width:0;
    padding:0;
    border:0;
  }
  .cut-history-state {
    grid-column:2;
    grid-row:1;
    justify-self:end;
  }
  .cut-history-spent, .cut-history-received {
    display:grid;
    grid-column:1 / -1;
    grid-template-columns:4.25rem minmax(0, 1fr);
    align-items:baseline;
    gap:6px;
  }
  .cut-history-label {
    display:block;
    color:var(--muted);
    font-size:12px;
    font-weight:700;
  }
  .cut-history-arrow { display:none; }
}
.roll-cut-card {
  display:block;
  min-width:0;
  container-type:inline-size;
  overflow-wrap:anywhere;
  font-size:14px;
  line-height:1.35;
}
.roll-cut-history-item {
  margin:6px 0;
  padding:9px 12px;
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--card);
  color:var(--text);
}
.roll-cut-history-item:is(:hover, .selected) {
  border-color:var(--blue);
  color:var(--text);
  text-decoration:none;
}
.roll-cut-history-item:focus-visible {
  outline:2px solid var(--blue);
  outline-offset:-2px;
}
.roll-cut-card-header {
  display:grid;
  grid-template-columns:fit-content(45%) minmax(10rem, 1fr) auto;
  align-items:center;
  gap:4px 12px;
  padding-bottom:7px;
  border-bottom:1px solid var(--line);
}
.roll-cut-card-header > :is(strong, h2) {
  margin:0;
  font-size:14px;
  line-height:inherit;
}
.roll-cut-card-meta, .roll-cut-audit {
  color:var(--muted);
  font-size:12px;
}
.roll-cut-card .receipt-status {
  grid-column:auto;
  width:auto;
  max-width:20ch;
  padding:3px 7px;
}
.roll-cut-card-movements {
  display:grid;
  grid-template-columns:minmax(0, 1fr) auto minmax(0, 1fr);
  align-items:start;
  gap:4px 12px;
  padding-top:7px;
}
.roll-cut-card-movements.expense {
  grid-template-columns:minmax(0, 1fr) minmax(0, 1fr);
}
.roll-cut-movement-group {
  display:grid;
  grid-template-columns:max-content minmax(0, 1fr);
  align-items:baseline;
  gap:3px 8px;
}
.roll-cut-movement-group > :first-child,
.roll-cut-movement-item > span,
.roll-cut-reason-text > b {
  color:var(--muted);
  font-size:12px;
}
.roll-cut-movement-group > :first-child { font-weight:700; }
.roll-cut-movement-item { grid-column:2; }
.roll-cut-movement-item > a { font-size:12px; }
.roll-cut-movement-arrow { color:var(--muted); }
.roll-cut-audit {
  display:block;
  margin-top:4px;
}
@container (max-width:36rem) {
  .roll-cut-card-header {
    grid-template-columns:minmax(0, 1fr) auto;
    column-gap:8px;
  }
  .roll-cut-card-header > :is(strong, h2) { grid-column:1; }
  .roll-cut-card .receipt-status {
    grid-column:2;
    grid-row:1 / span 2;
    max-width:14ch;
  }
}
@container (max-width:27rem) {
  .roll-cut-card-movements,
  .roll-cut-card-movements.expense {
    grid-template-columns:minmax(0, 1fr);
  }
  .roll-cut-movement-arrow {
    justify-self:start;
    transform:rotate(90deg);
  }
}
@media (max-width:1000px) {
  .roll-cut-history .receipt-detail { order:-1; }
}
.roll-cut-dialog {
  box-sizing:border-box;
  width:min(850px, calc(100vw - 40px));
  max-height:calc(100dvh - 40px);
  padding:24px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--card);
  color:var(--text);
  overflow:auto;
}
.roll-cut-dialog::backdrop { background:rgb(15 23 42 / 45%); }
.roll-cut-heading {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:24px;
}
.roll-cut-heading h2 { margin:0 0 6px; }
.roll-cut-heading p { margin:0; }
.roll-cut-heading button { flex-shrink:0; }
.roll-cut-reason {
  border:0;
  padding:0;
  margin:0 0 20px;
  min-width:0;
}
.roll-cut-dialog textarea {
  box-sizing:border-box;
  width:100%;
  margin-top:6px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:10px;
  font:inherit;
  font-size:16px;
  color:var(--text);
  background:var(--card);
  resize:vertical;
  min-height:72px;
}
.material-products [data-material-rows] { display:grid; gap:12px; margin-bottom:12px; }
.material-add { display:inline-flex; align-items:center; gap:8px; min-height:44px; margin:0 0 16px; }
[data-material-use="true"] .roll-cut-products { grid-template-columns:minmax(0, 1fr); }
.material-heading h3 { margin:0 0 12px; font-size:18px; }
.material-columns,
[data-material-use="true"] .roll-cut-product {
  display:grid;
  grid-template-columns:140px minmax(0, 1fr) 90px 44px;
  gap:10px;
  align-items:start;
}
.material-columns { margin-bottom:6px; font-size:13px; color:var(--muted); }
[data-material-use="true"] .roll-cut-products { margin-bottom:12px; }
[data-material-use="true"] .roll-cut-product-fields { display:contents; }
[data-material-use="true"] .roll-cut-product :is(legend, [data-cut-search-label], [data-cut-unit]) { display:none; }
[data-material-use="true"] .roll-cut-product-fields label:first-child { grid-column:1; grid-row:1; }
[data-material-use="true"] .roll-cut-product-fields label:nth-child(2) { grid-column:3; grid-row:1; }
[data-material-use="true"] .roll-cut-product input { margin-top:0; }
[data-material-use="true"] .roll-cut-remove { grid-column:4; grid-row:1; align-self:start; }
[data-material-use="true"] .roll-cut-selected {
  grid-column:2;
  grid-row:1;
  margin:0;
  padding:10px 0;
  min-width:0;
  font-size:14px;
  line-height:1.5;
  color:var(--text);
}
[data-material-use="true"] .roll-cut-results { grid-column:1 / -1; grid-row:2; margin-top:0; }
.roll-cut-summary { overflow-wrap:anywhere; }
.roll-cut-products {
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:20px;
}
.roll-cut-product {
  min-width:0;
  padding:0;
  border:0;
  margin:0;
}
.roll-cut-product legend {
  margin-bottom:12px;
  font-size:18px;
  font-weight:700;
}
.roll-cut-targets {
  display:grid;
  align-content:start;
  gap:20px;
  min-width:0;
}
.roll-cut-add,
.roll-cut-remove { min-height:44px; margin:0; }
.roll-cut-add { justify-self:start; }
.roll-cut-add[hidden] { display:none; }
.roll-cut-product-fields.has-remove { grid-template-columns:minmax(0, 1fr) 90px 44px; }
.roll-cut-remove { align-self:end; padding:0; font-size:18px; }
.roll-cut-product-fields {
  display:grid;
  grid-template-columns:minmax(0, 1fr) 90px;
  gap:10px;
  margin-top:0;
}
.roll-cut-product select[hidden] { display:none; }
.roll-cut-results:not([hidden]) {
  display:grid;
  max-height:240px;
  overflow-y:auto;
  margin-top:8px;
  border:1px solid var(--line);
  border-radius:10px;
}
.roll-cut-results button {
  min-height:44px;
  margin:0;
  padding:10px 12px;
  border:0;
  border-bottom:1px solid var(--line);
  border-radius:0;
  background:var(--card);
  color:var(--text);
  text-align:left;
  font-size:14px;
  font-weight:500;
  line-height:1.4;
  overflow-wrap:anywhere;
}
.roll-cut-results button:last-child { border-bottom:0; }
.roll-cut-results button:is(:hover, :focus-visible) {
  background:var(--bg);
  outline:2px solid var(--blue);
  outline-offset:-2px;
}
.roll-cut-dialog :is(input, select) {
  box-sizing:border-box;
  width:100%;
  min-width:0;
  min-height:44px;
  margin-top:6px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:10px;
  font-size:16px;
  background:var(--card);
  color:var(--text);
}
.roll-cut-dialog label { display:block; font-size:13px; }
.roll-cut-selected {
  margin:8px 0 16px;
  overflow-wrap:anywhere;
  font-size:13px;
  color:var(--muted);
}
.roll-cut-summary {
  padding:14px 0;
  border-top:1px solid var(--line);
  line-height:1.6;
  white-space:pre-line;
  font-weight:600;
}
.roll-cut-actions { display:flex; justify-content:flex-end; padding-top:6px; }
.roll-cut-actions button { min-height:44px; }
@media (max-width:640px) {
  .material-columns,
  [data-material-use="true"] .roll-cut-product {
    grid-template-columns:80px minmax(0, 1fr) 58px 44px;
    gap:6px;
  }
  [data-material-use="true"] .roll-cut-product input { padding:10px 8px; }
  .roll-cut-dialog {
    width:100%;
    height:100dvh;
    max-width:100%;
    max-height:100dvh;
    margin:0;
    padding:20px 16px max(20px, env(safe-area-inset-bottom));
    border-radius:0;
  }
  .roll-cut-products { grid-template-columns:minmax(0, 1fr); gap:8px; }
  .roll-cut-targets { gap:8px; margin-bottom:16px; }
  .roll-cut-heading { margin-bottom:20px; }
  .roll-cut-heading h2 { font-size:22px; }
  .roll-cut-actions button { width:100%; }
}

.crm-purchase-history-controls {
  display:flex;
  flex-wrap:wrap;
  align-items:flex-start;
  gap:10px 16px;
}
.crm-purchase-history-controls [hidden] { display:none; }
.crm-purchase-history-controls .crm-client-history-switch { max-width:100%; flex-wrap:wrap; }
.crm-purchase-history-controls .crm-client-history-switch button { min-height:38px; }
.crm-purchase-history-sources { min-width:0; align-self:center; overflow-wrap:anywhere; }
.crm-purchase-history-sources summary { cursor:pointer; color:var(--text); font-size:13px; font-weight:700; }
.crm-purchase-history-sources p { margin:8px 0; }
.crm-purchase-history-sources li { margin-bottom:5px; }
#combined-purchases .crm-client-purchase-brief { grid-template-columns:repeat(2,minmax(0,1fr)); }
#combined-purchases .crm-client-purchase-brief > div { min-width:0; overflow-wrap:anywhere; }
#combined-purchases [data-client-history-summary] p { margin:8px 0 0; }
.crm-purchase-history-metrics { margin-top:12px; }
.crm-purchase-history-metrics:not([hidden]) { display:flex; }
.crm-purchase-history-layout:not(:has([data-client-history-series]:not([hidden]))) { grid-template-columns:1fr; }
.crm-purchase-history-layout [data-client-history-series] { min-width:0; overflow-wrap:anywhere; }
.crm-purchase-history-layout .crm-client-directory-series { flex-wrap:wrap; gap:8px; }
.crm-purchase-history-chart { min-height:0; }
.crm-purchase-history-chart [data-client-history-fallback] .crm-column-chart { height:230px; }
.crm-purchase-history-chart [data-client-history-keyboard]:focus-visible {
  outline:2px solid var(--blue);
  outline-offset:3px;
}
