/* ═══════════════════════════════════════════════════
   OrderHub — Global CSS
   Premium light theme with soft shadows
   ═══════════════════════════════════════════════════ */

/* ─── Reset & Base ──────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-input: rgba(0,0,0,0.03);
  --bg-hover: rgba(0,0,0,0.04);
  --border-color: rgba(0,0,0,0.1);
  --border-focus: #667eea;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent-gradient: linear-gradient(135deg, #667eea, #764ba2);
  --accent-blue: #667eea;
  --accent-purple: #764ba2;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #2563eb;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-dropdown: 0 4px 16px rgba(0,0,0,0.12);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: 0.2s ease;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Layout ────────────────────────────────────── */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Topbar ────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-brand {
  font-size: 20px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  cursor: pointer;
  text-decoration: none;
}

.topbar-nav {
  display: flex;
  gap: 4px;
}

.topbar-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}

.topbar-nav a:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.topbar-nav a.active {
  color: var(--accent-blue);
  background: rgba(102,126,234,0.1);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  font-size: 13px;
  color: var(--text-secondary);
}

.btn-logout {
  padding: 6px 14px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  color: #dc2626;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
  transition: all var(--transition);
}

.btn-logout:hover {
  background: rgba(239,68,68,0.15);
}

/* ─── Main Content ──────────────────────────────── */
.main-content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ─── Page Header ───────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  position: sticky;
  top: 56px;
  z-index: 50;
  background: var(--bg-primary);
  padding: 16px 0 12px;
}

/* ─── Toolbar (Filters) ─────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  position: sticky;
  top: 122px;  /* 56 topbar + 66 page-header */
  z-index: 49;
  background: var(--bg-primary);
  padding: 8px 0 12px;
}

/* ─── Sticky Table Header ───────────────────────── */
.table-container thead th {
  position: sticky;
  top: 181px;  /* 56 topbar + 66 page-header + 59 toolbar */
  z-index: 48;
  background: #ffffff;
  box-shadow: 0 1px 0 var(--border-color);
}

/* Tables inside .card (reports, dashboard) don't have the page-header/toolbar offset */
.card .table-container thead th {
  position: static;
}

/* Tables inside modals — no sticky header (modal scrolls independently) */
.modal .table-container thead th,
.modal .line-items-table thead th,
.modal thead th {
  position: static;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
}

/* ─── Cards ─────────────────────────────────────── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

/* ─── KPI Cards Grid ────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(102,126,234,0.3);
}

.kpi-card .kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
}

.kpi-card .kpi-icon {
  font-size: 20px;
}

.kpi-card.blue .kpi-value { color: var(--info); }
.kpi-card.green .kpi-value { color: var(--success); }
.kpi-card.orange .kpi-value { color: var(--warning); }
.kpi-card.red .kpi-value { color: var(--danger); }
.kpi-card.purple .kpi-value { color: var(--accent-purple); }

/* ─── Buttons ───────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  border: none;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-success { background: rgba(22,163,74,0.08); color: #16a34a; border-color: rgba(22,163,74,0.2); }
.btn-success:hover { background: rgba(22,163,74,0.15); }

.btn-danger { background: rgba(220,38,38,0.08); color: #dc2626; border-color: rgba(220,38,38,0.2); }
.btn-danger:hover { background: rgba(220,38,38,0.15); }

.btn-warning { background: rgba(217,119,6,0.08); color: #d97706; border-color: rgba(217,119,6,0.2); }
.btn-warning:hover { background: rgba(217,119,6,0.15); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ─── Tables ────────────────────────────────────── */
.table-container {
  overflow-x: auto;  /* auto allows horizontal scroll when needed, doesn't clip buttons */
}

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

thead th {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  background: #f8f9fa;
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  white-space: nowrap;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody tr.selected {
  background: rgba(102,126,234,0.1);
}

/* ─── Status Badges ─────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-draft { background: rgba(148,163,184,0.1); color: #64748b; }
.badge-unconfirmed { background: rgba(217,119,6,0.1); color: #b45309; }
.badge-confirmed { background: rgba(37,99,235,0.1); color: #2563eb; }
.badge-waiting_stock { background: rgba(234,88,12,0.1); color: #c2410c; }
.badge-invoiced { background: rgba(124,58,237,0.1); color: #7c3aed; }
.badge-cancelled { background: rgba(220,38,38,0.1); color: #dc2626; }

.badge-new { background: rgba(37,99,235,0.1); color: #2563eb; }
.badge-processing { background: rgba(217,119,6,0.1); color: #b45309; }
.badge-ready_to_ship { background: rgba(8,145,178,0.1); color: #0891b2; }
.badge-shipped { background: rgba(124,58,237,0.1); color: #7c3aed; }
.badge-delivered { background: rgba(22,163,74,0.1); color: #16a34a; }
.badge-delivery_failed { background: rgba(220,38,38,0.1); color: #dc2626; }
.badge-completed { background: rgba(22,163,74,0.12); color: #15803d; }
.badge-returned { background: rgba(220,38,38,0.12); color: #b91c1c; }
.badge-refunded { background: rgba(148,163,184,0.12); color: #64748b; }
/* Return statuses */
.badge-requested { background: rgba(217,119,6,0.1); color: #b45309; }
.badge-shipping_back { background: rgba(37,99,235,0.1); color: #2563eb; }
.badge-received { background: rgba(8,145,178,0.1); color: #0891b2; }
.badge-approved { background: rgba(22,163,74,0.1); color: #16a34a; }
.badge-rejected { background: rgba(220,38,38,0.1); color: #dc2626; }
.badge-partial_return { background: rgba(234,88,12,0.1); color: #c2410c; }
.badge-full_return { background: rgba(220,38,38,0.1); color: #dc2626; }
.badge-reshipped { background: rgba(124,58,237,0.1); color: #7c3aed; }
.badge-returning { background: rgba(217,119,6,0.1); color: #b45309; }
/* Generic color badges */
.badge-orange { background: rgba(217,119,6,0.1); color: #b45309; }
.badge-blue { background: rgba(37,99,235,0.1); color: #2563eb; }
.badge-green { background: rgba(22,163,74,0.1); color: #16a34a; }
.badge-red { background: rgba(220,38,38,0.1); color: #dc2626; }
.badge-purple { background: rgba(124,58,237,0.1); color: #7c3aed; }

/* ─── Forms ─────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 9px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  transition: all var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}

.form-control::placeholder {
  color: var(--text-muted);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* ─── Modal ─────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 90vw;
  max-width: 800px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  transform: translateY(20px);
  transition: transform 0.2s;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  transition: all var(--transition);
}

.modal-close:hover {
  background: rgba(220,38,38,0.1);
  color: #dc2626;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
}
.modal-footer-actions {
  display: flex;
  gap: 6px;
  margin-right: auto;
  align-items: center;
}
.modal-footer-actions .btn-icon {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
}

/* ─── Footer Action Buttons (Chat / Call / Edit) ── */
.btn-footer-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px !important;
  font-size: 13px !important;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid;
  white-space: nowrap;
}
.btn-footer-chat {
  background: rgba(22, 163, 74, 0.08);
  border-color: rgba(22, 163, 74, 0.25);
  color: #16a34a;
}
.btn-footer-chat:hover {
  background: rgba(22, 163, 74, 0.15);
  border-color: rgba(22, 163, 74, 0.4);
  transform: translateY(-1px);
}
.btn-footer-call {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.25);
  color: #2563eb;
}
.btn-footer-call:hover {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.4);
  transform: translateY(-1px);
}

/* ─── Toolbar ───────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar .search-input {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

/* ─── Pagination ────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.pagination-buttons {
  display: flex;
  gap: 4px;
}

.pagination-buttons button {
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  transition: all var(--transition);
}

.pagination-buttons button:hover:not(:disabled) {
  background: var(--bg-hover);
}

.pagination-buttons button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ─── Toast ─────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(20px);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  max-width: 360px;
}

.toast-success { background: rgba(22,163,74,0.1); border: 1px solid rgba(22,163,74,0.25); color: #16a34a; }
.toast-error { background: rgba(220,38,38,0.1); border: 1px solid rgba(220,38,38,0.25); color: #dc2626; }
.toast-warning { background: rgba(217,119,6,0.1); border: 1px solid rgba(217,119,6,0.25); color: #d97706; }

@keyframes toastIn { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-20px); } }

/* ─── Empty State ───────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 14px;
}

/* ─── Loading ───────────────────────────────────── */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.loading-spinner::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─── Line Items Table ──────────────────────────── */
.line-items-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.line-items-table th {
  font-size: 11px;
  padding: 8px 10px;
}

.line-items-table td {
  padding: 8px 10px;
  font-size: 13px;
}

.line-items-table .line-input {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
}

.line-items-table .line-input:focus {
  border-color: var(--accent-blue);
  outline: none;
}

/* Product name column: allow word-wrap for long names */
.line-items-table td:nth-child(2) {
  white-space: normal;
  word-break: break-word;
}
.line-items-table .sp-edit-name {
  white-space: normal;
  word-break: break-word;
  min-height: 32px;
  line-height: 1.3;
}
/* Compact number inputs: hide spinner arrows to save space */
.line-items-table input[type="number"].sp-edit-qty,
.line-items-table input[type="number"].sp-edit-price {
  -moz-appearance: textfield;
  text-align: center;
}
.line-items-table input[type="number"].sp-edit-qty::-webkit-inner-spin-button,
.line-items-table input[type="number"].sp-edit-qty::-webkit-outer-spin-button,
.line-items-table input[type="number"].sp-edit-price::-webkit-inner-spin-button,
.line-items-table input[type="number"].sp-edit-price::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.line-cut { opacity: 0.4; text-decoration: line-through; }

/* ─── Financial Summary ─────────────────────────── */
.financial-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 20px;
  background: #f8f9fa;
  border-radius: var(--radius-md);
  margin-top: 16px;
}

.financial-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
}

.financial-row.total {
  font-size: 18px;
  font-weight: 700;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  color: #d97706;
}

/* ─── Section Title ─────────────────────────────── */
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-blue);
  margin: 20px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(102,126,234,0.15);
}

.section-title:first-child {
  margin-top: 0;
}

/* ─── Small Form Controls ──────────────────────── */
.form-control-sm {
  padding: 5px 8px !important;
  font-size: 12px !important;
  border-radius: 4px !important;
}

.form-control:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(0,0,0,0.05);
}

/* ─── Cut / Moved Line Styles ───────────────────── */
.line-cut td {
  opacity: 0.45;
  text-decoration: line-through;
  text-decoration-color: var(--danger);
}
.line-cut td:last-child {
  text-decoration: none;
}
.line-moved td {
  opacity: 0.35;
  font-style: italic;
}
.line-moved td:last-child {
  text-decoration: none;
}
.split-check {
  width: 16px;
  height: 16px;
  accent-color: var(--warning);
  cursor: pointer;
}
.vnpost-match-row:hover {
  background: rgba(102, 126, 234, 0.15) !important;
  border: 1px solid rgba(102, 126, 234, 0.3);
}

/* ─── Upload / Import Styles ────────────────────── */
.upload-zone {
  border: 2px dashed rgba(102, 126, 234, 0.4);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  background: rgba(102, 126, 234, 0.05);
  transition: all 0.3s ease;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent-blue);
  background: rgba(102, 126, 234, 0.12);
  transform: scale(1.01);
}
.progress-bar {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
  border-radius: 3px;
  transition: width 0.5s ease;
}
.import-product {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(102, 126, 234, 0.15);
  border-radius: 4px;
  font-size: 11px;
  margin: 2px;
  border: 1px solid rgba(102, 126, 234, 0.2);
}
.import-product.product-invalid {
  background: rgba(255, 107, 107, 0.15);
  border-color: rgba(255, 107, 107, 0.3);
  color: var(--danger);
}
/* Import merge indicator */
.row-merge { background: rgba(102, 126, 234, 0.06); }
.row-merge:hover { background: rgba(102, 126, 234, 0.12) !important; }
.badge-merge {
  background: rgba(102, 126, 234, 0.15);
  color: #93a5f6;
  font-size: 10px;
  padding: 2px 8px;
}
.badge-new-order {
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
}
.new-check {
  width: 15px;
  height: 15px;
  accent-color: var(--success);
  cursor: pointer;
}
/* Create Invoice Modal */
.order-select-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: all var(--transition);
  cursor: pointer;
}
.order-select-card:hover {
  border-color: var(--accent-blue);
  background: rgba(102, 126, 234, 0.08);
}
.order-select-card.selected {
  border-color: var(--accent-blue);
  background: rgba(102, 126, 234, 0.12);
}
.order-select-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-blue);
}
.order-select-info {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
}
.order-select-info .order-code {
  font-weight: 600;
  color: var(--accent-blue);
}
.order-select-info .order-amount {
  color: var(--warning);
  font-weight: 500;
}
/* Return action dropdown */
.return-action-select {
  padding: 4px 8px;
  font-size: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font);
}
.return-action-refund { color: #fbbf24; }
.return-action-warranty { color: #60a5fa; }
.return-action-exchange { color: #4ade80; }

/* Order Select Card (Create Invoice from Orders) */
.order-select-card {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all 0.2s;
}
.order-select-card:hover {
  background: rgba(139,92,246,0.08);
  border-color: rgba(139,92,246,0.3);
}
.order-select-card.selected {
  background: rgba(34,197,94,0.1);
  border-color: rgba(34,197,94,0.4);
  box-shadow: 0 0 0 1px rgba(34,197,94,0.2);
}
.order-select-card input[type="checkbox"] {
  margin-top: 4px;
  flex-shrink: 0;
}
.order-select-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.order-select-info .order-code {
  font-weight: 600;
  color: var(--accent-blue);
  font-size: 13px;
}
.order-select-info .order-amount {
  font-weight: 600;
  color: var(--accent-purple);
}
.exchange-fields input {
  padding: 3px 6px;
  font-size: 11px;
  background: var(--bg-input);
  border: 1px solid rgba(74,222,128,0.3);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font);
}

/* ─── Responsive ────────────────────────────────── */
@media (max-width: 768px) {
  .main-content { padding: 16px; }
  .topbar-nav { display: none; }
  .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; }
  .toolbar .search-input { max-width: 100%; }
}

/* ─── Tab Bar (COD page) ────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 0;
}

.tab-btn {
  padding: 10px 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
  font-weight: 600;
}

/* ─── Nav Bar (COD/Reports pages) ─────────────────── */
.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  height: 56px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-logo {
  font-size: 20px;
  text-decoration: none;
  margin-right: 12px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s;
}

.nav-link:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }
.nav-link.active { color: var(--accent-blue); background: rgba(59,130,246,0.12); font-weight: 600; }

.nav-user { color: var(--text-muted); font-size: 13px; }

/* ─── Convert Button (Topbar) ──────────────────── */
.btn-convert {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
  animation: convertPulse 2s ease-in-out infinite;
}
.btn-convert:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
  animation: none;
}
@keyframes convertPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); }
}
.convert-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: rgba(255,255,255,0.25);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

/* ─── Convertible Row Indicator ────────────────── */
.row-convertible {
  border-left: 3px solid rgba(59, 130, 246, 0.4);
}
.row-convertible:hover {
  border-left-color: var(--accent-blue);
}

/* ─── Convert Preview Modal ────────────────────── */
.convert-summary {
  margin-bottom: 16px;
}

.convert-kpi {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.convert-kpi-card {
  text-align: center;
  padding: 14px 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all 0.2s;
}
.convert-kpi-card:hover {
  background: rgba(255,255,255,0.06);
}
.convert-kpi-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}
.convert-kpi-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.convert-kpi-card.ready .convert-kpi-value { color: #22c55e; }
.convert-kpi-card.warning .convert-kpi-value { color: #f59e0b; }
.convert-kpi-card.invalid .convert-kpi-value { color: #ef4444; }

/* ─── Convert Filter Bar ───────────────────────── */
.convert-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
  flex-wrap: wrap;
}

.convert-filter-tabs {
  display: flex;
  gap: 4px;
}

.convert-filter-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
}
.convert-filter-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}
.convert-filter-btn.active {
  background: rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.3);
  color: var(--accent-blue);
  font-weight: 600;
}

/* ─── Convert List ─────────────────────────────── */
.convert-list {
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}
.convert-list::-webkit-scrollbar { width: 6px; }
.convert-list::-webkit-scrollbar-track { background: transparent; }
.convert-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* ─── Convert Item Card ────────────────────────── */
.convert-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: all 0.2s;
  border-left: 4px solid transparent;
}
.convert-item:hover {
  background: rgba(255,255,255,0.05);
}

/* Status-based left border */
.convert-item.ready { border-left-color: #22c55e; }
.convert-item.warning { border-left-color: #f59e0b; }
.convert-item.invalid { border-left-color: #ef4444; }

/* Selected state */
.convert-item.checked {
  background: rgba(34, 197, 94, 0.06);
  border-color: rgba(34, 197, 94, 0.2);
}
.convert-item.warning.checked {
  background: rgba(245, 158, 11, 0.06);
  border-color: rgba(245, 158, 11, 0.2);
}

/* Disabled (invalid) */
.convert-item.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.convert-item.disabled .convert-item-info { pointer-events: none; }

.convert-item-check {
  display: flex;
  align-items: flex-start;
  padding-top: 2px;
}
.convert-item-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #22c55e;
  cursor: pointer;
}
.convert-item.warning .convert-item-check input[type="checkbox"] {
  accent-color: #f59e0b;
}

.convert-item-info {
  flex: 1;
  min-width: 0;
}

.convert-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.convert-item-code {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent-blue);
}

.convert-item-status-icon {
  font-size: 14px;
}

.convert-item-source {
  font-size: 11px;
  color: var(--text-muted);
}

.convert-item-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.convert-item-detail em {
  color: var(--danger);
  font-style: italic;
}

.convert-item-address {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.convert-item-address.missing {
  color: var(--danger);
}
.convert-item-address.missing em {
  font-style: italic;
}

/* ─── Issue Badges ─────────────────────────────── */
.convert-item-issues {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.convert-issue {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
}
.convert-issue.warn {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}
.convert-issue.error {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ─── Convert Footer ───────────────────────────── */
.convert-footer-info {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ─── Toast Info ───────────────────────────────── */
.toast-info { background: rgba(59,130,246,0.2); border: 1px solid rgba(59,130,246,0.3); color: #60a5fa; }

/* ─── Mass Actions Dropdown ───────────────────── */
.mass-actions-dropdown {
  position: relative;
  display: inline-flex;
}
.mass-actions-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mass-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  padding: 0 7px;
  font-size: 11px;
  min-width: 20px;
  height: 20px;
  font-weight: 700;
}
.mass-actions-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: rgba(30,30,60,0.96);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 4px;
  min-width: 210px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.mass-actions-menu.show { display: block; }
.mass-actions-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  border-radius: 7px;
  transition: background 0.15s;
  text-align: left;
}
.mass-actions-menu button:hover {
  background: rgba(255,255,255,0.08);
}

/* ─── Mass Remove Modals ───────────────────────── */
.mass-remove-kpi {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}
.mass-remove-kpi .kpi-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  text-align: center;
}
.mass-remove-kpi .kpi-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}
.mass-remove-kpi .kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.mass-remove-kpi .kpi-danger .kpi-value { color: var(--danger); }
.mass-remove-kpi .kpi-success .kpi-value { color: var(--success); }

.mass-remove-table {
  width: 100%;
  font-size: 12px;
}
.mass-remove-table th {
  background: rgba(0,0,0,0.2);
  padding: 6px 10px;
  font-weight: 600;
  white-space: nowrap;
  text-align: left;
}
.mass-remove-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-color);
}

.mass-remove-table .row-skipped {
  opacity: 0.45;
}
.mass-remove-table .row-cancelled {
  background: rgba(239, 68, 68, 0.08);
}
.mass-remove-table .row-cancelled td:first-child {
  border-left: 3px solid var(--danger);
}

.mass-notice {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.15);
  color: var(--warning);
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  border: none;
}
.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(239,68,68,0.3);
}
.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ─── Suggestion Dropdown ───────────────────────── */
.suggest-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 200;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  max-height: 260px;
  overflow-y: auto;
  margin-top: 2px;
}
.suggest-dropdown::-webkit-scrollbar { width: 6px; }
.suggest-dropdown::-webkit-scrollbar-track { background: transparent; }
.suggest-dropdown::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.suggest-dropdown::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.suggest-dropdown.suggest-dropup {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 2px;
}
.suggest-item {
  padding: 9px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: background 0.1s ease;
  border-bottom: 1px solid #f1f5f9;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover {
  background: #f1f5f9;
}
.suggest-item.suggest-highlight {
  background: rgba(102, 126, 234, 0.08);
  outline: none;
}
.suggest-value {
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.suggest-extra {
  font-size: 12px;
  color: #667eea;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 500;
}
.suggest-price {
  font-size: 11px;
  color: #16a34a;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 600;
  background: rgba(22, 163, 74, 0.08);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
}

/* ─── Time Filter Bar ───────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter-bar .filter-sep {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  margin: 0 4px;
}
.filter-bar .form-control {
  width: auto;
  min-width: 120px;
}
.filter-bar .date-range {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.filter-bar .date-range span {
  color: var(--text-muted);
  font-size: 12px;
}
.filter-bar .date-range input[type="date"] {
  width: 140px;
}

/* ─── Advanced Filter Modal ─────────────────────── */
.adv-filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.adv-filter-grid .form-group { margin-bottom: 0; }
.adv-filter-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* ─── Row Action Buttons (Chat/Call) ────────────── */
.row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.btn-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition);
  padding: 0;
}
.btn-icon:hover {
  background: rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.3);
  transform: scale(1.1);
}
.btn-icon.btn-chat:hover { border-color: rgba(34, 197, 94, 0.4); background: rgba(34, 197, 94, 0.1); }
.btn-icon.btn-call:hover { border-color: rgba(59, 130, 246, 0.4); background: rgba(59, 130, 246, 0.1); }

/* ─── Customer Lookup Modal ─────────────────────── */
.customer-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border: 1px solid transparent;
  transition: all var(--transition);
  cursor: pointer;
}
.customer-result:hover {
  border-color: rgba(102, 126, 234, 0.3);
  background: rgba(102, 126, 234, 0.08);
}
.customer-result .cr-info { flex: 1; }
.customer-result .cr-name { font-size: 14px; font-weight: 600; }
.customer-result .cr-phone { font-size: 12px; color: var(--text-secondary); }
.customer-result .cr-address { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.customer-result .cr-orders {
  font-size: 11px;
  color: var(--accent-blue);
  margin-top: 4px;
}

/* ─── Row Actions (Order/Invoice table action column) ─── */
.row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  white-space: nowrap;
}
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, transform 0.1s;
  line-height: 1;
}
.btn-icon:hover {
  background: rgba(102, 126, 234, 0.15);
  transform: scale(1.15);
}



/* ─── Order Card Enrichment Badges ─────────────────── */
.enrich-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}

.badge-new {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  animation: badge-new-pulse 2s ease-in-out infinite;
}

@keyframes badge-new-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(102,126,234,0.4); }
  50% { box-shadow: 0 0 6px 2px rgba(102,126,234,0.3); }
}

.badge-failed {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(239,68,68,0.1);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.2);
}

.badge-missed {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(245,158,11,0.1);
  color: #f59e0b;
  border: 1px solid rgba(245,158,11,0.2);
}

.elapsed-normal {
  color: var(--text-muted);
}

.elapsed-warn {
  color: #f59e0b;
  font-weight: 600;
}

.elapsed-danger {
  color: #ef4444;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════
   GPT Chat Panel — Floating AI Assistant
   ═══════════════════════════════════════════════════════ */

/* Toggle Button */
.gpt-toggle-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gpt-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(99, 102, 241, 0.5);
}
.gpt-toggle-btn.active {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  transform: scale(0.95);
}
.gpt-toggle-icon {
  font-size: 26px;
  line-height: 1;
}
.gpt-toggle-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #fff;
}

/* Chat Panel */
.gpt-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 9998;
  width: 420px;
  max-height: 600px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Inter', sans-serif;
}
.gpt-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
}

/* Header */
.gpt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-radius: 16px 16px 0 0;
  flex-shrink: 0;
}
.gpt-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gpt-header-icon {
  font-size: 22px;
}
.gpt-header-title {
  font-size: 15px;
  font-weight: 600;
}
.gpt-header-model {
  font-size: 10px;
  background: rgba(255,255,255,0.2);
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 500;
}
.gpt-header-right {
  display: flex;
  gap: 4px;
}
.gpt-header-right button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.gpt-header-right button:hover {
  background: rgba(255,255,255,0.3);
}

/* Messages Area */
.gpt-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 300px;
  max-height: 420px;
}
.gpt-messages::-webkit-scrollbar { width: 5px; }
.gpt-messages::-webkit-scrollbar-track { background: transparent; }
.gpt-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* Welcome */
.gpt-welcome {
  text-align: center;
  padding: 24px 16px;
}
.gpt-welcome-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.gpt-welcome-text {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 6px;
}
.gpt-welcome-hint {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 16px;
}
.gpt-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.gpt-quick-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #475569;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}
.gpt-quick-btn:hover {
  background: #e8edf4;
  border-color: #6366f1;
  color: #4f46e5;
}

/* Message Bubbles */
.gpt-msg {
  display: flex;
  gap: 8px;
  animation: gptFadeIn 0.3s ease;
}
@keyframes gptFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.gpt-msg-user {
  justify-content: flex-end;
}
.gpt-msg-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}
.gpt-msg-user-bubble {
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.gpt-msg-assistant-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}
.gpt-msg-assistant-bubble strong { color: #4f46e5; }
.gpt-msg-assistant-bubble code {
  background: #e2e8f0;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}
.gpt-msg-assistant-bubble .gpt-link {
  color: #6366f1;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid rgba(99, 102, 241, 0.3);
  transition: all 0.15s ease;
  padding-bottom: 0.5px;
}
.gpt-msg-assistant-bubble .gpt-link:hover {
  color: #4f46e5;
  border-bottom-color: #4f46e5;
  background: rgba(99, 102, 241, 0.06);
  border-radius: 2px;
  padding: 0 2px 0.5px 2px;
  margin: 0 -2px;
}
.gpt-msg-error-bubble {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}
.gpt-msg-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

/* Tool Call Chips */
.gpt-tools-used {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.gpt-tool-chip {
  background: #ede9fe;
  color: #6d28d9;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

/* Typing Animation */
.gpt-loading-bubble {
  padding: 14px 18px;
}
.gpt-typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}
.gpt-typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  animation: gptBounce 1.4s infinite ease-in-out both;
}
.gpt-typing-dots span:nth-child(1) { animation-delay: 0s; }
.gpt-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.gpt-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes gptBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.gpt-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  background: #fafbfc;
  border-radius: 0 0 16px 16px;
}
.gpt-input {
  flex: 1;
  resize: none;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
  max-height: 120px;
  min-height: 40px;
  line-height: 1.4;
  color: #1e293b;
}
.gpt-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.gpt-input::placeholder {
  color: #94a3b8;
}
.gpt-send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.gpt-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.gpt-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Reminder Toast */
.gpt-reminder-toast {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10001;
  width: 320px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  border-left: 4px solid #f59e0b;
  padding: 14px 16px;
  animation: gptSlideIn 0.4s ease;
}
@keyframes gptSlideIn {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}
.gpt-toast-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
  margin-bottom: 6px;
}
.gpt-toast-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #94a3b8;
  padding: 0;
}
.gpt-toast-body {
  font-size: 13px;
  color: #1e293b;
  line-height: 1.4;
}
.gpt-toast-time {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

/* ─── Confirm Card (Write Actions) ─── */
.gpt-confirm-card {
  margin: 8px 12px;
  border-radius: 10px;
  border: 2px solid #f59e0b;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  overflow: hidden;
  flex-shrink: 0; /* Prevent flexbox from collapsing the card */
  animation: gptCardSlide 0.3s ease;
}
@keyframes gptCardSlide {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.gpt-confirm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(245, 158, 11, 0.12);
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
}
.gpt-confirm-label {
  font-size: 13px;
  font-weight: 700;
  color: #92400e;
}
.gpt-confirm-warning {
  font-size: 11px;
  color: #d97706;
  font-weight: 600;
}
.gpt-confirm-body {
  padding: 10px 14px;
}
.gpt-confirm-summary {
  font-size: 13px;
  color: #451a03;
  line-height: 1.5;
}
.gpt-confirm-summary strong {
  color: #92400e;
}
.gpt-confirm-actions {
  display: flex;
  gap: 8px;
  padding: 8px 14px 12px;
}
.gpt-confirm-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.gpt-confirm-yes {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
}
.gpt-confirm-yes:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
}
.gpt-confirm-no {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #d1d5db;
}
.gpt-confirm-no:hover:not(:disabled) {
  background: #e5e7eb;
  color: #374151;
}
.gpt-confirm-btn:disabled {
  cursor: not-allowed;
}

/* Confirm result states */
.gpt-confirm-card.gpt-confirm-done {
  border-color: #d1d5db;
  background: #f9fafb;
}
.gpt-confirm-result {
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 8px;
}
.gpt-confirm-success {
  color: #065f46;
  background: #d1fae5;
  border-left: 3px solid #10b981;
}
.gpt-confirm-error {
  color: #991b1b;
  background: #fee2e2;
  border-left: 3px solid #ef4444;
}
.gpt-confirm-cancelled {
  color: #6b7280;
  background: #f3f4f6;
  border-left: 3px solid #9ca3af;
  font-style: italic;
}

/* Responsive */
@media (max-width: 480px) {
  .gpt-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 76px;
    max-height: calc(100vh - 100px);
    border-radius: 12px;
  }
  .gpt-toggle-btn {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }
  .gpt-toggle-icon { font-size: 22px; }
}

/* ─── Customer Level Badges (on Order/Invoice cards) ── */
.badge-level {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  margin-left: 2px;
  vertical-align: middle;
}
.badge-vip {
  background: linear-gradient(135deg, rgba(234,179,8,0.15), rgba(245,158,11,0.15));
  color: #b45309;
  border: 1px solid rgba(234,179,8,0.3);
}
.badge-blacklisted {
  background: rgba(220,38,38,0.1);
  color: #dc2626;
  border: 1px solid rgba(220,38,38,0.2);
}

/* ─── Failed/Missed Call Badges ──────────────────── */
.badge-failed, .badge-missed {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  margin-left: 2px;
}
.badge-failed { background: rgba(220,38,38,0.08); color: #dc2626; }
.badge-missed { background: rgba(217,119,6,0.08); color: #d97706; }

/* ─── View Customer Button (in slide panel) ─────── */
.btn-cust-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(102,126,234,0.3);
  background: rgba(102,126,234,0.08);
  color: var(--accent-blue);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  margin-left: 8px;
  vertical-align: middle;
  transition: all var(--transition);
}
.btn-cust-link:hover {
  background: rgba(102,126,234,0.2);
  border-color: rgba(102,126,234,0.5);
  transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════════════
   Slide Panel Tab System
   ═══════════════════════════════════════════════════════ */
.sp-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-color);
  padding: 0 16px;
  background: rgba(0,0,0,0.02);
  flex-shrink: 0;
}
.sp-tab {
  position: relative;
  padding: 10px 16px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.sp-tab:hover {
  color: var(--text-primary);
  background: rgba(102,126,234,0.04);
}
.sp-tab.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
  font-weight: 600;
}
.sp-tab .tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(102,126,234,0.12);
  color: var(--accent-blue);
}
.sp-tab.active .tab-badge {
  background: var(--accent-blue);
  color: #fff;
}

/* ═══════════════════════════════════════════════════════
   Merge Tab — Accordion Cards
   ═══════════════════════════════════════════════════════ */
.merge-tab-content {
  padding: 12px 0;
}
.merge-tab-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.merge-tab-empty .empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* Accordion Card */
.merge-acc {
  margin: 0 0 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s;
}
.merge-acc.selected {
  border-color: rgba(102,126,234,0.5);
  box-shadow: 0 0 0 1px rgba(102,126,234,0.15);
}
.merge-acc-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  background: rgba(0,0,0,0.02);
  transition: background 0.15s;
  user-select: none;
}
.merge-acc-header:hover {
  background: rgba(102,126,234,0.04);
}
.merge-acc-header .acc-check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--accent-blue);
  cursor: pointer;
}
.merge-acc-header .acc-code {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.merge-acc-header .acc-status {
  font-size: 11px;
}
.merge-acc-header .acc-date {
  font-size: 11px;
  color: var(--text-muted);
}
.merge-acc-header .acc-summary {
  flex: 1;
  font-size: 11px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.merge-acc-header .acc-total {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-blue);
  white-space: nowrap;
}
.merge-acc-header .acc-toggle {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.merge-acc.open .acc-toggle {
  transform: rotate(180deg);
}

/* Accordion Body */
.merge-acc-body {
  display: none;
  border-top: 1px solid var(--border-color);
  background: rgba(0,0,0,0.01);
}
.merge-acc.open .merge-acc-body {
  display: block;
}

/* Line Row */
.merge-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 36px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  font-size: 12px;
  transition: background 0.15s;
}
.merge-line:last-child { border-bottom: none; }
.merge-line:hover { background: rgba(102,126,234,0.03); }
.merge-line .ml-check {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  accent-color: var(--accent-blue);
}
.merge-line .ml-name {
  flex: 1;
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.merge-line .ml-code {
  font-size: 11px;
  color: #667eea;
  white-space: nowrap;
}
.merge-line .ml-qty {
  width: 44px;
  text-align: center;
  font-size: 12px;
  padding: 2px 4px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
}
.merge-line .ml-qty:disabled {
  opacity: 0.5;
  background: transparent;
  border-color: transparent;
}
.merge-line .ml-price {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 50px;
  text-align: right;
}
.merge-line .ml-orig-qty {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Accordion Footer (per-order summary) */
.merge-acc-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px 6px 36px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  background: rgba(0,0,0,0.02);
}

/* Merge Action Footer (sticky) */
.merge-tab-footer {
  position: sticky;
  bottom: 0;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 10;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
.merge-tab-footer .merge-preview-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.merge-tab-footer .merge-preview-text b {
  color: var(--text-primary);
}
.merge-tab-footer .btn-merge-execute {
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.merge-tab-footer .btn-merge-execute:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}
.merge-tab-footer .btn-merge-execute:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ═══════════════════════════════════════════════════
   OH-43: COD Enhancement — Collection Form + Staff
   ═══════════════════════════════════════════════════ */

/* Badge: partially collected */
.badge-partial { background: rgba(249,115,22,0.1); color: #ea580c; }

/* Carrier badge on card row */
.or-carrier-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(102,126,234,0.08);
  color: #667eea;
  margin-top: 2px;
}

/* ─── Collection Form (inside slide panel) ─────── */
.collect-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.collect-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.collect-row label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 80px;
}

.collect-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.collect-input {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition);
  width: 140px;
}

.collect-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}

.collect-unit {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.collect-methods {
  display: flex;
  gap: 8px;
}

.collect-method {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.collect-method:hover {
  border-color: var(--accent-blue);
}

.collect-method.active {
  background: rgba(102,126,234,0.08);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.collect-method input[type=radio] {
  display: none;
}

.btn-collect {
  padding: 10px 20px;
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 4px;
}

.btn-collect:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ─── Payment History ──────────────────────────── */
.payment-history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-size: 12px;
}

.payment-history-row:last-child {
  border-bottom: none;
}

.ph-time { color: var(--text-muted); min-width: 100px; }
.ph-type { font-weight: 500; min-width: 80px; }
.ph-amount { font-weight: 600; color: #22c55e; }
.ph-user { color: var(--text-secondary); flex: 1; text-align: right; }
.ph-note { cursor: help; }

/* ─── Staff Summary Tab ────────────────────────── */
.staff-grand-total {
  display: flex;
  gap: 20px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 600;
  flex-wrap: wrap;
}

.staff-group {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
}

.staff-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  transition: background var(--transition);
}

.staff-header:hover {
  background: var(--bg-hover);
}

.staff-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.staff-name {
  font-weight: 600;
  font-size: 14px;
}

.staff-phone {
  font-size: 12px;
  color: var(--text-muted);
}

.staff-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  font-weight: 500;
}

.staff-pct {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(102,126,234,0.1);
  color: var(--accent-blue);
  font-weight: 600;
}

.staff-invoices {
  padding: 4px 0;
}

.staff-group.collapsed .staff-invoices {
  display: none;
}

.staff-inv-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition);
}

.staff-inv-row:hover {
  background: var(--bg-hover);
}

.si-code { font-weight: 500; min-width: 110px; color: var(--accent-blue); }
.si-customer { flex: 1; color: var(--text-secondary); }
.si-cod { min-width: 90px; text-align: right; font-weight: 500; }
.si-status { min-width: 100px; text-align: right; font-weight: 500; }
.si-time { min-width: 50px; text-align: right; color: var(--text-muted); font-size: 12px; }

.content-loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ═══ OH-50: VNPost COD Ledger ═══ */
.ledger-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}

.ledger-card:hover {
  background: rgba(102, 126, 234, 0.04);
}

.ledger-vnpost-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #0369a1;
  background: rgba(3, 105, 161, 0.08);
  padding: 1px 6px;
  border-radius: 3px;
  margin-top: 2px;
  white-space: nowrap;
}

.ledger-header + .content-empty {
  border-top: none;
}

/* ═══════════════════════════════════════════════════ */
/* ─── OH-51: Settings Page ──────────────────────── */
/* ═══════════════════════════════════════════════════ */

/* Taskbar Tabs */
.settings-tabs {
  display: flex;
  gap: 2px;
  background: rgba(0,0,0,0.04);
  border-radius: 6px;
  padding: 2px;
}

.settings-tabs .stab {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  white-space: nowrap;
}

.settings-tabs .stab:hover {
  color: #1e293b;
  background: rgba(0,0,0,0.04);
}

.settings-tabs .stab.active {
  background: #ffffff;
  color: #1e293b;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Section */
.settings-section {
  padding: 0 4px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 8px;
}

.section-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.section-subtitle {
  font-size: 11.5px;
  color: #94a3b8;
  margin-top: 2px;
  display: block;
}

.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-add:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(102,126,234,0.35);
}

/* Table */
.settings-table-wrap {
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.08);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.settings-table thead {
  background: #f8fafc;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.settings-table th {
  padding: 8px 12px;
  font-weight: 600;
  font-size: 11.5px;
  color: #64748b;
  text-align: left;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.settings-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  color: #334155;
  vertical-align: middle;
}

.settings-table tr:last-child td {
  border-bottom: none;
}

.settings-table tr:hover {
  background: rgba(102,126,234,0.03);
}

.settings-table tr.row-inactive {
  opacity: 0.5;
}

.settings-table tr.row-inactive:hover {
  opacity: 0.7;
}

.td-center { text-align: center; }

.td-name {
  font-weight: 500;
  color: #1e293b;
}

.td-note {
  font-size: 11.5px;
  color: #94a3b8;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-badge {
  display: inline-block;
  background: rgba(102,126,234,0.08);
  color: #4f6ade;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: 'Consolas', 'Monaco', monospace;
}

.phone-link {
  color: #2563eb;
  text-decoration: none;
  font-size: 12px;
}
.phone-link:hover { text-decoration: underline; }

.status-active {
  font-size: 11px;
  color: #059669;
}

.status-inactive {
  font-size: 11px;
  color: #dc2626;
}

.empty-row {
  text-align: center !important;
  color: #94a3b8 !important;
  padding: 24px 12px !important;
  font-style: italic;
}

/* Action Buttons */
.td-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 26px;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 5px;
  background: #ffffff;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.12s;
}

.btn-action:hover {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.2);
  transform: translateY(-1px);
}

.btn-action.btn-delete:hover {
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.3);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.settings-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 480px;
  max-width: 90vw;
  max-height: 85vh;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-modal.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.sm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.sm-title {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

.sm-close {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(0,0,0,0.04);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #64748b;
  transition: all 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sm-close:hover {
  background: rgba(239,68,68,0.1);
  color: #dc2626;
}

.sm-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}

.sm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid rgba(0,0,0,0.08);
}

.btn-modal {
  padding: 7px 18px;
  font-size: 12.5px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s;
}

.btn-cancel {
  background: rgba(0,0,0,0.04);
  color: #64748b;
  border: 1px solid rgba(0,0,0,0.1);
}

.btn-cancel:hover {
  background: rgba(0,0,0,0.08);
  color: #1e293b;
}

.btn-save {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
}

.btn-save:hover {
  filter: brightness(1.1);
}

.btn-save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Form */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 5px;
}

.form-group label .required {
  color: #ef4444;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 6px;
  color: #1e293b;
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}

.form-group input[readonly] {
  background: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.form-hint {
  display: block;
  font-size: 10.5px;
  color: #94a3b8;
  margin-top: 3px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500 !important;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #667eea;
}

/* ═══════════════════════════════════════════════════
   Batch — KPI / Preview / Invoice List
   ═══════════════════════════════════════════════════ */

.batch-preview-kpi,
.batch-kpi-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.batch-kpi-card {
  flex: 1;
  min-width: 100px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
}

.batch-kpi-card .batch-kpi-value {
  font-size: 22px;
  font-weight: 700;
}

.batch-kpi-card .batch-kpi-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.batch-kpi-success { background: rgba(22,163,74,0.06); border-color: rgba(22,163,74,0.2); }
.batch-kpi-success .batch-kpi-value { color: #16a34a; }

.batch-kpi-danger { background: rgba(239,68,68,0.06); border-color: rgba(239,68,68,0.2); }
.batch-kpi-danger .batch-kpi-value { color: #ef4444; }

.batch-kpi-info { background: rgba(37,99,235,0.06); border-color: rgba(37,99,235,0.2); }
.batch-kpi-info .batch-kpi-value { color: #2563eb; }

/* Batch Invoice List (inside slide panel) */
.batch-inv-list {
  display: flex;
  flex-direction: column;
}

.batch-inv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-size: 13px;
  transition: background var(--transition);
}

.batch-inv-item:last-child { border-bottom: none; }
.batch-inv-item:hover { background: var(--bg-hover); }

.batch-inv-idx {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(102,126,234,0.08);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-blue);
  flex-shrink: 0;
}

.batch-inv-info {
  flex: 1;
  min-width: 0;
}

.batch-inv-code {
  font-weight: 600;
  color: var(--accent-blue);
  cursor: pointer;
}
.batch-inv-code:hover { text-decoration: underline; }

.batch-inv-customer {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.batch-inv-tracking {
  font-size: 11px;
  color: var(--text-muted);
}

.batch-inv-cod {
  font-weight: 600;
  color: #d97706;
  white-space: nowrap;
}

.batch-inv-status { flex-shrink: 0; }

/* ═══════════════════════════════════════════════════
   OH-59: Recall Lines (Thu hồi SP kèm đơn)
   ═══════════════════════════════════════════════════ */

.recall-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #f97316, #ea580c);
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
  margin-left: 4px;
  box-shadow: 0 1px 3px rgba(249, 115, 22, 0.3);
}

/* Recall section in panel */
#spRecallSection .sp-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.recall-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #fb923c;
}

/* Recall modal */
#recallModal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#recallModal .modal-content {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  width: 700px;
}

#recallModal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

#recallModal .modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

#recallModal .modal-close {
  width: 30px;
  height: 30px;
  border: none;
  background: rgba(0,0,0,0.06);
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  transition: all 0.15s;
}

#recallModal .modal-close:hover {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
}

#recallModal .modal-body {
  padding: 16px 20px;
}

#recallModal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
}

/* Recall line checkbox styling */
.recall-cb {
  width: 16px;
  height: 16px;
  accent-color: #f97316;
  cursor: pointer;
}

.recall-line-pick:hover {
  background: rgba(249, 115, 22, 0.04);
}

.recall-invoice-card {
  transition: border-color 0.2s;
}

.recall-invoice-card:hover {
  border-color: rgba(102,126,234,0.3) !important;
}
