.billing-workspace {
  grid-template-columns: minmax(0, 1fr) 390px;
}

.billing-toolbar {
  align-items: end;
}

.billing-workspace .table-wrap table {
  min-width: 1080px;
}

.billing-stats strong {
  font-size: 24px;
  overflow-wrap: anywhere;
}

#billRows tr {
  cursor: pointer;
}

#billRows tr.selected-row {
  background: #eef5ff;
}

#billRows td strong,
#billRows td small {
  display: block;
}

#billRows td small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.billing-detail-panel {
  max-height: calc(100vh - 94px);
  overflow: auto;
}

.detail-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.detail-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.detail-tab {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.detail-tab.active {
  border-color: rgba(20, 104, 216, 0.45);
  background: #e8f1ff;
  color: var(--accent);
}

.bill-form {
  display: grid;
  gap: 12px;
}

.bill-form.hidden {
  display: none;
}

.form-grid,
.fee-grid {
  display: grid;
  gap: 10px;
}

.two-column,
.fee-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.total-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(20, 104, 216, 0.22);
  border-radius: 8px;
  background: #e8f1ff;
  color: var(--accent);
  padding: 12px;
}

.total-preview span {
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.total-preview strong {
  font-size: 20px;
  line-height: 1;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.form-warning,
.form-message {
  margin: -4px 0 0;
  font-size: 12px;
  font-weight: 750;
}

.form-warning {
  color: var(--warning);
}

.form-message {
  min-height: 16px;
  color: var(--muted);
}

.form-message.error {
  color: var(--issue);
}

.form-message.success {
  color: var(--ok);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.status-draft {
  background: #f1f5f9;
  color: #475569;
}

.status-submitted,
.status-under-review {
  background: rgba(20, 104, 216, 0.1);
  color: var(--accent);
}

.status-approved {
  background: rgba(6, 118, 71, 0.1);
  color: var(--ok);
}

.status-disputed {
  background: #fff7ed;
  color: var(--warning);
}

.status-paid {
  background: #ecfdf3;
  color: var(--ok);
}

.status-cancelled,
.status-voided {
  background: #f4f4f5;
  color: var(--muted);
}

.status-at-risk {
  background: #fff0ee;
  color: var(--issue);
}

.overdue-text {
  color: var(--issue);
  font-weight: 850;
}

.fee-breakdown,
.bill-log-list {
  display: grid;
  gap: 8px;
}

.fee-breakdown div,
.bill-log-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 8px 10px;
}

.fee-breakdown span,
.bill-log-entry span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.fee-breakdown strong,
.bill-log-entry strong {
  font-size: 12px;
}

.bill-log-entry {
  grid-template-columns: 1fr;
}

.bill-log-entry p {
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

.detail-section {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.detail-section h3 {
  font-size: 14px;
}

.detail-section header,
.document-card,
.document-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-section header,
.document-card {
  justify-content: space-between;
}

.detail-section header span,
.document-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.document-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.document-card strong,
.document-card span {
  display: block;
}

.document-card span {
  margin-top: 3px;
}

.document-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.billing-overview-grid,
.readiness-list {
  display: grid;
  gap: 8px;
}

.billing-overview-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.billing-overview-grid article,
.readiness-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.billing-overview-grid span,
.billing-overview-grid strong,
.readiness-item span,
.readiness-item strong,
.readiness-item p,
.ready-chip,
.todo-chip {
  display: block;
}

.billing-overview-grid span,
.readiness-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.billing-overview-grid strong,
.readiness-item strong {
  margin-top: 5px;
  color: var(--text);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.readiness-item.ready {
  border-color: rgba(6, 118, 71, 0.22);
}

.readiness-item.warning {
  border-color: rgba(181, 71, 8, 0.24);
  background: #fffaf4;
}

.readiness-item p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.ready-chip,
.todo-chip {
  width: fit-content;
  margin: 5px 0 0;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 900;
}

.ready-chip {
  background: rgba(6, 118, 71, 0.1);
  color: var(--ok);
}

.todo-chip {
  background: #fff7ed;
  color: var(--warning);
}

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

.button.compact {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.import-status.connected-text {
  color: var(--ok);
}

.import-status.error-text {
  color: var(--issue);
  overflow-wrap: anywhere;
}

.billing-shell .empty-state:not(.hidden) {
  display: block;
}

@media (max-width: 1180px) {
  .billing-workspace {
    grid-template-columns: 1fr;
  }

  .billing-toolbar {
    align-items: stretch;
  }

  .billing-detail-panel {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .billing-workspace,
  .two-column,
  .fee-grid,
  .billing-overview-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
  }

  .detail-tabs {
    grid-template-columns: 1fr;
  }

  .document-card,
  .detail-section header {
    align-items: flex-start;
    flex-direction: column;
  }

  .row-actions,
  .row-actions .button,
  .document-actions,
  .document-actions .button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .total-preview {
    align-items: flex-start;
    flex-direction: column;
  }
}
