/* ═══════════════════════════════════════════════════════════════
   ELMETIC ServiceHub – Order Billing View Styles
   Route: #order-billing/:orderId
   ═══════════════════════════════════════════════════════════════ */

.ob-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 100px 16px; /* bottom padding for sticky footer */
}

/* ── Header ─────────────────────────────────────────────────── */
.ob-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  padding-top: 8px;
}
.ob-back-btn {
  white-space: nowrap;
  margin-top: 4px;
}
.ob-header-info h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: #1a1a1a;
}
.ob-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: #666;
}

/* ── Controls Row ───────────────────────────────────────────── */
.ob-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: #f8f9fa;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.ob-type-toggle {
  display: flex;
  gap: 0;
  background: #fff;
  border: 1px solid #d8e0ec;
  border-radius: 6px;
  overflow: hidden;
}
.ob-toggle-label {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  color: #555;
}
.ob-toggle-label input[type="radio"] { display: none; }
.ob-toggle-active {
  background: #E73D25;
  color: #fff;
}
.ob-due-date {
  margin-left: auto;
  font-size: 13px;
  color: #555;
}
.ob-due-date label { display: flex; align-items: center; gap: 6px; }

/* ── KPI Row ────────────────────────────────────────────────── */
.ob-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.ob-kpi {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
}
.ob-kpi-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  margin-bottom: 4px;
}
.ob-kpi-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
}
.ob-kpi-invoiced { color: #0d7d3e; }
.ob-kpi-open { color: #E73D25; }
.ob-kpi-sub {
  display: block;
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

/* ── Update Banner ──────────────────────────────────────────── */
.ob-update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #856404;
}

/* ── Previous Invoices ──────────────────────────────────────── */
.ob-previous-invoices {
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}
.ob-previous-invoices summary {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  user-select: none;
}
.ob-previous-invoices[open] summary {
  border-bottom: 1px solid #e2e8f0;
}

/* ── Sections ───────────────────────────────────────────────── */
.ob-section {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.ob-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.ob-section-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
}
.ob-section-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}
.ob-select-all,
.ob-toggle-sm {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
}
.ob-hourly-rate {
  font-size: 13px;
  color: #555;
  margin-bottom: 10px;
}
.ob-hourly-rate label { display: flex; align-items: center; gap: 6px; }
.ob-empty {
  font-size: 13px;
  color: #999;
  font-style: italic;
  margin: 8px 0;
}

/* ── Tables ─────────────────────────────────────────────────── */
.ob-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ob-table th {
  text-align: left;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #888;
  border-bottom: 2px solid #e2e8f0;
}
.ob-table td {
  padding: 7px 8px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
.ob-table tbody tr:hover {
  background: #f8f9fa;
}
.ob-table-sm td { padding: 5px 8px; }
.ob-col-check { width: 32px; text-align: center; }
.ob-text-right { text-align: right; }
.ob-desc-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #888;
  font-size: 12px;
}
.ob-row-selected {
  background: #e8edff !important;
}
.ob-row-zero {
  opacity: 0.6;
}
.ob-total-cell {
  font-weight: 600;
  white-space: nowrap;
}

/* ── Inputs ─────────────────────────────────────────────────── */
.ob-input-qty,
.ob-input-price {
  width: 80px;
  padding: 3px 6px;
  border: 1px solid #d8e0ec;
  border-radius: 4px;
  font-size: 13px;
  text-align: right;
}
.ob-input-sm {
  width: 60px;
  padding: 3px 6px;
  border: 1px solid #d8e0ec;
  border-radius: 4px;
  font-size: 13px;
  text-align: right;
}
.ob-input {
  padding: 4px 8px;
  border: 1px solid #d8e0ec;
  border-radius: 4px;
  font-size: 13px;
}
.ob-input-qty:focus,
.ob-input-price:focus,
.ob-input-sm:focus,
.ob-input:focus {
  outline: none;
  border-color: #E73D25;
  box-shadow: 0 0 0 2px rgba(231, 61, 37, 0.12);
}

/* ── Badges ─────────────────────────────────────────────────── */
.ob-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}
.ob-badge-draft { background: #f0f0f0; color: #666; }
.ob-badge-sent { background: #d6eaf8; color: #1a5f8a; }
.ob-badge-paid { background: #d5f5e3; color: #1a7a44; }
.ob-badge-overdue { background: #fde8d8; color: #c0392b; }
.ob-badge-cancelled { background: #f5f5f5; color: #999; }

/* ── Freetext Items ─────────────────────────────────────────── */
.ob-freetext-items {
  margin-top: 8px;
  border-top: 1px dashed #e2e8f0;
  padding-top: 8px;
}
.ob-freetext-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.ob-ft-artnr { width: 160px; flex: none; position: relative; }
.ob-ft-title { flex: 2; min-width: 150px; }
.ob-ft-desc { flex: 2; min-width: 120px; }
.ob-ft-qty { width: 60px; flex: none; }
.ob-ft-unit { width: 60px; flex: none; }
.ob-ft-price { width: 80px; flex: none; }
.ob-ft-tax { width: 55px; flex: none; }
.ob-ft-total {
  width: 90px;
  text-align: right;
  font-weight: 600;
  font-size: 13px;
  flex: none;
}
.ob-ft-remove {
  font-size: 16px;
  color: #c0392b;
  padding: 2px 6px;
  line-height: 1;
}
.ob-add-freetext {
  margin-top: 8px;
  font-size: 12px;
  color: #E73D25;
}

/* ── Sticky Footer ──────────────────────────────────────────── */
.ob-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 2px solid #e2e8f0;
  padding: 10px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
}
.ob-footer-totals {
  display: flex;
  gap: 24px;
  align-items: center;
}
.ob-footer-item {
  font-size: 13px;
  color: #555;
}
.ob-footer-item strong {
  font-size: 15px;
  color: #1a1a1a;
}
.ob-footer-gross strong {
  font-size: 18px;
  color: #E73D25;
}
.ob-footer-actions {
  display: flex;
  gap: 8px;
}

/* ── Preview Overlay ────────────────────────────────────────── */
.ob-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.ob-preview-card {
  background: #fff;
  border-radius: 12px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.ob-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}
.ob-preview-header h2 {
  margin: 0;
  font-size: 18px;
}
.ob-preview-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 0 4px;
}
.ob-preview-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.ob-preview-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  margin-bottom: 16px;
  font-size: 13px;
}
.ob-preview-meta p { margin: 0; }
.ob-preview-table {
  margin-bottom: 16px;
}
.ob-preview-deductions {
  margin-bottom: 16px;
  padding: 12px;
  background: #fef3f2;
  border-radius: 6px;
}
.ob-preview-deductions h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #c0392b;
}
.ob-preview-totals {
  text-align: right;
  font-size: 14px;
  border-top: 2px solid #e2e8f0;
  padding-top: 12px;
}
.ob-preview-totals > div { margin-bottom: 4px; }
.ob-preview-gross {
  font-size: 18px;
  color: #E73D25;
}
.ob-preview-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #e2e8f0;
}

/* ── Responsive: Tablet ────────────────────────────────────── */
@media (max-width: 1180px) {
  .ob-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .ob-controls { flex-direction: column; align-items: flex-start; }
  .ob-due-date { margin-left: 0; }
  .ob-freetext-row { flex-direction: column; }
  .ob-ft-title, .ob-ft-desc { min-width: 100%; }
  .ob-table { font-size: 12px; }
  .ob-input-qty, .ob-input-price { width: 65px; }
}

@media (max-width: 768px) {
  .ob-container { padding: 0 8px 110px; }
  .ob-kpi-row { grid-template-columns: 1fr; }
  .ob-header { flex-direction: column; gap: 8px; }
  .ob-footer { flex-direction: column; gap: 8px; padding: 8px 12px; }
  .ob-footer-totals { justify-content: center; flex-wrap: wrap; }
  .ob-preview-card { margin: 8px; max-height: 95vh; }
  .ob-section { padding: 10px; }
  .ob-table th, .ob-table td { padding: 4px 6px; }
}
