/* Abrechnung / Rechnungen – Neues modernes Design */

.billing-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 40px 48px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  min-height: 100vh;
}
.theme-dark .billing-wrap {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

/* Header */
.billing-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.billing-header-left { flex: 1; }

.billing-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: #1e293b;
  margin: 0 0 6px 0;
}
.theme-dark .billing-title { color: #f1f5f9; }

.billing-subtitle {
  font-size: 15px;
  font-weight: 500;
  color: #64748b;
  margin: 0;
}
.theme-dark .billing-subtitle { color: #94a3b8; }

.billing-header-right { flex-shrink: 0; }

.billing-year-select {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.theme-dark .billing-year-select {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

.billing-select-inline {
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  cursor: pointer;
  padding: 0;
}
.theme-dark .billing-select-inline { color: #f1f5f9; }

/* KPI Cards */
.billing-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.billing-kpi-card {
  position: relative;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 24px 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.02);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.billing-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.theme-dark .billing-kpi-card {
  background: #1e293b;
  border-color: #334155;
}

.kpi-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-bottom: 12px;
  text-transform: uppercase;
}
.theme-dark .kpi-label { color: #94a3b8; }

.kpi-value {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.kpi-number {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -1.5px;
  color: #1e293b;
  line-height: 1;
}
.theme-dark .kpi-number { color: #f1f5f9; }

.kpi-unit {
  font-size: 15px;
  font-weight: 600;
  color: #64748b;
}
.theme-dark .kpi-unit { color: #94a3b8; }

/* Success Card */
.billing-kpi-card.kpi-success .kpi-label { color: #059669; }
.theme-dark .billing-kpi-card.kpi-success .kpi-label { color: #34d399; }
.billing-kpi-card.kpi-success .kpi-unit { color: #059669; }
.theme-dark .billing-kpi-card.kpi-success .kpi-unit { color: #34d399; }

.kpi-check {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #dcfce7;
  border-radius: 50%;
  color: #16a34a;
  font-size: 18px;
  font-weight: 700;
}
.theme-dark .kpi-check {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

/* Danger Card */
.billing-kpi-card.kpi-danger .kpi-label { color: #dc2626; }
.theme-dark .billing-kpi-card.kpi-danger .kpi-label { color: #f87171; }
.billing-kpi-card.kpi-danger .kpi-number { color: #dc2626; }
.theme-dark .billing-kpi-card.kpi-danger .kpi-number { color: #f87171; }
.billing-kpi-card.kpi-danger .kpi-unit { color: #dc2626; }
.theme-dark .billing-kpi-card.kpi-danger .kpi-unit { color: #f87171; }

/* Filters */
.billing-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.billing-search-wrap {
  flex: 1;
  min-width: 280px;
}

.billing-search {
  width: 100%;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 500;
  color: #334155;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.billing-search::placeholder { color: #94a3b8; }
.billing-search:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.theme-dark .billing-search {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
.theme-dark .billing-search::placeholder { color: #64748b; }

.billing-filter-select {
  padding: 14px 36px 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M2 4l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  appearance: none;
  min-width: 140px;
}
.billing-filter-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.theme-dark .billing-filter-select {
  background-color: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

.billing-csv-btn {
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 700;
  color: #334155;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.billing-csv-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.theme-dark .billing-csv-btn {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
.theme-dark .billing-csv-btn:hover { background: #334155; }

/* Table */
.billing-table-wrap {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.02);
}
.theme-dark .billing-table-wrap {
  background: #1e293b;
  border-color: #334155;
}

.billing-table {
  width: 100%;
  border-collapse: collapse;
}

.billing-table thead tr {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.theme-dark .billing-table thead tr {
  background: #0f172a;
  border-bottom-color: #334155;
}

.billing-table th {
  padding: 16px 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #64748b;
  text-align: left;
}
.theme-dark .billing-table th { color: #94a3b8; }

.billing-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s ease;
}
.billing-table tbody tr:last-child { border-bottom: none; }
.billing-table tbody tr:hover { background: #f8fafc; }
.theme-dark .billing-table tbody tr { border-bottom-color: #1e293b; }
.theme-dark .billing-table tbody tr:hover { background: #0f172a; }

.billing-table td {
  padding: 18px 20px;
  vertical-align: middle;
}

.billing-date {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
}
.theme-dark .billing-date { color: #f1f5f9; }

.billing-date-sub {
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  margin-top: 4px;
}

.billing-client {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
}
.theme-dark .billing-client { color: #f1f5f9; }

.billing-patient {
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  margin-top: 4px;
}
.theme-dark .billing-patient { color: #94a3b8; }

.billing-notes {
  font-size: 14px;
  color: #64748b;
}
.theme-dark .billing-notes { color: #94a3b8; }

.billing-units-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  background: #eff6ff;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  color: #3b82f6;
}
.theme-dark .billing-units-badge {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.billing-action-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.billing-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  background: #f1f5f9;
  color: #64748b;
}
.billing-status-badge.status-open {
  background: #fef3c7;
  color: #d97706;
}
.billing-status-badge.status-overdue {
  background: #fee2e2;
  color: #dc2626;
}
.billing-status-badge.status-done {
  background: #dcfce7;
  color: #16a34a;
}
.theme-dark .billing-status-badge {
  background: #334155;
  color: #94a3b8;
}
.theme-dark .billing-status-badge.status-open {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}
.theme-dark .billing-status-badge.status-overdue {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}
.theme-dark .billing-status-badge.status-done {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.billing-action-btn {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.billing-action-btn:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
}
.billing-action-btn.done {
  background: #dcfce7;
  border-color: #bbf7d0;
  color: #16a34a;
  cursor: default;
}
.theme-dark .billing-action-btn {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}
.theme-dark .billing-action-btn:hover { background: #475569; }
.theme-dark .billing-action-btn.done {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.25);
  color: #4ade80;
}

.billing-empty {
  padding: 60px 20px;
  text-align: center;
  color: #94a3b8;
  font-size: 15px;
  font-weight: 500;
}

.billing-table tbody tr.is-overdue { background: #fef2f2; }
.theme-dark .billing-table tbody tr.is-overdue { background: rgba(239, 68, 68, 0.08); }

/* Embedded mode */
.embedded body { background: transparent !important; }
.embedded .billing-wrap {
  background: transparent;
  max-width: none;
  margin: 0;
  padding: 20px;
  min-height: auto;
}
.embedded .billing-table-wrap {
  background: transparent;
  border: none;
  box-shadow: none;
}
.embedded .billing-kpi-card { background: rgba(255,255,255,0.6); }
.theme-dark.embedded .billing-kpi-card { background: rgba(30,41,59,0.6); }

/* Responsive */
@media (max-width: 1100px) {
  .billing-kpi-row { grid-template-columns: 1fr; }
  .billing-kpi-card { padding: 20px 24px; }
  .kpi-number { font-size: 36px; }
}

@media (max-width: 900px) {
  .billing-wrap { padding: 20px; }
  .billing-header { flex-direction: column; gap: 16px; }
  .billing-title { font-size: 26px; }
  .billing-table th, .billing-table td { padding: 14px 12px; }
  .billing-action-wrap { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media (max-width: 700px) {
  .billing-filters { flex-direction: column; align-items: stretch; }
  .billing-search-wrap { min-width: 100%; }
  .billing-filter-select, .billing-csv-btn { width: 100%; }
}
