/* ============================================================
   FSI CRM — crm.css
   Extends menu.css with page-level and component styles
   ============================================================ */

/* ── Dark scrollbar ── */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.25); }

/* ── Page content wrapper ──────────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Flash messages ─────────────────────────────────────────── */
.flash {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  border: 1px solid transparent;
}
.flash-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #4ade80;
}
.flash-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* ── Stats grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.stat-card.accent { border-color: rgba(201,106,46,0.3); }
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 28px;
  font-weight: 300;
  color: var(--text-primary);
  letter-spacing: -.03em;
}
.stat-card.accent .stat-value { color: var(--accent); }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
}
.card-action {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}
.card-action:hover { text-decoration: underline; }

/* ── Tables ─────────────────────────────────────────────────── */
.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.crm-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.crm-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.crm-table tr:last-child td { border-bottom: none; }
.crm-table tr:hover td { background: var(--surface-hover); }
.crm-table a { color: var(--accent); text-decoration: none; }
.crm-table a:hover { text-decoration: underline; }
code {
  font-size: 11.5px;
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.crm-table code {
  font-size: 11.5px;
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px !important;
  font-size: 13px;
}
.table-action {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}
.table-action:hover { color: var(--accent); }

/* ── Status & badge pills ───────────────────────────────────── */
.status-pill, .badge, .priority-pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.status-new           { background: rgba(99,102,241,0.15); color: #818cf8; border: 1px solid rgba(99,102,241,0.3); }
.status-in_review     { background: rgba(234,179,8,0.12);  color: #fbbf24; border: 1px solid rgba(234,179,8,0.3); }
.status-awaiting_parts{ background: rgba(249,115,22,0.12); color: #fb923c; border: 1px solid rgba(249,115,22,0.3); }
.status-in_progress   { background: rgba(59,130,246,0.12); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.status-pending_shipment{ background: rgba(168,85,247,0.12); color: #c084fc; border: 1px solid rgba(168,85,247,0.3); }
.status-closed        { background: rgba(34,197,94,0.12);  color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.status-cancelled     { background: rgba(239,68,68,0.1);   color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.status-open          { background: rgba(59,130,246,0.12);  color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.status-in_transit    { background: rgba(234,179,8,0.12);   color: #fbbf24; border: 1px solid rgba(234,179,8,0.3); }
.status-received      { background: rgba(34,197,94,0.12);   color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.status-draft         { background: rgba(100,116,139,0.15); color: #94a3b8; border: 1px solid rgba(100,116,139,0.3); }
.status-sent          { background: rgba(59,130,246,0.12); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.status-accepted      { background: rgba(34,197,94,0.12);  color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.status-declined      { background: rgba(239,68,68,0.1);   color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.status-expired       { background: rgba(107,114,128,0.12); color: #9ca3af; border: 1px solid rgba(107,114,128,0.3); }
.status-active        { background: rgba(34,197,94,0.12);   color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.status-fsi_inventory { background: rgba(59,130,246,0.12);  color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.status-under_repair  { background: rgba(234,179,8,0.12);   color: #fbbf24; border: 1px solid rgba(234,179,8,0.3); }
.status-returned      { background: rgba(59,130,246,0.12);  color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.status-stolen        { background: rgba(239,68,68,0.1);    color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.status-order_received    { background: rgba(100,116,139,0.15); color: #94a3b8; border: 1px solid rgba(100,116,139,0.3); }
.status-processing        { background: rgba(59,130,246,0.12);  color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.status-partially_shipped { background: rgba(234,179,8,0.12);   color: #fbbf24; border: 1px solid rgba(234,179,8,0.3); }
.status-partially_received { background: rgba(234,179,8,0.12); color: #fbbf24; border: 1px solid rgba(234,179,8,0.3); }
.status-shipped_complete  { background: rgba(34,197,94,0.12);   color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.badge-calibration    { background: rgba(59,130,246,0.12); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.badge-repair         { background: rgba(234,179,8,0.12);  color: #fbbf24; border: 1px solid rgba(234,179,8,0.3); }
.badge-return_for_credit { background: rgba(168,85,247,0.12); color: #c084fc; border: 1px solid rgba(168,85,247,0.3); }
.priority-low    { background: rgba(100,116,139,0.1); color: #94a3b8; border:1px solid rgba(100,116,139,0.3); }
.priority-normal { background: rgba(59,130,246,0.1);  color: #60a5fa; border:1px solid rgba(59,130,246,0.3); }
.priority-high   { background: rgba(249,115,22,0.12); color: #fb923c; border:1px solid rgba(249,115,22,0.3); }
.priority-urgent { background: rgba(239,68,68,0.12);  color: #f87171; border:1px solid rgba(239,68,68,0.3); }

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-search {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
.filter-search:focus { border-color: rgba(255,255,255,0.2); }
.filter-select {
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  text-align: center;
}
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: #b85e27; border-color: #b85e27; color: white; }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text-primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; display: block; }

/* ── Forms ──────────────────────────────────────────────────── */
.crm-form { display: flex; flex-direction: column; gap: 0; }

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 16px;
  margin-top: 0;
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 0;
}
.form-group {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.form-group-wide { flex: 2; min-width: 240px; }
.form-group-full { width: 100%; flex: none; }
.form-group label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: .02em;
}
.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 11px;
  outline: none;
  transition: border-color .15s;
  width: 100%;
  box-sizing: border-box;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: rgba(201,106,46,0.5);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group select { cursor: pointer; }
/* Generic field styles used outside .form-group contexts */
.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 5px;
}
.field-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 11px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .15s;
}
.field-input:focus { border-color: rgba(201,106,46,0.5); }
.field-input[type=date]::-webkit-calendar-picker-indicator { filter: invert(0.6); cursor: pointer; }
.has-error input,
.has-error select,
.has-error textarea { border-color: rgba(239,68,68,0.6) !important; }
.field-error { font-size: 11.5px; color: #f87171; }
.req { color: var(--accent); }
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 8px 0 4px;
}

/* ── Serial lookup hint ─────────────────────────────────────── */
.lookup-hint {
  font-size: 11.5px;
  margin-top: 4px;
  padding: 4px 8px;
  border-radius: 5px;
  min-height: 20px;
}
.lookup-found    { background: rgba(34,197,94,0.1); color: #4ade80; }
.lookup-notfound { background: rgba(234,179,8,0.1);  color: #fbbf24; }

/* ── Detail view layout ─────────────────────────────────────── */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .detail-layout { grid-template-columns: 1fr; }
}
.detail-main { display: flex; flex-direction: column; gap: 16px; }
.detail-sidebar { display: flex; flex-direction: column; gap: 16px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px 20px;
}
.detail-section { }
.detail-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.detail-value { font-size: 13.5px; color: var(--text-primary); }
.detail-text { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }
.detail-value a { color: var(--accent); text-decoration: none; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }

/* ── Quote builder line items ───────────────────────────────── */
.line-items-header {
  display: flex;
  gap: 10px;
  padding: 0 0 6px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.line-item-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}
.line-item-row input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.line-item-row input:focus { border-color: rgba(201,106,46,0.5); }
.remove-line-btn {
  width: 28px; height: 32px; flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  transition: all .15s;
}
.remove-line-btn:hover { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.4); color: #f87171; }

/* Product dropdown */
.product-dropdown {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: #1e1f20;
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  overflow: hidden;
}
.dd-item {
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
}
.dd-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.dd-price { font-size: 11.5px; color: var(--text-muted); }

/* ── Quote totals ───────────────────────────────────────────── */
.quote-totals-wrap {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}
.quote-totals {
  min-width: 280px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.totals-row:last-child { border-bottom: none; }
.totals-total {
  font-weight: 600;
  font-size: 15px;
  color: var(--accent);
  background: rgba(201,106,46,0.07);
}

/* ── Quote preview card ─────────────────────────────────────── */
.quote-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.quote-preview-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.quote-bill-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.7;
}
.quote-items-table th { text-align: left; }
.quote-items-table th, .quote-items-table td { padding: 9px 10px; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  padding: 16px 12px 4px;
  flex-wrap: wrap;
}
.page-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  text-decoration: none;
  transition: all .15s;
}
.page-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

/* ── Misc ───────────────────────────────────────────────────── */
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

/* ── Role badges (profile, user management) ─────────────────── */
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.role-admin { background: rgba(201,106,46,0.15); color: var(--accent); border: 1px solid rgba(201,106,46,0.3); }
.role-staff { background: rgba(100,116,139,0.15); color: #94a3b8; border: 1px solid rgba(100,116,139,0.3); }
.status-retired       { background: rgba(107,114,128,0.12); color: #9ca3af; border: 1px solid rgba(107,114,128,0.3); }
.status-select-pill { appearance:none; -webkit-appearance:none; cursor:pointer; font-weight:500; border:1px solid transparent; }
.status-select-pill.status-fsi_inventory { background:rgba(59,130,246,0.12); color:#60a5fa; border-color:rgba(59,130,246,0.3); }
.status-select-pill.status-active        { background:rgba(34,197,94,0.12);  color:#4ade80; border-color:rgba(34,197,94,0.3); }
.status-select-pill.status-under_repair  { background:rgba(234,179,8,0.12);  color:#fbbf24; border-color:rgba(234,179,8,0.3); }
.status-select-pill.status-stolen        { background:rgba(239,68,68,0.1);   color:#f87171; border-color:rgba(239,68,68,0.3); }
.status-select-pill.status-retired       { background:rgba(107,114,128,0.12);color:#9ca3af; border-color:rgba(107,114,128,0.3); }
.status-select-pill option { background:var(--surface); color:var(--text-primary); }
.status-payment-paid   { background: rgba(34,197,94,0.12);   color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.status-payment-unpaid { background: rgba(239,68,68,0.1);    color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.status-pending       { background: rgba(234,179,8,0.12);   color: #fbbf24; border: 1px solid rgba(234,179,8,0.3); }
.status-processing    { background: rgba(99,102,241,0.15);  color: #818cf8; border: 1px solid rgba(99,102,241,0.3); }
.status-shipped       { background: rgba(59,130,246,0.12);  color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.status-completed     { background: rgba(34,197,94,0.12);   color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }