* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  max-width: 100%;
  -webkit-text-size-adjust: 100%;
}

:root {
  --bg: #f5f7fb;
  --bg-end: #eef6f5;
  --panel: #ffffff;
  --line: #e2e8f0;
  --text: #172033;
  --muted: #65758b;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --blue: #2563eb;
  --gold: #d97706;
  --cyan: #0891b2;
  --danger: #dc2626;
  --soft: #f1f5f9;
  --shadow: 0 10px 24px rgba(23, 32, 51, 0.06);
}

body[data-theme="navy"] {
  --bg: #eef2f8;
  --bg-end: #e8eef8;
  --line: #c5d3e8;
  --text: #0f1c35;
  --muted: #4d6484;
  --brand: #1e3a5f;
  --brand-dark: #142a47;
  --blue: #3b82f6;
  --gold: #ca8a04;
  --cyan: #0f766e;
  --soft: #edf3fc;
  --shadow: 0 14px 35px rgba(30, 58, 95, 0.12);
}

body[data-theme="sapphire"] {
  --bg: #eef8fb;
  --bg-end: #eef4ff;
  --line: #d5e6ed;
  --text: #12303f;
  --muted: #5d7280;
  --brand: #155e75;
  --brand-dark: #164e63;
  --blue: #2563eb;
  --gold: #d97706;
  --cyan: #0891b2;
  --soft: #edf8fb;
  --shadow: 0 14px 35px rgba(21, 94, 117, 0.1);
}

body[data-theme="forest"] {
  --bg: #f0f8f2;
  --bg-end: #eaf5ec;
  --line: #c2ddc8;
  --text: #122018;
  --muted: #4e6b55;
  --brand: #166534;
  --brand-dark: #14532d;
  --blue: #15803d;
  --gold: #ca8a04;
  --cyan: #22c55e;
  --soft: #ecf8ee;
  --shadow: 0 14px 35px rgba(22, 101, 52, 0.12);
}

body[data-theme="steel"] {
  --bg: #f4f7fb;
  --bg-end: #eef2f7;
  --line: #d8dee7;
  --text: #182230;
  --muted: #64748b;
  --brand: #475569;
  --brand-dark: #1e293b;
  --blue: #0f766e;
  --gold: #b45309;
  --cyan: #0891b2;
  --soft: #f1f5f9;
  --shadow: 0 14px 35px rgba(30, 41, 59, 0.1);
}

body[data-theme="graphite"] {
  --bg: #f4f6f8;
  --bg-end: #eef2f5;
  --line: #d0d8e0;
  --text: #111827;
  --muted: #6b7280;
  --brand: #374151;
  --brand-dark: #1f2937;
  --blue: #4b5563;
  --gold: #b45309;
  --cyan: #9ca3af;
  --soft: #f3f5f7;
  --shadow: 0 14px 35px rgba(55, 65, 81, 0.12);
}

body[data-theme="copper"] {
  --bg: #fdf6ee;
  --bg-end: #fff7ed;
  --line: #d4b89a;
  --text: #1c120a;
  --muted: #7a5c40;
  --brand: #92400e;
  --brand-dark: #78350f;
  --blue: #f59e0b;
  --gold: #d97706;
  --cyan: #b45309;
  --soft: #fef3e2;
  --shadow: 0 14px 35px rgba(146, 64, 14, 0.12);
}

body[data-theme="ocean"] {
  --bg: #eff6ff;
  --bg-end: #eef2ff;
  --line: #bfdbfe;
  --text: #1e3a5f;
  --muted: #3b6fa0;
  --brand: #1d4ed8;
  --brand-dark: #1e40af;
  --blue: #60a5fa;
  --gold: #d97706;
  --cyan: #0891b2;
  --soft: #eff6ff;
  --shadow: 0 14px 35px rgba(29, 78, 216, 0.12);
}

body[data-theme="ruby"] {
  --bg: #fff3f4;
  --bg-end: #fef2f2;
  --line: #fecdd3;
  --text: #1a0608;
  --muted: #7f4550;
  --brand: #991b1b;
  --brand-dark: #7f1d1d;
  --blue: #dc2626;
  --gold: #ef4444;
  --cyan: #b91c1c;
  --soft: #fff1f1;
  --shadow: 0 14px 35px rgba(153, 27, 27, 0.12);
}

body[data-theme="dark"] {
  --bg: #111827;
  --bg-end: #0d1117;
  --panel: #1f2937;
  --line: #374151;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --brand: #6366f1;
  --brand-dark: #4f46e5;
  --blue: #818cf8;
  --gold: #fbbf24;
  --cyan: #22d3ee;
  --danger: #f87171;
  --soft: #1f2937;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}

body[data-theme="purple"] {
  --bg: #f6f3ff;
  --bg-end: #ede9fe;
  --line: #d8d0f8;
  --text: #1a0a3c;
  --muted: #6b50a0;
  --brand: #6d28d9;
  --brand-dark: #5b21b6;
  --blue: #8b5cf6;
  --gold: #d97706;
  --cyan: #7c3aed;
  --soft: #f0ebff;
  --shadow: 0 14px 35px rgba(109, 40, 217, 0.13);
}

body {
  margin: 0;
  min-width: 320px;
  max-width: 100%;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, #ffffff 0%, var(--bg) 42%, var(--bg-end) 100%);
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  color: #ffffff;
  background: var(--brand);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.14);
}

button:hover {
  background: var(--brand-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-btn {
  color: var(--text);
  background: #f1f5f9;
  border: 1px solid #dbe4ec;
  box-shadow: none;
}

.secondary-btn:hover {
  background: #e8eef5;
}

.danger-btn {
  background: var(--danger);
}

.danger-btn:hover {
  background: #b91c1c;
}

.hidden {
  display: none !important;
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.18), transparent 28%),
    radial-gradient(circle at 80% 30%, rgba(15, 118, 110, 0.18), transparent 26%),
    linear-gradient(135deg, #f6f8fb 0%, #e6edf1 100%);
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 60px rgba(23, 32, 51, 0.16);
}

.login-card h1 {
  margin-bottom: 8px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.04), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), transparent 260px);
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: min(280px, 86vw);
  height: 100vh;
  height: 100dvh;
  padding: 18px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  color: var(--text);
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow: 10px 0 30px rgba(15, 23, 42, 0.08);
  transform: translateX(-105%);
  transition: transform 180ms ease;
}

.app-shell.sidebar-open .sidebar {
  transform: translateX(0);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: rgba(15, 23, 42, 0.46);
  box-shadow: none;
}

.sidebar-backdrop:hover {
  background: rgba(15, 23, 42, 0.46);
}

.app-shell.sidebar-open .sidebar-backdrop {
  display: block;
}

.mobile-tabbar {
  display: none;
}

.mobile-nav-link {
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 1px solid #edf2f7;
  border-radius: 8px;
  background: #ffffff;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand), var(--blue));
  font-weight: 800;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.brand strong {
  color: var(--text);
}

.nav {
  display: grid;
  gap: 6px;
  padding-bottom: 8px;
}

.nav-link {
  min-height: 42px;
  justify-content: flex-start;
  width: 100%;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  box-shadow: none;
}

.nav-link:hover,
.nav-link.active {
  color: var(--brand-dark);
  border-left-color: var(--brand);
  border-color: rgba(15, 118, 110, 0.14);
  background: #eef7f6;
  box-shadow: none;
}

.sidebar #logoutBtn {
  margin-top: auto;
  color: var(--text);
  border: 1px solid var(--line);
  background: #f8fafc;
  box-shadow: none;
}

.workspace {
  flex: 1;
  min-height: 0;
  width: 100%;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.topbar {
  position: sticky;
  top: 14px;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-title h1 {
  line-height: 1.1;
}

.menu-toggle {
  min-width: 76px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: min(760px, 100%);
}

.topbar-actions > * {
  min-width: 0;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.sync-pill[data-state="ok"] {
  color: #047857;
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.sync-pill[data-state="syncing"] {
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.sync-pill[data-state="error"] {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

.sync-center {
  display: grid;
  gap: 14px;
  margin: -4px 0 18px;
  padding: 16px;
  border: 1px solid rgba(14, 165, 164, 0.22);
  border-radius: 8px;
  background: #f8fbfc;
  box-shadow: var(--shadow);
}

.sync-center-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.sync-center-head h2 {
  line-height: 1.2;
}

.sync-center-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.sync-center-actions button {
  min-height: 36px;
  padding: 8px 12px;
}

.sync-center-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.sync-center-grid article {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.sync-center-grid span,
.sync-center-details span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.sync-center-grid strong,
.sync-center-details strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
}

.sync-center-details {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.sync-center-details p {
  min-width: 0;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
}

@media (max-width: 980px) {
  .sync-center-grid,
  .sync-center-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .sync-center {
    margin: -4px 0 14px;
    padding: 12px;
  }

  .sync-center-head {
    align-items: stretch;
    flex-direction: column;
  }

  .sync-center-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .sync-center-actions button {
    width: 100%;
  }

  .sync-center-grid,
  .sync-center-details {
    grid-template-columns: 1fr;
  }
}

.page-view {
  display: none;
}

.page-view.active {
  display: block;
}

.panel,
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.panel {
  padding: 20px;
}

.panel + .panel {
  margin-top: 18px;
}

.quotation-panel {
  display: grid;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
}

/* Prevent any grid/flex child inside the quote panels from overflowing */
.quotation-panel > *,
.quote-details-grid > *,
.summary > * {
  min-width: 0;
}

.quote-status-bar {
  position: sticky;
  top: 92px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: -18px -18px 0;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: linear-gradient(135deg, #ffffff, #eef8f7);
}

.quote-status-bar strong {
  display: block;
  color: var(--brand-dark);
  font-size: 15px;
}

.quote-status-actions {
  display: flex;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  min-height: 124px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
}

.stat-card[data-go] {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.stat-card[data-go]:hover,
.stat-card[data-go]:focus {
  transform: translateY(-2px);
  border-color: rgba(15, 118, 110, 0.28);
  box-shadow: 0 18px 38px rgba(23, 32, 51, 0.12);
  outline: none;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  width: auto;
  background: var(--brand);
}

.stat-card:nth-child(2)::before {
  background: var(--blue);
}

.stat-card:nth-child(3)::before {
  background: var(--gold);
}

.stat-card:nth-child(4)::before {
  background: var(--blue);
}

.stat-card:nth-child(5)::before {
  background: var(--brand);
}

.stat-card:nth-child(6)::before {
  background: var(--danger);
}

.stat-card span {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-card strong {
  overflow-wrap: anywhere;
  font-size: 30px;
  line-height: 1.05;
}

.stat-card:nth-child(1) strong {
  color: var(--brand-dark);
}

.stat-card:nth-child(2) strong {
  color: var(--blue);
}

.stat-card:nth-child(3) strong {
  color: var(--gold);
}

.stat-card:nth-child(4) strong {
  color: var(--blue);
}

.stat-card:nth-child(5) strong {
  color: var(--brand-dark);
}

.stat-card:nth-child(6) strong {
  color: var(--danger);
}

.quick-actions,
.inventory-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.85fr);
  gap: 18px;
  margin-top: 20px;
}

.report-dashboard-grid {
  margin-top: 14px;
}

.report-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.report-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.report-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.report-card strong {
  display: block;
  color: var(--text);
  font-size: 20px;
}

.mini-report-list {
  display: grid;
  gap: 10px;
}

.mini-report-row {
  display: grid;
  grid-template-columns: minmax(86px, 0.7fr) minmax(90px, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.mini-report-row span,
.mini-report-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-report-row span {
  color: var(--muted);
  font-size: 13px;
}

.mini-report-row strong {
  color: var(--text);
  font-size: 13px;
}

.mini-report-row div {
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.mini-report-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

#staffPerformancePanel {
  margin-top: 18px;
}

.staff-performance-table {
  min-width: 720px;
}

.staff-performance-table th,
.staff-performance-table td {
  text-align: center;
}

.staff-performance-table th:first-child,
.staff-performance-table td:first-child {
  width: auto;
  text-align: left;
}

.staff-performance-name small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-panel {
  min-width: 0;
}

.dashboard-panel .section-heading {
  align-items: start;
}

#dashboardQuotationFilter {
  flex: 0 0 170px;
  width: 170px;
  max-width: 100%;
}

.dashboard-list {
  display: grid;
  gap: 12px;
}

.dashboard-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  width: 100%;
  border: 1px solid #e3e9ef;
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
  text-align: left;
}

.dashboard-list-item:hover {
  color: var(--text);
  background: #f8fafc;
  border-color: #cbd5e1;
}

.dashboard-list-item span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.dashboard-list-item strong,
.dashboard-list-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-list-item small {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-list-item b {
  flex: 0 0 auto;
  color: var(--brand-dark);
}

.dashboard-list-item.due b {
  color: var(--gold);
}

.dashboard-list-item.overdue b {
  color: var(--danger);
}

.dashboard-empty {
  padding: 16px;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafc;
}

.smart-alert-list,
.task-list {
  display: grid;
  gap: 10px;
}

.smart-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #dbe5ec;
  border-left-width: 4px;
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  box-shadow: none;
  text-align: left;
}

.smart-alert:hover {
  color: var(--text);
  background: #f8fafc;
}

.smart-alert span,
.task-item span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.smart-alert strong,
.smart-alert small,
.task-item strong,
.task-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smart-alert small,
.task-item small {
  color: var(--muted);
  font-size: 12px;
}

.smart-alert b,
.task-item b {
  flex: 0 0 auto;
  font-size: 12px;
}

.smart-alert-critical {
  border-left-color: var(--danger);
}

.smart-alert-warning {
  border-left-color: var(--gold);
}

.smart-alert-success {
  border-left-color: var(--brand);
}

.smart-alert-info {
  border-left-color: var(--blue);
}

.task-summary-grid {
  margin-bottom: 14px;
}

.task-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.task-column {
  min-width: 0;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.task-column-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.task-column-heading h3 {
  margin: 0;
  font-size: 14px;
}

.task-column-heading span {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  min-height: 24px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 70px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  box-shadow: none;
  text-align: left;
}

.task-item:hover {
  color: var(--text);
  background: #ffffff;
  border-color: #cbd5e1;
}

.task-item.priority-overdue {
  border-left-color: var(--danger);
}

.task-item.priority-today {
  border-left-color: var(--gold);
}

.task-item.priority-upcoming {
  border-left-color: var(--brand);
}

.lead-pipeline-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.lead-pipeline-card {
  display: grid;
  gap: 5px;
  min-height: 86px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  box-shadow: none;
  text-align: left;
}

.lead-pipeline-card:hover { color: var(--text); background: #f8fafc; }

.lead-pipeline-card.status-New              { background:#eff6ff; border-color:#bfdbfe; }
.lead-pipeline-card.status-New em           { background:#2563eb; }
.lead-pipeline-card.status-Contacted        { background:#ecfeff; border-color:#a5f3fc; }
.lead-pipeline-card.status-Contacted em     { background:#0891b2; }
.lead-pipeline-card.status-Requirement-Received       { background:#f5f3ff; border-color:#ddd6fe; }
.lead-pipeline-card.status-Requirement-Received em    { background:#7c3aed; }
.lead-pipeline-card.status-Quoted           { background:#fffbeb; border-color:#fde68a; }
.lead-pipeline-card.status-Quoted em        { background:#d97706; }
.lead-pipeline-card.status-Follow-Up        { background:#fff1f2; border-color:#fecdd3; }
.lead-pipeline-card.status-Follow-Up em     { background:#e11d48; }
.lead-pipeline-card.status-Converted        { background:#f0fdf4; border-color:#bbf7d0; }
.lead-pipeline-card.status-Converted em     { background:#16a34a; }
.lead-pipeline-card.status-Lost             { background:#fef2f2; border-color:#fecaca; }
.lead-pipeline-card.status-Lost em          { background:#dc2626; }

.lead-pipeline-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.lead-pipeline-card strong {
  font-size: 20px;
}

.lead-pipeline-card small {
  color: var(--muted);
}

.lead-pipeline-card i {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.lead-pipeline-card em {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.activity-log-table td:last-child {
  min-width: 260px;
}

.activity-log-table td:last-child strong,
.activity-log-table td:last-child small {
  display: block;
}

.activity-log-table td:last-child small {
  margin-top: 3px;
  color: var(--muted);
}

.activity-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--text);
  background: #e2e8f0;
  font-size: 12px;
  font-weight: 800;
}

.activity-critical {
  color: #991b1b;
  background: #fee2e2;
}

.activity-warning {
  color: #92400e;
  background: #fef3c7;
}

.activity-success {
  color: #166534;
  background: #dcfce7;
}

.activity-info {
  color: #1e40af;
  background: #dbeafe;
}

.board-filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.board-filter-bar .field {
  margin: 0;
}

.board-filter-bar button {
  width: 100%;
  min-height: 44px;
}

.board-filter-summary {
  grid-column: 1 / -1;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-filter-bar {
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
}

.saved-quotes-filter-bar {
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
}

.lead-filter-bar {
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.activity-filter-bar {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.lead-tracker-summary {
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.lead-tracker-summary .report-card {
  padding: 8px 10px;
}

.lead-tracker-summary .report-card span {
  margin-bottom: 3px;
  font-size: 10px;
}

.lead-tracker-summary .report-card strong {
  font-size: 16px;
}

.lead-form-panel {
  margin-bottom: 10px;
  padding: 10px;
}

.lead-form-panel .sub-panel-heading {
  margin-bottom: 8px;
}

.lead-form-panel .sub-panel-heading h2 {
  font-size: 15px;
}

.lead-form-grid {
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
  align-items: end;
}

.lead-form-grid .full-width {
  grid-column: 1 / -1;
}

.lead-form-grid button {
  min-height: 34px;
  padding: 8px 10px;
}

.activity-log-table td {
  padding: 8px;
}

.status-board-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.status-summary-card {
  display: grid;
  justify-content: stretch;
  gap: 4px;
  min-height: 76px;
  padding: 11px 12px;
  border: 1px solid #dce4ee;
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  box-shadow: none;
  text-align: left;
}

.status-summary-card:hover {
  color: var(--text);
  background: #f8fafc;
}

.status-summary-card span,
.status-summary-card small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-summary-card strong {
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.status-summary-card.active {
  border-color: var(--brand);
  background: #ecfdf5;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.13);
}

.status-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  align-items: start;
}

.status-board.single-status-board {
  grid-template-columns: minmax(0, 1fr);
}

.status-column {
  min-width: 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fbfdff;
  overflow: hidden;
}

.status-column-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 2;
}

.status-column-title {
  min-width: 0;
}

.status-column-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-column-heading h2 {
  margin: 0;
  font-size: 15px;
}

.status-column-count {
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--brand);
  font-weight: 800;
  font-size: 12px;
}

.status-column-list {
  display: grid;
  gap: 8px;
  max-height: min(720px, 70vh);
  overflow: auto;
  padding: 8px;
  scrollbar-gutter: stable;
}

.status-card {
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 5px 14px rgba(15, 23, 42, 0.04);
}

.status-card-main {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.status-card-title {
  min-width: 0;
}

.status-card-title strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-card-title span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-card-amount {
  flex: 0 0 auto;
  color: var(--brand-dark);
  font-size: 13px;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
}

.status-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.status-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-card-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.status-card select {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
}

.status-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.status-card-actions button {
  min-height: 32px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-actions button {
  min-height: 34px;
  padding: 7px 10px;
}

.customer-ledger-panel {
  margin-top: 16px;
}

.inventory-panel {
  display: grid;
  gap: 16px;
}

.inventory-workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(360px, 1fr);
  gap: 14px;
}

.inventory-upload-panel,
.inventory-filter-panel,
.inventory-history-panel,
.inventory-results {
  min-width: 0;
}

.inventory-tools,
.inventory-filter-grid {
  display: grid;
  gap: 12px;
  align-items: end;
}

.inventory-tools {
  grid-template-columns: minmax(220px, 1fr) minmax(140px, 180px);
}

.inventory-filter-grid {
  grid-template-columns: minmax(150px, 190px) minmax(220px, 1fr);
}

.inventory-maintenance {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #edf2f7;
}

.inventory-maintenance button {
  flex: 0 0 auto;
}

.inventory-maintenance span {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.inventory-batch-list {
  display: grid;
  gap: 8px;
}

.inventory-batch-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.inventory-batch-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.inventory-batch-item button {
  flex: 0 0 auto;
}

.inventory-export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.inventory-dup-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  margin-top: 12px;
  background: #fefce8;
  border: 1px solid #fde047;
  border-radius: 8px;
  font-size: 13px;
}

[data-theme="dark"] .inventory-dup-banner {
  background: #2d1f00;
  border-color: #92400e;
}

.inventory-dup-banner.hidden {
  display: none;
}

.inventory-dup-banner span {
  flex: 1;
  min-width: 0;
  color: #92400e;
  font-weight: 500;
}

[data-theme="dark"] .inventory-dup-banner span {
  color: #fcd34d;
}

.inventory-dup-merge-btn {
  flex-shrink: 0;
  padding: 5px 14px;
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 32px;
}

.inventory-dup-merge-btn:hover {
  opacity: 0.88;
}

.inventory-dup-dismiss {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  padding: 0;
}

.inventory-dup-dismiss:hover {
  background: var(--line);
  border-color: var(--line);
}

.inventory-results {
  display: grid;
  gap: 10px;
  margin-top: 2px;
}

.inventory-filter-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.inventory-filter-note button {
  min-height: 34px;
  padding: 7px 10px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eef2f6;
}

.section-heading > div,
.sub-panel-heading {
  min-width: 0;
}

.section-heading .muted,
.sub-panel-heading .muted {
  margin: 6px 0 0;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: end;
  gap: 8px;
}

.section-actions button {
  min-height: 38px;
  padding: 8px 12px;
}

.inline-field {
  min-width: 160px;
}

.inline-field select {
  min-height: 38px;
}

.section-heading h2,
.sub-panel-heading h2 {
  line-height: 1.2;
}

.section-heading select {
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted,
.hint {
  color: var(--muted);
}

.hint {
  margin: 14px 0;
  font-size: 13px;
  line-height: 1.45;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

.checkbox-field {
  justify-content: end;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.toggle-row input {
  width: 18px;
  min-height: auto;
  flex: 0 0 auto;
}

input,
textarea,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--text);
  background: #ffffff;
  font-weight: 400;
  line-height: 1.35;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.14);
}

input:disabled,
textarea:disabled,
select:disabled {
  color: #475569;
  background: #f1f5f9;
  cursor: not-allowed;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

select {
  min-height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 7px 10px;
  font: inherit;
  font-weight: 700;
  background: #ffffff;
}

.status-select {
  min-width: 110px;
}

.quote-type-select {
  min-width: 136px;
}

.quote-type-badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  min-height: 24px;
  padding: 4px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  color: #334155;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

.quote-mode-pill {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  min-height: 22px;
  margin-top: 4px;
  padding: 3px 8px;
  border: 1px solid #d4dde7;
  border-radius: 999px;
  color: var(--muted);
  background: #ffffff;
  font-size: 11px;
  font-weight: 800;
}

.quote-type-badge.type-Steel,
.lead-requirement-badge.type-Steel {
  color: #334155;
  border-color: #cbd5e1;
  background: #f8fafc;
}

.quote-type-badge.type-Electricals,
.lead-requirement-badge.type-Electricals {
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.quote-type-badge.type-Plumbing,
.lead-requirement-badge.type-Plumbing {
  color: #047857;
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.quote-type-badge.type-Hardware,
.lead-requirement-badge.type-Hardware {
  color: #b45309;
  border-color: #fde68a;
  background: #fffbeb;
}

.quote-type-badge.type-Others,
.lead-requirement-badge.type-Others {
  color: #6d28d9;
  border-color: #ddd6fe;
  background: #f5f3ff;
}

.status-Pending {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.status-Converted {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.status-Rejected {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

.status-Next-Month {
  color: #b45309;
  background: #fffbeb;
  border-color: #fde68a;
}

.follow-date-input {
  min-width: 145px;
}

.follow-note-input {
  min-width: 260px;
}

textarea {
  min-height: 76px;
  resize: vertical;
}

.file-drop {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 82px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  color: var(--brand-dark);
  background: linear-gradient(135deg, #f8fafc, #edf9f7);
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.file-drop input {
  display: none;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.backup-actions button {
  min-width: 150px;
}

.inventory-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.inventory-empty {
  padding: 16px;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafc;
  line-height: 1.5;
}

.inventory-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, #fbfdff);
  box-shadow: 0 8px 20px rgba(23, 32, 51, 0.05);
}

.inventory-item:hover {
  border-color: rgba(15, 118, 110, 0.32);
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.1);
}

.inventory-item strong {
  display: block;
  margin-bottom: 4px;
}

.inventory-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.company-block {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 190px;
  gap: 16px;
  align-items: start;
  margin-bottom: 0;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.quote-company-profile {
  align-items: stretch;
  padding: 16px;
  border: 1px solid #dbe5ee;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(8, 145, 178, 0.08), rgba(16, 185, 129, 0.05)),
    #ffffff;
}

.company-logo {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
}

.company-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.company-profile-copy {
  display: grid;
  align-content: center;
  gap: 5px;
  min-width: 0;
}

.company-profile-copy h2 {
  margin: 0;
  color: var(--brand-dark);
  font-size: 22px;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.company-profile-copy p:last-child {
  margin: 0;
  color: #475569;
  line-height: 1.55;
  white-space: pre-line;
}

.company-profile-lock {
  display: grid;
  align-content: center;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #cfe3dd;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
}

.company-profile-lock span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.company-profile-lock strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.company-profile-lock button {
  width: 100%;
}

.company-fields {
  display: grid;
  gap: 12px;
}

.hidden-form-field {
  display: none !important;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.compact {
  gap: 12px;
}

.quote-details-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(360px, 1.35fr);
  gap: 14px;
}

.sub-panel {
  padding: 16px;
  border: 1px solid #e4e9ef;
  border-radius: 8px;
  background: linear-gradient(135deg, #fbfcfd, #ffffff);
}

.sub-panel-heading {
  margin-bottom: 14px;
}

.sub-panel-heading h2 {
  font-size: 18px;
}

.full-width {
  grid-column: 1 / -1;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  table-layout: auto;
}

th,
td {
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 9px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #475569;
  font-size: 13px;
  font-weight: 800;
  background: #f8fafc;
  white-space: nowrap;
}

tbody tr:hover {
  background: #fbfdff;
}

td {
  overflow-wrap: anywhere;
}

.line-items-table,
.cash-table {
  min-width: 920px;
  table-layout: fixed;
}

/* ════════════════════════════════════════════════════════════
   QUOTATION RECORDS
   Desktop ≥900px : sticky header + full-width striped rows
   Mobile  <900px : compact 2-row cards
   ════════════════════════════════════════════════════════════ */
/* ════════════════════════════════════════════════════════════
   QUOTATION RECORDS TABLE
   Desktop ≥900px : sticky header + full-width striped rows
   Mobile  <900px : 4-row stacked cards
   ════════════════════════════════════════════════════════════ */
.saved-quotes-table {
  display: block;
  width: 100%;
}
.saved-quotes-table thead { display: none; }
.saved-quotes-table tbody { display: flex; flex-direction: column; gap: 8px; }
.saved-quotes-table td   { display: block; padding: 0; min-width: 0; }
.saved-quotes-table td[colspan] {
  grid-column: 1 / -1; padding: 16px;
  color: var(--muted); text-align: center;
}

/* Named grid areas */
.sqt-no-cell       { grid-area: qno; }
.sqt-customer-cell { grid-area: customer; }
.sqt-dates-cell    { grid-area: dates; }
.sqt-total-cell    { grid-area: total; }
.sqt-status-cell   { grid-area: status; }
.saved-quotes-table .table-actions { grid-area: actions; }

/* Cell content */
.sqt-no-cell .qno-badge { display: block; font-weight: 700; font-size: 13px; }
.sqt-mode { display: block; margin-top: 2px; font-size: 10px; color: var(--muted); }
.sqt-customer-cell .quote-customer-name {
  display: block; font-size: 13px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sqt-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 3px; font-size: 11px; color: var(--muted);
}
.sqt-type-select {
  font-size: 11px; padding: 1px 4px; height: 22px;
  min-height: unset; max-width: 100px; flex-shrink: 0;
}
.sqt-date-val { display: block; font-size: 12px; white-space: nowrap; }
.sqt-followup {
  display: block; margin-top: 3px; font-size: 11px;
  min-height: unset; padding: 2px 5px; height: 24px; width: 120px;
}
.sqt-total-cell { text-align: right; font-weight: 800; font-size: 14px; white-space: nowrap; color: var(--brand-dark); }
.sqt-status-cell .status-select { font-size: 12px; width: 100%; }
.saved-quotes-table .table-actions {
  display: flex; flex-wrap: nowrap; gap: 5px;
  align-items: center; justify-content: flex-end;
}
.saved-quotes-table .table-actions button,
.quote-action-btn {
  width: auto; font-size: 11px; padding: 4px 10px; min-height: 28px; white-space: nowrap;
}

/* Status accent — left border colour */
.saved-quotes-table tbody tr[data-status="Pending"]    { border-left: 3px solid #3b82f6; }
.saved-quotes-table tbody tr[data-status="Converted"]  { border-left: 3px solid #10b981; }
.saved-quotes-table tbody tr[data-status="Rejected"]   { border-left: 3px solid #ef4444; }
.saved-quotes-table tbody tr[data-status="Next Month"] { border-left: 3px solid #f59e0b; }

/* ── Desktop ≥900px ── */
@media (min-width: 900px) {
  .saved-quotes-table thead {
    display: block; position: sticky; top: 0; z-index: 2;
  }
  .saved-quotes-table thead tr,
  .saved-quotes-table tbody tr {
    display: grid;
    grid-template-areas: "qno customer dates total status actions";
    grid-template-columns: 100px minmax(200px, 1.5fr) 150px 110px 130px auto;
    column-gap: 16px; align-items: center;
  }
  .saved-quotes-table thead tr {
    padding: 8px 18px 8px 20px;
    background: var(--soft);
    border-bottom: 2px solid var(--line);
    border-radius: 8px 8px 0 0;
  }
  .saved-quotes-table thead th {
    display: block; padding: 0;
    font-size: 10px; font-weight: 800; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.05em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .saved-quotes-table thead th:nth-child(4) { text-align: right; }
  .saved-quotes-table tbody { display: block; }
  .saved-quotes-table tbody tr {
    padding: 9px 18px 9px 17px;
    border-bottom: 1px solid var(--line);
    border-left: 3px solid transparent;
    background: var(--panel);
  }
  .saved-quotes-table tbody tr:last-child { border-bottom: none; }
  .saved-quotes-table tbody tr:nth-child(even) { background: var(--soft); }
  .saved-quotes-table tbody tr:hover { background: rgba(59,130,246,0.05); }
  .saved-quotes-table td[colspan] { padding: 20px 0; }
  .sqt-status-cell .status-select { max-width: 125px; }
  .sqt-followup { width: 130px; }
}

/* ── Mobile <900px : 4-row stacked card ── */
@media (max-width: 899px) {
  .saved-quotes-table tbody tr {
    display: grid;
    grid-template-areas:
      "qno     total"
      "customer customer"
      "dates    dates"
      "status   actions";
    grid-template-columns: 1fr auto;
    column-gap: 10px; row-gap: 6px;
    padding: 11px 13px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--panel); box-shadow: 0 1px 5px rgba(0,0,0,.05);
  }
  .sqt-total-cell { text-align: right; font-size: 16px; align-self: center; }
  .saved-quotes-table td[colspan] { grid-column: 1 / -1; padding: 12px 0; }
}

/* ════════════════════════════════════════════════════════════
   LEAD TRACKER TABLE
   Desktop ≥900px : sticky header + full-width striped rows
   Mobile  <900px : 4-row stacked cards
   ════════════════════════════════════════════════════════════ */
.lead-tracker-table {
  display: block;
  width: 100%;
}
.lead-tracker-table thead { display: none; }
.lead-tracker-table tbody { display: flex; flex-direction: column; gap: 8px; }
.lead-tracker-table td   { display: block; padding: 0; min-width: 0; }

/* Named grid areas */
.lead-customer-cell { grid-area: customer; }
.lead-req-cell      { grid-area: req; }
.lead-contact-cell  { grid-area: contact; }
.lead-money-cell    { grid-area: value; }
.lead-status-cell   { grid-area: status; }
.lead-tracker-table .lead-actions { grid-area: actions; }

/* Cell content */
.lead-customer-cell strong {
  display: block; font-size: 13px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lead-customer-cell small { display: block; margin-top: 2px; font-size: 10px; color: var(--muted); }
.lead-req-cell .lead-requirement-badge {
  display: inline-block; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
}
.lead-by-line {
  display: block; margin-top: 4px; font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lead-contact-cell strong { display: block; font-size: 12px; white-space: nowrap; color: var(--text); }
.lead-contact-cell small  { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.lead-money-cell { white-space: nowrap; font-weight: 800; color: var(--brand-dark); font-size: 13px; }
.lead-remark-preview {
  display: block; margin-top: 3px; font-size: 11px; color: var(--muted);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: help;
}
/* ── Lead remark full-width sub-row ── */
.lead-remark-row { display: block !important; width: 100%; }
.lead-remark-row td { display: block !important; padding: 0 18px 12px !important; border-bottom: 1px solid var(--line); }
.lead-remark-block {
  background: var(--soft); border-left: 3px solid var(--brand); border-radius: 0 6px 6px 0;
  padding: 8px 12px; font-size: 12.5px; color: var(--text); line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
}
.lead-remark-list { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.lead-remark-list li { padding: 1px 0; }
.lead-remark-list li::before { content: "•"; color: var(--brand); margin-right: 6px; font-size: 14px; }
@media (max-width: 899px) {
  .lead-remark-row td { padding: 0 10px 10px !important; }
  /* Cards with no remark row get full border-radius */
  .lead-tracker-table tbody tr.lead-no-remark {
    border-radius: 10px !important;
  }
}
.lead-tracker-table .lead-actions {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: flex-end;
  min-width: 0;
}
.lead-tracker-table .lead-actions button {
  width: auto; font-size: 11px; padding: 4px 8px; min-height: 28px; white-space: nowrap; flex-shrink: 0;
}

/* ── Desktop ≥900px ── */
@media (min-width: 900px) {
  .lead-tracker-table thead {
    display: block; position: sticky; top: 0; z-index: 2;
  }
  .lead-tracker-table thead tr,
  .lead-tracker-table tbody tr {
    display: grid;
    grid-template-areas: "customer req contact value status actions";
    grid-template-columns: minmax(150px, 1.2fr) minmax(130px, 1fr) 140px 90px minmax(145px,1fr) 160px;
    column-gap: 16px; align-items: center;
  }
  .lead-tracker-table thead tr {
    padding: 8px 18px;
    background: var(--soft);
    border-bottom: 2px solid var(--line);
    border-radius: 8px 8px 0 0;
  }
  .lead-tracker-table thead th {
    display: block; padding: 0;
    font-size: 10px; font-weight: 800; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.05em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .lead-tracker-table thead th:nth-child(4) { text-align: right; }
  .lead-tracker-table tbody { display: block; }
  .lead-tracker-table tbody tr {
    padding: 9px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
  }
  .lead-tracker-table tbody tr:last-child { border-bottom: none; }
  .lead-tracker-table tbody tr:nth-child(even) { background: var(--soft); }
  .lead-tracker-table tbody tr:hover { background: rgba(59,130,246,0.05); }
  .lead-money-cell { text-align: right; }
  .lead-remark-preview { white-space: normal; -webkit-line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; }
}

/* ── Mobile <900px : 4-row stacked card ── */
@media (max-width: 899px) {
  .lead-tracker-table tbody tr:not(.lead-remark-row) {
    display: grid;
    grid-template-areas:
      "customer customer"
      "req      contact"
      "value    status"
      "actions  actions";
    grid-template-columns: 1fr 1fr;
    column-gap: 10px; row-gap: 7px; align-items: start;
    padding: 11px 13px;
    border: 1px solid var(--line); border-radius: 10px 10px 0 0;
    background: var(--panel); box-shadow: 0 1px 5px rgba(0,0,0,.05);
  }
  .lead-tracker-table tbody tr.lead-remark-row {
    display: table-row;
    border: 1px solid var(--line); border-top: none; border-radius: 0 0 10px 10px;
    box-shadow: 0 1px 5px rgba(0,0,0,.05);
  }
  .lead-tracker-table tbody tr.lead-remark-row td { display: block; }
  .lead-money-cell { font-size: 15px; }
  .lead-status-cell { text-align: right; }
  .lead-tracker-table .lead-actions { flex-wrap: wrap; justify-content: flex-start; }
}

.quotation-records-table-wrap,
.lead-tracker-table-wrap { overflow-x: hidden; }

.lead-requirement-badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid #d5dde8;
  border-radius: 999px;
  color: #334155;
  background: #f8fafc;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.lead-remark-cell {
  min-width: 150px;
  max-width: 220px;
  color: #334155;
  font-size: 12px;
  line-height: 1.35;
}

.lead-empty-note {
  color: var(--muted);
  font-style: italic;
}

.lead-actions button {
  width: 100%;
  min-height: 28px;
  padding: 5px 6px;
  font-size: 11px;
}

.lead-status-pill {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid #d5dde8;
  border-radius: 999px;
  color: #334155;
  background: #f8fafc;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.lead-status-pill.status-Converted {
  color: #047857;
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.lead-status-pill.status-Lost {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

.lead-status-pill.status-Quoted,
.lead-status-pill.status-Follow-Up {
  color: #b45309;
  border-color: #fde68a;
  background: #fffbeb;
}

.lead-status-pill.status-New,
.lead-status-pill.status-Contacted,
.lead-status-pill.status-Requirement-Received {
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.line-items-table th:nth-child(1) {
  width: 58px;
  text-align: center;
}

.line-items-table th:nth-child(2) {
  width: 34%;
}

.line-items-table th:nth-child(4),
.line-items-table th:nth-child(5) {
  width: 96px;
}

.line-items-table th:nth-child(3) {
  width: 82px;
  text-align: center;
}

.line-items-table th:nth-child(6),
.line-items-table th:nth-child(7) {
  width: 118px;
}

.line-items-table th:nth-child(8) {
  width: 100px;
}

td input {
  min-width: 0;
}

td select {
  min-width: 0;
}

.line-items-table td:nth-child(1),
.line-items-table td:nth-child(3),
.line-items-table td:nth-child(8),
.cash-table td:nth-child(1),
.cash-table td:nth-child(3),
.cash-table td:nth-child(8) {
  text-align: center;
}

.line-items-table td:nth-child(4) input,
.line-items-table td:nth-child(6) input,
.cash-table td:nth-child(4) input,
.cash-table td:nth-child(6) input,
.qty-input,
.line-total,
.cash-line-total {
  text-align: right;
}

.line-items-table td:nth-child(5) select,
.cash-table td:nth-child(5) select {
  text-align: center;
}

td .danger-btn {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
}

.item-image-picker {
  display: block;
  width: 58px;
  height: 46px;
  margin: 0 auto;
  cursor: pointer;
}

.item-image-picker input {
  display: none;
}

.item-image-preview {
  display: grid;
  place-items: center;
  width: 58px;
  height: 46px;
  border: 1px dashed #94a3b8;
  border-radius: 6px;
  color: var(--brand-dark);
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
}

.item-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.inventory-suggestion-menu {
  position: fixed;
  z-index: 1000;
  display: grid;
  max-height: min(480px, 60vh);
  overflow-y: auto;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.18);
}

.inventory-suggestion-menu.hidden {
  display: none;
}

.inventory-suggestion {
  display: grid;
  gap: 2px;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 6px 11px;
  color: var(--text);
  background: #ffffff;
  box-shadow: none;
  text-align: left;
}

.inventory-suggestion:hover,
.inventory-suggestion.active {
  color: var(--brand-dark);
  background: #ecfdf5;
}

.inventory-suggestion strong,
.inventory-suggestion span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-suggestion span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.line-total {
  font-weight: 700;
  white-space: nowrap;
}

.cash-line-total {
  font-weight: 700;
  white-space: nowrap;
}

.item-serial {
  color: #475569;
  font-weight: 800;
  text-align: center;
}

.summary {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.totals {
  padding: 16px;
  border: 1px solid #dce3ea;
  border-radius: 8px;
  background: linear-gradient(135deg, #f8fafc, #ecfdf5);
}

.totals .field {
  margin-bottom: 12px;
}

.totals p {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(207, 227, 221, 0.7);
}

.totals p:last-child {
  margin-bottom: 0;
  border-bottom: 0;
}

.round-adjustment {
  color: var(--brand-dark);
  font-weight: 700;
}

.grand-total {
  color: var(--brand-dark);
  font-size: 20px;
  padding-top: 12px;
  border-top: 1px solid #cfe3dd;
}

.cash-panel .quote-status-bar {
  background: linear-gradient(135deg, #ffffff, #eef9f7);
}

.cash-panel .quote-status-bar strong,
.cash-panel .grand-total {
  color: var(--brand-dark);
}

.cash-panel .totals {
  background: linear-gradient(135deg, #f8fafc, #ecfdf5);
}

.terms-panel {
  min-height: 100%;
}

.payment-terms-panel {
  display: grid;
  gap: 14px;
}

.bank-details-preview {
  padding: 12px;
  border: 1px solid #d8e6e2;
  border-radius: 8px;
  color: #334155;
  background: #f8fafc;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
}

.bank-details-preview:empty {
  display: none;
}

.cash-panel {
  max-width: 1120px;
}

.cash-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid #dbe5ee;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(8, 145, 178, 0.08), rgba(16, 185, 129, 0.05)),
    #ffffff;
}

.cash-header h2 {
  margin: 0;
  color: var(--brand-dark);
  font-size: 28px;
  line-height: 1.15;
}

.cash-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.cash-summary > .field {
  padding: 16px;
  border: 1px solid #e4e9ef;
  border-radius: 8px;
  background: linear-gradient(135deg, #fbfcfd, #ffffff);
}

.cash-table th:nth-child(1) {
  width: 58px;
  text-align: center;
}

.cash-table th:nth-child(2) {
  width: 34%;
}

.cash-table th:nth-child(3) {
  width: 82px;
  text-align: center;
}

.cash-table th:nth-child(4),
.cash-table th:nth-child(5) {
  width: 96px;
}

.cash-table th:nth-child(6),
.cash-table th:nth-child(7) {
  width: 118px;
}

.cash-table th:nth-child(8) {
  width: 100px;
}

.print-document {
  display: none;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.settings-panel {
  display: grid;
  gap: 16px;
  width: min(1280px, 100%);
  max-width: 100%;
  margin: 0 auto;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.settings-panel .section-heading {
  margin-bottom: 0;
}

.settings-hero {
  align-items: stretch;
  padding: 18px;
  border: 1px solid rgba(203, 213, 225, 0.8);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96)),
    var(--panel);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

.settings-hero h2 {
  font-size: clamp(24px, 2vw, 32px);
  letter-spacing: 0;
}

.settings-hero .muted {
  max-width: 760px;
  font-size: 14px;
  line-height: 1.55;
}

.settings-hero-actions {
  display: grid;
  align-content: center;
  justify-items: stretch;
  min-width: 210px;
  gap: 8px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
}

.settings-hero-actions span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.settings-hero-actions button {
  width: 100%;
  min-height: 42px;
}

.settings-panel .form-grid,
.settings-panel .form-grid.compact {
  gap: 14px;
}

.settings-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.settings-overview article {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-areas:
    "icon label"
    "icon value";
  align-items: center;
  gap: 4px 10px;
  min-height: 78px;
  padding: 14px;
  border: 1px solid #dde6ef;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.settings-overview article::before {
  content: attr(data-settings-icon);
  grid-area: icon;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  color: var(--brand-dark);
  background: rgba(15, 118, 110, 0.1);
  font-size: 11px;
  font-weight: 900;
}

.settings-overview span {
  grid-area: label;
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.settings-overview strong {
  grid-area: value;
  display: block;
  overflow-wrap: anywhere;
  color: var(--brand-dark);
  font-size: 17px;
  line-height: 1.2;
}

.settings-section-picker {
  display: none;
  max-width: 360px;
  margin: 0;
}

.settings-crm-shell {
  display: grid;
  grid-template-columns: 282px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-width: 0;
  max-width: 100%;
}

.settings-control-nav {
  position: sticky;
  top: 76px;
  display: grid;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

.settings-control-content {
  display: grid;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.theme-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.theme-preset {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "swatches title"
    "swatches note";
  justify-content: start;
  align-items: center;
  min-height: 72px;
  padding: 12px;
  border: 1px solid #dce5ef;
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
  text-align: left;
}

.theme-preset:hover,
.theme-preset.active {
  border-color: var(--preset-brand);
  background: #ffffff;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.08);
}

.theme-preset.active {
  outline: 2px solid var(--preset-brand);
  outline-offset: 1px;
}

.theme-swatches {
  grid-area: swatches;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-right: 10px;
}

.theme-swatches i {
  display: block;
  width: 22px;
  height: 10px;
  border-radius: 999px;
  background: var(--preset-brand);
}

.theme-swatches i:nth-child(2) {
  background: var(--preset-blue);
}

.theme-swatches i:nth-child(3) {
  background: var(--preset-gold);
}

.theme-preset strong {
  grid-area: title;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
  line-height: 1.15;
}

.theme-preset small {
  grid-area: note;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.settings-tabs {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 6px;
  border: 1px solid #dde6ef;
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.92);
  min-width: 0;
  max-width: 100%;
}

.settings-tabs .hidden {
  display: none !important;
}

.settings-tab {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  grid-template-areas:
    "icon title"
    "icon note";
  align-items: center;
  gap: 3px 10px;
  min-height: 66px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  text-align: left;
}

.settings-tab::before {
  content: attr(data-settings-icon);
  grid-area: icon;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--brand-dark);
  background: #ffffff;
  font-size: 10px;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px #dbe5ee;
}

.settings-tab:hover {
  background: #ffffff;
  color: var(--brand-dark);
}

.settings-tab.active {
  border-color: rgba(15, 118, 110, 0.35);
  background: #ffffff;
  color: var(--brand-dark);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
}

.settings-tab.active::before {
  color: #ffffff;
  background: var(--brand);
  box-shadow: none;
}

.settings-tab strong {
  grid-area: title;
  color: inherit;
  font-size: 14px;
  line-height: 1.2;
}

.settings-tab span {
  grid-area: note;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.settings-control-links {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #dde6ef;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
  min-width: 0;
  max-width: 100%;
}

.settings-control-links span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.settings-control-links button {
  width: 100%;
  gap: 8px;
  justify-content: flex-start;
  min-height: 38px;
}

.settings-control-links button::before {
  content: attr(data-tool-icon);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--brand-dark);
  background: #ffffff;
  font-size: 9px;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px #dbe5ee;
}

.staff-access-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.staff-access-summary article {
  padding: 14px;
  border: 1px solid #dde6ef;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.staff-access-summary span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.staff-access-summary strong {
  color: var(--brand-dark);
  font-size: 22px;
  line-height: 1;
}

.settings-section {
  display: none;
}

.settings-section.active {
  display: block;
  min-width: 0;
  max-width: 100%;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
  max-width: 100%;
}

.settings-layout .settings-section.active[data-settings-section-panel="defaults"] {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.85fr);
  gap: 14px;
}

.settings-panel .sub-panel {
  padding: 18px;
  border: 1px solid #dde6ef;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.06);
}

.settings-panel .sub-panel-heading {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eef2f6;
}

.settings-panel .sub-panel-heading h2 {
  font-size: 18px;
}

.settings-panel .sub-panel-heading .muted {
  max-width: 760px;
  line-height: 1.5;
}

.settings-logo-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 14px;
  align-items: end;
  margin-bottom: 14px;
}

.settings-logo-row .company-logo {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.settings-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 0.85fr);
  gap: 14px;
  min-width: 0;
  max-width: 100%;
}

.admin-settings {
  display: grid;
  gap: 14px;
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
  min-width: 0;
  max-width: 100%;
}

.admin-settings.settings-section {
  display: none;
}

.admin-settings.settings-section.active {
  display: grid;
}

.staff-settings-accordions {
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.settings-accordion {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid #dde6ef;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.settings-accordion > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 12px 14px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.settings-accordion > summary::-webkit-details-marker {
  display: none;
}

.settings-accordion > summary::after {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--brand-dark);
  background: #f1f5f9;
  font-size: 18px;
  font-weight: 800;
}

.settings-accordion[open] > summary::after {
  content: "-";
}

.settings-accordion > summary strong {
  display: block;
  color: var(--brand-dark);
  font-size: 14px;
  line-height: 1.25;
}

.settings-accordion > summary small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.settings-accordion-body {
  min-width: 0;
  max-width: 100%;
  padding: 14px;
  border-top: 1px solid #eef2f6;
  background: #fbfdff;
}

.settings-accordion .sub-panel {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.settings-accordion .sub-panel-heading {
  display: none;
}

.admin-info-list,
.security-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-info-list span,
.security-list span {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  line-height: 1.35;
}

.security-list strong {
  color: var(--text);
  text-align: right;
}

.admin-info-list strong {
  color: var(--text);
  text-align: right;
}

.security-checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.security-checklist article {
  padding: 14px;
  border: 1px solid #dde6ef;
  border-radius: 8px;
  background: #ffffff;
}

.security-checklist strong {
  display: block;
  margin-bottom: 6px;
  color: var(--brand-dark);
  line-height: 1.3;
}

.security-checklist span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.staff-form {
  align-items: end;
}

.settings-panel .field {
  gap: 7px;
  color: #334155;
  font-size: 13px;
  letter-spacing: 0;
}

.settings-panel input,
.settings-panel textarea,
.settings-panel select {
  min-height: 42px;
  border-color: #d7e0ea;
  border-radius: 8px;
  background: #ffffff;
}

.settings-panel textarea {
  line-height: 1.5;
}

.settings-panel input:focus,
.settings-panel textarea:focus,
.settings-panel select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.13);
}

.settings-panel .toggle-row {
  justify-content: space-between;
  min-height: 46px;
  border-color: #d7e0ea;
  border-radius: 8px;
  background: #f8fafc;
}

.settings-panel .toggle-row input[type="checkbox"] {
  position: relative;
  width: 42px;
  height: 24px;
  min-height: 24px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: #cbd5e1;
  appearance: none;
  cursor: pointer;
  transition: background-color 0.18s ease;
}

.settings-panel .toggle-row input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
  transition: transform 0.18s ease;
}

.settings-panel .toggle-row input[type="checkbox"]:checked {
  background: var(--brand);
}

.settings-panel .toggle-row input[type="checkbox"]:checked::before {
  transform: translateX(18px);
}

.staff-type-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.staff-type-options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid #d7e0ea;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.staff-type-options input {
  min-height: auto;
  width: auto;
  accent-color: var(--brand);
}

.staff-type-options-table {
  min-width: 220px;
}

.staff-preset-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 7px;
}

.staff-preset-actions button {
  min-height: 38px;
  padding: 8px 10px;
}

.staff-work-view-toggle {
  display: grid;
  grid-template-columns: auto minmax(90px, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}

.staff-work-view-toggle input {
  min-height: auto;
  width: auto;
}

@media (max-width: 1180px) {
  .settings-crm-shell {
    grid-template-columns: 1fr;
  }

  .settings-control-nav {
    position: static;
  }

  .settings-tabs {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    overflow-x: visible;
    padding-bottom: 8px;
  }

  .settings-control-links {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .settings-control-links span {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  .quote-details-grid,
  .summary,
  .settings-layout,
  .settings-layout .settings-section.active[data-settings-section-panel="defaults"],
  .inventory-workspace,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .lead-form-grid .full-width {
    grid-column: 1 / -1;
  }

  .quick-actions,
  .inventory-tools,
  .inventory-filter-grid,
  .dashboard-grid,
  .task-board {
    grid-template-columns: 1fr;
  }

  .status-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-board-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 761px) and (max-width: 1179px) {
  .workspace {
    padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  }

  .topbar {
    top: 10px;
    align-items: flex-start;
    padding: 14px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .panel {
    padding: 16px;
  }

  .quotation-panel {
    max-width: none;
  }

  .lead-form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .lead-form-grid .full-width {
    grid-column: 1 / -1;
  }

  .lead-filter-bar,
  .saved-quotes-filter-bar,
  .status-filter-bar,
  .activity-filter-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .lead-pipeline-board,
  .lead-tracker-summary,
  .status-board-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .workspace {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) calc(92px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .mobile-tabbar {
    position: fixed;
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 10px;
    z-index: 35;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 6px;
    border: 1px solid rgba(148, 163, 184, 0.42);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(16px);
  }

  .mobile-nav-link {
    min-height: 48px;
    padding: 7px 4px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--muted);
    background: transparent;
    box-shadow: none;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.1;
  }

  .mobile-nav-link:hover,
  .mobile-nav-link.active {
    color: #ffffff;
    border-color: var(--brand);
    background: var(--brand);
    box-shadow: none;
  }

  .login-card {
    padding: 22px;
  }

  button,
  input,
  textarea,
  select {
    min-height: 44px;
    font-size: 16px;
  }

  button {
    padding: 11px 14px;
  }

  .lead-actions button,
  .lead-form-grid button,
  .status-card select,
  .sync-center-actions button {
    min-height: 44px;
  }

  .panel {
    padding: 14px;
  }

  .panel + .panel {
    margin-top: 14px;
  }

  .quotation-panel {
    gap: 14px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat-card {
    min-height: 96px;
    padding: 14px;
  }

  .stat-card span {
    margin-bottom: 8px;
    font-size: 12px;
  }

  .stat-card strong {
    font-size: 22px;
  }

  .topbar,
  .section-heading,
  .inventory-item,
  .inventory-batch-item {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 25;
    margin: -10px -10px 12px;
    padding: max(10px, env(safe-area-inset-top)) 10px 10px;
    border-radius: 0 0 8px 8px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
  }

  .topbar-title {
    align-items: center;
    width: 100%;
  }

  .topbar-title h1 {
    font-size: 20px;
  }

  .menu-toggle {
    flex: 0 0 auto;
    width: auto;
    min-width: 64px;
    min-height: 38px;
    padding: 8px 10px;
  }

  .section-heading select {
    width: 100%;
  }

  .section-actions,
  .section-actions button,
  .inline-field {
    width: 100%;
  }

  .settings-crm-shell {
    grid-template-columns: 1fr;
  }

  .settings-control-nav {
    position: static;
  }

  .settings-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 8px 0 12px;
  }

  .settings-control-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-tab {
    min-height: 58px;
  }

  .settings-section-picker {
    display: grid;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .topbar-actions .sync-pill {
    justify-content: flex-start;
    width: 100%;
  }

  .topbar-actions button {
    width: 100%;
  }

  .topbar-actions #newQuoteBtn,
  .topbar-actions #saveQuoteBtn,
  .topbar-actions #printBtn,
  .topbar-actions #pdfBtn {
    display: none !important;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .quote-status-bar {
    position: sticky;
    top: 58px;
    z-index: 12;
    align-items: stretch;
    flex-direction: column;
    margin: -14px -14px 0;
    padding: 12px 14px;
  }

  .quote-status-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .quote-status-actions button {
    width: 100%;
  }

  .dashboard-list-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .smart-alert,
  .task-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .smart-alert b,
  .task-item b {
    width: 100%;
  }

  .dashboard-list-item b {
    width: 100%;
  }

  .status-board {
    grid-template-columns: 1fr;
  }

  .status-board-summary {
    grid-template-columns: 1fr;
  }

  .status-column-list {
    max-height: none;
  }

  .status-card-controls,
  .status-card-actions {
    grid-template-columns: 1fr;
  }

  .company-block,
  .form-grid,
  .cash-header,
  .cash-meta,
  .settings-grid,
  .settings-overview,
  .settings-logo-row,
  .staff-access-summary,
  .staff-preset-actions,
  .security-checklist {
    grid-template-columns: 1fr;
  }

  .company-block {
    gap: 12px;
  }

  .quote-company-profile {
    grid-template-columns: 58px minmax(0, 1fr);
    padding: 12px;
  }

  .company-logo {
    width: 58px;
    height: 58px;
    font-size: 11px;
  }

  .company-profile-copy h2,
  .cash-header h2 {
    font-size: 18px;
  }

  .company-profile-lock {
    display: none;
  }

  .sub-panel {
    padding: 12px;
  }

  .inventory-tools {
    gap: 10px;
  }

  .inventory-maintenance,
  .inventory-maintenance button {
    width: 100%;
  }

  .inventory-item .table-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  table {
    min-width: 720px;
  }

  .lead-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lead-form-grid .field:first-of-type,
  .lead-form-grid .full-width {
    grid-column: 1 / -1;
  }

}

@media (max-width: 760px) {
  #quotationArea .table-wrap,
  #cashQuotationArea .table-wrap {
    border: 0;
    background: transparent;
  }

  .line-items-table,
  .cash-table {
    display: block;
    min-width: 0;
    border-collapse: separate;
  }

  .line-items-table thead,
  .cash-table thead {
    display: none;
  }

  .line-items-table tbody,
  .cash-table tbody {
    display: grid;
    gap: 12px;
  }

  .line-items-table tr,
  .cash-table tr {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) minmax(92px, 0.45fr);
    gap: 10px;
    padding: 12px;
    border: 1px solid #dfe7ef;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(23, 32, 51, 0.07);
  }

  .line-items-table td,
  .cash-table td {
    display: block;
    width: auto;
    min-width: 0;
    border-bottom: 0;
    padding: 0;
    text-align: left !important;
  }

  .line-items-table td::before,
  .cash-table td::before {
    content: "";
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
  }

  .line-items-table td:nth-child(1),
  .cash-table td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    order: 1;
  }

  .line-items-table td:nth-child(2),
  .cash-table td:nth-child(2) {
    grid-column: 2 / -1;
    grid-row: 1;
    order: 1;
  }

  .line-items-table td:nth-child(3),
  .cash-table td:nth-child(3) {
    grid-column: 1;
    grid-row: 2;
    order: 2;
  }

  .line-items-table td:nth-child(4),
  .cash-table td:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
    order: 2;
  }

  .line-items-table td:nth-child(5),
  .cash-table td:nth-child(5) {
    grid-column: 3;
    grid-row: 2;
    order: 2;
  }

  .line-items-table td:nth-child(6),
  .cash-table td:nth-child(6) {
    grid-column: 1;
    grid-row: 3;
    order: 3;
  }

  .line-items-table td:nth-child(7),
  .cash-table td:nth-child(7) {
    grid-column: 2;
    grid-row: 3;
    order: 3;
  }

  .line-items-table td:nth-child(8),
  .cash-table td:nth-child(8) {
    grid-column: 3;
    grid-row: 3;
    order: 3;
  }

  .line-items-table td:nth-child(1)::before,
  .cash-table td:nth-child(1)::before {
    content: "Sl.No";
  }

  .line-items-table td:nth-child(2)::before,
  .cash-table td:nth-child(2)::before {
    content: "Item";
  }

  .line-items-table td:nth-child(3)::before,
  .cash-table td:nth-child(3)::before {
    content: "Image";
  }

  .line-items-table td:nth-child(4)::before,
  .cash-table td:nth-child(4)::before {
    content: "Qty";
  }

  .line-items-table td:nth-child(5)::before,
  .cash-table td:nth-child(5)::before {
    content: "Unit";
  }

  .line-items-table td:nth-child(6)::before,
  .cash-table td:nth-child(6)::before {
    content: "Rate";
  }

  .line-items-table td:nth-child(7)::before,
  .cash-table td:nth-child(7)::before {
    content: "Total";
  }

  .line-items-table td:nth-child(8)::before,
  .cash-table td:nth-child(8)::before {
    content: "Action";
  }

  .line-items-table tr,
  .cash-table tr {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .line-items-table td:nth-child(1),
  .cash-table td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }

  .line-items-table td:nth-child(3),
  .cash-table td:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
  }

  .line-items-table td:nth-child(2),
  .cash-table td:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .line-items-table td:nth-child(4),
  .cash-table td:nth-child(4) {
    grid-column: 1;
    grid-row: 3;
  }

  .line-items-table td:nth-child(5),
  .cash-table td:nth-child(5) {
    grid-column: 2;
    grid-row: 3;
  }

  .line-items-table td:nth-child(6),
  .cash-table td:nth-child(6) {
    grid-column: 1;
    grid-row: 4;
  }

  .line-items-table td:nth-child(7),
  .cash-table td:nth-child(7) {
    grid-column: 2;
    grid-row: 4;
  }

  .line-items-table td:nth-child(8),
  .cash-table td:nth-child(8) {
    grid-column: 1 / -1;
    grid-row: 5;
  }

  .item-image-picker,
  .item-image-preview {
    width: 100%;
    height: 54px;
    margin: 0;
  }

  .line-total,
  .cash-line-total {
    display: block;
    min-height: 44px;
    padding: 11px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #f8fafc;
    text-align: right;
  }

  td .danger-btn {
    min-height: 44px;
  }

  .inventory-suggestion-menu {
    max-height: min(360px, 54vh);
    border-radius: 8px;
  }

  .inventory-suggestion {
    min-height: 44px;
    padding: 8px 10px;
  }
}

@media (max-width: 420px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .quote-status-actions {
    grid-template-columns: 1fr;
  }

  .line-items-table tr,
  .cash-table tr {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .line-items-table td:nth-child(2),
  .cash-table td:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .line-items-table td:nth-child(3),
  .cash-table td:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
  }

  .line-items-table td:nth-child(4),
  .cash-table td:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
  }

  .line-items-table td:nth-child(5),
  .cash-table td:nth-child(5) {
    grid-column: 1;
    grid-row: 3;
  }

  .line-items-table td:nth-child(6),
  .cash-table td:nth-child(6) {
    grid-column: 2;
    grid-row: 3;
  }

  .line-items-table td:nth-child(7),
  .cash-table td:nth-child(7) {
    grid-column: 1;
    grid-row: 4;
  }

  .line-items-table td:nth-child(8),
  .cash-table td:nth-child(8) {
    grid-column: 1 / -1;
    grid-row: 5;
  }

  .inventory-item .table-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .settings-panel {
    gap: 12px;
  }

  .settings-hero,
  .settings-panel .sub-panel {
    padding: 14px;
  }

  .settings-hero-actions {
    width: 100%;
    min-width: 0;
  }

  .settings-overview {
    gap: 8px;
  }

  .settings-overview article {
    min-height: 70px;
    padding: 12px;
  }

  .settings-tabs,
  .settings-control-links,
  .theme-preset-grid {
    grid-template-columns: 1fr;
  }

  .staff-settings-accordions {
    gap: 8px;
  }

  .settings-accordion > summary {
    align-items: flex-start;
    padding: 11px 12px;
  }

  .settings-accordion-body {
    padding: 12px;
  }

  .settings-tab {
    min-height: 54px;
  }

  .settings-logo-row {
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: center;
  }

  .settings-logo-row .company-logo {
    width: 64px;
    height: 64px;
  }

  .admin-info-list span,
  .security-list span {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .admin-info-list strong,
  .security-list strong {
    text-align: left;
  }

  .staff-type-options label {
    width: 100%;
  }
}

/* UX refresh: persistent desktop shell, clearer command areas, and mobile-first records. */
:root {
  --sidebar-width: 292px;
  --control-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  --panel-shadow: 0 12px 30px rgba(15, 23, 42, 0.055);
}

body {
  background:
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 44%, #eef6f5 100%);
}

.app-shell {
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.035), transparent 36%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), transparent 300px);
}

.sidebar {
  gap: 16px;
  width: min(var(--sidebar-width), 90vw);
  padding: 16px;
  background: #ffffff;
  box-shadow: 14px 0 36px rgba(15, 23, 42, 0.12);
}

.brand {
  padding: 10px;
  border-color: #e6edf4;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
}

.brand-mark {
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.2);
}

.nav {
  gap: 3px;
}

.nav-section-label {
  display: block;
  margin: 12px 8px 5px;
  color: #7a889a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.nav-link {
  position: relative;
  gap: 10px;
  min-height: 40px;
  padding: 9px 12px;
  color: #475569;
  font-weight: 800;
}

.nav-link::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: #cbd5e1;
}

.nav-link:hover,
.nav-link.active {
  color: var(--brand-dark);
  border-color: rgba(15, 118, 110, 0.18);
  border-left-color: var(--brand);
  background: #edf8f6;
}

.nav-link.active::before {
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.topbar {
  border-color: rgba(203, 213, 225, 0.86);
  box-shadow: var(--control-shadow);
}

.topbar-actions button {
  min-height: 36px;
  padding: 8px 12px;
}

.sync-pill {
  gap: 8px;
  border-color: #d8e1ea;
  background: #ffffff;
}

.sync-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #94a3b8;
}

.sync-pill[data-state="ok"]::before {
  background: #059669;
}

.sync-pill[data-state="syncing"]::before {
  background: #2563eb;
}

.sync-pill[data-state="error"]::before {
  background: #dc2626;
}

.panel,
.stat-card,
.sub-panel {
  box-shadow: var(--panel-shadow);
}

.sub-panel {
  background: #ffffff;
}

#dashboardPage.active {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
  align-items: start;
}

#dashboardPage > .stats-grid,
#dashboardPage > .panel.admin-only,
#dashboardPage > #staffPerformancePanel,
#dashboardPage > .dashboard-grid {
  grid-column: 1 / -1;
}

#dashboardPage > .stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 0;
}

#dashboardPage > .smart-alert-panel {
  grid-column: 1;
}

#dashboardPage > .quick-start-panel {
  grid-column: 2;
}

#dashboardPage > .panel + .panel,
#dashboardPage > .dashboard-grid,
#staffPerformancePanel {
  margin-top: 0;
}

.quick-start-panel .quick-actions {
  grid-template-columns: 1fr;
}

.quick-actions button {
  justify-content: flex-start;
  min-height: 48px;
  text-align: left;
}

.quick-actions button::after {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.58;
}

.stat-card {
  min-height: 112px;
  padding: 18px;
}

.stat-card::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(15, 118, 110, 0.1);
  border-radius: 50%;
  background: rgba(15, 118, 110, 0.045);
}

.stat-card:nth-child(2)::after {
  border-color: rgba(37, 99, 235, 0.11);
  background: rgba(37, 99, 235, 0.045);
}

.stat-card:nth-child(3)::after {
  border-color: rgba(217, 119, 6, 0.13);
  background: rgba(217, 119, 6, 0.05);
}

.stat-card strong {
  position: relative;
  z-index: 1;
  font-size: 28px;
}

.dashboard-list-item,
.smart-alert {
  min-height: 62px;
  border-color: #dfe7ef;
}

.dashboard-list-item {
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.045);
}

.dashboard-empty {
  border: 1px dashed #cbd5e1;
  background: #fbfdff;
}

.board-filter-bar {
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.035);
}

.quote-status-bar {
  top: 96px;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
}

.table-wrap {
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.035);
}

@media (min-width: 1180px) {
  .workspace {
    padding: max(22px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) max(34px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
  }

  .topbar {
    top: 16px;
  }
}

@media (max-width: 1179px) {
  #dashboardPage.active {
    grid-template-columns: 1fr;
  }

  #dashboardPage > .smart-alert-panel,
  #dashboardPage > .quick-start-panel {
    grid-column: 1;
  }

  #dashboardPage > .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .sidebar {
    width: min(312px, 92vw);
  }

  .nav-section-label {
    margin-left: 6px;
  }

  .topbar {
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.09);
  }

  #dashboardPage.active {
    gap: 14px;
  }

  #dashboardPage > .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-start-panel .quick-actions {
    grid-template-columns: 1fr;
  }

  .board-filter-bar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .report-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quote-status-bar {
    top: 58px;
  }

  #quotationsPage .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

}

@media (max-width: 420px) {
  #dashboardPage > .stats-grid,
  .report-card-grid {
    grid-template-columns: 1fr;
  }

}

/* Tailwind-compatible responsive utilities used without adding a new build system. */
.grid {
  display: grid;
}

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.gap-4 {
  gap: 16px;
}

.w-full {
  width: 100%;
}

.min-w-0 {
  min-width: 0;
}

.overflow-x-auto {
  overflow-x: auto;
}

.table-auto {
  table-layout: auto;
}

.whitespace-nowrap {
  white-space: nowrap;
}

.px-3 {
  padding-right: 12px;
  padding-left: 12px;
}

.py-2 {
  padding-top: 8px;
  padding-bottom: 8px;
}

.min-w-\[90px\] {
  min-width: 90px;
}

.min-w-\[1400px\] {
  min-width: 1400px;
}

@media (min-width: 640px) {
  .sm\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .md\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lg\:grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .lg\:grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .lg\:grid-cols-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .xl\:grid-cols-6 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* Full-app responsive hardening: mobile base, sm 640, md 768, lg 1024, desktop 1180+. */
html,
body,
.app-shell,
.workspace,
.page-view,
.panel,
.sub-panel,
.topbar,
.section-heading,
.section-actions,
.table-wrap,
.board-filter-bar,
.sync-center,
.settings-crm-shell,
.settings-panel,
.settings-layout,
.settings-section,
.settings-tabs,
.settings-control-links,
.status-board,
.dashboard-grid,
.inventory-workspace,
.form-grid,
.field {
  min-width: 0;
}

button,
.secondary-btn,
.danger-btn {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

input,
textarea,
select {
  max-width: 100%;
  min-width: 0;
}

.topbar-title,
.brand,
.dashboard-list-item,
.smart-alert,
.status-card-main,
.inventory-item,
.settings-tab,
.mobile-nav-link {
  min-width: 0;
}

.topbar-title h1,
.section-heading h2,
.sub-panel-heading h2,
.brand strong,
.dashboard-list-item strong,
.dashboard-list-item small,
.status-card-title strong,
.status-card-title span,
.settings-tab strong,
.settings-tab span,
.mobile-nav-link {
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-gutter: stable;
}

.table-wrap table {
  width: max-content;
  min-width: 100%;
}

.settings-tabs {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.settings-control-links {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.settings-control-links span {
  grid-column: 1 / -1;
}

.board-filter-bar {
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
}

.lead-pipeline-board {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.quick-start-panel .quick-actions {
  grid-template-columns: 1fr !important;
}

.status-board {
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
}

.status-board.single-status-board {
  grid-template-columns: minmax(0, 1fr) !important;
}

.form-grid,
.form-grid.compact,
.lead-form-grid,
.settings-panel .form-grid,
.settings-panel .form-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.full-width,
.lead-form-grid .full-width {
  grid-column: 1 / -1;
}

.table-actions,
.lead-actions,
.backup-actions,
.settings-hero-actions,
.inventory-maintenance,
.section-actions {
  max-width: 100%;
}

[role="dialog"],
.modal,
.dialog,
.popup,
.overlay,
.inventory-suggestion-menu,
.sync-center {
  max-width: min(100%, calc(100vw - 24px));
}

@media (max-width: 639px) {
  body {
    font-size: 14px;
  }

  h1,
  .topbar-title h1 {
    font-size: 20px;
    line-height: 1.15;
  }

  h2,
  .section-heading h2,
  .sub-panel-heading h2 {
    font-size: 17px;
  }

  .workspace {
    padding-right: max(10px, env(safe-area-inset-right));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .topbar,
  .sync-center-head,
  .section-heading,
  .status-card-main,
  .inventory-filter-note {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .section-actions,
  .sync-center-actions,
  .quote-status-actions,
  .table-actions,
  .lead-actions,
  .backup-actions,
  .settings-hero-actions,
  .inventory-maintenance,
  .staff-preset-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .topbar-actions button,
  .section-actions button,
  .sync-center-actions button,
  .quote-status-actions button,
  .table-actions button,
  .lead-actions button,
  .backup-actions button,
  .settings-hero-actions button,
  .inventory-maintenance button,
  .staff-preset-actions button,
  .quick-actions button {
    width: 100%;
  }

  .mobile-tabbar {
    grid-template-columns: repeat(5, minmax(58px, 1fr));
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .mobile-nav-link {
    min-height: 50px;
    padding: 7px 5px;
    font-size: 12px;
  }

  .settings-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding: 8px;
  }

  .settings-tab {
    flex: 0 0 min(78vw, 260px);
    scroll-snap-align: start;
  }

  .settings-control-links,
  .board-filter-bar,
  .form-grid,
  .form-grid.compact,
  .lead-form-grid,
  .settings-panel .form-grid,
  .settings-panel .form-grid.compact,
  .quote-details-grid,
  .summary,
  .inventory-workspace,
  .settings-layout,
  .admin-grid,
  .staff-access-summary,
  .settings-overview,
  .security-checklist,
  .cash-header,
  .cash-meta {
    grid-template-columns: 1fr !important;
  }

  .stats-grid,
  #dashboardPage > .stats-grid,
  .report-card-grid,
  .lead-pipeline-board,
  .status-board-summary,
  .dashboard-grid,
  .status-board,
  .sync-center-grid,
  .sync-center-details,
  .quick-actions {
    grid-template-columns: 1fr !important;
  }

  .panel,
  .sub-panel,
  .settings-panel .sub-panel,
  .settings-hero {
    padding: 12px;
  }

  .stat-card,
  .report-card,
  .lead-pipeline-card,
  .status-summary-card {
    min-height: auto;
    padding: 13px;
  }

  .table-wrap {
    margin-right: -2px;
    margin-left: -2px;
    border-radius: 8px;
  }

  .table-wrap table {
    min-width: 720px;
  }

  #quotationArea .table-wrap table,
  #cashQuotationArea .table-wrap table,
  .saved-quotes-table,
  .lead-tracker-table,
  .line-items-table,
  .cash-table {
    min-width: 0;
    width: 100%;
  }

  .field {
    font-size: 13px;
  }

  input,
  textarea,
  select,
  button {
    font-size: 16px;
  }
}

@media (min-width: 640px) and (max-width: 767px) {
  .stats-grid,
  #dashboardPage > .stats-grid,
  .report-card-grid,
  .lead-pipeline-board,
  .status-board-summary,
  .sync-center-grid,
  .sync-center-details,
  .quick-actions,
  .staff-access-summary,
  .settings-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .board-filter-bar,
  .settings-control-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  body {
    font-size: 15px;
  }

  .stats-grid,
  #dashboardPage > .stats-grid,
  .report-card-grid,
  .lead-pipeline-board,
  .status-board-summary,
  .sync-center-grid,
  .sync-center-details,
  .staff-access-summary,
  .settings-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .quote-details-grid,
  .inventory-workspace,
  .settings-layout,
  .admin-grid,
  .status-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .board-filter-bar,
  .settings-tabs,
  .settings-control-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid,
  .form-grid.compact,
  .lead-form-grid,
  .settings-panel .form-grid,
  .settings-panel .form-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .stats-grid,
  #dashboardPage > .stats-grid,
  .report-card-grid,
  .lead-pipeline-board,
  .status-board-summary,
  .sync-center-grid,
  .staff-access-summary,
  .settings-overview {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .sync-center-details {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .board-filter-bar,
  .settings-tabs,
  .settings-control-links {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .form-grid,
  .form-grid.compact,
  .lead-form-grid,
  .settings-panel .form-grid,
  .settings-panel .form-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Responsive polish: mobile-first controls, dropdown tabs, and contained overflow. */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.app-shell,
.workspace,
.page-view.active,
.panel,
.sub-panel,
.settings-control-content,
.settings-layout,
.quote-details-grid,
.summary,
.cash-summary,
.inventory-workspace,
.dashboard-grid,
.status-board,
.status-board-summary,
.stats-grid,
.report-card-grid,
.form-grid,
.board-filter-bar {
  max-width: 100%;
}

.workspace {
  overflow-x: clip;
}

.field,
.field input,
.field textarea,
.field select,
.inline-field,
.inline-field select {
  min-width: 0;
}

.panel,
.sub-panel,
.stat-card,
.report-card,
.status-card,
.dashboard-list-item,
.smart-alert,
.lead-pipeline-card,
.status-summary-card {
  overflow-wrap: anywhere;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  touch-action: pan-x pan-y;
}

.table-wrap table {
  min-width: max(720px, 100%);
}

.inventory-suggestion-menu,
[role="dialog"],
.modal,
.dialog,
.popup,
.overlay {
  max-width: calc(100vw - 20px);
  max-height: min(640px, calc(100vh - 24px));
}

@media (max-width: 767px) {
  #quotationArea .table-wrap table,
  #cashQuotationArea .table-wrap table,
  .line-items-table,
  .cash-table,
  .saved-quotes-table,
  .lead-tracker-table {
    width: 100%;
    min-width: 0 !important;
  }
}

@media (max-width: 639px) {
  body {
    font-size: 14px;
    line-height: 1.45;
  }

  .workspace {
    width: 100%;
    padding-right: max(10px, env(safe-area-inset-right));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .topbar-title {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .topbar-title h1,
  .section-heading h2,
  .sub-panel-heading h2 {
    overflow-wrap: anywhere;
  }

  .topbar-actions,
  .section-actions,
  .sync-center-actions,
  .quote-status-actions,
  .table-actions,
  .lead-actions,
  .backup-actions,
  .settings-hero-actions,
  .inventory-maintenance,
  .staff-preset-actions,
  .quick-actions {
    grid-template-columns: 1fr !important;
  }

  .topbar-actions > *,
  .section-actions > *,
  .sync-center-actions > *,
  .quote-status-actions > *,
  .table-actions > *,
  .lead-actions > *,
  .backup-actions > *,
  .settings-hero-actions > *,
  .inventory-maintenance > *,
  .staff-preset-actions > *,
  .quick-actions > * {
    width: 100%;
    min-width: 0;
  }

  .sidebar {
    width: min(318px, calc(100vw - 28px));
  }

  .mobile-tabbar {
    right: 8px;
    left: 8px;
    grid-template-columns: repeat(5, minmax(60px, 1fr));
    max-width: calc(100vw - 16px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .mobile-tabbar::-webkit-scrollbar {
    display: none;
  }

  .mobile-nav-link {
    white-space: normal;
  }

  .settings-tabs {
    display: none !important;
  }

  .settings-section-picker {
    display: grid !important;
    width: 100%;
    max-width: none;
    margin: 0 0 12px;
  }

  .settings-control-links {
    grid-template-columns: 1fr !important;
    padding: 10px;
  }

  .settings-control-links button {
    min-height: 44px;
  }

  .stats-grid,
  #dashboardPage > .stats-grid,
  .report-card-grid,
  .lead-pipeline-board,
  .status-board-summary,
  .dashboard-grid,
  .report-dashboard-grid,
  .status-board,
  .sync-center-grid,
  .sync-center-details,
  .form-grid,
  .form-grid.compact,
  .lead-form-grid,
  .settings-panel .form-grid,
  .settings-panel .form-grid.compact,
  .board-filter-bar,
  .settings-layout,
  .quote-details-grid,
  .summary,
  .cash-summary,
  .inventory-workspace,
  .admin-grid,
  .staff-access-summary,
  .settings-overview,
  .security-checklist,
  .cash-header,
  .cash-meta {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .panel,
  .quotation-panel,
  .settings-panel,
  .inventory-panel {
    width: 100%;
    max-width: 100%;
  }

  .stat-card strong,
  .report-card strong,
  .status-summary-card strong,
  .lead-pipeline-card strong {
    font-size: clamp(20px, 8vw, 28px);
  }

  .dashboard-list-item,
  .smart-alert,
  .status-card-main,
  .inventory-item,
  .inventory-batch-item {
    min-width: 0;
  }

  .board-filter-summary {
    font-size: 12px;
  }

  .table-wrap {
    width: 100%;
    margin-right: 0;
    margin-left: 0;
    overscroll-behavior-x: contain;
  }

  .staff-performance-table,
  .activity-log-table,
  .inventory-table table,
  table:not(.line-items-table):not(.cash-table):not(.saved-quotes-table):not(.lead-tracker-table) {
    min-width: 720px;
  }

  .line-items-table tr,
  .cash-table tr,
  .saved-quotes-table tr,
  .lead-tracker-table tr {
    max-width: 100%;
  }

  .inventory-suggestion-menu {
    left: 10px !important;
    right: 10px;
    width: auto !important;
  }
}

@media (min-width: 640px) and (max-width: 767px) {
  .settings-tabs {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  .settings-tab {
    flex: 0 0 240px;
    scroll-snap-align: start;
  }

  .settings-section-picker {
    display: grid;
    width: 100%;
    max-width: 420px;
    margin-bottom: 12px;
  }

  .dashboard-grid,
  .report-dashboard-grid,
  .quote-details-grid,
  .summary,
  .inventory-workspace,
  .settings-layout,
  .status-board {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .workspace {
    padding-right: 18px;
    padding-left: 18px;
  }

  .settings-crm-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-control-nav {
    position: static;
  }

  .settings-tabs {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  .settings-tab {
    flex: 0 0 240px;
    scroll-snap-align: start;
  }

  .status-board {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .inventory-workspace,
  .settings-layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (min-width: 1024px) {
  .workspace {
    max-width: 1440px;
  }

  .quotation-panel,
  .settings-panel,
  .inventory-panel,
  #leadTrackerPage .panel,
  #quotationsPage .panel,
  #statusPage .panel,
  #activityLogPage .panel,
  #backupPage .panel {
    max-width: 1240px;
    margin-right: auto;
    margin-left: auto;
  }

  .status-board {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
}

/* Lead Tracker alignment: keep cards, filters, form fields, and rows contained. */
#leadTrackerPage,
#leadTrackerPage .panel,
#leadTrackerPage .sub-panel,
#leadTrackerPage .section-heading,
#leadTrackerPage .lead-tracker-summary,
#leadTrackerPage .lead-pipeline-board,
#leadTrackerPage .lead-form-panel,
#leadTrackerPage .lead-form-grid,
#leadTrackerPage .lead-filter-bar,
#leadTrackerPage .table-wrap {
  min-width: 0;
  max-width: 100%;
}

#leadTrackerPage .section-heading {
  align-items: flex-start;
}

#leadTrackerPage .section-actions {
  max-width: 100%;
}

#leadTrackerPage .section-actions span {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  white-space: nowrap;
}

#leadTrackerPage .lead-form-panel {
  border-left: 4px solid #0891b2;
  background:
    linear-gradient(135deg, rgba(8, 145, 178, 0.08), rgba(34, 197, 94, 0.06)),
    #ffffff;
}

#leadTrackerPage .lead-filter-bar {
  border-color: #dbeafe;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(15, 118, 110, 0.05)),
    #f8fafc;
}

#leadTrackerPage .lead-tracker-summary .report-card,
#leadTrackerPage .lead-pipeline-card {
  border-left: 4px solid #94a3b8;
}

#leadTrackerPage .lead-tracker-summary .report-card:nth-child(1) {
  border-left-color: #2563eb;
  background: #eff6ff;
}

#leadTrackerPage .lead-tracker-summary .report-card:nth-child(2) {
  border-left-color: #0891b2;
  background: #ecfeff;
}

#leadTrackerPage .lead-tracker-summary .report-card:nth-child(3) {
  border-left-color: #d97706;
  background: #fffbeb;
}

#leadTrackerPage .lead-tracker-summary .report-card:nth-child(4),
#leadTrackerPage .lead-tracker-summary .report-card:nth-child(5) {
  border-left-color: #16a34a;
  background: #f0fdf4;
}

#leadTrackerPage .lead-pipeline-card {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.96)),
    #ffffff;
}

#leadTrackerPage .lead-pipeline-card.status-New {
  border-left-color: #2563eb;
  background: #eff6ff;
}

#leadTrackerPage .lead-pipeline-card.status-Contacted {
  border-left-color: #0891b2;
  background: #ecfeff;
}

#leadTrackerPage .lead-pipeline-card.status-Requirement-Received {
  border-left-color: #7c3aed;
  background: #f5f3ff;
}

#leadTrackerPage .lead-pipeline-card.status-Quoted {
  border-left-color: #d97706;
  background: #fffbeb;
}

#leadTrackerPage .lead-pipeline-card.status-Follow-Up {
  border-left-color: #ea580c;
  background: #fff7ed;
}

#leadTrackerPage .lead-pipeline-card.status-Converted {
  border-left-color: #16a34a;
  background: #f0fdf4;
}

#leadTrackerPage .lead-pipeline-card.status-Lost {
  border-left-color: #dc2626;
  background: #fef2f2;
}

#leadTrackerPage .lead-pipeline-card.status-New em {
  background: #2563eb;
}

#leadTrackerPage .lead-pipeline-card.status-Contacted em {
  background: #0891b2;
}

#leadTrackerPage .lead-pipeline-card.status-Requirement-Received em {
  background: #7c3aed;
}

#leadTrackerPage .lead-pipeline-card.status-Quoted em {
  background: #d97706;
}

#leadTrackerPage .lead-pipeline-card.status-Follow-Up em {
  background: #ea580c;
}

#leadTrackerPage .lead-pipeline-card.status-Converted em {
  background: #16a34a;
}

#leadTrackerPage .lead-pipeline-card.status-Lost em {
  background: #dc2626;
}

#leadTrackerPage .lead-status-pill.status-New {
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #eff6ff;
}

#leadTrackerPage .lead-status-pill.status-Contacted {
  color: #0e7490;
  border-color: #a5f3fc;
  background: #ecfeff;
}

#leadTrackerPage .lead-status-pill.status-Requirement-Received {
  color: #6d28d9;
  border-color: #ddd6fe;
  background: #f5f3ff;
}

#leadTrackerPage .lead-status-pill.status-Quoted {
  color: #b45309;
  border-color: #fde68a;
  background: #fffbeb;
}

#leadTrackerPage .lead-status-pill.status-Follow-Up {
  color: #c2410c;
  border-color: #fed7aa;
  background: #fff7ed;
}

#leadTrackerPage .lead-status-pill.status-Converted {
  color: #166534;
  border-color: #bbf7d0;
  background: #f0fdf4;
}

#leadTrackerPage .lead-status-pill.status-Lost {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

#leadTrackerPage .lead-tracker-summary {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

#leadTrackerPage .lead-pipeline-board {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

#leadTrackerPage .lead-form-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

#leadTrackerPage .lead-filter-bar {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

#leadTrackerPage .lead-form-grid .full-width,
#leadTrackerPage .lead-filter-bar .board-filter-summary {
  grid-column: 1 / -1;
}

#leadTrackerPage .lead-form-grid .field,
#leadTrackerPage .lead-filter-bar .field,
#leadTrackerPage .lead-form-grid input,
#leadTrackerPage .lead-form-grid select,
#leadTrackerPage .lead-form-grid textarea,
#leadTrackerPage .lead-filter-bar input,
#leadTrackerPage .lead-filter-bar select {
  min-width: 0;
  max-width: 100%;
}

#leadTrackerPage .table-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

@media (max-width: 899px) {
  #leadTrackerPage .table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
}

#leadTrackerPage .lead-tracker-table {
  width: 100%;
}

#leadTrackerPage .lead-tracker-table select,
#leadTrackerPage .lead-tracker-table input,
#leadTrackerPage .lead-actions,
#leadTrackerPage .lead-actions button {
  max-width: 100%;
}

@media (max-width: 639px) {
  #leadTrackerPage .section-heading,
  #leadTrackerPage .section-actions {
    align-items: stretch;
  }

  #leadTrackerPage .section-actions,
  #leadTrackerPage .lead-form-grid,
  #leadTrackerPage .lead-filter-bar {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
  }

  #leadTrackerPage .section-actions > *,
  #leadTrackerPage .lead-form-grid > *,
  #leadTrackerPage .lead-filter-bar > * {
    width: 100%;
  }

  #leadTrackerPage .lead-tracker-summary,
  #leadTrackerPage .lead-pipeline-board {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #leadTrackerPage .lead-form-panel {
    padding: 12px;
  }

  #leadTrackerPage .lead-tracker-table {
    min-width: 0;
  }
}

@media (min-width: 640px) and (max-width: 1023px) {
  #leadTrackerPage .lead-tracker-summary,
  #leadTrackerPage .lead-pipeline-board,
  #leadTrackerPage .lead-form-grid,
  #leadTrackerPage .lead-filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (min-width: 1024px) {
  #leadTrackerPage .lead-tracker-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  #leadTrackerPage .lead-form-grid,
  #leadTrackerPage .lead-filter-bar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 12mm;
  }

  @page lead-report {
    size: A4 landscape;
    margin: 8mm;
  }

  html,
  body {
    width: auto;
    height: auto !important;
    min-height: 0 !important;
    margin: 0;
    overflow: visible !important;
  }

  body {
    min-width: 0;
    background: #ffffff;
    color: #111827;
    font-size: 10.5px;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .login-screen,
  .sidebar,
  .sidebar-backdrop,
  .sync-center,
  #syncCenterPanel,
  .sync-pill,
  .menu-toggle,
  .mobile-tabbar,
  .topbar,
  .quote-status-bar,
  .view-only-banner,
  .page-view:not(.active),
  .logo-field,
  .danger-btn,
  .secondary-btn,
  #printBtn,
  #saveQuoteBtn,
  #pdfBtn,
  .no-print,
  .quote-record-actions,
  .share-quote-btn,
  .revision-badge,
  .portal-badge,
  .offline-bar,
  .board-filter-bar,
  .section-heading,
  .quotes-stats-strip,
  .lead-tracker-summary,
  .notes-fab-btn,
  .notif-bell-btn {
    display: none !important;
  }

  .app-shell {
    display: block;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    background: #ffffff !important;
  }

  .workspace {
    box-sizing: border-box;
    width: auto;
    min-height: 0 !important;
    height: auto !important;
    padding: 0;
    overflow: visible !important;
  }

  .page-view.active {
    display: block !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  .panel {
    border: 0;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  input,
  textarea,
  select {
    min-height: 28px;
    border: 1px solid #d8dee6;
    border-radius: 6px;
    padding: 5px 7px;
    background: #ffffff;
    color: #111827;
    font-size: 10px;
    resize: none;
  }

  .quotation-panel {
    display: block !important;
    gap: 9px;
    max-width: none;
  }

  .company-block {
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .quote-company-profile {
    border-color: #d8dee6;
    background: #ffffff;
  }

  .company-logo {
    width: 70px;
    height: 70px;
  }

  .company-profile-copy {
    gap: 3px;
  }

  .company-profile-copy h2 {
    font-size: 16px;
  }

  .company-profile-copy p:last-child {
    font-size: 10px;
    line-height: 1.4;
  }

  .company-profile-lock {
    display: none !important;
  }

  .quote-details-grid {
    grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.22fr);
    gap: 8px;
  }

  .form-grid,
  .form-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
  }

  .field {
    gap: 2px;
    color: #4b5563;
    font-size: 10px;
  }

  .field input,
  .field textarea,
  .field select {
    color: #111827;
    font-weight: 600;
  }

  .sub-panel {
    padding: 8px;
    background: #ffffff;
  }

  .sub-panel-heading {
    margin-bottom: 6px;
  }

  .sub-panel-heading h2,
  .cash-header h2,
  .items-section h2 {
    font-size: 13px;
  }

  .eyebrow {
    margin-bottom: 2px;
    font-size: 9px;
  }

  .company-block,
  .sub-panel,
  .totals {
    border-color: #d8dee6;
  }

  .bank-details-preview {
    padding: 7px;
    font-size: 10px;
    line-height: 1.4;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  table {
    table-layout: fixed;
    min-width: 0;
    font-size: 9.8px;
  }

  th,
  td {
    padding: 5px;
    border-bottom-color: #d8dee6;
  }

  th:nth-child(8),
  td:nth-child(8) {
    display: none !important;
  }

  .line-items-table,
  .cash-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  .line-items-table th:nth-child(1),
  .cash-table th:nth-child(1) {
    width: 34px;
  }

  .line-items-table th:nth-child(2),
  .cash-table th:nth-child(2) {
    width: auto;
  }

  .line-items-table th:nth-child(3),
  .cash-table th:nth-child(3) {
    width: 48px;
  }

  .line-items-table th:nth-child(4),
  .cash-table th:nth-child(4) {
    width: 52px;
  }

  .line-items-table th:nth-child(5),
  .cash-table th:nth-child(5) {
    width: 58px;
  }

  .line-items-table th:nth-child(6),
  .cash-table th:nth-child(6),
  .line-items-table th:nth-child(7),
  .cash-table th:nth-child(7) {
    width: 78px;
  }

  .line-items-table input,
  .line-items-table select,
  .cash-table input,
  .cash-table select {
    min-height: 0;
    border: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    font-weight: 600;
  }

  .line-items-table tr,
  .cash-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .item-image-picker,
  .item-image-preview {
    width: 38px;
    height: 32px;
  }

  .item-image-preview {
    border: 0;
    background: transparent;
    color: transparent;
  }

  .summary {
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 8px;
  }

  .totals {
    padding: 8px;
  }

  .totals .field {
    margin-bottom: 6px;
  }

  .totals p {
    margin-bottom: 4px;
    padding: 3px 0;
  }

  .grand-total {
    font-size: 14px;
  }

  .quote-company-profile,
  .quote-details-grid,
  .summary {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .cash-panel {
    max-width: none;
  }

  .cash-header {
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 8px;
    padding: 10px;
    background: #ffffff;
  }

  .cash-header h2 {
    font-size: 18px;
  }

  .cash-meta {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .cash-table th:nth-child(1) {
    width: 34px;
  }

  .cash-table th:nth-child(2) {
    width: auto;
  }

  .cash-table th:nth-child(3) {
    width: 48px;
  }

  .cash-table th:nth-child(4) {
    width: 52px;
  }

  .cash-table th:nth-child(5) {
    width: 58px;
  }

  .cash-table th:nth-child(6),
  .cash-table th:nth-child(7) {
    width: 78px;
  }

  .cash-table th:nth-child(8),
  .cash-table td:nth-child(8) {
    display: none;
  }

  .cash-summary {
    grid-template-columns: minmax(0, 1fr) 220px;
  }

  .cash-summary > .field {
    padding: 8px;
    background: #ffffff;
  }

  /* ── Quotation print isolation ──────────────────────────── */
  /* body.quotation-print-mode: show ONLY the rendered print doc */
  body.quotation-print-mode > *:not(.app-shell) { display: none !important; }
  body.quotation-print-mode .app-shell > *:not(.workspace) { display: none !important; }
  body.quotation-print-mode .workspace > *:not(.page-view) { display: none !important; }
  body.quotation-print-mode .page-view:not(.active) { display: none !important; }
  body.quotation-print-mode .page-view.active > *:not(.quotation-panel) { display: none !important; }
  body.quotation-print-mode .quotation-panel > :not(.print-document) { display: none !important; }

  body.quotation-print-mode .app-shell,
  body.quotation-print-mode .workspace,
  body.quotation-print-mode .page-view.active,
  body.quotation-print-mode .quotation-panel {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: #ffffff !important;
    overflow: visible !important;
    height: auto !important;
    min-height: 0 !important;
  }

  body.quotation-print-mode .print-document {
    display: block !important;
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  body.report-print-mode .page-view.active .panel > :not(.report-print-document) {
    display: none !important;
  }

  body.report-print-mode .page-view.active .report-print-document {
    display: block !important;
    width: 100%;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  body.report-print-mode .topbar,
  body.report-print-mode .sync-center,
  body.report-print-mode .sidebar,
  body.report-print-mode .sidebar-backdrop {
    display: none !important;
  }

  body.report-print-mode .workspace {
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
  }

  body.lead-report-print-mode .lead-report-page {
    page: lead-report;
    width: 281mm;
    min-height: 0;
    padding: 0 2mm 1mm;
    border-top-color: #0f766e;
    font-size: 9.4px;
  }

  body.lead-report-print-mode .report-print-page .print-brand-header {
    grid-template-columns: minmax(0, 1fr) 190px;
    gap: 14px;
    padding: 10px 0 11px;
  }

  .print-page {
    box-sizing: border-box;
    width: 100%;
    max-width: 186mm;
    min-height: 0;
    height: auto;
    margin: 0 auto;
    color: #151b23;
    font-family: Arial, sans-serif;
    font-size: 9.7px;
    line-height: 1.32;
    overflow: visible;
    break-after: auto;
    page-break-after: auto;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .quote-print-v2 {
    border-top: 5px solid var(--print-accent, #164e63);
  }

  .print-brand-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 198px;
    gap: 13px;
    align-items: stretch;
    padding: 9px 0 10px;
    border-bottom: 1px solid #d7dee8;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-brand {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 11px;
    align-items: center;
  }

  .cash-print-header .print-brand {
    grid-template-columns: minmax(0, 1fr);
  }

  .print-logo-wrap {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    overflow: hidden;
    border: 1px solid #d7dee8;
    border-radius: 8px;
    background: #f8fafc;
  }

  .print-logo-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .print-logo-fallback {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: var(--print-accent, #164e63);
    font-size: 17px;
    font-weight: 800;
  }

  .print-brand h1 {
    margin: 0 0 4px;
    color: #0f172a;
    font-size: 16px;
    line-height: 1.2;
  }

  .print-brand p,
  .print-party-grid p,
  .print-footer-grid p,
  .print-footer-note {
    margin: 0;
    color: #3f4a5a;
  }

  .print-document-title {
    display: grid;
    align-content: center;
    justify-items: end;
    text-align: right;
  }

  .print-document-title span {
    display: inline-block;
    margin-bottom: 4px;
    padding: 4px 9px;
    border-radius: 999px;
    color: var(--print-accent, #164e63);
    background: #e6f3f6;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
  }

  .print-document-title h2 {
    margin: 0;
    color: #0f172a;
    font-size: 23px;
    line-height: 1.15;
  }

  .print-document-title p {
    margin: 4px 0 0;
    color: #5a6575;
    font-size: 10.5px;
  }

  .print-info-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 9px 0;
    border: 1px solid #d7dee8;
    border-radius: 8px;
    overflow: hidden;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-info-strip article {
    min-height: 42px;
    padding: 7px 9px;
    border-right: 1px solid #d7dee8;
    background: #f8fafc;
  }

  .print-info-strip article:last-child {
    border-right: 0;
  }

  .print-info-strip span,
  .print-party-grid span {
    display: block;
    margin-bottom: 3px;
    color: #64748b;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
  }

  .print-info-strip strong {
    display: block;
    color: #111827;
    font-size: 10.5px;
    line-height: 1.25;
    word-break: break-word;
  }

  .print-party-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    margin-bottom: 9px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-party-grid article {
    min-height: 66px;
    padding: 8px 10px;
    border: 1px solid #d7dee8;
    border-radius: 8px;
  }

  .print-party-grid h3 {
    margin: 0 0 4px;
    color: #0f172a;
    font-size: 13.5px;
    line-height: 1.25;
  }

  .print-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 7px;
  }

  .print-section-title h3 {
    margin: 0;
    color: #0f172a;
    font-size: 13.5px;
  }

  .print-section-title span {
    color: #64748b;
    font-size: 10.5px;
    font-weight: 700;
  }

  .print-items-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    table-layout: fixed;
    border: 1px solid #d7dee8;
    font-size: 9.3px;
  }

  .print-items-table thead {
    display: table-header-group;
  }

  .print-items-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-items-table th,
  .print-items-table td {
    display: table-cell !important;
    border: 1px solid #d7dee8;
    padding: 4px 5px;
    vertical-align: middle;
  }

  .print-items-table th {
    color: #ffffff;
    background: var(--print-accent, #164e63);
    font-size: 8.8px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .print-items-table th:nth-child(1),
  .print-items-table td:nth-child(1) {
    width: 34px;
    text-align: center;
  }

  .print-items-table th:nth-child(2),
  .print-items-table td:nth-child(2) {
    width: auto;
    text-align: left;
  }

  .print-items-table th:nth-child(3),
  .print-items-table td:nth-child(3) {
    width: 48px;
    text-align: center;
  }

  .print-items-table th:nth-child(4),
  .print-items-table td:nth-child(4) {
    width: 38px;
    text-align: center;
  }

  .print-items-table th:nth-child(5),
  .print-items-table td:nth-child(5) {
    width: 46px;
    text-align: center;
  }

  .print-items-table th:nth-child(6),
  .print-items-table td:nth-child(6) {
    width: 68px;
    text-align: right;
  }

  .print-items-table th:nth-child(7),
  .print-items-table td:nth-child(7) {
    width: 78px;
    text-align: right;
  }

  .print-items-table tbody tr:nth-child(even) {
    background: #f8fafc;
  }

  .print-item-title {
    display: block;
    color: #111827;
    font-size: 9.5px;
    line-height: 1.24;
    word-break: break-word;
  }

  .print-items-table td small {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 9px;
  }

  .print-item-image img {
    width: 38px;
    height: 30px;
    object-fit: contain;
  }

  .print-item-image span {
    color: #94a3b8;
  }

  .print-items-section {
    break-inside: auto;
    page-break-inside: auto;
  }

  .print-empty-row {
    padding: 18px !important;
    color: #64748b;
    text-align: center !important;
  }

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

  .print-money {
    text-align: right;
    white-space: nowrap;
  }

  .print-footer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 235px;
    gap: 11px;
    margin-top: 9px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-footer-grid h3 {
    margin: 0 0 7px;
    color: #0f172a;
    font-size: 12px;
  }

  .print-footer-grid h3:not(:first-child) {
    margin-top: 14px;
  }

  .print-notes {
    display: grid;
    gap: 8px;
    padding: 9px 10px;
    border: 1px solid #d7dee8;
    border-radius: 8px;
  }

  .print-amount-words {
    padding-bottom: 6px;
    border-bottom: 1px solid #e2e8f0;
  }

  .print-terms-grid {
    display: grid;
    grid-template-columns: minmax(170px, 0.85fr) minmax(0, 1.15fr);
    gap: 8px;
  }

  .print-terms-grid article:only-child {
    grid-column: 1 / -1;
  }

  .print-totals {
    display: grid;
    align-content: start;
    gap: 5px;
    padding: 9px 10px;
    border: 1px solid var(--print-accent, #164e63);
    border-radius: 8px;
    background: #f8fafc;
  }

  .print-totals p {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin: 0;
    color: #334155;
    font-weight: 700;
  }

  .print-total-row {
    margin-top: 3px !important;
    padding: 7px 0 0;
    border-top: 1px solid var(--print-accent, #164e63);
    color: #0f172a !important;
    font-size: 13.5px;
  }

  .print-signature {
    margin-top: 28px;
    padding-top: 6px;
    border-top: 1px solid #94a3b8;
    text-align: right;
    font-weight: 700;
  }

  .print-footer-note {
    margin-top: 10px;
    padding-top: 7px;
    border-top: 1px solid #e2e8f0;
    text-align: center;
    font-size: 9px;
  }

  .report-print-page {
    border-top: 4px solid #164e63;
    font-size: 9px;
    line-height: 1.28;
  }

  .report-print-page .print-brand-header {
    grid-template-columns: minmax(0, 1fr) 172px;
    gap: 10px;
    padding: 8px 0;
  }

  .report-print-page .print-brand {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 9px;
  }

  .report-print-page .print-logo-wrap {
    width: 48px;
    height: 48px;
  }

  .report-print-page .print-brand h1 {
    margin-bottom: 3px;
    font-size: 15px;
  }

  .lead-report-company p {
    margin: 0;
    color: #334155;
    font-size: 8.8px;
    line-height: 1.28;
  }

  .report-print-page .print-document-title h2 {
    font-size: 20px;
  }

  .report-print-page .print-footer-note {
    margin-top: 8px;
    padding-top: 6px;
  }

  .report-summary-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
    margin: 9px 0;
  }

  .report-summary-grid article {
    padding: 7px 8px;
    border: 1px solid #d7dee8;
    border-radius: 8px;
    background: #f8fafc;
  }

  .report-summary-grid span {
    display: block;
    color: #64748b;
    font-size: 8.8px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .report-summary-grid strong {
    display: block;
    margin-top: 3px;
    color: #111827;
    font-size: 13px;
  }

  .lead-report-meta-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 0.8fr) minmax(0, 0.9fr);
    gap: 9px;
    margin: 10px 0 10px;
  }

  .lead-report-meta-grid article {
    padding: 9px 10px;
    border: 1px solid #d7dee8;
    border-radius: 8px;
    background: #ffffff;
  }

  .lead-report-meta-grid span {
    display: block;
    color: #64748b;
    font-size: 8.8px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .lead-report-meta-grid strong {
    display: block;
    margin-top: 4px;
    color: #111827;
    font-size: 10.4px;
    line-height: 1.3;
  }

  .lead-report-summary-grid {
    gap: 9px;
    margin: 10px 0 11px;
  }

  .lead-report-summary-grid article {
    padding: 9px 10px;
    border-color: #bbf7d0;
    background: #f0fdf4;
  }

  .lead-report-summary-grid span {
    color: #0f766e;
    font-size: 9px;
  }

  .lead-report-summary-grid strong {
    font-size: 15px;
  }

  .lead-report-section-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin: 11px 0 7px;
    padding-top: 8px;
    border-top: 1px solid #d7dee8;
  }

  .lead-report-section-title span {
    display: block;
    color: #0f766e;
    font-size: 8.8px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .lead-report-section-title strong {
    display: block;
    margin-top: 2px;
    color: #111827;
    font-size: 13.5px;
  }

  .lead-report-section-title p {
    max-width: 155mm;
    margin: 0;
    color: #475569;
    font-size: 9.4px;
    line-height: 1.3;
    text-align: right;
  }

  .report-print-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    table-layout: fixed;
    border: 1px solid #d7dee8;
    font-size: 8.7px;
  }

  .report-print-table th,
  .report-print-table td {
    display: table-cell !important;
    border: 1px solid #d7dee8;
    padding: 4px 4px;
    line-height: 1.22;
    vertical-align: middle;
    word-break: normal;
    overflow-wrap: anywhere;
  }

  .report-print-table thead {
    display: table-header-group;
  }

  .report-print-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-print-table th {
    color: #ffffff;
    background: #164e63;
    font-size: 8.4px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .report-print-table tbody tr:nth-child(even) {
    background: #f8fafc;
  }

  .lead-report-table {
    border-color: #cbd5e1;
    font-size: 9.1px;
  }

  .lead-report-table th,
  .lead-report-table td {
    padding: 6px 7px;
    line-height: 1.3;
  }

  .lead-report-table th {
    background: #0f766e;
    color: #ffffff;
    font-size: 9.2px;
    white-space: normal;
  }

  .lead-report-table td {
    vertical-align: top;
  }

  .report-print-table th:nth-child(1),
  .report-print-table td:nth-child(1) {
    width: 64px !important;
    text-align: left !important;
  }

  .report-print-table th:nth-child(2),
  .report-print-table td:nth-child(2) {
    width: 50px !important;
    text-align: left !important;
  }

  .report-print-table th:nth-child(3),
  .report-print-table td:nth-child(3) {
    width: auto !important;
    text-align: left !important;
  }

  .report-print-table th:nth-child(4),
  .report-print-table td:nth-child(4) {
    width: 54px !important;
    text-align: left !important;
  }

  .report-print-table th:nth-child(5),
  .report-print-table td:nth-child(5) {
    width: 58px !important;
    text-align: left !important;
  }

  .report-print-table th:nth-child(6),
  .report-print-table td:nth-child(6) {
    width: 58px !important;
    text-align: center !important;
  }

  .report-print-table th:nth-child(7),
  .report-print-table td:nth-child(7) {
    width: 54px !important;
    text-align: center !important;
  }

  .report-print-table th:nth-child(8),
  .report-print-table td:nth-child(8) {
    width: 64px !important;
    text-align: right !important;
  }

  .lead-report-table th:nth-child(1),
  .lead-report-table td:nth-child(1) {
    width: 15% !important;
    text-align: left !important;
  }

  .lead-report-table th:nth-child(2),
  .lead-report-table td:nth-child(2) {
    width: 9% !important;
    text-align: left !important;
  }

  .lead-report-table th:nth-child(3),
  .lead-report-table td:nth-child(3) {
    width: 12% !important;
    text-align: left !important;
  }

  .lead-report-table th:nth-child(4),
  .lead-report-table td:nth-child(4) {
    width: 12% !important;
    text-align: left !important;
  }

  .lead-report-table th:nth-child(5),
  .lead-report-table td:nth-child(5) {
    width: 11% !important;
    text-align: left !important;
  }

  .lead-report-table th:nth-child(6),
  .lead-report-table td:nth-child(6) {
    width: 10% !important;
    text-align: right !important;
  }

  .lead-report-table th:nth-child(7),
  .lead-report-table td:nth-child(7) {
    width: 10% !important;
    text-align: center !important;
  }

  .lead-report-table th:nth-child(8),
  .lead-report-table td:nth-child(8) {
    width: 21% !important;
    text-align: left !important;
  }

  .lead-report-table td:first-child strong {
    font-size: 9.4px;
  }

  .lead-report-customer-cell,
  .lead-report-staff-cell,
  .lead-report-remark-cell {
    word-break: normal;
    overflow-wrap: anywhere;
  }

  .lead-report-remark-cell .lead-remark-list {
    gap: 2px;
    padding-left: 13px;
  }

  .lead-report-remark-cell .lead-remark-list li {
    line-height: 1.24;
  }

  .lead-print-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 58px;
    padding: 3px 7px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #f8fafc;
    color: #334155;
    font-size: 8.1px;
    font-weight: 800;
    line-height: 1.1;
  }

  .lead-print-status.status-Converted {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
  }

  .lead-print-status.status-Lost,
  .lead-print-status.status-Rejected {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
  }

  .lead-print-status.status-Follow-Up {
    border-color: #fde68a;
    background: #fffbeb;
    color: #92400e;
  }

  .report-print-table td small {
    display: block;
    margin-top: 2px;
    color: #64748b;
    font-size: 7.6px;
    line-height: 1.18;
  }
}

/* Final containment and quotation image polish. */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

img,
video,
canvas {
  max-width: 100%;
}

.app-shell,
.workspace,
.page-view,
.page-view.active,
.panel,
.sub-panel,
.topbar,
.section-heading,
.section-actions,
.quote-status-bar,
.quote-details-grid,
.summary,
.cash-summary,
.settings-layout,
.settings-panel,
.inventory-workspace,
.status-board,
.dashboard-grid,
.table-wrap {
  min-width: 0;
  max-width: 100%;
}

.workspace {
  overflow-x: clip;
}

.line-items-table th:nth-child(3),
.cash-table th:nth-child(3) {
  width: 110px;
}

.item-image-cell {
  min-width: 0;
  text-align: center !important;
}

.item-image-picker {
  width: 88px;
  height: auto;
}

.item-image-preview {
  width: 88px;
  height: 70px;
  padding: 4px;
  background: #ffffff;
}

.item-image-preview.has-image {
  border-style: solid;
  border-color: #cbd5e1;
}

.item-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.item-image-remove {
  width: 88px;
  min-height: 28px;
  margin: 6px auto 0;
  padding: 4px 8px;
  font-size: 11px;
  line-height: 1.15;
  box-shadow: none;
}

@media (max-width: 760px) {
  #quotationArea .table-wrap,
  #cashQuotationArea .table-wrap {
    overflow: visible;
  }

  .line-items-table,
  .cash-table {
    width: 100%;
    min-width: 0 !important;
  }

  .line-items-table tr,
  .cash-table tr {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    max-width: 100%;
    overflow: hidden;
  }

  .line-items-table td,
  .cash-table td {
    min-width: 0;
    max-width: 100%;
  }

  .line-items-table td:nth-child(1),
  .cash-table td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }

  .line-items-table td:nth-child(3),
  .cash-table td:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
  }

  .line-items-table td:nth-child(2),
  .cash-table td:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .line-items-table td:nth-child(4),
  .cash-table td:nth-child(4) {
    grid-column: 1;
    grid-row: 3;
  }

  .line-items-table td:nth-child(5),
  .cash-table td:nth-child(5) {
    grid-column: 2;
    grid-row: 3;
  }

  .line-items-table td:nth-child(6),
  .cash-table td:nth-child(6) {
    grid-column: 1;
    grid-row: 4;
  }

  .line-items-table td:nth-child(7),
  .cash-table td:nth-child(7) {
    grid-column: 2;
    grid-row: 4;
  }

  .line-items-table td:nth-child(8),
  .cash-table td:nth-child(8) {
    grid-column: 1 / -1;
    grid-row: 5;
  }

  .item-image-picker,
  .item-image-preview,
  .item-image-remove {
    width: 100%;
  }

  .item-image-preview {
    height: 92px;
  }
}

@media (max-width: 420px) {
  .line-items-table tr,
  .cash-table tr {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .line-items-table td,
  .cash-table td {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
  }

  .item-image-preview {
    height: 120px;
  }
}

@media print {
  .print-items-table th:nth-child(3),
  .print-items-table td:nth-child(3) {
    width: 74px;
  }

  .print-item-image img {
    width: 66px;
    height: 54px;
    object-fit: contain;
  }
}

/* Mobile card tables for pages that should never require horizontal page scrolling. */
.topbar {
  flex-wrap: wrap;
}

.topbar-title {
  flex: 1 1 280px;
}

.topbar-actions {
  flex: 1 1 360px;
}

@media (max-width: 760px) {
  .staff-performance-wrap,
  #trashPage .table-wrap,
  #activityLogPage .table-wrap,
  #settingsPage .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .staff-performance-table,
  #trashPage table,
  #activityLogPage .activity-log-table,
  #settingsPage .table-wrap table {
    display: block;
    width: 100%;
    min-width: 0 !important;
    border-collapse: separate;
  }

  .staff-performance-table thead,
  #trashPage table thead,
  #activityLogPage .activity-log-table thead,
  #settingsPage .table-wrap table thead {
    display: none;
  }

  .staff-performance-table tbody,
  #trashPage table tbody,
  #activityLogPage .activity-log-table tbody,
  #settingsPage .table-wrap table tbody {
    display: grid;
    gap: 12px;
  }

  .staff-performance-table tr,
  #trashPage table tr,
  #activityLogPage .activity-log-table tr,
  #settingsPage .table-wrap table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
    width: 100%;
    max-width: 100%;
    padding: 12px;
    overflow: hidden;
    border: 1px solid #dfe7ef;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(23, 32, 51, 0.07);
  }

  .staff-performance-table td,
  #trashPage table td,
  #activityLogPage .activity-log-table td,
  #settingsPage .table-wrap table td {
    display: block;
    width: 100% !important;
    min-width: 0;
    max-width: 100%;
    border-bottom: 0;
    padding: 0;
    text-align: left !important;
  }

  .staff-performance-table td::before,
  #trashPage table td::before,
  #activityLogPage .activity-log-table td::before,
  #settingsPage .table-wrap table td::before {
    content: "";
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
  }

  .staff-performance-table td:nth-child(1)::before { content: "Staff"; }
  .staff-performance-table td:nth-child(2)::before { content: "Total"; }
  .staff-performance-table td:nth-child(3)::before { content: "Pending"; }
  .staff-performance-table td:nth-child(4)::before { content: "Converted"; }
  .staff-performance-table td:nth-child(5)::before { content: "Rejected"; }
  .staff-performance-table td:nth-child(6)::before { content: "Next Month"; }

  #trashPage table td:nth-child(1)::before { content: "Quotation"; }
  #trashPage table td:nth-child(2)::before { content: "Customer"; }
  #trashPage table td:nth-child(3)::before { content: "Deleted"; }
  #trashPage table td:nth-child(4)::before { content: "Auto Delete"; }
  #trashPage table td:nth-child(5)::before { content: "Action"; }

  #activityLogPage .activity-log-table td:nth-child(1)::before { content: "Time"; }
  #activityLogPage .activity-log-table td:nth-child(2)::before { content: "Staff"; }
  #activityLogPage .activity-log-table td:nth-child(3)::before { content: "Action"; }
  #activityLogPage .activity-log-table td:nth-child(4)::before { content: "Record"; }
  #activityLogPage .activity-log-table td:nth-child(5)::before { content: "Details"; }

  #settingsPage .table-wrap table td:nth-child(1)::before { content: "Staff ID"; }
  #settingsPage .table-wrap table td:nth-child(2)::before { content: "Name"; }
  #settingsPage .table-wrap table td:nth-child(3)::before { content: "Role"; }
  #settingsPage .table-wrap table td:nth-child(4)::before { content: "Password"; }
  #settingsPage .table-wrap table td:nth-child(5)::before { content: "Quote Types"; }
  #settingsPage .table-wrap table td:nth-child(6)::before { content: "Website Access"; }
  #settingsPage .table-wrap table td:nth-child(7)::before { content: "Work Permissions"; }
  #settingsPage .table-wrap table td:nth-child(8)::before { content: "Created"; }
  #settingsPage .table-wrap table td:nth-child(9)::before { content: "Action"; }

  .staff-performance-table td[colspan],
  #trashPage table td[colspan],
  #activityLogPage .activity-log-table td[colspan],
  #settingsPage .table-wrap table td[colspan] {
    color: var(--muted);
  }

  .staff-performance-table td[colspan]::before,
  #trashPage table td[colspan]::before,
  #activityLogPage .activity-log-table td[colspan]::before,
  #settingsPage .table-wrap table td[colspan]::before {
    content: none;
  }
}

/* Whole-program layout guard: every page stays inside the device viewport. */
:root {
  --safe-page-gutter: clamp(10px, 2vw, 28px);
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body * {
  min-width: 0;
}

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
}

.app-shell,
.login-screen,
.workspace,
.page-view,
.page-view.active,
.panel,
.sub-panel,
.topbar,
.sync-center,
.section-heading,
.section-actions,
.quote-status-bar,
.dashboard-grid,
.stats-grid,
.report-card-grid,
.task-board,
.quick-actions,
.quote-details-grid,
.summary,
.cash-summary,
.cash-header,
.cash-meta,
.items-section,
.form-grid,
.form-grid.compact,
.board-filter-bar,
.status-board,
.status-board-summary,
.lead-tracker-summary,
.lead-pipeline-board,
.lead-form-grid,
.lead-filter-bar,
.inventory-workspace,
.inventory-tools,
.inventory-filter-grid,
.inventory-list,
.settings-panel,
.settings-hero,
.settings-overview,
.settings-crm-shell,
.settings-control-nav,
.settings-control-content,
.settings-layout,
.settings-section,
.settings-tabs,
.settings-control-links,
.settings-accordion,
.settings-accordion-body,
.backup-actions,
.table-wrap {
  min-width: 0;
  max-width: 100%;
}

.workspace {
  width: 100%;
  max-width: min(1440px, 100vw);
  overflow-x: clip;
  padding-right: max(var(--safe-page-gutter), env(safe-area-inset-right));
  padding-left: max(var(--safe-page-gutter), env(safe-area-inset-left));
}

.page-view,
.panel,
.sub-panel,
.settings-panel,
.inventory-panel,
.quotation-panel {
  width: 100%;
  overflow-x: clip;
}

.topbar,
.section-heading,
.sync-center-head,
.quote-status-bar,
.inventory-filter-note,
.status-card-main,
.dashboard-list-item,
.smart-alert,
.task-item,
.inventory-item,
.inventory-batch-item,
.settings-hero,
.settings-logo-row {
  min-width: 0;
}

.topbar-actions,
.section-actions,
.sync-center-actions,
.quote-status-actions,
.table-actions,
.lead-actions,
.status-card-actions,
.backup-actions,
.settings-hero-actions,
.inventory-maintenance,
.staff-preset-actions {
  min-width: 0;
  max-width: 100%;
}

.topbar-actions > *,
.section-actions > *,
.sync-center-actions > *,
.quote-status-actions > *,
.table-actions > *,
.lead-actions > *,
.status-card-actions > *,
.backup-actions > *,
.settings-hero-actions > *,
.inventory-maintenance > *,
.staff-preset-actions > * {
  min-width: 0;
}

.field,
.inline-field,
.field input,
.field textarea,
.field select,
.inline-field input,
.inline-field textarea,
.inline-field select,
td input,
td textarea,
td select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

input,
textarea,
select,
button {
  max-width: 100%;
}

.dashboard-list-item,
.smart-alert,
.task-item,
.status-card,
.inventory-item,
.inventory-batch-item,
.report-card,
.stat-card,
.lead-pipeline-card,
.settings-overview article,
.settings-tab,
.nav-link,
.mobile-nav-link {
  overflow-wrap: anywhere;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overscroll-behavior-x: contain;
}

@media (max-width: 760px) {
  :root {
    --safe-page-gutter: 10px;
  }

  .app-shell {
    width: 100%;
    max-width: 100vw;
    overflow-x: clip;
  }

  .workspace {
    width: 100%;
    max-width: 100vw;
    padding-right: max(10px, env(safe-area-inset-right));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .topbar {
    width: auto;
    max-width: none;
    margin-right: calc(-1 * max(10px, env(safe-area-inset-right)));
    margin-left: calc(-1 * max(10px, env(safe-area-inset-left)));
  }

  .topbar-title,
  .topbar-actions {
    flex: 1 1 100%;
    width: 100%;
  }

  .topbar-actions,
  .section-actions,
  .sync-center-actions,
  .quote-status-actions,
  .table-actions,
  .lead-actions,
  .status-card-actions,
  .backup-actions,
  .settings-hero-actions,
  .inventory-maintenance,
  .staff-preset-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
  }

  .topbar-actions > *,
  .section-actions > *,
  .sync-center-actions > *,
  .quote-status-actions > *,
  .table-actions > *,
  .lead-actions > *,
  .status-card-actions > *,
  .backup-actions > *,
  .settings-hero-actions > *,
  .inventory-maintenance > *,
  .staff-preset-actions > * {
    width: 100%;
  }

  .stats-grid,
  #dashboardPage > .stats-grid,
  .report-card-grid,
  .dashboard-grid,
  .report-dashboard-grid,
  .task-board,
  .quick-actions,
  .sync-center-grid,
  .sync-center-details,
  .quote-details-grid,
  .summary,
  .cash-summary,
  .cash-header,
  .cash-meta,
  .form-grid,
  .form-grid.compact,
  .board-filter-bar,
  .status-board,
  .status-board-summary,
  .lead-tracker-summary,
  .lead-pipeline-board,
  .lead-form-grid,
  .lead-filter-bar,
  .inventory-workspace,
  .inventory-tools,
  .inventory-filter-grid,
  .settings-overview,
  .settings-crm-shell,
  .settings-layout,
  .settings-tabs,
  .settings-control-links,
  .admin-grid,
  .staff-access-summary,
  .security-checklist {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .panel,
  .sub-panel,
  .quotation-panel,
  .inventory-panel,
  .settings-panel {
    max-width: 100%;
    overflow-x: clip;
  }

  .mobile-tabbar {
    right: 8px;
    left: 8px;
    width: auto;
    max-width: calc(100vw - 16px);
  }
}

/* ── Quotation Records: compact contained table ─────────────────────────── */
/* table-wrap is the sole horizontal scroll container — no overflow:visible on parents */
#quotationsPage .table-wrap {
  border-radius: 8px;
  overflow-x: auto;
}

#quotationsPage .saved-quotes-table {
  width: 100%;
}

/* ── Quotation Records: stats strip ────────────────────────────────────────── */
.quotes-stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 0 10px;
}

.qstats-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 18px;
  background: #f8fafc;
  border: 1px solid #dfe7ef;
  border-radius: 10px;
  min-width: 80px;
}

.qstats-val {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.1;
  color: var(--text);
}

.qstats-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.qstats-pending     .qstats-val { color: #1d4ed8; }
.qstats-converted   .qstats-val { color: #047857; }
.qstats-rejected    .qstats-val { color: #b91c1c; }
.qstats-value       .qstats-val { color: var(--brand); }
.qstats-outstanding .qstats-val { color: #c2410c; }

.qstats-pending     { border-color: #bfdbfe; background: #eff6ff; }
.qstats-converted   { border-color: #a7f3d0; background: #ecfdf5; }
.qstats-rejected    { border-color: #fecaca; background: #fef2f2; }
.qstats-value       { border-color: #99f6e4; background: #f0fdfa; }
.qstats-outstanding { border-color: #fed7aa; background: #fff7ed; }

/* Row status left border */
#quotationsPage .saved-quotes-table tr[data-status="Pending"]    td:first-child { border-left: 4px solid #1d4ed8; padding-left: 10px; }
#quotationsPage .saved-quotes-table tr[data-status="Converted"]  td:first-child { border-left: 4px solid #047857; padding-left: 10px; }
#quotationsPage .saved-quotes-table tr[data-status="Rejected"]   td:first-child { border-left: 4px solid #b91c1c; padding-left: 10px; }
#quotationsPage .saved-quotes-table tr[data-status="Next Month"] td:first-child { border-left: 4px solid #b45309; padding-left: 10px; }

/* Quotation number badge */
.qno-badge {
  display: inline-block;
  padding: 2px 7px;
  background: #f1f5f9;
  border: 1px solid #dfe7ef;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
  font-family: monospace;
  color: var(--text);
  letter-spacing: 0.02em;
}

/* Customer name in table */
.quote-customer-name {
  font-weight: 700;
  color: var(--text);
}

/* Total cell */
.quote-total-cell {
  font-weight: 800;
  color: var(--brand);
  text-align: right !important;
}

/* Staff / date cells — slightly muted */
.quote-staff-cell,
.quote-date-cell {
  color: var(--muted);
  font-size: 12px;
}

/* Compact action buttons inside the record table */
#quotationsPage .saved-quotes-table .quote-action-btn {
  font-size: 11px;
  padding: 5px 6px;
  min-height: 28px;
}

/* Final responsive foundation: prevent page leakage without clipping usable content. */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.workspace,
.page-view,
.page-view.active,
.panel,
.sub-panel,
.quotation-panel,
.inventory-panel,
.settings-panel,
.table-wrap {
  max-width: 100%;
}

.workspace,
.page-view,
.page-view.active,
.panel,
.sub-panel,
.quotation-panel,
.inventory-panel,
.settings-panel {
  overflow-x: visible;
}

.workspace {
  width: 100%;
  max-width: min(1600px, 100vw);
  margin-right: auto;
  margin-left: auto;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  max-width: none;
}

.topbar,
.section-heading,
.sync-center-head,
.quote-status-bar,
.dashboard-list-item,
.smart-alert,
.task-item,
.inventory-item,
.inventory-batch-item,
.status-card-main,
.settings-hero {
  flex-wrap: wrap;
}

.topbar-title,
.topbar-actions,
.section-actions,
.sync-center-actions,
.quote-status-actions,
.table-actions,
.lead-actions,
.status-card-actions,
.backup-actions,
.settings-hero-actions,
.inventory-maintenance,
.staff-preset-actions {
  min-width: 0;
  max-width: 100%;
}

@media (min-width: 1181px) {
  #quotationsPage .panel,
  #leadTrackerPage .panel,
  #statusPage .panel,
  #activityLogPage .panel,
  #backupPage .panel,
  #settingsPage .settings-panel,
  #inventoryPage .inventory-panel,
  .quotation-panel {
    max-width: min(1480px, 100%);
  }

  #quotationsPage .saved-quotes-table {
    min-width: 0 !important;
  }

  #leadTrackerPage .lead-tracker-table {
    min-width: 0;
  }
}

@media (max-width: 1180px) {
  .workspace {
    max-width: 100vw;
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  .topbar-actions,
  .section-actions,
  .sync-center-actions,
  .quote-status-actions,
  .status-card-actions,
  .backup-actions,
  .settings-hero-actions,
  .inventory-maintenance,
  .staff-preset-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
    width: 100%;
  }

  .board-filter-bar,
  .form-grid,
  .form-grid.compact,
  .quote-details-grid,
  .summary,
  .cash-summary,
  .cash-header,
  .cash-meta,
  .inventory-workspace,
  .settings-layout,
  .settings-crm-shell,
  .lead-form-grid,
  .lead-filter-bar {
    grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)) !important;
  }

  .stats-grid,
  #dashboardPage > .stats-grid,
  .report-card-grid,
  .dashboard-grid,
  .report-dashboard-grid,
  .status-board,
  .status-board-summary,
  .lead-tracker-summary,
  .lead-pipeline-board,
  .settings-overview,
  .sync-center-grid,
  .sync-center-details {
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)) !important;
  }
}

@media (max-width: 1180px) {
  .staff-performance-wrap,
  #trashPage .table-wrap,
  #activityLogPage .table-wrap,
  #settingsPage .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .staff-performance-table,
  #trashPage table,
  #activityLogPage .activity-log-table,
  #settingsPage .table-wrap table {
    display: block;
    width: 100%;
    min-width: 0 !important;
    border-collapse: separate;
  }

  #leadTrackerPage .lead-tracker-table thead,
  .staff-performance-table thead,
  #trashPage table thead,
  #activityLogPage .activity-log-table thead,
  #settingsPage .table-wrap table thead {
    display: none;
  }

  #leadTrackerPage .lead-tracker-table tbody,
  .staff-performance-table tbody,
  #trashPage table tbody,
  #activityLogPage .activity-log-table tbody,
  #settingsPage .table-wrap table tbody {
    display: grid;
    gap: 12px;
  }

  #leadTrackerPage .lead-tracker-table tr,
  .staff-performance-table tr,
  #trashPage table tr,
  #activityLogPage .activity-log-table tr,
  #settingsPage .table-wrap table tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    max-width: 100%;
    padding: 12px;
    overflow: hidden;
    border: 1px solid #dfe7ef;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(23, 32, 51, 0.07);
  }

  #leadTrackerPage .lead-tracker-table td,
  .staff-performance-table td,
  #trashPage table td,
  #activityLogPage .activity-log-table td,
  #settingsPage .table-wrap table td {
    display: block;
    width: 100% !important;
    min-width: 0;
    max-width: 100%;
    border-bottom: 0;
    padding: 0;
    text-align: left !important;
  }

  #leadTrackerPage .lead-tracker-table td::before,
  .staff-performance-table td::before,
  #trashPage table td::before,
  #activityLogPage .activity-log-table td::before,
  #settingsPage .table-wrap table td::before {
    content: "";
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
  }

  #leadTrackerPage .lead-tracker-table td:nth-child(1),
  #leadTrackerPage .lead-tracker-table td:nth-child(8),
  #leadTrackerPage .lead-tracker-table td:nth-child(9),
  #settingsPage .table-wrap table td:nth-child(5),
  #settingsPage .table-wrap table td:nth-child(6),
  #settingsPage .table-wrap table td:nth-child(7),
  #settingsPage .table-wrap table td:nth-child(9) {
    grid-column: 1 / -1;
  }

  #leadTrackerPage .lead-tracker-table td:nth-child(1)::before { content: "Customer"; }
  #leadTrackerPage .lead-tracker-table td:nth-child(2)::before { content: "Requirement"; }
  #leadTrackerPage .lead-tracker-table td:nth-child(3)::before { content: "Lead By"; }
  #leadTrackerPage .lead-tracker-table td:nth-child(4)::before { content: "Date"; }
  #leadTrackerPage .lead-tracker-table td:nth-child(5)::before { content: "Contact"; }
  #leadTrackerPage .lead-tracker-table td:nth-child(6)::before { content: "Value"; }
  #leadTrackerPage .lead-tracker-table td:nth-child(7)::before { content: "Status"; }
  #leadTrackerPage .lead-tracker-table td:nth-child(8)::before { content: "Remark"; }
  #leadTrackerPage .lead-tracker-table td:nth-child(9)::before { content: "Action"; }

  .staff-performance-table td[colspan],
  #leadTrackerPage .lead-tracker-table td[colspan],
  #trashPage table td[colspan],
  #activityLogPage .activity-log-table td[colspan],
  #settingsPage .table-wrap table td[colspan] {
    grid-column: 1 / -1;
    color: var(--muted);
  }

  .staff-performance-table td[colspan]::before,
  #leadTrackerPage .lead-tracker-table td[colspan]::before,
  #trashPage table td[colspan]::before,
  #activityLogPage .activity-log-table td[colspan]::before,
  #settingsPage .table-wrap table td[colspan]::before {
    content: none;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding-right: max(10px, env(safe-area-inset-right));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  #leadTrackerPage .lead-tracker-table tr,
  .staff-performance-table tr,
  #trashPage table tr,
  #activityLogPage .activity-log-table tr,
  #settingsPage .table-wrap table tr {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  #leadTrackerPage .lead-tracker-table tr,
  .staff-performance-table tr,
  #trashPage table tr,
  #activityLogPage .activity-log-table tr,
  #settingsPage .table-wrap table tr {
    grid-template-columns: minmax(0, 1fr);
  }

  #leadTrackerPage .lead-tracker-table td,
  .staff-performance-table td,
  #trashPage table td,
  #activityLogPage .activity-log-table td,
  #settingsPage .table-wrap table td {
    grid-column: 1 / -1 !important;
  }
}

/* Quotation Records desktop repair: fixed by a scoped table scroller, not page overflow. */
#quotationsPage {
  min-width: 0;
}

#quotationsPage .panel {
  width: 100%;
  padding: 16px;
}

#quotationsPage .saved-quotes-filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}

#quotationsPage .saved-quotes-filter-bar .field,
#quotationsPage .saved-quotes-filter-bar input,
#quotationsPage .saved-quotes-filter-bar select,
#quotationsPage .saved-quotes-filter-bar button {
  width: 100%;
  min-width: 0;
}

#quotationsPage .saved-quotes-filter-bar .board-filter-summary {
  grid-column: 1 / -1;
  font-size: 12px;
}

#quotationsPage .quotation-records-table-wrap {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

@media (max-width: 899px) {
  #quotationsPage .quotation-records-table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
}

/* ═══════════════════════════════════════════════════════
   PHASE 1-5 ENHANCEMENTS
   ═══════════════════════════════════════════════════════ */

/* --- Period filter bar --- */
.dash-period-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.dash-period-btn {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.dash-period-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.dash-period-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* --- Stat card trend arrow --- */
.stat-trend {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.stat-trend.up   { color: #16a34a; }
.stat-trend.down { color: var(--danger); }
.stat-trend.flat { color: var(--muted); }

/* ═══════════════════════════════════════════════════════
   CRM DASHBOARD — Full redesign
   ═══════════════════════════════════════════════════════ */

/* Control bar: period pills + month picker + range label */
.crm-control-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 14px;
}
.crm-period-btns { display: flex; gap: 5px; flex-wrap: wrap; }
.crm-month-pick {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}
.crm-month-pick select {
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--text);
  cursor: pointer;
}
.crm-period-range {
  margin-left: auto;
  font-size: 12px;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ── 6-Card KPI Strip ──────────────────────────────────── */
.crm-kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 1100px) { .crm-kpi-strip { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px)  { .crm-kpi-strip { grid-template-columns: repeat(2, 1fr); } }

.crm-kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: default;
  transition: box-shadow 0.15s, transform 0.12s;
  position: relative;
  overflow: hidden;
}
.crm-kpi[data-go] { cursor: pointer; }
.crm-kpi[data-go]:hover { box-shadow: 0 4px 18px rgba(15,23,42,0.1); transform: translateY(-2px); }
.crm-kpi-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.crm-kpi-value {
  font-size: 21px;
  font-weight: 900;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.crm-kpi-trend {
  font-size: 10.5px;
  font-weight: 700;
  font-style: normal;
  color: var(--muted);
  min-height: 14px;
}
.crm-kpi-trend.up   { color: #16a34a; }
.crm-kpi-trend.down { color: var(--danger); }

/* Colour top-border per card type */
.crm-kpi--revenue   { border-top: 3px solid #22c55e; }
.crm-kpi--pipeline  { border-top: 3px solid var(--brand); }
.crm-kpi--winrate   { border-top: 3px solid #f59e0b; }
.crm-kpi--quotes    { border-top: 3px solid #3b82f6; }
.crm-kpi--leads     { border-top: 3px solid #8b5cf6; }
.crm-kpi--avg       { border-top: 3px solid #06b6d4; }

/* Revenue target bar inside KPI card */
.crm-kpi-target {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.crm-kpi-target-fill {
  height: 5px;
  background: #22c55e;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.crm-kpi-target small {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}

/* ── Sales Funnel ──────────────────────────────────────── */
.crm-funnel-panel { margin-bottom: 14px; }
.crm-funnel {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-top: 12px;
  overflow-x: auto;
}
.crm-funnel-stage {
  flex: 1;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 16px 10px 12px;
  background: var(--soft);
  border-radius: 8px;
  text-align: center;
  border: 1px solid var(--line);
  transition: background 0.15s;
}
.crm-funnel-stage:hover { background: rgba(15,118,110,0.04); }
.crm-funnel-icon { font-size: 20px; line-height: 1; }
.crm-funnel-count { font-size: 26px; font-weight: 900; color: var(--text); line-height: 1; }
.crm-funnel-label {
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted);
}
.crm-funnel-value { font-size: 12.5px; font-weight: 700; color: var(--brand-dark); }
.crm-funnel-bar-wrap {
  width: 80%; height: 4px;
  background: var(--line); border-radius: 2px;
}
.crm-funnel-bar-fill { height: 100%; border-radius: 2px; background: var(--brand); min-width: 4px; }
.crm-funnel-pct { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.crm-funnel-arrow {
  display: flex; align-items: center; justify-content: center;
  padding: 0 8px; font-size: 22px; color: var(--muted);
  flex-shrink: 0;
}
/* Stage-specific bar colours */
.stage-pending    .crm-funnel-bar-fill { background: #3b82f6; }
.stage-next-month .crm-funnel-bar-fill { background: #f59e0b; }
.stage-converted  .crm-funnel-bar-fill { background: #22c55e; }
.stage-rejected   .crm-funnel-bar-fill { background: #ef4444; }
.stage-converted  .crm-funnel-count { color: #16a34a; }
.stage-rejected   .crm-funnel-count { color: #dc2626; }
/* Extra report cards below funnel */
.crm-funnel-extra {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.crm-funnel-extra .report-card {
  background: var(--soft);
  border-radius: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
}

/* ── Charts Row ────────────────────────────────────────── */
.crm-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 768px) { .crm-charts-row { grid-template-columns: 1fr; } }

/* ── Tri-grid: Staff | Aging | Customers ───────────────── */
.crm-tri-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 1100px) { .crm-tri-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px)  { .crm-tri-grid { grid-template-columns: 1fr; } }
.crm-tri-grid .panel { margin-bottom: 0; }

/* ── Alerts + Today dual-panel ─────────────────────────── */
.crm-alerts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 768px) { .crm-alerts-row { grid-template-columns: 1fr; } }

/* ── Dual grid: Quotes + Follow-ups / PO + Portal ──────── */
.crm-dual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 768px) { .crm-dual-grid { grid-template-columns: 1fr; } }

.crm-control-title {
  min-width: 190px;
}

.crm-control-bar {
  border-radius: 8px;
  align-items: stretch;
}

.crm-control-title h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: 0;
}

.crm-control-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.crm-control-actions .secondary-btn {
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 12px;
}

.crm-command-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(320px, 0.85fr);
  gap: 14px;
  margin-bottom: 14px;
  align-items: stretch;
}

.crm-kpi {
  border-radius: 8px;
  min-height: 110px;
}

.crm-kpi-value {
  letter-spacing: 0;
}

.crm-command-grid > .panel,
.crm-sales-grid > .panel,
.crm-modules-panel {
  margin-bottom: 0;
}

.crm-forecast-panel {
  min-width: 0;
}

.crm-forecast-body {
  display: grid;
  gap: 12px;
}

.crm-forecast-top {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.1), rgba(37, 99, 235, 0.08));
}

.crm-forecast-top span,
.crm-forecast-progress span,
.crm-forecast-stat-grid span,
.crm-stage-bar-row span,
.crm-module-card span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.crm-forecast-top strong {
  display: block;
  margin-top: 5px;
  color: var(--brand-dark);
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

.crm-forecast-top em,
.crm-forecast-progress small,
.crm-stage-bar-row em,
.crm-module-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
}

.crm-forecast-progress {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.crm-forecast-progress > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.crm-forecast-progress strong {
  color: var(--text);
  font-size: 16px;
  letter-spacing: 0;
}

.crm-forecast-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.crm-forecast-track i {
  display: block;
  height: 100%;
  min-width: 4px;
  border-radius: inherit;
  background: var(--brand);
}

.crm-forecast-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.crm-forecast-stat-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--soft);
}

.crm-forecast-stat-grid strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 17px;
  line-height: 1.1;
  letter-spacing: 0;
}

.crm-stage-bars {
  display: grid;
  gap: 8px;
}

.crm-stage-bar-row {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) minmax(90px, 1.15fr) auto;
  gap: 8px;
  align-items: center;
}

.crm-stage-bar-row > div {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.crm-stage-bar-row i {
  display: block;
  height: 100%;
  min-width: 4px;
  border-radius: inherit;
  background: var(--brand);
}

.crm-stage-bar-row.lead i { background: #2563eb; }
.crm-stage-bar-row.won i { background: #16a34a; }

.crm-stage-bar-row strong {
  color: var(--text);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.crm-sales-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.crm-lead-stage-list,
.crm-action-list {
  display: grid;
  gap: 8px;
}

.crm-lead-stage-card,
.crm-action-item,
.crm-module-card {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.crm-lead-stage-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(90px, 0.7fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  min-height: 58px;
}

.crm-lead-stage-card:hover,
.crm-action-item:hover,
.crm-module-card:hover {
  border-color: var(--brand);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.crm-lead-stage-card strong,
.crm-action-item strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
}

.crm-lead-stage-card small,
.crm-action-item small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.crm-lead-stage-card b {
  color: var(--brand-dark);
  font-size: 12px;
  white-space: nowrap;
}

.crm-lead-stage-meter {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.crm-lead-stage-meter i {
  display: block;
  height: 100%;
  min-width: 4px;
  border-radius: inherit;
  background: #2563eb;
}

.crm-action-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
  border-left-width: 4px;
}

.crm-action-item b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 800;
}

.crm-action-item.critical { border-left-color: #dc2626; }
.crm-action-item.warning { border-left-color: #d97706; }
.crm-action-item.info { border-left-color: #2563eb; }

.crm-module-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.crm-module-card {
  display: grid;
  gap: 4px;
  min-height: 92px;
  padding: 12px;
  border-top-width: 3px;
}

.crm-module-card strong {
  display: block;
  color: var(--text);
  font-size: 23px;
  line-height: 1.05;
  letter-spacing: 0;
}

.crm-module-card.tone-blue { border-top-color: #2563eb; }
.crm-module-card.tone-green { border-top-color: #16a34a; }
.crm-module-card.tone-gold { border-top-color: #d97706; }
.crm-module-card.tone-red { border-top-color: #dc2626; }
.crm-module-card.tone-cyan { border-top-color: #0891b2; }
.crm-module-card.tone-violet { border-top-color: #7c3aed; }

.stage-leads .crm-funnel-bar-fill { background: #2563eb; }
.stage-leads .crm-funnel-count { color: #1d4ed8; }

@media (max-width: 1180px) {
  .crm-command-grid,
  .crm-sales-grid {
    grid-template-columns: 1fr;
  }

  .crm-module-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .crm-control-title {
    width: 100%;
  }

  .crm-control-actions {
    width: 100%;
  }

  .crm-control-actions .secondary-btn {
    flex: 1 1 90px;
  }

  .crm-module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .crm-lead-stage-card {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .crm-lead-stage-meter {
    grid-column: 1 / -1;
  }
}

/* Staff performance table — wider with more columns */
.staff-performance-table { font-size: 12.5px; }
.staff-performance-table th { font-size: 10px; padding: 7px 8px; }
.staff-performance-table td { padding: 7px 8px; }

/* Dark-mode overrides for new CRM elements */
body[data-theme="dark"] .crm-kpi {
  background: var(--panel);
  border-color: var(--line);
}
body[data-theme="dark"] .crm-funnel-stage {
  background: rgba(255,255,255,0.03);
  border-color: var(--line);
}
body[data-theme="dark"] .crm-month-pick select {
  background: var(--soft);
  color: var(--text);
  border-color: var(--line);
}

body[data-theme="dark"] .crm-forecast-top {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.12), rgba(96, 165, 250, 0.1));
}

body[data-theme="dark"] .crm-forecast-progress,
body[data-theme="dark"] .crm-forecast-stat-grid > div,
body[data-theme="dark"] .crm-lead-stage-card,
body[data-theme="dark"] .crm-action-item,
body[data-theme="dark"] .crm-module-card {
  background: rgba(255,255,255,0.03);
  border-color: var(--line);
}

body[data-theme="dark"] .crm-action-item b {
  background: rgba(255,255,255,0.06);
}

/* --- Target progress bar inside pipeline card --- */
.stat-target-bar {
  height: 5px;
  margin-top: 10px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.stat-target-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--brand);
  transition: width 0.4s ease;
  max-width: 100%;
}

.stat-target-label {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

/* --- Chart canvas wrappers --- */
.chart-canvas-wrap {
  position: relative;
  width: 100%;
  padding: 8px 0 4px;
}

.chart-canvas-wrap canvas {
  width: 100% !important;
  display: block;
}

.chart-canvas-wrap--donut {
  max-width: 320px;
  margin: 0 auto;
}

.chart-fallback {
  display: none;
}

.no-chartjs .chart-canvas-wrap {
  display: none;
}

.no-chartjs .chart-fallback {
  display: grid;
}

/* --- Dashboard 3-column grid for leaderboard / aging / top customers --- */
.dashboard-tri-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}

@media (max-width: 1024px) {
  .dashboard-tri-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .dashboard-tri-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Quote aging list --- */
.aging-list {
  display: grid;
  gap: 8px;
}

.aging-row {
  display: grid;
  grid-template-columns: minmax(72px, auto) 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.aging-row:last-child { border-bottom: 0; }

.aging-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.aging-badge.healthy { background: #dcfce7; color: #15803d; }
.aging-badge.watch   { background: #fef9c3; color: #a16207; }
.aging-badge.risk    { background: #ffedd5; color: #c2410c; }
.aging-badge.stale   { background: #fee2e2; color: #b91c1c; }

.aging-row .aging-bar-wrap {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.aging-row .aging-bar-fill {
  height: 100%;
  border-radius: 3px;
}

.aging-badge.healthy + * .aging-bar-fill, .aging-bar-fill.healthy { background: #16a34a; }
.aging-bar-fill.watch   { background: #ca8a04; }
.aging-bar-fill.risk    { background: #ea580c; }
.aging-bar-fill.stale   { background: var(--danger); }

.aging-row strong {
  font-size: 13px;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
}

/* --- Top customers list --- */
.top-customers-list {
  display: grid;
  gap: 6px;
}

.top-customer-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.top-customer-row:last-child { border-bottom: 0; }

.top-customer-rank {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.top-customer-rank.gold   { background: #fef3c7; color: #92400e; }
.top-customer-rank.silver { background: #f1f5f9; color: #475569; }
.top-customer-rank.bronze { background: #ffedd5; color: #9a3412; }

.top-customer-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.top-customer-name small {
  display: block;
  font-weight: 500;
  color: var(--muted);
  font-size: 11px;
}

.top-customer-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-dark);
  white-space: nowrap;
}

/* --- Health score widget --- */
.health-score-widget {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  align-items: center;
}

@media (max-width: 640px) {
  .health-score-widget {
    grid-template-columns: 1fr;
  }
}

.health-score-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.health-score-number {
  font-size: 52px;
  font-weight: 900;
  line-height: 1;
}

.health-score-number.score-great  { color: #16a34a; }
.health-score-number.score-good   { color: var(--brand); }
.health-score-number.score-fair   { color: #ca8a04; }
.health-score-number.score-poor   { color: var(--danger); }

.health-score-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.health-score-breakdown {
  display: grid;
  gap: 10px;
  flex: 1;
}

.health-factor-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.6fr) 1fr 36px;
  align-items: center;
  gap: 10px;
}

.health-factor-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.health-factor-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.health-factor-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--brand);
  transition: width 0.4s ease;
}

.health-factor-score {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-align: right;
}

/* --- Notification bell button --- */
.notif-bell-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.notif-bell-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.notif-bell-btn.has-notifs {
  border-color: var(--gold);
  color: var(--gold);
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid var(--panel);
}

.notif-badge.hidden {
  display: none;
}

/* --- Notification drawer --- */
.notif-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 100%;
  z-index: 200;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(0);
  transition: transform 0.25s ease;
}

.notif-drawer.hidden {
  transform: translateX(110%);
  pointer-events: none;
}

.notif-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.notif-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notif-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  transition: opacity 0.2s ease;
}

.notif-item.dismissed {
  opacity: 0.45;
}

.notif-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.notif-dot.critical { background: var(--danger); }
.notif-dot.warning  { background: var(--gold); }
.notif-dot.info     { background: var(--blue); }
.notif-dot.success  { background: #16a34a; }

.notif-body strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 2px;
}

.notif-body small {
  font-size: 12px;
  color: var(--muted);
}

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

/* --- Analytics page --- */
.analytics-panel {
  max-width: 1200px;
}

.analytics-heading {
  flex-wrap: wrap;
  gap: 12px;
}

.analytics-period-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.analytics-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}

@media (max-width: 860px) {
  .analytics-charts-grid {
    grid-template-columns: 1fr;
  }
}

.analytics-chart-panel {
  min-width: 0;
}

.analytics-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}

@media (max-width: 860px) {
  .analytics-bottom-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Conversion funnel --- */
.analytics-funnel {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.funnel-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.5fr) 1fr 48px 36px;
  align-items: center;
  gap: 10px;
}

.funnel-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.funnel-bar {
  height: 22px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}

.funnel-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--brand);
  display: flex;
  align-items: center;
  padding-left: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  transition: width 0.4s ease;
}

.funnel-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-align: right;
}

.funnel-pct {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-align: right;
}

/* --- Customers page --- */
.customers-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

@media (max-width: 640px) {
  .customers-workspace {
    grid-template-columns: 1fr;
  }
}

.customer-ledger-panel {
  margin-top: 18px;
}

.customers-table {
  width: 100%;
}

/* --- Health score panel margin --- */
#healthScorePanel {
  margin-top: 18px;
}

/* ═══════════════════════════════════════════════════════════
   Template settings cards
═══════════════════════════════════════════════════════════ */
.template-settings-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 20px;
  background: var(--panel);
}

.template-card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.template-card-badge {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #ffffff;
}

.gst-badge  { background: #164e63; }
.cash-badge { background: #854d0e; }

.template-card-header h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.template-card-header p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.field-hint {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

/* Color picker row */
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.color-picker-row input[type="color"] {
  flex-shrink: 0;
  width: 44px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: var(--bg);
  min-height: unset;
}

.color-hex-input {
  flex: 1;
  min-width: 0;
  font-family: monospace;
  font-size: 13px !important;
}

/* Toggle grid */
.template-toggles {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.toggle-section-label {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px 14px;
}

.toggle-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.toggle-option input[type="checkbox"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  min-height: unset;
  accent-color: var(--brand);
  cursor: pointer;
}

.toggle-option span {
  line-height: 1.3;
}

/* GST number line in print */
.print-company-gst {
  margin: 2px 0 0;
  font-size: 9px;
  color: #5a7080;
  font-weight: 600;
}

@media (max-width: 760px) {
  .template-card-header {
    flex-direction: column;
  }

  .toggle-grid {
    grid-template-columns: 1fr 1fr;
  }

  .color-picker-row {
    flex-wrap: wrap;
  }
}

/* ═══════════════════════════════════════════════════════════
   PO Tracker
═══════════════════════════════════════════════════════════ */
.po-tracker-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  min-height: 0;
  height: calc(100vh - var(--topbar-h, 64px));
  overflow: hidden;
}

/* Left company panel */
.po-company-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}

.po-company-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.po-company-panel-head h2 {
  font-size: 15px;
  margin: 0;
}

.po-company-panel-head .eyebrow {
  margin: 0 0 2px;
}

.po-company-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.po-company-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.po-company-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.po-company-card:hover {
  border-color: var(--brand);
  background: var(--panel);
}

.po-company-card.active {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, var(--panel));
}

.po-company-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.po-company-card-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.po-company-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 11px;
}

.po-company-card-stats span {
  background: var(--surface, #f1f5f9);
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--muted);
}

.po-outstanding-badge {
  background: #fef3c7 !important;
  color: #92400e !important;
  font-weight: 700;
}

.po-paid-badge {
  background: #dcfce7 !important;
  color: #15803d !important;
  font-weight: 700;
}

/* Right orders panel */
.po-orders-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.po-empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 40px;
}

/* CRM summary bar */
.po-crm-bar {
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}

.po-crm-company-name {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.po-crm-company-name h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.po-crm-gst,
.po-crm-contact {
  font-size: 12px;
  color: var(--muted);
}

.po-crm-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.po-crm-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.po-crm-stat span {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}

.po-crm-stat strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.po-crm-paid { color: #16a34a !important; }
.po-crm-due  { color: #dc2626 !important; }

/* Toolbar */
.po-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.po-search-input {
  flex: 1;
  min-width: 160px;
}

/* PO table */
.po-table-wrap {
  flex: 1;
  overflow: auto;
}

.po-orders-table {
  width: 100%;
  min-width: 1000px;
}

.po-orders-table th,
.po-orders-table td {
  white-space: nowrap;
}

.po-cell-items {
  max-width: 200px;
  white-space: normal !important;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.4;
}

.po-cell-poNo strong {
  font-size: 12px;
}

.po-row-overdue {
  background: #fff7ed !important;
}

.po-cell-overdue-date {
  color: #dc2626;
  font-weight: 600;
}

.text-right { text-align: right; }

/* Payment cells */
.po-paid-text     { font-size: 11px; color: #16a34a; font-weight: 600; }
.po-due-text      { font-size: 11px; color: #dc2626; font-weight: 700; }
.po-settled-text  { font-size: 11px; color: #16a34a; }

/* Status badges */
.po-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.po-status-pending    { background: #e0f2fe; color: #0369a1; }
.po-status-processing { background: #fef9c3; color: #854d0e; }
.po-status-dispatched { background: #ede9fe; color: #6d28d9; }
.po-status-delivered  { background: #dcfce7; color: #15803d; }
.po-status-invoiced   { background: #dbeafe; color: #1d4ed8; }
.po-status-paid       { background: #bbf7d0; color: #15803d; }
.po-status-cancelled  { background: #fee2e2; color: #b91c1c; }

.po-remarks-text {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  white-space: normal;
  line-height: 1.3;
}

/* Company modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-box {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.po-company-modal-box {
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

/* PO form grid */
.po-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin-bottom: 16px;
}

.po-form-full {
  grid-column: 1 / -1;
}

/* Responsive */
@media (max-width: 900px) {
  .po-tracker-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
  }

  .po-company-panel {
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 260px;
  }

  .po-tracker-layout .po-orders-panel {
    height: auto;
  }

  .po-table-wrap {
    overflow-x: auto;
  }
}

@media (max-width: 600px) {
  .po-form-grid {
    grid-template-columns: 1fr;
  }

  .po-toolbar {
    gap: 6px;
  }

  .po-search-input {
    min-width: 100%;
  }
}

/* ── Feature 7: PO Dashboard Summary ─────────────────────── */
.po-dashboard-summary {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.po-dash-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.po-dash-stat-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  min-width: 100px;
}

.po-dash-stat-card span {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}

.po-dash-stat-card strong {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.po-dash-stat-alert strong { color: #dc2626; }
.po-dash-stat-warn   strong { color: #d97706; }
.po-dash-stat-danger { border-color: #fca5a5; background: #fff1f2; }
.po-dash-stat-danger strong { color: #dc2626; }

.po-dash-top-companies {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
  flex-shrink: 0;
}

.po-dash-top-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 2px;
}

.po-dash-top-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s;
}

.po-dash-top-item:hover { border-color: var(--brand); }
.po-dash-top-item span { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.po-dash-top-item b { color: #dc2626; font-size: 13px; white-space: nowrap; }

/* ── Feature 8: Main Dashboard PO Widget ─────────────────── */
.po-dash-widget-panel { margin-bottom: 0; }

.po-widget-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin-bottom: 12px;
}

.po-widget-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
}

.po-widget-stat span {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}

.po-widget-stat strong {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.po-widget-stat em {
  font-size: 11px;
  color: var(--muted);
  font-style: normal;
}

.po-widget-companies {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.po-widget-company-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s, background 0.12s;
}

.po-widget-company-item:hover { border-color: var(--brand); background: var(--panel); }
.po-widget-company-item span { color: var(--text); font-weight: 600; }
.po-widget-company-item b { color: #dc2626; white-space: nowrap; }

/* ── Feature 9: Company Notes Log ────────────────────────── */
.po-notes-section {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}

.po-notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 16px;
}

.po-notes-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.po-notes-body {
  border-top: 1px solid var(--line);
}

.po-notes-list {
  max-height: 180px;
  overflow-y: auto;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.po-notes-empty {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 8px 0;
}

.po-note-item {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
}

.po-note-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}

.po-note-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 5px;
  gap: 8px;
}

.po-note-meta span {
  font-size: 10px;
  color: var(--muted);
}

.po-note-delete {
  background: none;
  border: none;
  padding: 0 2px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.po-note-delete:hover { color: var(--danger); }

.po-notes-add {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
}

.po-note-input {
  flex: 1;
  font-size: 13px;
}

@media (max-width: 600px) {
  .po-dashboard-summary { flex-direction: column; }
  .po-dash-top-companies { min-width: 100%; }
  .po-widget-row { gap: 10px 14px; }
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD STICKY NOTES & TASK LIST
═══════════════════════════════════════════════════════════ */

.dash-sticky-panel,
.dash-task-panel {
  display: flex;
  flex-direction: column;
}

.dash-sticky-list,
.dash-task-list {
  min-height: 80px;
  max-height: 260px;
  overflow-y: auto;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.dash-notes-empty {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 12px 0;
}

/* Sticky note cards */
.dash-sticky-card {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  border-radius: 7px;
  padding: 10px 12px;
}

.dark-mode .dash-sticky-card {
  background: #2d2513;
  border-color: #78350f;
  border-left-color: #d97706;
}

.dash-sticky-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
  margin: 0 0 6px;
}

.dash-sticky-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dash-sticky-meta span {
  font-size: 10px;
  color: var(--muted);
}

.dash-sticky-del {
  background: none;
  border: none;
  padding: 0 2px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}
.dash-sticky-del:hover { color: var(--danger); }

/* Task list items */
.dash-task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--bg);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s;
}
.dash-task-item:hover { background: var(--hover); }

.dash-task-check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.dash-task-text {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
  line-height: 1.4;
}

.dash-task-item.done .dash-task-text {
  text-decoration: line-through;
  color: var(--muted);
}

.dash-task-del {
  background: none;
  border: none;
  padding: 0 2px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}
.dash-task-del:hover { color: var(--danger); }

/* Shared add row */
.dash-notes-add {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}

.dash-note-input {
  flex: 1;
  font-size: 13px;
}

.small-btn {
  padding: 6px 14px;
  font-size: 13px;
}

@media (max-width: 600px) {
  .dash-sticky-list,
  .dash-task-list { max-height: 200px; }
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD CRM LAYOUT IMPROVEMENTS
═══════════════════════════════════════════════════════════ */

/* 2-column row wrapper for paired panels */
.dashboard-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  grid-column: 1 / -1;
  align-items: start;
}

.dashboard-2col > .panel {
  margin-top: 0;
}

/* Ensure new elements take full width in the dashboard grid */
#dashboardPage > .today-snapshot-strip,
#dashboardPage > .overdue-po-alert,
#dashboardPage > .dashboard-2col {
  grid-column: 1 / -1;
}

/* ── Today's Snapshot Strip ─────────────────────────────── */
.today-snapshot-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.today-snap-card {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px 14px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 3px solid var(--brand);
  transition: box-shadow 0.15s, transform 0.15s;
}

.today-snap-card:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}

.today-snap-deliveries { border-top-color: var(--blue); }
.today-snap-outstanding { border-top-color: var(--gold); }

.today-snap-card span {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 4px;
}

.today-snap-card strong {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--brand-dark);
}

.today-snap-deliveries strong { color: var(--blue); }
.today-snap-outstanding strong { color: var(--gold); }

.today-snap-card em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Overdue PO Alert ───────────────────────────────────── */
.overdue-po-alert {
  border-radius: 10px;
  border: 1px solid #fca5a5;
  border-left: 4px solid #dc2626;
  background: linear-gradient(135deg, #fff5f5, #fff8f8);
  padding: 14px 16px;
  animation: alertFadeIn 0.25s ease;
}

@keyframes alertFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.overdue-po-inner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}

.overdue-po-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
  margin-top: 1px;
}

.overdue-po-content {
  flex: 1;
  min-width: 0;
}

.overdue-po-content > strong {
  display: block;
  color: #991b1b;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}

.overdue-po-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.overdue-po-tag {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 20px;
  padding: 3px 11px;
  font-size: 12px;
  color: #7f1d1d;
  white-space: nowrap;
}

.overdue-po-more {
  background: #fecaca;
  color: #991b1b;
  font-weight: 700;
}

.overdue-po-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 7px;
  border: 1.5px solid #dc2626;
  background: transparent;
  color: #dc2626;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.overdue-po-btn:hover {
  background: #dc2626;
  color: #fff;
}

/* ── CRM-style panel & heading polish ───────────────────── */
.section-heading {
  border-bottom-color: var(--line);
  padding-bottom: 14px;
  margin-bottom: 14px;
}

.section-heading h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.8px;
  margin-bottom: 2px;
}

/* CRM list items — cleaner left accent */
.dashboard-list-item {
  border-left: 3px solid transparent;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.dashboard-list-item:hover {
  border-left-color: var(--brand);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.07);
}

.dashboard-list-item.overdue {
  border-left-color: #dc2626;
}

.dashboard-list-item.due {
  border-left-color: var(--gold);
}

/* Smart alerts — slightly tighter */
.smart-alert {
  border-radius: 8px;
  transition: transform 0.12s, box-shadow 0.12s;
}

.smart-alert:hover {
  transform: translateX(2px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.07);
}

/* Stat cards — CRM accent dots */
.stat-card {
  transition: box-shadow 0.15s, transform 0.15s;
}

/* ── Collapsible dashboard sections ────────────────────── */
.dash-collapsible .section-heading {
  margin-bottom: 0;
  padding-bottom: 12px;
  transition: border-color 0.2s, padding-bottom 0.2s, margin-bottom 0.2s;
}

.dash-collapsible:not(.dash-collapsed) .section-heading {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom-color: var(--line);
}

.collapsible-body {
  overflow: hidden;
}

.dash-collapsed .collapsible-body {
  display: none;
}

.dash-collapsed {
  padding-bottom: 0;
}

/* Chevron toggle button */
.collapse-toggle {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.collapse-toggle:hover {
  background: var(--panel);
  border-color: var(--brand);
  color: var(--brand);
}

.toggle-icon {
  display: block;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s;
  margin-top: 3px;
}

.dash-collapsed .toggle-icon {
  transform: rotate(135deg);
  margin-top: -3px;
}

/* Inner tri-grid panels don't need panel card styling when inside collapsible */
.dashboard-tri-grid section {
  min-width: 0;
}

.dashboard-tri-grid .section-heading {
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
  padding-bottom: 10px;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1179px) {
  .today-snapshot-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 800px) {
  .dashboard-2col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .today-snapshot-strip {
    grid-template-columns: 1fr 1fr;
  }

  .today-snap-outstanding {
    grid-column: 1 / -1;
  }

  .overdue-po-inner {
    gap: 10px;
  }

  .overdue-po-btn {
    width: 100%;
    text-align: center;
  }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE TABBAR — ICONS + REDESIGN
═══════════════════════════════════════════════════════════ */

@media (max-width: 760px) {
  .mobile-tabbar {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 4px 6px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(15, 23, 42, 0.08);
    border-color: rgba(148, 163, 184, 0.3);
  }

  .mobile-nav-link {
    min-height: 52px;
    padding: 6px 2px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1px;
    color: #94a3b8;
    background: transparent;
    border: none;
    box-shadow: none;
    transition: color 0.15s, background 0.15s;
  }

  .tab-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-width: 2;
    transition: transform 0.15s;
  }

  .mobile-nav-link:hover {
    color: var(--brand);
    background: transparent;
    border: none;
    box-shadow: none;
  }

  .mobile-nav-link.active {
    color: var(--brand);
    background: rgba(15, 118, 110, 0.1);
    border: none;
    box-shadow: none;
  }

  .mobile-nav-link.active .tab-icon {
    transform: scale(1.1);
  }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE MOBILE IMPROVEMENTS
═══════════════════════════════════════════════════════════ */

@media (max-width: 760px) {
  /* Topbar — compact and clean */
  .topbar {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: max(12px, env(safe-area-inset-top)) 12px 12px;
    margin: -10px -10px 14px;
    border-radius: 0 0 12px 12px;
  }

  .topbar-title {
    flex: 1;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    width: auto;
  }

  .topbar-title div { flex: 1; min-width: 0; }

  .topbar-title h1 {
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-title .eyebrow { display: none; }

  .topbar-actions {
    display: none; /* Hidden on mobile — use quote-status-bar instead */
  }

  /* Quote status bar — cleaner mobile */
  .quote-status-bar {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    margin: -14px -14px 12px;
  }

  .quote-status-bar > div { flex: 1; min-width: 0; }

  .quote-status-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  .quote-status-actions button {
    flex: 1 0 auto;
    min-width: 60px;
    padding: 8px 10px;
    font-size: 13px;
  }

  /* Panel spacing */
  .panel { padding: 14px; border-radius: 10px; }
  .panel + .panel { margin-top: 12px; }

  /* Section heading tighter on mobile */
  .section-heading { margin-bottom: 12px; padding-bottom: 10px; }
  .section-heading h2 { font-size: 15px; }

  /* Dashboard 2col → single on small screens */
  .dashboard-2col { grid-template-columns: 1fr; gap: 12px; }

  /* Today snapshot — 2+1 layout */
  .today-snapshot-strip { gap: 10px; }
  .today-snap-card { padding: 12px 14px; }
  .today-snap-card strong { font-size: 22px; }

  /* Stat cards */
  .stats-grid { gap: 10px; }
  .stat-card { min-height: 88px; padding: 12px; }
  .stat-card strong { font-size: 20px; }

  /* PO Tracker — single column on mobile */
  .po-crm-layout { grid-template-columns: 1fr; }
  .po-company-list-panel { border-right: none; border-bottom: 1px solid var(--line); max-height: 260px; overflow-y: auto; }
  .po-orders-panel { min-height: auto; }

  /* Dashboard list items — more compact */
  .dashboard-list-item { min-height: 52px; padding: 10px 12px; }
  .dashboard-list-item small { font-size: 11px; }

  /* Smart alerts compact */
  .smart-alert { padding: 10px 12px; }

  /* Dash notes */
  .dash-sticky-list, .dash-task-list { max-height: 180px; }

  /* Staff table — scroll on mobile */
  .staff-users-table-wrap { overflow-x: auto; }

  /* Better form fields on mobile */
  .form-grid { grid-template-columns: 1fr; }
  .field label, .field { font-size: 14px; }

  .line-items-table,
  .cash-table {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .line-items-table thead,
  .cash-table thead {
    display: none;
  }

  .line-items-table tbody,
  .cash-table tbody {
    display: grid;
    gap: 10px;
  }

  .line-items-table tbody tr,
  .cash-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "serial image"
      "item item"
      "qty unit"
      "rate total"
      "action action";
    gap: 9px 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    box-shadow: 0 1px 5px rgba(15, 23, 42, 0.05);
  }

  .line-items-table td,
  .cash-table td {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 0 !important;
    border: 0 !important;
  }

  .line-items-table td::before,
  .cash-table td::before {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .line-items-table td:nth-child(1),
  .cash-table td:nth-child(1) {
    grid-area: serial;
    align-content: center;
    justify-items: start;
    text-align: left;
  }

  .line-items-table td:nth-child(1)::before,
  .cash-table td:nth-child(1)::before { content: "Line"; }

  .line-items-table td:nth-child(2),
  .cash-table td:nth-child(2) { grid-area: item; }
  .line-items-table td:nth-child(2)::before,
  .cash-table td:nth-child(2)::before { content: "Item"; }

  .line-items-table td:nth-child(3),
  .cash-table td:nth-child(3) {
    grid-area: image;
    align-content: center;
    justify-items: end;
  }
  .line-items-table td:nth-child(3)::before,
  .cash-table td:nth-child(3)::before { content: "Image"; }

  .line-items-table td:nth-child(4),
  .cash-table td:nth-child(4) { grid-area: qty; }
  .line-items-table td:nth-child(4)::before,
  .cash-table td:nth-child(4)::before { content: "Qty"; }

  .line-items-table td:nth-child(5),
  .cash-table td:nth-child(5) { grid-area: unit; }
  .line-items-table td:nth-child(5)::before,
  .cash-table td:nth-child(5)::before { content: "Unit"; }

  .line-items-table td:nth-child(6),
  .cash-table td:nth-child(6) { grid-area: rate; }
  .line-items-table td:nth-child(6)::before,
  .cash-table td:nth-child(6)::before { content: "Rate"; }

  .line-items-table td:nth-child(7),
  .cash-table td:nth-child(7) {
    grid-area: total;
    align-content: end;
    text-align: right;
  }
  .line-items-table td:nth-child(7)::before,
  .cash-table td:nth-child(7)::before {
    content: "Total";
    text-align: right;
  }

  .line-items-table td:nth-child(8),
  .cash-table td:nth-child(8) { grid-area: action; }
  .line-items-table td:nth-child(8)::before,
  .cash-table td:nth-child(8)::before { content: "Action"; }

  .item-image-cell {
    grid-template-columns: auto;
  }

  .item-image-picker {
    margin: 0;
  }

  .item-image-cell .item-image-remove {
    width: 58px;
    justify-self: end;
    min-height: 28px;
    padding: 4px 6px;
    font-size: 11px;
  }

  .line-items-table td .danger-btn,
  .cash-table td .danger-btn {
    min-height: 34px;
  }

  /* View-only banner */
  .view-only-banner { padding: 8px 12px; font-size: 12px; }
}

@media (max-width: 480px) {
  .mobile-tabbar { left: 6px; right: 6px; }
  .mobile-nav-link { min-height: 48px; font-size: 9px; }
  .tab-icon { width: 18px; height: 18px; }
  .today-snapshot-strip { grid-template-columns: 1fr; }
  .today-snap-outstanding { grid-column: auto; }

  .line-items-table tbody tr,
  .cash-table tbody tr {
    grid-template-columns: 1fr;
    grid-template-areas:
      "serial"
      "item"
      "image"
      "qty"
      "unit"
      "rate"
      "total"
      "action";
  }

  .line-items-table td:nth-child(3),
  .cash-table td:nth-child(3),
  .line-items-table td:nth-child(7),
  .cash-table td:nth-child(7) {
    justify-items: stretch;
    text-align: left;
  }

  .line-items-table td:nth-child(7)::before,
  .cash-table td:nth-child(7)::before {
    text-align: left;
  }

  .item-image-cell .item-image-remove {
    justify-self: stretch;
    width: 100%;
  }
}

/* ═══════════════════════════════════════════════════════════
   VIEW-ONLY MODE
═══════════════════════════════════════════════════════════ */

.view-only-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  margin-bottom: 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-left: 4px solid #3b82f6;
  border-radius: 8px;
  color: #1e40af;
  font-size: 13px;
  font-weight: 600;
}

.view-only-banner svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.page-view-only input:not([type="button"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]):not([type="search"]):not([readonly]) {
  pointer-events: none;
  background: var(--soft) !important;
  color: var(--muted) !important;
  border-style: dashed;
}

.page-view-only select:not(.view-safe-select),
.page-view-only textarea:not([readonly]) {
  pointer-events: none;
  background: var(--soft) !important;
  color: var(--muted) !important;
}

.page-view-only [data-edit-only] { display: none !important; }

/* ═══════════════════════════════════════════════════════════
   STAFF PERMISSIONS — PAGE MODE UI
═══════════════════════════════════════════════════════════ */

.staff-page-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}

.staff-page-check {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 120px;
  font-size: 12px;
  cursor: pointer;
}

.staff-page-mode {
  display: flex;
  gap: 6px;
}

.staff-page-mode.hidden { display: none; }

.staff-mode-opt {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--soft);
  transition: background 0.12s, border-color 0.12s;
}

.staff-mode-opt:has(input:checked) {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.staff-mode-opt input[type="radio"] { display: none; }

/* ═══════════════════════════════════════════════════════════
   DELIVERY CHALLAN PANEL
═══════════════════════════════════════════════════════════ */

.challan-panel {
  position: fixed;
  inset: 0;
  z-index: 300;
}

.challan-panel.hidden { display: none; }

.challan-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
}

.challan-panel-inner {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(700px, 100vw);
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -10px 0 40px rgba(15, 23, 42, 0.15);
}

.challan-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  flex-shrink: 0;
}

.challan-panel-header .eyebrow { color: #1d4ed8; }

.challan-panel-header h3 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.challan-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.challan-close-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.challan-close-btn:hover { background: var(--soft); color: var(--text); }

.challan-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8fafc;
}

/* Challan document preview */
.challan-preview {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 24px 28px;
  max-width: 620px;
  margin: 0 auto;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  font-size: 13px;
  color: #172033;
}

.challan-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.challan-company h2 {
  font-size: 16px;
  font-weight: 800;
  color: #172033;
  margin: 0 0 4px;
}

.challan-company p {
  font-size: 11px;
  color: #64748b;
  margin: 0;
  white-space: pre-wrap;
}

.challan-badge {
  display: inline-block;
  background: #1d4ed8;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  border-radius: 5px;
  margin-bottom: 8px;
  text-align: center;
}

.challan-meta-table { border-collapse: collapse; font-size: 11px; }
.challan-meta-table td { padding: 2px 6px; }
.challan-meta-table td:first-child { color: #64748b; }

.challan-divider { border: none; border-top: 2px solid #1d4ed8; margin: 12px 0; }

.challan-label {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #94a3b8;
  margin: 0 0 4px;
}

.challan-customer { font-size: 14px; font-weight: 700; margin: 0 0 3px; }
.challan-address, .challan-contact { font-size: 11px; color: #475569; margin: 0; }
.challan-to { margin-bottom: 16px; }

.challan-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
  font-size: 12px;
}

.challan-items-table th {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 7px 8px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
}

.challan-items-table td {
  border: 1px solid #e2e8f0;
  padding: 7px 8px;
  vertical-align: top;
}

.challan-items-table tbody tr:nth-child(even) td { background: #f8fafc; }

.challan-transport { margin-bottom: 18px; }

.challan-transport-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}

.challan-transport-field span {
  font-size: 10px;
  color: #64748b;
  display: block;
  margin-bottom: 4px;
}

.challan-line {
  border-bottom: 1px solid #94a3b8;
  min-height: 24px;
}

.challan-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed #cbd5e1;
}

.challan-sig-box { text-align: center; }
.challan-sig-box .challan-line { height: 44px; }
.challan-sig-box span { font-size: 10px; color: #64748b; display: block; margin-top: 6px; }

@media (max-width: 760px) {
  .challan-panel-inner { width: 100vw; }
  .challan-preview { padding: 16px; }
  .challan-transport-grid { grid-template-columns: 1fr; }
  .challan-signatures { gap: 20px; }
}

/* ============================================================
   MOBILE SLIM — Quote page, Lead page, global form compaction
   ============================================================ */

/* --- Global mobile input/select sizing (keep 16px to prevent iOS zoom) --- */
@media (max-width: 760px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
  select,
  textarea {
    min-height: 42px;
    padding: 8px 10px;
    font-size: 16px;
  }

  button {
    min-height: 40px;
    padding: 9px 12px;
    font-size: 14px;
  }

  /* ── Quote status bar: collapse to a single compact row ─────────────── */
  .quote-status-bar {
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 12px !important;
    border-radius: 0 !important;
  }

  /* Hide "Active Draft / Unsaved quotation" text — save the row height */
  .quote-status-bar > div:first-child {
    display: none !important;
  }

  .quote-status-actions {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 5px !important;
    width: 100% !important;
  }

  .quote-status-actions button {
    min-height: 36px !important;
    padding: 6px 4px !important;
    font-size: 12px !important;
    border-radius: 7px !important;
  }

  /* ── Company profile: slim one-line strip ─────────────────────────────── */
  .quote-company-profile {
    grid-template-columns: 40px minmax(0, 1fr) !important;
    gap: 8px !important;
    padding: 8px 10px !important;
    border-radius: 8px !important;
    background: var(--surface-alt, #f8fafc) !important;
  }

  .company-logo {
    width: 40px !important;
    height: 40px !important;
    font-size: 9px !important;
    border-radius: 6px !important;
  }

  .company-profile-copy h2 {
    font-size: 13px !important;
    margin: 0 !important;
  }

  .company-profile-copy p {
    display: none !important;
  }

  /* ── Sub-panel headings: remove eyebrow, shrink h2 ──────────────────── */
  .quotation-panel .sub-panel-heading,
  .lead-form-panel .sub-panel-heading {
    padding-bottom: 8px !important;
    margin-bottom: 10px !important;
  }

  .quotation-panel .sub-panel-heading .eyebrow,
  .lead-form-panel .sub-panel-heading .eyebrow {
    display: none !important;
  }

  .quotation-panel .sub-panel-heading h2,
  .lead-form-panel .sub-panel-heading h2 {
    font-size: 13px !important;
    margin: 0 !important;
  }

  /* ── Sub-panel padding ────────────────────────────────────────────────── */
  .quotation-panel .sub-panel,
  .lead-form-panel {
    padding: 10px !important;
    border-radius: 10px !important;
  }

  /* ── Form grid gap ────────────────────────────────────────────────────── */
  .quotation-panel .form-grid.compact,
  .lead-form-grid {
    gap: 8px !important;
  }

  /* ── Items section ────────────────────────────────────────────────────── */
  .items-section .section-heading {
    margin-bottom: 8px !important;
  }

  .items-section .section-heading h2 {
    font-size: 14px !important;
  }

  /* ── Totals compact ───────────────────────────────────────────────────── */
  .totals {
    padding: 10px !important;
  }

  .totals .field {
    margin-bottom: 8px !important;
  }

  .totals p {
    padding: 3px 0 !important;
    font-size: 13px !important;
  }

  .totals p.grand-total {
    font-size: 15px !important;
    padding: 6px 0 !important;
  }

  /* ── Terms / bank panel ───────────────────────────────────────────────── */
  .terms-panel {
    padding: 10px !important;
  }

  .terms-panel .sub-panel-heading .eyebrow {
    display: none !important;
  }

  .terms-panel .sub-panel-heading h2 {
    font-size: 13px !important;
    margin: 0 0 8px !important;
  }

  /* ── Lead form: compact action buttons ───────────────────────────────── */
  .lead-form-grid button {
    min-height: 40px !important;
    padding: 9px 12px !important;
    font-size: 14px !important;
  }

  /* ── Lead form panel: tighten spacing ────────────────────────────────── */
  .lead-form-panel {
    margin-bottom: 0 !important;
  }

  /* ── Lead tracker summary strip: smaller cards ───────────────────────── */
  .lead-tracker-summary {
    gap: 8px !important;
    margin-bottom: 12px !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .lead-tracker-summary .report-card {
    padding: 10px 12px !important;
    min-height: unset !important;
  }

  .lead-tracker-summary .report-card strong {
    font-size: 18px !important;
  }

  .lead-tracker-summary .report-card span {
    font-size: 11px !important;
  }

  /* ── Lead pipeline board: compact columns ─────────────────────────────── */
  .lead-pipeline-board {
    gap: 10px !important;
    margin-bottom: 12px !important;
  }

  /* ── Section heading (Lead page top heading) ─────────────────────────── */
  #leadTrackerPage .section-heading h2 {
    font-size: 15px !important;
  }

  #leadTrackerPage .section-heading .section-actions {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  #leadTrackerPage .section-heading .section-actions button,
  #leadTrackerPage .section-heading .section-actions span {
    font-size: 13px !important;
    min-height: 34px !important;
    padding: 6px 10px !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   NOTES & TASKS POPUP
═══════════════════════════════════════════════════════════ */

/* Topbar trigger button */
.notes-fab-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: #f8fafc;
  border: 1px solid #dfe7ef;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.notes-fab-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: #f0fdfa;
}

/* Popup overlay */
.notes-popup {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}
.notes-popup:not([hidden]) { pointer-events: auto; }

.notes-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  transition: opacity 0.28s ease;
}
.notes-popup.open .notes-popup-backdrop { opacity: 1; }

/* Drawer panel */
.notes-popup-panel {
  position: relative;
  width: min(460px, 100vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  box-shadow: -6px 0 40px rgba(15, 23, 42, 0.14);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.notes-popup.open .notes-popup-panel { transform: translateX(0); }

.notes-popup-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
}
.notes-popup-hdr .eyebrow { margin: 0 0 2px; }
.notes-popup-hdr h2 { font-size: 16px; margin: 0; }

.notes-popup-close {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.notes-popup-close:hover { background: #fee2e2; border-color: #fca5a5; color: var(--danger); }

.notes-popup-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.notes-popup-section {
  border-bottom: 1px solid #f1f5f9;
}

.notes-popup-section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 4px;
}
.notes-popup-section-hdr h3 {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0;
}

/* Override list/add dimensions inside the popup */
.notes-popup .dash-sticky-list,
.notes-popup .dash-task-list {
  max-height: none;
  min-height: 60px;
  padding: 8px 20px 4px;
}

.notes-popup .dash-notes-add {
  padding: 8px 20px 14px;
  border-top: none;
  background: none;
}

/* Dashboard preview strip */
.dash-notes-preview-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
  flex-wrap: wrap;
}
.dash-notes-preview-strip:hover { border-color: #f59e0b; }

.dash-notes-preview-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-size: 12px;
  font-weight: 700;
  color: #92400e;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
  flex-shrink: 0;
}

.dash-notes-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.dash-notes-preview-item {
  display: inline-block;
  padding: 3px 8px;
  background: #fffaeb;
  border: 1px solid #fde68a;
  border-radius: 5px;
  font-size: 11px;
  color: #78350f;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Private Notes field on Quote form ───────────────────── */
.private-notes-field {
  margin-top: 10px;
  padding: 10px 12px 12px;
  background: #fffbeb;
  border: 1.5px dashed #f59e0b;
  border-radius: 8px;
}
.private-notes-field textarea {
  background: #fffdf5 !important;
  border-color: #fde68a !important;
  font-size: 13px;
  resize: vertical;
}
.private-notes-label-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 6px;
}
.private-notes-hint {
  font-size: 10px;
  font-weight: 500;
  color: #b45309;
  margin-left: 4px;
}

/* Hide private notes from all print/PDF outputs */
@media print {
  .private-notes-field { display: none !important; }
  .notes-popup         { display: none !important; }
  .notes-fab-btn       { display: none !important; }
}

/*
═══════════════════════════════════════════════════════════
   DARK MODE — component overrides for hardcoded colors
═══════════════════════════════════════════════════════════ */

body[data-theme="dark"] {
  background: linear-gradient(180deg, #0d1117 0%, #0d1117 100%);
  color: var(--text);
}

body[data-theme="dark"] .secondary-btn {
  color: var(--text);
  background: #253047;
  border-color: var(--line);
}

body[data-theme="dark"] .secondary-btn:hover {
  background: #2d3a52;
}

body[data-theme="dark"] input,
body[data-theme="dark"] textarea,
body[data-theme="dark"] select {
  background: #161e2e;
  color: var(--text);
  border-color: var(--line);
}

body[data-theme="dark"] input::placeholder,
body[data-theme="dark"] textarea::placeholder {
  color: var(--muted);
}

body[data-theme="dark"] .panel,
body[data-theme="dark"] .login-card,
body[data-theme="dark"] .modal-content,
body[data-theme="dark"] .sync-center,
body[data-theme="dark"] .dropdown-menu,
body[data-theme="dark"] .suggestion-menu,
body[data-theme="dark"] .challan-preview-panel,
body[data-theme="dark"] .status-print-document {
  background: var(--panel);
  border-color: var(--line);
}

body[data-theme="dark"] .sidebar {
  background: #0a0f1a;
  border-color: var(--line);
}

body[data-theme="dark"] .topbar {
  background: #0d1117;
  border-color: var(--line);
}

body[data-theme="dark"] table th,
body[data-theme="dark"] .board-header {
  background: #192130;
  color: var(--muted);
}

body[data-theme="dark"] table td {
  border-color: #1e2d3d;
}

body[data-theme="dark"] tr:hover td {
  background: #192130;
}

body[data-theme="dark"] .qstats-pill {
  background: #192130;
  border-color: var(--line);
}

body[data-theme="dark"] .quote-company-profile,
body[data-theme="dark"] .company-block,
body[data-theme="dark"] .quotation-panel,
body[data-theme="dark"] .print-area {
  background: var(--panel);
  border-color: var(--line);
}

body[data-theme="dark"] .login-screen {
  background: linear-gradient(135deg, #0a0f1a 0%, #0d1117 100%);
}

body[data-theme="dark"] .board-filter-bar,
body[data-theme="dark"] .filter-bar,
body[data-theme="dark"] .section-heading {
  background: #131a26;
  border-color: var(--line);
}

body[data-theme="dark"] .nav-link:hover,
body[data-theme="dark"] .nav-link.active {
  background: #192130;
}

body[data-theme="dark"] .stat-card,
body[data-theme="dark"] .kpi-card,
body[data-theme="dark"] .dashboard-kpi {
  background: var(--panel);
  border-color: var(--line);
}

body[data-theme="dark"] .theme-preset {
  background: #192130;
  border-color: var(--line);
  color: var(--text);
}

body[data-theme="dark"] .settings-tab {
  color: var(--muted);
}

body[data-theme="dark"] .settings-tab.active {
  color: var(--brand);
  border-color: var(--brand);
}

body[data-theme="dark"] .view-only-banner {
  background: #0f2a1e;
  border-color: #1a5c3a;
  color: #4ade80;
}

body[data-theme="dark"] code,
body[data-theme="dark"] pre {
  background: #0a0f1a;
  color: var(--text);
}

body[data-theme="dark"] .mobile-tabbar {
  background: #0a0f1a;
  border-color: var(--line);
}

body[data-theme="dark"] .filter-pill,
body[data-theme="dark"] .filter-pill.active,
body[data-theme="dark"] .qstats-pill {
  background: #192130;
  border-color: var(--line);
  color: var(--text);
}

body[data-theme="dark"] .qstats-pill.qstats-pending { background: rgba(251,191,36,0.1); }
body[data-theme="dark"] .qstats-pill.qstats-converted { background: rgba(20,184,166,0.1); }
body[data-theme="dark"] .qstats-pill.qstats-rejected { background: rgba(248,113,113,0.1); }

body[data-theme="dark"] .saved-quotes-filter-bar,
body[data-theme="dark"] .board-filter-bar,
body[data-theme="dark"] .filter-bar {
  background: #111827;
  border-color: var(--line);
}

body[data-theme="dark"] .section-heading {
  background: #111827;
}

body[data-theme="dark"] .page-view {
  background: #0d1117;
}

body[data-theme="dark"] .panel {
  background: var(--panel);
  border-color: var(--line);
}

body[data-theme="dark"] .sub-panel {
  background: var(--panel);
  border-color: var(--line);
}

body[data-theme="dark"] .settings-sidebar {
  background: #111827;
  border-color: var(--line);
}

body[data-theme="dark"] .settings-content {
  background: #0d1117;
}

body[data-theme="dark"] .settings-accordion {
  background: var(--panel);
  border-color: var(--line);
}

body[data-theme="dark"] .settings-tab:hover {
  background: #192130;
}

body[data-theme="dark"] .settings-tab.active {
  background: #0d2a26;
}

body[data-theme="dark"] .lead-status-badge,
body[data-theme="dark"] .status-badge {
  border-color: var(--line);
}

body[data-theme="dark"] .table-wrap {
  background: transparent;
}

body[data-theme="dark"] table {
  background: var(--panel);
}

body[data-theme="dark"] .today-snap-card {
  background: #192130;
  border-color: var(--line);
  color: var(--text);
}

body[data-theme="dark"] .dashboard-list-item {
  background: #192130;
  border-color: var(--line);
  color: var(--text);
}

body[data-theme="dark"] .dashboard-list-item:hover {
  background: #1e2d40;
}

body[data-theme="dark"] .add-item-row {
  background: #161e2e;
}

body[data-theme="dark"] .quotation-panel,
body[data-theme="dark"] .quote-company-profile {
  background: var(--panel);
  border-color: var(--line);
}

body[data-theme="dark"] .kpi-card strong,
body[data-theme="dark"] .stat-card strong {
  color: var(--brand);
}

body[data-theme="dark"] .offline-bar {
  background: #7c2d12;
}

body[data-theme="dark"] .branch-settings-card {
  background: #192130;
  border-color: var(--line);
}

/* Print — always white regardless of dark mode */
@media print {
  body[data-theme="dark"] {
    background: #ffffff !important;
    color: #111827 !important;
  }
  body[data-theme="dark"] input,
  body[data-theme="dark"] textarea,
  body[data-theme="dark"] select {
    background: #ffffff !important;
    color: #111827 !important;
    border-color: #d8dee6 !important;
  }
  body[data-theme="dark"] .panel,
  body[data-theme="dark"] .quote-company-profile {
    background: #ffffff !important;
  }
}

/*
═══════════════════════════════════════════════════════════
   ROLE-BASED VISIBILITY
   .admin-only elements are shown/hidden by JS via renderAdminAccess().
   .staff-only elements are hidden for admin.
═══════════════════════════════════════════════════════════ */

/* Private notes — staff see their own (handled by JS); admin always sees */
.private-notes-field.admin-only {
  display: block;
}

/*
═══════════════════════════════════════════════════════════
   OFFLINE INDICATOR
═══════════════════════════════════════════════════════════ */

.offline-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #92400e;
  color: #fff;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  letter-spacing: 0.02em;
}

body.is-offline .offline-bar {
  display: block;
}

body.is-offline .topbar {
  top: 35px;
}

body.is-offline .sidebar {
  top: 35px;
}

/*
═══════════════════════════════════════════════════════════
   QUOTE PORTAL & SHARE BADGE
═══════════════════════════════════════════════════════════ */

.portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  white-space: nowrap;
}

.portal-badge.viewed {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

.portal-badge.accepted {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

.share-quote-btn {
  font-size: 11px;
  padding: 4px 8px;
  min-height: 28px;
  border-radius: 5px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  box-shadow: none;
  font-weight: 600;
}

.share-quote-btn:hover {
  background: #dbeafe;
  color: #1e40af;
}

body[data-theme="dark"] .share-quote-btn {
  background: #1e3a5f;
  color: #93c5fd;
  border-color: #2d4f7a;
}

/*
═══════════════════════════════════════════════════════════
   REVISION HISTORY
═══════════════════════════════════════════════════════════ */

.revision-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  background: #f5f3ff;
  color: #7c3aed;
  border: 1px solid #ddd6fe;
  cursor: pointer;
}

.revision-badge:hover {
  background: #ede9fe;
}

body[data-theme="dark"] .revision-badge {
  background: #1e1a3f;
  color: #c4b5fd;
  border-color: #3730a3;
}

.revision-list {
  max-height: 340px;
  overflow-y: auto;
}

.revision-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s;
}

.revision-item:hover {
  background: var(--soft);
}

.revision-item:last-child {
  border-bottom: none;
}

.revision-item-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}

.revision-item-summary {
  font-size: 13px;
  font-weight: 600;
}

/*
═══════════════════════════════════════════════════════════
   REJECTION REASON
═══════════════════════════════════════════════════════════ */

.rejection-reason-badge {
  display: inline-block;
  font-size: 11px;
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  padding: 1px 6px;
  margin-top: 3px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-theme="dark"] .rejection-reason-badge {
  background: #3f1212;
  color: #fca5a5;
  border-color: #7f1d1d;
}

/*
═══════════════════════════════════════════════════════════
   BRANCH BADGE
═══════════════════════════════════════════════════════════ */

.branch-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

body[data-theme="dark"] .branch-badge {
  background: #2a1a00;
  color: #fbbf24;
  border-color: #78350f;
}

.branch-settings-card {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.branch-settings-card .branch-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}

.branch-settings-card .branch-card-name {
  font-weight: 700;
  font-size: 15px;
}

.add-branch-btn {
  font-size: 13px;
  padding: 8px 14px;
  min-height: 36px;
  background: var(--soft);
  color: var(--brand);
  border: 1px dashed var(--brand);
  box-shadow: none;
  width: 100%;
  border-radius: 6px;
  font-weight: 600;
  margin-top: 8px;
}

.add-branch-btn:hover {
  background: rgba(15, 118, 110, 0.08);
}

/*
═══════════════════════════════════════════════════════════
   SLIDE PANEL — shared by PO Order panel and other drawers
   (uses .payment-panel class names inherited from legacy HTML)
═══════════════════════════════════════════════════════════ */

.payment-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1199;
  backdrop-filter: blur(2px);
}

.payment-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 96vw);
  background: var(--panel, #fff);
  border-left: 1px solid var(--line, #e5e7eb);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.payment-panel.hidden,
.payment-panel-backdrop.hidden {
  display: none;
}

.payment-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.payment-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--line, #e5e7eb);
  flex-shrink: 0;
}

.payment-panel-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text, #111827);
}

.payment-panel-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted, #6b7280);
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
  box-shadow: none;
  min-height: unset;
}

.payment-panel-close:hover {
  background: var(--soft, #f3f4f6);
  color: var(--text, #111827);
}

.payment-history-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #6b7280);
  padding: 12px 20px 6px;
  border-bottom: 1px solid var(--line, #e5e7eb);
  flex-shrink: 0;
}

body[data-theme="dark"] .payment-panel {
  background: var(--panel);
  border-color: var(--line);
}

body[data-theme="dark"] .payment-panel-header {
  border-color: var(--line);
}

body[data-theme="dark"] .payment-panel-close:hover {
  background: #192130;
}

body[data-theme="dark"] .payment-history-label {
  border-color: var(--line);
}

/*
═══════════════════════════════════════════════════════════
   DARK MODE — Status pills, badges, and remaining overrides
═══════════════════════════════════════════════════════════ */

/* Quote status select dropdowns */
body[data-theme="dark"] .status-select,
body[data-theme="dark"] .quote-type-select,
body[data-theme="dark"] .follow-date-input {
  background: #161e2e;
  color: var(--text);
  border-color: var(--line);
}

/* Quote status pills (in saved-quotes-table and board) */
body[data-theme="dark"] .status-Pending {
  background: rgba(29,78,216,0.15);
  border-color: rgba(96,165,250,0.3);
  color: #93c5fd;
}
body[data-theme="dark"] .status-Converted {
  background: rgba(4,120,87,0.15);
  border-color: rgba(52,211,153,0.3);
  color: #6ee7b7;
}
body[data-theme="dark"] .status-Rejected {
  background: rgba(185,28,28,0.15);
  border-color: rgba(248,113,113,0.3);
  color: #fca5a5;
}
body[data-theme="dark"] .status-Next-Month,
body[data-theme="dark"] .status-Follow-Up {
  background: rgba(180,83,9,0.15);
  border-color: rgba(251,191,36,0.3);
  color: #fcd34d;
}
body[data-theme="dark"] .status-Quoted {
  background: rgba(124,58,237,0.15);
  border-color: rgba(167,139,250,0.3);
  color: #c4b5fd;
}

/* Lead status pills */
body[data-theme="dark"] .lead-status-pill {
  background: #1a2433;
  border-color: var(--line);
  color: var(--muted);
}
body[data-theme="dark"] .lead-status-pill.status-Converted {
  background: rgba(4,120,87,0.15);
  border-color: rgba(52,211,153,0.25);
  color: #6ee7b7;
}
body[data-theme="dark"] .lead-status-pill.status-Lost {
  background: rgba(185,28,28,0.15);
  border-color: rgba(248,113,113,0.25);
  color: #fca5a5;
}
body[data-theme="dark"] .lead-status-pill.status-Quoted,
body[data-theme="dark"] .lead-status-pill.status-Follow-Up {
  background: rgba(180,83,9,0.15);
  border-color: rgba(251,191,36,0.25);
  color: #fcd34d;
}
body[data-theme="dark"] .lead-status-pill.status-New,
body[data-theme="dark"] .lead-status-pill.status-Contacted,
body[data-theme="dark"] .lead-status-pill.status-Requirement-Received {
  background: rgba(29,78,216,0.15);
  border-color: rgba(96,165,250,0.25);
  color: #93c5fd;
}

/* Requirement badge, mode pill, quote number badge */
body[data-theme="dark"] .lead-requirement-badge {
  background: #1a2433;
  color: var(--muted);
  border-color: var(--line);
}
body[data-theme="dark"] .quote-mode-pill {
  background: #1a2433;
  color: var(--muted);
  border-color: var(--line);
}
body[data-theme="dark"] .qno-badge {
  background: #1a2433;
  color: var(--text);
  border-color: var(--line);
}

/* Filter bar inputs and selects */
body[data-theme="dark"] .saved-quotes-filter-bar input,
body[data-theme="dark"] .saved-quotes-filter-bar select,
body[data-theme="dark"] .lead-filter-bar input,
body[data-theme="dark"] .lead-filter-bar select,
body[data-theme="dark"] .board-filter-bar input,
body[data-theme="dark"] .board-filter-bar select {
  background: #161e2e;
  border-color: var(--line);
  color: var(--text);
}

/* Lead pipeline cards */
body[data-theme="dark"] .lead-pipeline-card {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
}
body[data-theme="dark"] .lead-pipeline-card:hover {
  border-color: var(--brand);
}

/* Notification */
body[data-theme="dark"] .notification-panel,
body[data-theme="dark"] .notification-dropdown {
  background: var(--panel);
  border-color: var(--line);
}
body[data-theme="dark"] .notification-item {
  border-color: var(--line);
}
body[data-theme="dark"] .notification-item:hover {
  background: #192130;
}

/* Customer cards */
body[data-theme="dark"] .customer-card {
  background: var(--panel);
  border-color: var(--line);
}
body[data-theme="dark"] .customer-card:hover {
  background: #1e2d40;
  border-color: var(--brand);
}

/* Report / analytics cards */
body[data-theme="dark"] .report-stat-card,
body[data-theme="dark"] .analytics-card {
  background: var(--panel);
  border-color: var(--line);
}

/* Line items table inside quotation form */
body[data-theme="dark"] .line-items-table th {
  background: #192130;
  color: var(--muted);
}
body[data-theme="dark"] .line-items-table td {
  border-color: var(--line);
}
body[data-theme="dark"] .line-items-table .add-item-row td {
  background: #161e2e;
}

/* Quotation form inputs */
body[data-theme="dark"] .quotation-panel input,
body[data-theme="dark"] .quotation-panel select,
body[data-theme="dark"] .quotation-panel textarea {
  background: #161e2e;
  border-color: var(--line);
  color: var(--text);
}

/* Sub-panel heading border */
body[data-theme="dark"] .sub-panel-heading {
  border-color: var(--line);
}

/* Settings accordion summary */
body[data-theme="dark"] .settings-accordion summary {
  color: var(--text);
}
body[data-theme="dark"] .settings-accordion summary:hover {
  background: #192130;
}
body[data-theme="dark"] .settings-accordion[open] summary {
  border-color: var(--brand);
  color: var(--brand);
}

/* Sync center / control center */
body[data-theme="dark"] .sync-center,
body[data-theme="dark"] #syncCenterPanel {
  background: var(--panel);
  border-color: var(--line);
}
body[data-theme="dark"] .sync-pill {
  background: #192130;
  border-color: var(--line);
  color: var(--muted);
}

/* Activity log entries */
body[data-theme="dark"] .activity-entry {
  border-color: var(--line);
}
body[data-theme="dark"] .activity-entry:hover {
  background: #192130;
}

/* Today snapshot cards */
body[data-theme="dark"] .today-snap-card {
  background: #192130;
  border-color: var(--line);
}

/* Smart alert / notification cards */
body[data-theme="dark"] .alert-card,
body[data-theme="dark"] .smart-alert {
  background: var(--panel);
  border-color: var(--line);
}

/* Dashboard list items */
body[data-theme="dark"] .dashboard-list-item {
  background: #192130;
  border-color: var(--line);
  color: var(--text);
}
body[data-theme="dark"] .dashboard-list-item:hover {
  background: #1e2d40;
}

/* PO table and panel */
body[data-theme="dark"] .po-orders-table th {
  background: #192130;
  color: var(--muted);
}
body[data-theme="dark"] .po-orders-table td {
  border-color: var(--line);
}

/* Inventory */
body[data-theme="dark"] .inventory-table th {
  background: #192130;
  color: var(--muted);
}
body[data-theme="dark"] .inventory-dup-banner {
  background: #1a1500;
  border-color: #3d2e00;
  color: #fde68a;
}

/* Staff performance table */
body[data-theme="dark"] .staff-performance-table th {
  background: #192130;
  color: var(--muted);
}

/* ══════════════════════════════════════════════════════════════
   Dashboard CRM structural reset
   Keeps the dashboard as ordered stacks inside the app shell.
   ══════════════════════════════════════════════════════════════ */
#dashboardPage.active {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

#dashboardPage > * {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-bottom: 0;
}

#dashboardPage .panel,
#dashboardPage .sub-panel,
#dashboardPage .crm-kpi,
#dashboardPage button,
#dashboardPage select,
#dashboardPage canvas {
  max-width: 100%;
}

#dashboardPage .section-heading,
#dashboardPage .sub-panel-heading {
  min-width: 0;
  gap: 10px;
  flex-wrap: wrap;
}

#dashboardPage .section-heading > *,
#dashboardPage .sub-panel-heading > * {
  min-width: 0;
}

.crm-control-bar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 1.4fr) minmax(190px, auto) auto;
  align-items: center;
  gap: 10px 12px;
}

.crm-control-title,
.crm-period-btns,
.crm-month-pick,
.crm-control-actions {
  min-width: 0;
}

.crm-period-btns,
.crm-control-actions {
  display: flex;
  flex-wrap: wrap;
}

.crm-period-range {
  margin-left: 0;
  justify-self: end;
}

.crm-month-pick {
  justify-self: start;
}

.crm-month-pick select {
  max-width: 150px;
}

.crm-kpi-strip {
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 10px;
}

.crm-kpi {
  min-height: 96px;
  padding: 12px;
}

.crm-kpi-value {
  overflow-wrap: anywhere;
  font-size: clamp(17px, 1.55vw, 21px);
}

.crm-command-grid,
.crm-sales-grid,
.crm-alerts-row,
.crm-dual-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.crm-tri-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.crm-funnel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
  overflow: visible;
}

.crm-funnel-arrow {
  display: none;
}

.crm-funnel-stage {
  min-width: 0;
  min-height: 132px;
  justify-content: center;
  padding: 12px 10px;
}

.crm-funnel-value,
.crm-funnel-label,
.crm-funnel-pct {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.crm-funnel-extra {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.crm-forecast-stat-grid,
.today-snapshot-strip,
.po-widget-row {
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
}

.crm-stage-bar-row {
  grid-template-columns: minmax(0, 1fr) minmax(86px, 1fr) auto;
}

.crm-stage-bar-row strong,
.crm-module-card strong,
.crm-lead-stage-card b {
  overflow-wrap: anywhere;
  white-space: normal;
}

.crm-lead-stage-card {
  grid-template-columns: minmax(0, 1fr) minmax(80px, 0.75fr);
}

.crm-lead-stage-card b {
  grid-column: 1 / -1;
  justify-self: start;
}

.crm-action-item {
  grid-template-columns: minmax(0, 1fr) auto;
}

.crm-action-item b {
  min-width: 44px;
}

.crm-module-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.dashboard-list-item,
.portal-dash-row,
.po-widget-company-item,
.top-customer-row,
.aging-row {
  min-width: 0;
}

.dashboard-list-item span,
.portal-dash-info,
.po-widget-company-item span,
.top-customer-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.dashboard-list-item b,
.po-widget-company-item b,
.portal-dash-meta {
  max-width: 42%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.chart-canvas-wrap {
  max-width: 100%;
  overflow: hidden;
}

@media (min-width: 1180px) {
  .crm-sales-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .crm-control-bar {
    grid-template-columns: 1fr;
  }

  .crm-period-range,
  .crm-month-pick {
    justify-self: stretch;
  }

  .crm-control-actions .secondary-btn {
    flex: 1 1 110px;
  }
}

@media (max-width: 560px) {
  #dashboardPage.active {
    gap: 10px;
  }

  .crm-control-bar,
  .crm-kpi-strip,
  .crm-funnel,
  .crm-sales-grid,
  .crm-alerts-row,
  .crm-dual-grid,
  .crm-tri-grid,
  .crm-module-grid {
    gap: 10px;
  }

  .crm-kpi-strip,
  .crm-module-grid,
  .crm-funnel,
  .today-snapshot-strip,
  .crm-forecast-stat-grid {
    grid-template-columns: 1fr;
  }

  .crm-stage-bar-row,
  .crm-action-item,
  .portal-dash-row {
    grid-template-columns: 1fr;
  }

  .crm-stage-bar-row strong,
  .crm-action-item b,
  .portal-dash-meta {
    justify-self: start;
    text-align: left;
    max-width: 100%;
  }

  .dashboard-list-item {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-list-item b {
    max-width: 100%;
    justify-self: start;
  }
}

/* Lead pipeline column headers */
body[data-theme="dark"] .lead-pipeline-col-header {
  background: #192130;
  border-color: var(--line);
  color: var(--muted);
}

/* Modal overlays */
body[data-theme="dark"] .modal-overlay,
body[data-theme="dark"] .backdrop {
  background: rgba(0,0,0,0.6);
}

/* Tags/pills inside modal */
body[data-theme="dark"] .tag,
body[data-theme="dark"] .pill {
  background: #192130;
  border-color: var(--line);
  color: var(--muted);
}

/* ── Reviews & History page ─────────────────────────────────── */
.reviews-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.reviews-row {
  display: grid;
  grid-template-columns: 110px minmax(140px, 1fr) minmax(160px, 1fr) 100px;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

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

.reviews-row:hover {
  background: var(--soft);
}

@media (max-width: 600px) {
  .reviews-row {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }
  .reviews-cell-date { grid-column: 1 / -1; }
}

/* ── Reviews page clickable rows ────────────────────────────── */
.reviews-row--clickable:hover { background: var(--soft); cursor: pointer; }
.reviews-row { grid-template-columns: 140px minmax(140px,1fr) minmax(120px,1fr) 90px 80px; }
.reviews-cell-action { display: flex; align-items: center; justify-content: flex-end; }
@media (max-width: 600px) {
  .reviews-row { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto; }
  .reviews-cell-date { grid-column: 1 / -1; }
  .reviews-cell-action { grid-column: 1 / -1; justify-content: flex-start; padding-bottom: 4px; }
}

/* ── Notification drawer dismiss buttons ─────────────────────── */
.notif-item { grid-template-columns: auto 1fr auto; }
.notif-dismiss-btn {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 13px; padding: 2px 6px; border-radius: 4px; line-height: 1;
  align-self: flex-start; flex-shrink: 0;
}
.notif-dismiss-btn:hover { background: var(--line); color: var(--text); }
.notif-open-btn {
  margin-top: 6px; font-size: 11px; padding: 3px 10px; background: var(--soft);
  border: 1px solid var(--line); border-radius: 5px; cursor: pointer; color: var(--text);
}
.notif-open-btn:hover { background: var(--line); }
.notif-clear-all-btn { font-size: 12px; padding: 4px 10px; }
.notif-drawer-head { flex-wrap: wrap; gap: 8px; }

/* ── Dashboard portal responses widget ──────────────────────── */
.portal-dash-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.portal-dash-row:last-child { border-bottom: none; }
.portal-dash-row:hover { background: var(--soft); margin: 0 -4px; padding-left: 4px; padding-right: 4px; border-radius: 6px; }
.portal-dash-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.portal-dash-dot--accepted { background: #16a34a; }
.portal-dash-dot--declined { background: #7c3aed; }
.portal-dash-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.portal-dash-qno { font-size: 13px; font-weight: 700; color: var(--text); }
.portal-dash-customer { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-dash-sub { font-size: 11px; color: var(--muted); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-dash-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.portal-dash-amt { font-size: 13px; font-weight: 700; color: var(--accent); }
.portal-dash-date { font-size: 11px; color: var(--muted); }
.portal-dash-badge { font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.portal-dash-badge--accepted { background: #f0fdf4; color: #15803d; border: 1px solid #86efac; }
.portal-dash-badge--declined { background: #fdf4ff; color: #7c3aed; border: 1px solid #d8b4fe; }
@media (max-width: 480px) {
  .portal-dash-row { grid-template-columns: 10px 1fr; }
  .portal-dash-meta { display: none; }
}

/* ── App toast notification ──────────────────────────────────── */
.app-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: #1e293b;
  color: #f1f5f9;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 99999;
  pointer-events: none;
  white-space: nowrap;
}
.app-toast.app-toast-success { border-left: 4px solid #22c55e; }
.app-toast.app-toast-warning { border-left: 4px solid #f59e0b; }
.app-toast.app-toast-error   { border-left: 4px solid #ef4444; }
.app-toast.app-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Portal response banner ──────────────────────────────────── */
.portal-banner {
  position: fixed;
  top: 16px;
  right: 16px;
  left: 16px;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity .3s ease, transform .3s ease;
  z-index: 99998;
  cursor: default;
}
.portal-banner.portal-banner-show {
  opacity: 1;
  transform: translateY(0);
}
.portal-banner-success {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
}
.portal-banner-warning {
  background: #fefce8;
  border: 1.5px solid #fde047;
}
.portal-banner-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}
.portal-banner-success .portal-banner-icon {
  background: #dcfce7;
  color: #15803d;
}
.portal-banner-warning .portal-banner-icon {
  background: #fef9c3;
  color: #92400e;
}
.portal-banner-body {
  flex: 1;
  min-width: 0;
}
.portal-banner-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.4;
}
.portal-banner-sub {
  font-size: 12px;
  color: #475569;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.portal-banner-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}
.portal-banner-close:hover { color: #475569; }
@media (max-width: 480px) {
  .portal-banner {
    top: 8px;
    right: 8px;
    left: 8px;
  }
}

/* ── Share / generic modal overlay ─────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  padding: 16px;
  backdrop-filter: blur(2px);
}
.modal-content {
  background: var(--panel, #fff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line, #e2e8f0);
  flex-shrink: 0;
}
.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text, #0f172a);
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted, #64748b);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--soft, #f1f5f9); }
.modal-body {
  padding: 18px 20px 12px;
  flex: 1;
  overflow-y: auto;
}
.modal-footer {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line, #e2e8f0);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.lead-modal-content {
  max-width: 520px;
  border-radius: 8px;
}

.lead-modal-content .modal-header {
  padding: 12px 14px 10px;
}

.lead-modal-content .modal-body {
  padding: 12px 14px 8px;
}

.lead-modal-content .modal-footer {
  padding: 10px 14px 12px;
}

.lead-modal-content .modal-title {
  font-size: 15px;
}

.lt-modal-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}

.lt-modal-form-grid .field {
  min-width: 0;
  gap: 4px;
  font-size: 12px;
}

.lt-modal-form-grid input:not([type="file"]),
.lt-modal-form-grid select,
.lt-modal-form-grid textarea {
  min-height: 34px;
  padding: 7px 9px;
  font-size: 13px;
}

.lt-modal-form-grid textarea {
  min-height: 58px;
  resize: vertical;
}

.lt-modal-full {
  grid-column: 1 / -1;
}

.lead-modal-content .lt-save-btn {
  min-width: 112px;
}

@media (max-width: 480px) {
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-content { border-radius: 14px 14px 0 0; max-height: 92vh; }
  .lead-modal-content {
    max-height: 92vh;
    border-radius: 12px 12px 0 0;
  }
  .lt-modal-form-grid {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════
   VISUAL POLISH — professional refinements
   ═══════════════════════════════════════════════════════════ */

/* ── Richer shadows & variables ─────────────────────────── */
:root {
  --shadow-card: 0 2px 8px rgba(15,23,42,0.06), 0 0 0 1px rgba(15,23,42,0.04);
  --shadow-hover: 0 8px 24px rgba(15,23,42,0.12), 0 0 0 1px rgba(15,23,42,0.05);
  --radius-card: 12px;
  --focus-ring: 0 0 0 3px rgba(15,118,110,0.18);
}

/* ── Input / select / textarea — crisp focus ring ──────── */
input:not([type="file"]):not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand) !important;
  box-shadow: var(--focus-ring) !important;
}

/* ── Panels & cards ─────────────────────────────────────── */
.panel, .stat-card {
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border-color: var(--line);
}

/* ── Buttons — smooth hover lift ───────────────────────── */
button {
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}
button:hover:not(:disabled) {
  box-shadow: 0 4px 14px rgba(15,118,110,0.28);
  transform: translateY(-1px);
}
.secondary-btn:hover:not(:disabled) {
  box-shadow: 0 2px 8px rgba(15,23,42,0.1);
}
.danger-btn:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(220,38,38,0.28);
}
button:active:not(:disabled) { transform: translateY(0); }

/* ── Topbar polish ──────────────────────────────────────── */
.topbar {
  border-radius: 12px;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 2px 12px rgba(15,23,42,0.07), 0 0 0 1px rgba(15,23,42,0.05);
}

/* ── Sidebar nav items ──────────────────────────────────── */
.sidebar-nav a, .sidebar-link, .nav-item {
  transition: background 0.12s ease, color 0.12s ease, padding-left 0.12s ease;
  border-radius: 8px;
}

/* ── Quote builder item rows — keyboard-friendly ────────── */
.line-items-table tbody tr,
.cash-table tbody tr {
  transition: background 0.1s ease;
}
.line-items-table tbody tr:focus-within,
.cash-table tbody tr:focus-within {
  background: rgba(15,118,110,0.04);
  outline: none;
}
.line-items-table tbody tr:focus-within td,
.cash-table tbody tr:focus-within td {
  border-top-color: rgba(15,118,110,0.15);
  border-bottom-color: rgba(15,118,110,0.15);
}

/* Item name / qty / price inputs inside quote rows */
.item-name, .cash-item-name {
  font-weight: 500;
}
.item-qty, .cash-item-qty,
.item-price, .cash-item-price {
  text-align: right;
}

/* ── Section headings ───────────────────────────────────── */
.section-heading h2 {
  letter-spacing: -0.01em;
}

/* ── Status badges (portal) ─────────────────────────────── */
.portal-badge {
  border-radius: 6px;
  font-size: 10.5px;
  letter-spacing: 0.01em;
}

/* ── Inventory suggestion menu ──────────────────────────── */
.inventory-suggestion-menu {
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(15,23,42,0.16), 0 0 0 1px rgba(15,23,42,0.07);
  border: none;
}
.inventory-suggestion {
  border-radius: 0;
  padding: 8px 12px;
}
.inventory-suggestion:first-child { border-radius: 10px 10px 0 0; }
.inventory-suggestion:last-child  { border-radius: 0 0 10px 10px; }
.inventory-suggestion:only-child  { border-radius: 10px; }
.inventory-suggestion strong { font-size: 13px; }

/* ── Table header polish ────────────────────────────────── */
table thead th {
  letter-spacing: 0.02em;
  font-size: 11px;
}

/* ── Form labels ────────────────────────────────────────── */
label, .form-label {
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ── Scrollbar slim ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(15,23,42,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(15,23,42,0.28); }

/* ══════════════════════════════════════════════════════════════
   LEAD TRACKER — rebuilt layout (lt-* classes)
   ══════════════════════════════════════════════════════════════ */

/* ── Stat cards row ─────────────────────────────────────── */
.lt-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.lt-stats .report-card {
  flex: 1 1 100px;
  min-width: 90px;
  padding: 10px 12px;
  border-radius: 10px;
}
.lt-stats .report-card span { font-size: 10px; margin-bottom: 4px; }
.lt-stats .report-card strong { font-size: 17px; }

/* ── Two-column layout ──────────────────────────────────── */
.lt-layout {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 16px;
  align-items: start;
}

/* ── Left sidebar (form) ────────────────────────────────── */
.lt-sidebar { position: sticky; top: 14px; }
.lt-form-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  border-top: 3px solid var(--brand);
  box-shadow: 0 2px 12px rgba(15,23,42,0.08);
  overflow: hidden;
}
.lt-form-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(15,118,110,0.06), rgba(8,145,178,0.04));
}
.lt-clear-btn {
  font-size: 11px;
  padding: 4px 10px;
  min-height: 26px;
  flex-shrink: 0;
}
.lt-form-fields {
  padding: 14px 16px 16px;
  display: grid;
  gap: 10px;
}
.lt-form-fields .field { margin: 0; }
.lt-remark-field textarea {
  resize: vertical;
  min-height: 80px;
}
.lt-save-btn {
  width: 100%;
  margin-top: 2px;
  font-size: 14px;
  padding: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 3px 10px rgba(15,118,110,0.3);
}
.lt-save-btn:hover { box-shadow: 0 5px 16px rgba(15,118,110,0.4); }

/* ── Right: main content ────────────────────────────────── */
.lt-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }

/* ── Top action bar ─────────────────────────────────────── */
.lt-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.lt-topbar-l {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 180px;
  min-width: 0;
}
.lt-search {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--panel);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lt-search:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15,118,110,0.12);
  outline: none;
}
.lt-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.lt-topbar-r { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.lt-topbar-r button { font-size: 12px; padding: 6px 12px; min-height: 36px; }

/* ── Filter bar ─────────────────────────────────────────── */
.lt-filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  align-items: end;
  background: rgba(239,246,255,0.7);
  border: 1px solid #dbeafe;
  border-radius: 10px;
  padding: 12px;
}
.lt-filter-bar .field { margin: 0; }
.lt-filter-summary {
  grid-column: 1 / -1;
  font-size: 11.5px;
  color: var(--muted);
  margin: 0;
}

/* ── Table container ────────────────────────────────────── */
.lt-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 1px 6px rgba(15,23,42,0.05);
}
.lt-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 12.5px;
  table-layout: auto;
}

/* Column widths — keeps the table balanced across 9 cols */
.lt-table colgroup .col-customer    { width: 140px; }
.lt-table colgroup .col-requirement { width: 105px; }
.lt-table colgroup .col-leadby      { width: 80px; }
.lt-table colgroup .col-contact     { width: 105px; }
.lt-table colgroup .col-date        { width: 78px; }
.lt-table colgroup .col-value       { width: 74px; }
.lt-table colgroup .col-status      { width: 115px; }
.lt-table colgroup .col-remark      { /* auto — takes remaining */ }
.lt-table colgroup .col-actions     { width: 150px; }

.lt-table thead th {
  padding: 8px 10px;
  background: var(--soft);
  border-bottom: 2px solid var(--line);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
  text-align: left;
  user-select: none;
  cursor: default;
}
.lt-table thead th[data-sort] { cursor: pointer; }
.lt-table thead th[data-sort]:hover { color: var(--brand); }
.lt-th-r { text-align: right !important; }
.lt-th-center { text-align: center !important; }
.lt-table tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background 0.1s;
}
.lt-table tbody tr:last-child { border-bottom: none; }
.lt-table tbody tr:hover { background: rgba(15,118,110,0.035); }
.lt-table tbody tr:nth-child(even) { background: var(--soft); }
.lt-table tbody tr:nth-child(even):hover { background: rgba(15,118,110,0.055); }
.lt-table td { padding: 7px 10px; vertical-align: middle; }

/* Cell types */
.lt-td-customer { white-space: nowrap; }
.lt-td-customer strong { display: block; font-size: 12.5px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.lt-td-customer small { display: block; font-size: 10px; color: var(--muted); margin-top: 1px; }
.lt-td-contact strong { display: block; font-size: 12px; font-weight: 600; }
.lt-td-leadby { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80px; }
.lt-td-date { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.lt-td-val { font-size: 12.5px; font-weight: 800; color: var(--brand-dark); white-space: nowrap; text-align: right; }
.lt-td-actions { text-align: center; white-space: nowrap; }

/* Action buttons */
.lt-action-btns { display: flex; gap: 3px; justify-content: center; flex-wrap: nowrap; }
.lt-action-btns button {
  font-size: 10.5px;
  padding: 3px 8px;
  min-height: 24px;
  border-radius: 5px;
  white-space: nowrap;
  transition: box-shadow 0.12s, transform 0.1s;
}
.lt-btn-open {
  color: var(--brand) !important;
  border-color: rgba(15,118,110,0.3) !important;
  background: rgba(15,118,110,0.06) !important;
}
.lt-btn-open:hover { background: rgba(15,118,110,0.12) !important; }

/* Compact pills inside the lead table */
.lt-table .lead-status-pill,
.lt-table .lead-requirement-badge {
  min-height: 20px;
  padding: 2px 7px;
  font-size: 10.5px;
}

/* Remark inline cell */
.lt-td-remark { vertical-align: middle; }
.lt-remark-inline {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
}

/* ── Lead detail popup ──────────────────────────────────── */
.lt-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
}
.lt-detail-field { display: grid; gap: 4px; }
.lt-detail-field > span {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.lt-detail-field > strong { font-size: 13.5px; color: var(--text); }
.lt-detail-remark { grid-column: 1 / -1; }
.lt-detail-remark-text {
  background: var(--soft);
  border-left: 3px solid var(--brand);
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  margin-top: 6px;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1080px) {
  .lt-layout {
    grid-template-columns: 280px 1fr;
    gap: 12px;
  }
}
@media (max-width: 860px) {
  .lt-layout {
    grid-template-columns: 1fr;
  }
  .lt-sidebar { position: static; }
  .lt-form-fields {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 520px) {
  .lt-form-fields { grid-template-columns: 1fr; }
  .lt-topbar { flex-direction: column; align-items: stretch; }
  .lt-topbar-l, .lt-topbar-r { width: 100%; }
  .lt-topbar-r { justify-content: flex-end; }
  .lt-stats .report-card { flex: 1 1 calc(50% - 4px); }
  .lt-detail-grid { grid-template-columns: 1fr; }
}
@media print {
  .lt-topbar, .lt-filter-bar, .lt-sidebar, .lt-action-btns, #leadPipelineBoard { display: none !important; }
}

/* ══════════════════════════════════════════════════════════════
   PREMIUM ANIMATIONS & TRANSITIONS
   ══════════════════════════════════════════════════════════════ */

/* Page fade-in when switching sections */
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-view.active {
  animation: pageEnter 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* Stat card hover lift */
.stat-card, .report-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.stat-card:hover, .report-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(15,23,42,0.14);
  border-color: var(--brand);
}

/* Button press scale */
button:not(:disabled):active { transform: scale(0.97) translateY(0) !important; }

/* Skeleton shimmer for loading states */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--line) 25%, var(--soft) 50%, var(--line) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
}

/* Number counter pop */
@keyframes countPop {
  0%   { transform: scale(0.8); opacity: 0; }
  60%  { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); }
}
.stat-card strong, .report-card strong {
  display: inline-block;
  animation: countPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Theme switch transition on root elements */
body, .sidebar, .topbar, .panel, .stat-card, button {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

/* Sidebar nav-link active indicator */
.nav-link {
  position: relative;
  overflow: hidden;
  transition: background 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
}
.nav-link::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand);
  border-radius: 0 2px 2px 0;
  transform: scaleY(0);
  transition: transform 0.15s ease;
}
.nav-link.active::before { transform: scaleY(1); }

/* Toast slide-in from top */
@keyframes toastSlideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.app-toast.app-toast-show {
  animation: toastSlideDown 0.2s ease forwards;
}

/* Modal scale-in */
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-overlay:not(.hidden) .modal-content,
.modal-overlay:not([hidden]) .modal-content {
  animation: modalIn 0.2s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}

/* Row delete shrink */
@keyframes rowShrink {
  to { opacity: 0; transform: scaleY(0); max-height: 0; padding: 0; }
}
.row-deleting {
  animation: rowShrink 0.25s ease forwards;
  transform-origin: top;
  overflow: hidden;
}

/* Pipeline bar fill animation */
@keyframes barFill {
  from { width: 0%; }
}
.lead-pipeline-card em {
  animation: barFill 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* Card grid stagger on render */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.report-card-grid .report-card,
.lt-stats .report-card {
  animation: cardIn 0.3s ease both;
}
.report-card-grid .report-card:nth-child(2),
.lt-stats .report-card:nth-child(2) { animation-delay: 0.04s; }
.report-card-grid .report-card:nth-child(3),
.lt-stats .report-card:nth-child(3) { animation-delay: 0.08s; }
.report-card-grid .report-card:nth-child(4),
.lt-stats .report-card:nth-child(4) { animation-delay: 0.12s; }
.report-card-grid .report-card:nth-child(5) { animation-delay: 0.16s; }
.report-card-grid .report-card:nth-child(6) { animation-delay: 0.20s; }
.report-card-grid .report-card:nth-child(n+7) { animation-delay: 0.24s; }

/* Purple dark-mode equivalent overrides */
body[data-theme="dark"] .panel,
body[data-theme="dark"] .sub-panel,
body[data-theme="dark"] .lt-form-card,
body[data-theme="dark"] .lt-table-wrap,
body[data-theme="dark"] .lt-filter-bar,
body[data-theme="dark"] .stat-card,
body[data-theme="dark"] .report-card,
body[data-theme="dark"] .modal-content,
body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
}
body[data-theme="dark"] .secondary-btn {
  background: #374151;
  border-color: #4b5563;
  color: #f1f5f9;
}
body[data-theme="dark"] .secondary-btn:hover { background: #4b5563; }
body[data-theme="dark"] .sidebar { background: #111827; border-color: #374151; }
body[data-theme="dark"] .topbar { background: rgba(31,41,55,0.96); border-color: #374151; }
body[data-theme="dark"] table thead th { background: #1f2937; color: var(--muted); }
body[data-theme="dark"] .lt-table tbody tr:nth-child(even) { background: #1f2937; }
body[data-theme="dark"] .lt-table tbody tr:hover { background: rgba(99,102,241,0.1); }
body[data-theme="dark"] .board-filter-bar,
body[data-theme="dark"] .lt-filter-bar { background: rgba(31,41,55,0.6); border-color: #374151; }

/* Emoji nav label spacing */
.nav-link { gap: 8px; }

/* Theme transition smooth */
:root { transition: --brand 0s; }
