:root {
  --cx-blue: #1769e0;
  --cx-blue-dark: #0b3778;
  --cx-green: #13a86b;
  --cx-bg: #f6f9fc;
  --cx-border: #e6edf5;
  --cx-text: #162033;
  --cx-muted: #65758b;
  --sidebar-w: 280px;
}

* { letter-spacing: 0; }
body {
  background: var(--cx-bg);
  color: var(--cx-text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { text-decoration: none; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--cx-border);
  padding: 18px 16px;
  overflow-y: auto;
  z-index: 1030;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--cx-text);
  margin-bottom: 22px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--cx-blue), var(--cx-green));
  font-weight: 800;
}
.brand small { display: block; color: var(--cx-muted); font-size: 12px; }
.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #41516a;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 600;
  margin-bottom: 3px;
}
.sidebar .nav-link i { font-size: 18px; width: 22px; }
.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  color: var(--cx-blue);
  background: #edf5ff;
}
.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--cx-border);
  position: sticky;
  top: 0;
  z-index: 1010;
}
.topbar-user { display: flex; gap: 12px; align-items: center; }
.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #e8f4ff;
  color: var(--cx-blue);
  font-weight: 800;
}
.content-wrap { padding: 26px; }
.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-title h1 { font-size: 26px; margin: 0; font-weight: 800; }
.page-title p { margin: 4px 0 0; color: var(--cx-muted); }
.card-soft, .stat-card, .form-card {
  background: #fff;
  border: 1px solid var(--cx-border);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(23, 105, 224, .06);
}
.stat-card { padding: 18px; height: 100%; }
.stat-card .icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--cx-blue);
  background: #edf5ff;
  font-size: 20px;
}
.stat-card .value { font-size: 24px; font-weight: 800; margin-top: 12px; }
.stat-card .label { color: var(--cx-muted); font-size: 13px; font-weight: 700; }
.form-card { padding: 20px; }
.table-card { padding: 0; overflow: hidden; }
.table-card .table { margin: 0; }
.table thead th {
  background: #f8fbff;
  color: #526176;
  font-size: 12px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--cx-border);
}
.btn-primary { --bs-btn-bg: var(--cx-blue); --bs-btn-border-color: var(--cx-blue); }
.btn-success { --bs-btn-bg: var(--cx-green); --bs-btn-border-color: var(--cx-green); }
.form-control, .form-select {
  border-color: #dce6f1;
  border-radius: 8px;
  min-height: 42px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--cx-blue);
  box-shadow: 0 0 0 .2rem rgba(23, 105, 224, .12);
}
.ts-control {
  border-color: #dce6f1;
  border-radius: 8px;
  min-height: 42px;
  padding: 8px 12px;
}
.ts-wrapper.focus .ts-control {
  border-color: var(--cx-blue);
  box-shadow: 0 0 0 .2rem rgba(23, 105, 224, .12);
}
.ts-dropdown {
  border-color: #dce6f1;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(22, 32, 51, .14);
  overflow: hidden;
}
.ts-dropdown .dropdown-input {
  border: 0;
  border-bottom: 1px solid var(--cx-border);
  padding: 10px 12px;
}
.ts-dropdown .option {
  padding: 9px 12px;
}
.required::after { content: " *"; color: #dc3545; }
.empty-state {
  padding: 34px;
  text-align: center;
  color: var(--cx-muted);
}
.pipeline-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.pipeline-column {
  min-height: 220px;
  background: #fff;
  border: 1px solid var(--cx-border);
  border-radius: 8px;
  padding: 10px;
}
.pipeline-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #526176;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
  margin-bottom: 10px;
}
.pipeline-head span {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #edf5ff;
  color: var(--cx-blue);
}
.pipeline-card {
  border: 1px solid var(--cx-border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  background: #f8fbff;
}
.letterhead-page {
  width: min(100%, 210mm);
  aspect-ratio: 210 / 297;
  margin: 0 auto;
  position: relative;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(22, 32, 51, .12);
}
.letterhead-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  z-index: 0;
}
.letterhead-content {
  position: absolute;
  left: 6.2%;
  right: 6.2%;
  top: 15.8%;
  bottom: 8%;
  font-size: 12px;
  line-height: 1.32;
  z-index: 1;
}
.doc-title-row, .doc-grid { display: table; width: 100%; }
.doc-title-row { margin-bottom: 18px; }
.doc-title-row > div, .doc-box { display: table-cell; vertical-align: top; }
.doc-title-row h1 { margin: 0; font-size: 28px; color: #202bd6; text-transform: uppercase; }
.doc-meta { text-align: right; }
.muted { color: var(--cx-muted); }
.mt-small { margin-top: 8px; }
.doc-grid { table-layout: fixed; margin-bottom: 16px; border-spacing: 12px 0; margin-left: -12px; }
.doc-box { border: 1px solid var(--cx-border); border-radius: 6px; padding: 10px; background: rgba(255,255,255,.74); }
.box-label { color: #202bd6; font-size: 10px; font-weight: 800; margin-bottom: 5px; }
.doc-box h2 { margin: 0 0 4px; font-size: 16px; }
.doc-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; table-layout: fixed; }
.doc-table th { background: #edf5ff; color: #202bd6; font-size: 10px; text-transform: uppercase; }
.doc-table th, .doc-table td { border: 1px solid var(--cx-border); padding: 7px; vertical-align: top; word-wrap: break-word; }
.doc-table th:nth-child(1), .doc-table td:nth-child(1) { width: 25%; }
.doc-table th:nth-child(2), .doc-table td:nth-child(2) { width: 35%; }
.doc-table th:nth-child(3), .doc-table td:nth-child(3) { width: 10%; }
.doc-table th:nth-child(4), .doc-table td:nth-child(4),
.doc-table th:nth-child(5), .doc-table td:nth-child(5) { width: 15%; }
.right { text-align: right; }
.totals-wrap { text-align: right; margin-bottom: 14px; }
.totals-box { display: inline-block; width: 270px; border: 1px solid var(--cx-border); background: rgba(255,255,255,.78); }
.totals-box div { display: table; width: 100%; border-bottom: 1px solid var(--cx-border); }
.totals-box div:last-child { border-bottom: 0; }
.totals-box span, .totals-box strong { display: table-cell; padding: 6px 8px; }
.totals-box strong { text-align: right; }
.grand-total { color: #202bd6; font-size: 14px; }
.doc-notes { max-height: 116px; overflow: hidden; font-size: 11px; color: #324056; }
.doc-thanks { text-align: center; font-weight: 800; margin: 12px 0 0; }
.letterhead-compact .letterhead-content { font-size: 10px; line-height: 1.18; top: 15.2%; }
.letterhead-compact .doc-title-row, .letterhead-compact .doc-grid { margin-bottom: 12px; }
.letterhead-compact .doc-table th, .letterhead-compact .doc-table td { padding: 4px; }
.letterhead-compact .doc-notes { max-height: 78px; font-size: 9.5px; }
.clipboard-image-preview,
.clipboard-card-image {
  width: auto;
  max-width: 160px;
  max-height: 160px;
  object-fit: contain;
  border: 1px solid var(--cx-border);
  border-radius: 8px;
  background: #f8fbff;
}
.clipboard-card-image {
  max-width: 180px;
  max-height: 180px;
}
.clipboard-card-image-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 100%;
}
.clipboard-pdf-card {
  width: 180px;
  min-height: 110px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  color: var(--cx-text);
  border: 1px solid var(--cx-border);
  border-radius: 8px;
  background: #f8fbff;
}
.clipboard-pdf-card i {
  color: #dc3545;
  font-size: 28px;
}
.clipboard-pdf-card span {
  font-size: 13px;
  font-weight: 700;
  word-break: break-word;
}
.message-box {
  min-height: 190px;
  font-size: 15px;
  line-height: 1.55;
}
.invoice-paper {
  background: #fff;
  border: 1px solid var(--cx-border);
  border-radius: 8px;
  padding: 30px;
}
.mobile-menu { display: none; position: fixed; top: 14px; left: 14px; z-index: 1040; }
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f5fbff 0%, #ffffff 48%, #effaf5 100%);
  padding: 20px;
}
.auth-card {
  max-width: 440px;
  width: 100%;
  background: #fff;
  border: 1px solid var(--cx-border);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(22, 32, 51, .1);
  padding: 28px;
}
.auth-logo { justify-content: center; margin-bottom: 18px; }

@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .mobile-menu { display: inline-flex; }
  .topbar { padding-left: 76px; }
  .content-wrap { padding: 18px; }
}

@media print {
  .sidebar, .topbar, .mobile-menu, .no-print { display: none !important; }
  .main { margin: 0; }
  .content-wrap { padding: 0; }
  body { background: #fff; }
  .invoice-paper { border: 0; box-shadow: none; padding: 0; }
}
