
:root {
  --ap-bg: #f4f7fb;
  --ap-card: #ffffff;
  --ap-border: #dce5ef;
  --ap-text: #172033;
  --ap-muted: #6b7a90;
  --ap-primary: #176b87;
  --ap-primary-soft: #e8f4f7;
  --ap-success: #157a55;
  --ap-danger: #b23838;
  --ap-warning: #9a6414;
  --ap-shadow: 0 14px 36px rgba(15, 23, 42, .08);
}

body.ap-procurement-open {
  overflow: hidden !important;
}

body.ap-procurement-open #root .asseta-page > .main {
  display: none !important;
}

body.ap-procurement-open > #ap-app {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: var(--asseta-sidebar-live-width, 82px) !important;
  z-index: 2147483000 !important;

  width: calc(100vw - var(--asseta-sidebar-live-width, 82px)) !important;
  min-width: 0 !important;
  max-width: calc(100vw - var(--asseta-sidebar-live-width, 82px)) !important;
  height: 100vh !important;

  overflow: auto !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  padding: 0 !important;

  color: var(--ap-text);
  background: var(--ap-bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

#ap-app *,
#ap-app *::before,
#ap-app *::after {
  box-sizing: border-box;
}

.ap-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--ap-border);
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(12px);
}

.ap-topbar h1 {
  margin: 0;
  color: var(--ap-text);
  font-size: 20px;
  line-height: 1.2;
}

.ap-topbar p {
  margin: 4px 0 0;
  color: var(--ap-muted);
  font-size: 11px;
}

.ap-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.ap-content {
  width: 100%;
  min-width: 0;
  max-width: none;
  padding: 16px 18px 36px;
}

.ap-card {
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--ap-border);
  border-radius: 14px;
  background: var(--ap-card);
  box-shadow: var(--ap-shadow);
}

.ap-inner-card {
  margin-top: 14px;
  margin-bottom: 0;
  box-shadow: none;
}

.ap-card-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--ap-border);
}

.ap-card-head h2,
.ap-card-head h3 {
  margin: 0;
  color: var(--ap-text);
  font-size: 14px;
}

.ap-card-head p {
  margin: 3px 0 0;
  color: var(--ap-muted);
  font-size: 10px;
}

.ap-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.ap-kpi {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--ap-border);
  border-radius: 14px;
  background: var(--ap-card);
  box-shadow: var(--ap-shadow);
}

.ap-kpi span {
  display: block;
  color: var(--ap-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.ap-kpi strong {
  display: block;
  margin: 6px 0 3px;
  color: var(--ap-text);
  font-size: 27px;
  line-height: 1;
}

.ap-kpi small {
  color: var(--ap-primary);
  font-size: 10px;
  font-weight: 700;
}

.ap-flow {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 14px;
}

.ap-flow-step {
  position: relative;
  min-height: 74px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  gap: 2px 9px;
  padding: 10px;
  border: 1px solid var(--ap-border);
  border-radius: 13px;
  color: var(--ap-text);
  background: var(--ap-card);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 7px 18px rgba(15, 23, 42, .05);
  transition: transform .14s ease, border-color .14s ease;
}

.ap-flow-step:hover {
  transform: translateY(-2px);
  border-color: #a9cbd7;
}

.ap-flow-step > span {
  grid-row: 1 / 3;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--ap-primary);
  font-size: 11px;
  font-weight: 900;
}

.ap-flow-step strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.ap-flow-step small {
  color: var(--ap-muted);
  font-size: 10px;
}

.ap-btn,
.ap-icon-btn,
.ap-link,
.ap-close,
.ap-remove-line {
  font: inherit;
}

.ap-btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid #cbd7e4;
  border-radius: 9px;
  color: #26374b;
  background: #fff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  transition: background .14s ease, transform .14s ease, border-color .14s ease;
}

.ap-btn:hover {
  transform: translateY(-1px);
  background: #f7fafc;
  border-color: #aab9c9;
}

.ap-btn.ap-primary {
  border-color: var(--ap-primary);
  color: #fff;
  background: var(--ap-primary);
}

.ap-btn.ap-primary-soft {
  border-color: #bedce5;
  color: #0f5b74;
  background: var(--ap-primary-soft);
}

.ap-icon-btn {
  min-height: 29px;
  padding: 5px 8px;
  border: 1px solid #d6e0ea;
  border-radius: 8px;
  color: #415469;
  background: #fff;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.ap-icon-btn:hover {
  color: var(--ap-primary);
  border-color: #abcbd6;
  background: #f4fafb;
}

.ap-success-text {
  color: var(--ap-success);
}

.ap-danger-text {
  color: var(--ap-danger);
}

.ap-post-text {
  color: #4d3c9a;
}

.ap-link {
  padding: 0;
  border: 0;
  color: var(--ap-primary);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
  text-align: left;
}

.ap-link:hover {
  text-decoration: underline;
}

.ap-filterbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 9px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--ap-border);
}

.ap-filterbar-docs {
  grid-template-columns: minmax(260px, 1fr) 190px auto;
}

.ap-input,
.ap-select,
.ap-textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cbd7e4;
  border-radius: 9px;
  color: var(--ap-text);
  background: #fff;
  font: inherit;
  font-size: 11px;
  outline: none;
}

.ap-input,
.ap-select {
  min-height: 36px;
  padding: 7px 9px;
}

.ap-textarea {
  min-height: 74px;
  padding: 9px;
  resize: vertical;
}

.ap-input:focus,
.ap-select:focus,
.ap-textarea:focus {
  border-color: var(--ap-primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, .10);
}

.ap-compact-select {
  width: min(300px, 100%);
}

.ap-multi {
  min-height: 108px;
}

.ap-table-wrap {
  width: 100%;
  overflow: auto;
}

.ap-table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 10px;
}

.ap-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 10px;
  border-bottom: 1px solid var(--ap-border);
  color: #506176;
  background: #f7f9fc;
  font-weight: 850;
  text-align: left;
}

.ap-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #edf1f6;
  color: #2f3f52;
  vertical-align: middle;
}

.ap-table tr:last-child td {
  border-bottom: 0;
}

.ap-table tbody tr:hover td {
  background: #fbfdff;
}

.ap-table td strong {
  display: block;
  color: var(--ap-text);
  font-size: 10px;
}

.ap-table td small {
  display: block;
  margin-top: 2px;
  color: var(--ap-muted);
  font-size: 9px;
}

.ap-row-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ap-number {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.ap-number-input {
  min-width: 88px;
  text-align: right;
}

.ap-strong {
  color: var(--ap-text) !important;
  font-weight: 900;
}

.ap-code {
  color: #31506a;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
}

.ap-empty-cell,
.ap-empty-inline {
  padding: 24px !important;
  color: var(--ap-muted) !important;
  text-align: center !important;
}

.ap-empty-inline {
  border: 1px dashed #cbd7e4;
  border-radius: 12px;
  background: #fafcff;
}

.ap-badge,
.ap-type {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .02em;
}

.ap-type {
  color: #36536a;
  background: #edf3f7;
}

.ap-badge {
  color: #495b70;
  background: #edf2f7;
}

.ap-approved,
.ap-posted,
.ap-paid,
.ap-active,
.ap-stock,
.ap-received,
.ap-invoiced {
  color: #0f704b;
  background: #e6f6ef;
}

.ap-submitted,
.ap-partially_received,
.ap-partially_invoiced,
.ap-partially_paid {
  color: #8a580d;
  background: #fff3d9;
}

.ap-rejected,
.ap-cancelled,
.ap-inactive {
  color: #a12f2f;
  background: #fdeaea;
}

.ap-draft,
.ap-service {
  color: #4d5f74;
  background: #edf2f7;
}

.ap-loading {
  min-height: 280px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--ap-muted);
}

.ap-loading span {
  width: 34px;
  height: 34px;
  border: 3px solid #d8e6ec;
  border-top-color: var(--ap-primary);
  border-radius: 50%;
  animation: ap-spin .7s linear infinite;
}

@keyframes ap-spin {
  to { transform: rotate(360deg); }
}

.ap-empty {
  min-height: 240px;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 28px;
  text-align: center;
}

.ap-empty strong {
  font-size: 15px;
}

.ap-empty p {
  max-width: 560px;
  color: var(--ap-muted);
  font-size: 11px;
}

.ap-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2147483500;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .56);
}

.ap-modal {
  width: min(720px, 97vw);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(15, 23, 42, .34);
}

.ap-modal-lg {
  width: min(900px, 97vw);
}

.ap-modal-xl {
  width: min(1180px, 98vw);
}

.ap-modal-xxl {
  width: min(1480px, 99vw);
}

.ap-modal-head {
  flex: 0 0 auto;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--ap-border);
}

.ap-modal-head h2 {
  margin: 0;
  font-size: 16px;
}

.ap-modal-head p {
  margin: 4px 0 0;
  color: var(--ap-muted);
  font-size: 10px;
}

.ap-close,
.ap-remove-line {
  width: 31px;
  min-width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  color: #526274;
  background: #eef3f7;
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
}

.ap-remove-line {
  width: 26px;
  min-width: 26px;
  height: 26px;
  color: var(--ap-danger);
  background: #fdeeee;
  font-size: 16px;
}

.ap-modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.ap-modal-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 11px 14px;
  border-top: 1px solid var(--ap-border);
  background: #fbfcfe;
}

.ap-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.ap-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ap-field > span {
  color: #4d5e72;
  font-size: 10px;
  font-weight: 800;
}

.ap-wide {
  grid-column: 1 / -1;
}

.ap-check {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #3f5064;
  font-size: 10px;
  font-weight: 800;
}

.ap-line-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 15px;
  padding: 10px 0;
}

.ap-line-toolbar h3 {
  margin: 0;
  font-size: 13px;
}

.ap-line-toolbar p {
  margin: 3px 0 0;
  color: var(--ap-muted);
  font-size: 9px;
}

.ap-line-toolbar > div:last-child {
  display: flex;
  align-items: center;
  gap: 7px;
}

.ap-lines-table {
  min-width: 1280px;
}

.ap-lines-table .ap-line-item {
  min-width: 220px;
}

.ap-lines-table .ap-line-description {
  min-width: 230px;
}

.ap-lines-table .ap-line-uom {
  min-width: 95px;
}

.ap-lines-table .ap-line-tax,
.ap-lines-table .ap-line-cost-code {
  min-width: 150px;
}

.ap-document-totals {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 0;
}

.ap-document-totals > div {
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--ap-border);
  border-radius: 11px;
  background: #f9fbfd;
}

.ap-document-totals span {
  display: block;
  color: var(--ap-muted);
  font-size: 8px;
  font-weight: 750;
  text-transform: uppercase;
}

.ap-document-totals strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ap-text);
  font-size: 12px;
  white-space: nowrap;
}

.ap-edit-totals {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-width: 720px;
  margin-left: auto;
}

.ap-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.ap-detail-grid > div {
  padding: 9px;
  border: 1px solid var(--ap-border);
  border-radius: 10px;
  background: #fbfcfe;
}

.ap-detail-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--ap-muted);
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
}

.ap-detail-grid strong {
  color: var(--ap-text);
  font-size: 10px;
}

.ap-report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.ap-toast-host {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 2147483640;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ap-toast {
  min-width: 240px;
  max-width: 420px;
  padding: 10px 13px;
  border-radius: 10px;
  color: #fff;
  background: #172033;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .3);
  font-size: 10px;
  font-weight: 800;
}

.ap-toast.is-error {
  background: var(--ap-danger);
}

@media (max-width: 1250px) {
  .ap-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ap-flow {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ap-report-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  body.ap-procurement-open > #ap-app {
    left: 76px !important;
    width: calc(100vw - 76px) !important;
    max-width: calc(100vw - 76px) !important;
  }

  .ap-topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 11px 13px;
  }

  .ap-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .ap-content {
    padding: 12px;
  }

  .ap-form-grid,
  .ap-detail-grid,
  .ap-document-totals,
  .ap-edit-totals {
    grid-template-columns: 1fr;
  }

  .ap-wide {
    grid-column: auto;
  }

  .ap-filterbar,
  .ap-filterbar-docs {
    grid-template-columns: 1fr;
  }

  .ap-line-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .ap-kpi-grid,
  .ap-flow {
    grid-template-columns: 1fr;
  }

  .ap-modal-backdrop {
    padding: 6px;
  }

  .ap-modal {
    width: 100%;
    max-height: 98vh;
    border-radius: 12px;
  }
}

