.sp-main {
  padding-top: 34px;
  padding-bottom: 52px;
}

.sp-page {
  display: grid;
  gap: 18px;
}

.sp-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sp-page-header h1 {
  margin: 0;
  font-size: 1.8rem;
}

.sp-page-header p {
  margin: 6px 0 0;
}

.sp-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sp-muted {
  color: #5f7598;
  font-size: 0.9rem;
}

.sp-summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.sp-summary-card {
  background: #ffffff;
  border: 1px solid #dce5f3;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 8px 16px rgba(22, 55, 112, 0.08);
}

.sp-summary-card h3 {
  margin: 0;
  color: #466089;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.sp-summary-card strong {
  margin-top: 6px;
  display: block;
  color: #153d7a;
  font-size: 1.3rem;
}

.sp-summary-card p {
  margin: 4px 0 0;
  color: #6680a8;
  font-size: 0.83rem;
}

.sp-filters {
  background: #ffffff;
  border: 1px solid #dbe5f3;
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.sp-filter-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.sp-filter-field {
  display: grid;
  gap: 4px;
}

.sp-filter-field label {
  font-size: 0.78rem;
  color: #5f779d;
  font-weight: 700;
}

.sp-filter-field input,
.sp-filter-field select,
.sp-search-wrap input,
.sp-search-wrap select,
.sp-form-field input,
.sp-form-field select,
.sp-form-field textarea,
.sp-table input,
.sp-table select,
.doc-total-grid input,
.doc-total-grid select {
  width: 100%;
  min-height: 36px;
  border: 1px solid #cfdced;
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  color: #1f3f74;
  background: #ffffff;
}

.sp-form-field textarea {
  min-height: 108px;
  padding: 10px;
  resize: vertical;
}

.sp-search-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sp-search-wrap input {
  min-width: 0;
}

.sp-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sp-tab {
  border: 1px solid #d1dceb;
  background: #f4f7fd;
  color: #345789;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.sp-tab.is-active {
  background: #1f68c8;
  border-color: #1f68c8;
  color: #ffffff;
}

.sp-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 0.72rem;
}

.sp-tab:not(.is-active) .sp-tab-badge {
  background: #dbe8fb;
  color: #2c5fae;
}

.sp-table-wrap {
  background: #ffffff;
  border: 1px solid #dbe5f3;
  border-radius: 12px;
  overflow-x: auto;
}

.sp-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}

.sp-table th,
.sp-table td {
  border-top: 1px solid #e4ebf8;
  padding: 10px 12px;
  text-align: left;
  font-size: 0.9rem;
  color: #365781;
  vertical-align: middle;
}

.sp-table thead th {
  border-top: 0;
  background: #f4f8ff;
  color: #5f789f;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sp-table tbody tr:hover {
  background: #f9fbff;
}

.sp-empty-row {
  text-align: center;
  color: #6a81a7;
}

.sp-link {
  color: #1f4f9c;
  font-weight: 700;
}

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

.sp-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  min-height: 24px;
  padding: 0 10px;
  font-size: 0.75rem;
  font-weight: 700;
}

.sp-pill.overdue {
  color: #ffffff;
  background: #d64b5c;
}

.sp-pill.unpaid {
  color: #7e6927;
  background: #efe6c6;
}

.sp-pill.paid {
  color: #ffffff;
  background: #3fb67c;
}

.sp-pill.partially_paid {
  color: #ffffff;
  background: #2d8aa5;
}

.sp-pill.draft {
  color: #5d6575;
  background: #e7eaf0;
}

.sp-pill.active {
  color: #ffffff;
  background: #1f68c8;
}

.sp-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sp-reminder-btn,
.sp-action-trigger,
.sp-ghost-btn,
.sp-mini-btn,
.sp-icon-btn,
.doc-column-btn {
  border: 1px solid #cfdaec;
  border-radius: 8px;
  min-height: 30px;
  padding: 0 10px;
  background: #f4f7fd;
  color: #31578f;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

a.sp-mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.sp-reminder-btn {
  background: #fff2e1;
  border-color: #ffd8a4;
  color: #9b5e0f;
}

.sp-action-menu {
  position: relative;
}

.sp-action-menu summary {
  list-style: none;
}

.sp-action-menu summary::-webkit-details-marker {
  display: none;
}

.sp-action-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 14;
  background: #ffffff;
  border: 1px solid #d7e2f2;
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(20, 45, 97, 0.18);
  min-width: 190px;
  padding: 6px;
  display: grid;
  gap: 4px;
}

.sp-action-item {
  border: 0;
  background: transparent;
  color: #315180;
  font-size: 0.82rem;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.sp-action-item:hover {
  background: #f2f6fd;
}

.sp-card {
  background: #ffffff;
  border: 1px solid #dce6f3;
  border-radius: 12px;
  padding: 16px;
}

.sp-card h2,
.sp-card h3 {
  margin: 0;
  font-size: 1.15rem;
}

.sp-card p {
  color: #577198;
}

.sp-grid-two {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
}

.sp-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: #456289;
}

.sp-list li + li {
  margin-top: 6px;
}

.sp-notice {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  border: 1px solid #d4e3fb;
  background: #edf4ff;
  color: #2a579f;
}

.sp-notice.warning {
  border-color: #f4cf9f;
  background: #fff4e5;
  color: #885314;
}

.sp-notice.success {
  border-color: #9ad8b2;
  background: #eaf9f0;
  color: #257145;
}

.sp-kpi-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sp-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #e8f1ff;
  color: #2f5fa9;
}

.doc-form {
  display: grid;
  gap: 14px;
}

.doc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.doc-head h1 {
  margin: 0;
}

.doc-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.doc-section {
  background: #ffffff;
  border: 1px solid #dbe5f3;
  border-radius: 12px;
  padding: 14px;
}

.doc-section h2 {
  margin: 0;
  font-size: 1.1rem;
}

.doc-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.doc-layout {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(260px, 1fr) minmax(340px, 1.1fr);
}

.doc-customer-card {
  border: 1px solid #d7e2f3;
  border-radius: 10px;
  background: #f7faff;
  padding: 12px;
  min-height: 170px;
}

.doc-customer-card h3 {
  margin: 0;
  font-size: 1rem;
}

.doc-customer-details {
  margin-top: 8px;
  color: #4f6a91;
  font-size: 0.9rem;
  line-height: 1.45;
}

.doc-meta-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sp-form-field {
  display: grid;
  gap: 5px;
}

.sp-form-field label {
  font-size: 0.8rem;
  color: #5f789f;
  font-weight: 700;
}

.doc-meta-note {
  margin: 0;
  color: #6d83a6;
  font-size: 0.78rem;
}

.doc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.doc-add-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.doc-add-item input {
  min-width: 240px;
  flex: 1;
}

.doc-total-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
}

.doc-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #e5edf8;
  padding-top: 8px;
  color: #3f5f89;
  font-size: 0.9rem;
}

.doc-total-row strong {
  font-size: 1.05rem;
  color: #173f7b;
}

.doc-notes-grid {
  display: grid;
  gap: 10px;
}

.doc-attachments {
  border: 1px dashed #9db8e3;
  background: #f6f9ff;
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.doc-attachments p {
  margin: 0;
}

.doc-attachments-list {
  margin: 10px 0 0;
  padding-left: 20px;
  color: #4b688f;
  text-align: left;
}

.doc-lock {
  margin-top: 8px;
  border: 1px solid #f0d0a4;
  background: #fff4e6;
  color: #8c5611;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.83rem;
}

.doc-columns-modal-layer {
  position: fixed;
  inset: 0;
  background: rgba(8, 25, 53, 0.44);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 20px;
}

.doc-columns-modal-layer.is-open {
  display: flex;
}

.doc-columns-modal {
  width: min(740px, 96vw);
  max-height: min(86vh, 900px);
  overflow: auto;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #d4e0f1;
  padding: 16px;
}

.doc-columns-modal h3 {
  margin: 0;
}

.doc-modal-grid {
  margin-top: 10px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.doc-checkbox-grid {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.doc-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #3f5f8f;
  font-size: 0.88rem;
}

.doc-modal-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.doc-inline-alert {
  margin-top: 8px;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.84rem;
  border: 1px solid #efb5b0;
  background: #fff0ef;
  color: #a5443a;
  display: none;
}

.doc-inline-alert.is-visible {
  display: block;
}

.col-hidden {
  display: none !important;
}

.sp-checklist {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 8px;
}

.sp-checklist li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #d9e4f4;
  border-radius: 8px;
  padding: 8px 10px;
  color: #40628d;
  font-size: 0.88rem;
}

.sp-checklist label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sp-price-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.sp-price-table th,
.sp-price-table td {
  border: 1px solid #dce6f3;
  padding: 8px 10px;
  text-align: left;
  color: #3d5f8c;
  font-size: 0.88rem;
}

.sp-price-table th {
  background: #f4f7fd;
  color: #5e789f;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sp-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #e8f3ff;
  color: #2a5da6;
}

.sp-badge.off {
  background: #edf0f5;
  color: #5f6877;
}

@media (max-width: 1080px) {
  .sp-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .doc-layout {
    grid-template-columns: 1fr;
  }

  .doc-meta-grid {
    grid-template-columns: 1fr;
  }

  .doc-total-grid {
    grid-template-columns: 1fr;
  }

  .sp-grid-two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .sp-summary-grid,
  .sp-filter-grid {
    grid-template-columns: 1fr;
  }

  .sp-page-header,
  .doc-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .doc-modal-grid {
    grid-template-columns: 1fr;
  }
}
