/* ════════════════════════════════════════════════════════════════
   CloudLedgerAI — Quotes & Sales Orders module
   Prefix: sd-  (reuses im- drawer / table / KPI primitives)
   ════════════════════════════════════════════════════════════════ */


/* Status pills */
.sd-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px; text-transform: capitalize;
  padding: 3px 10px; border-radius: 999px;
}
.sd-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.sd-pill.draft     { background: #f1f5f9; color: #475569; }
.sd-pill.sent      { background: var(--im-indigo-soft); color: var(--im-indigo); }
.sd-pill.accepted,
.sd-pill.confirmed { background: var(--im-teal-soft); color: #0f766e; }
.sd-pill.converted,
.sd-pill.invoiced  { background: var(--im-violet-soft); color: var(--im-violet); }
.sd-pill.declined,
.sd-pill.cancelled { background: var(--im-rose-soft); color: var(--im-rose); }
.sd-pill.expired   { background: var(--im-amber-soft); color: #b45309; }
.sd-pill.closed    { background: var(--im-green-soft); color: var(--im-green); }

.sd-link-chip {
  display: inline-block; margin-top: 3px;
  font-size: 11px; font-weight: 600; color: var(--im-indigo);
  background: var(--im-indigo-soft); padding: 1px 7px; border-radius: 5px;
}
.sd-num { font-family: var(--font-mono); font-weight: 600; color: var(--im-indigo); cursor: pointer; }
.sd-num:hover { text-decoration: underline; }
.sd-muted { color: #94a3b8; font-size: 12px; }
.sd-overdue { color: var(--im-rose); font-weight: 600; }

/* Drawer: line items */
.sd-drawer { width: min(1040px, 98vw); }
.sd-lines-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.sd-lines { width: 100%; border-collapse: collapse; min-width: 860px; }
.sd-lines th {
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: #64748b; padding: 8px 6px; border-bottom: 1px solid var(--border-color);
}
.sd-lines td { padding: 6px 4px; vertical-align: top; border-bottom: 1px dashed #eef0f4; }
.sd-lines .form-control { padding: 7px 9px; font-size: 13px; }
.sd-lines .sd-in-num { text-align: right; font-family: var(--font-mono); }
.sd-line-total { font-family: var(--font-mono); font-weight: 600; text-align: right; padding-top: 11px !important; white-space: nowrap; }
.sd-line-del {
  width: 28px; height: 28px; border: none; background: transparent; color: #94a3b8;
  border-radius: 7px; cursor: pointer; font-size: 14px; margin-top: 4px;
}
.sd-line-del:hover { background: var(--im-rose-soft); color: var(--im-rose); }
.sd-add-line {
  margin: 12px 0 14px; border: 1px dashed #c7d2fe; background: var(--im-indigo-soft);
  color: var(--im-indigo); font-weight: 600; font-size: 13px;
  padding: 8px 14px; border-radius: 9px; cursor: pointer; transition: all 0.15s ease;
}
.sd-add-line:hover { background: #e0e7ff; transform: translateY(-1px); }

.sd-totals-row { display: grid; grid-template-columns: 1fr 320px; gap: 24px; margin-bottom: 14px; }
.sd-totals {
  background: linear-gradient(180deg, #f8faff, #f1f5ff);
  border: 1px solid #e0e7ff; border-radius: 12px; padding: 14px 16px; align-self: start;
}
.sd-totals-line { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; color: var(--text-secondary); }
.sd-totals-line span:last-child { font-family: var(--font-mono); font-weight: 600; color: var(--text-primary); }
.sd-totals-grand {
  border-top: 1px solid #c7d2fe; margin-top: 6px; padding-top: 10px;
  font-size: 15px; font-weight: 700;
}
.sd-totals-grand span:last-child { color: var(--im-indigo); font-size: 17px; }
textarea.form-control { resize: vertical; min-height: 64px; }
.sd-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Read-only banner inside the drawer */
.sd-lock-note {
  margin-top: 18px; padding: 10px 14px; border-radius: 10px; font-size: 12.5px; font-weight: 600;
  background: var(--im-amber-soft); color: #92400e; border: 1px solid #fde68a;
}

/* ── Dark Mode Overrides for Quotes & Sales Orders ─────────────── */
[data-theme="dark"] .sd-totals {
  background: #0f172a !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .sd-totals-line {
  color: #94a3b8 !important;
}
[data-theme="dark"] .sd-totals-line span:last-child {
  color: #f8fafc !important;
}
[data-theme="dark"] .sd-totals-grand {
  border-top-color: #334155 !important;
  color: #f8fafc !important;
}
[data-theme="dark"] .sd-totals-grand span:last-child {
  color: #60a5fa !important;
}
[data-theme="dark"] .sd-pill.draft {
  background: #334155 !important;
  color: #cbd5e1 !important;
}
[data-theme="dark"] .sd-pill.sent {
  background: rgba(99, 102, 241, 0.22) !important;
  color: #a5b4fc !important;
}
[data-theme="dark"] .sd-pill.accepted,
[data-theme="dark"] .sd-pill.confirmed {
  background: rgba(20, 184, 166, 0.22) !important;
  color: #5eead4 !important;
}
[data-theme="dark"] .sd-pill.converted,
[data-theme="dark"] .sd-pill.invoiced {
  background: rgba(139, 92, 246, 0.22) !important;
  color: #c4b5fd !important;
}
[data-theme="dark"] .sd-pill.declined,
[data-theme="dark"] .sd-pill.cancelled {
  background: rgba(239, 68, 68, 0.22) !important;
  color: #fca5a5 !important;
}
[data-theme="dark"] .sd-pill.expired {
  background: rgba(245, 158, 11, 0.22) !important;
  color: #fcd34d !important;
}
[data-theme="dark"] .sd-pill.closed {
  background: rgba(16, 185, 129, 0.22) !important;
  color: #6ee7b7 !important;
}
[data-theme="dark"] .sd-link-chip {
  background: rgba(99, 102, 241, 0.2) !important;
  color: #a5b4fc !important;
}
[data-theme="dark"] .sd-num {
  color: #60a5fa !important;
}
[data-theme="dark"] .sd-lines th {
  border-bottom-color: #334155 !important;
  color: #94a3b8 !important;
}
[data-theme="dark"] .sd-lines td {
  border-bottom-color: #1e293b !important;
}
[data-theme="dark"] .sd-add-line {
  background: rgba(99, 102, 241, 0.15) !important;
  border-color: #4f46e5 !important;
  color: #a5b4fc !important;
}
[data-theme="dark"] .sd-add-line:hover {
  background: rgba(99, 102, 241, 0.28) !important;
  color: #ffffff !important;
}
[data-theme="dark"] .sd-lock-note {
  background: rgba(245, 158, 11, 0.15) !important;
  border-color: rgba(245, 158, 11, 0.3) !important;
  color: #fbbf24 !important;
}

@media (max-width: 760px) {
  .sd-totals-row, .sd-grid-3 { grid-template-columns: 1fr; }
}
