:root {
  --ink: #182230;
  --muted: #667085;
  --line: rgba(24, 34, 48, 0.12);
  --bg: #f4f8fb;
  --panel: rgba(255, 255, 255, 0.88);
  --primary: #0f766e;
  --primary-2: #115e59;
  --accent: #f59e0b;
  --mint: #22c55e;
  --amber: #f59e0b;
  --coral: #f97366;
  --indigo: #4f46e5;
  --sky: #0284c7;
  --red: #dc2626;
  --green: #15803d;
  --shadow: 0 22px 58px rgba(15, 23, 42, 0.12);
  --soft-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 14% 10%, rgba(34, 197, 94, 0.16), transparent 28%),
    radial-gradient(circle at 92% 4%, rgba(79, 70, 229, 0.13), transparent 30%),
    linear-gradient(135deg, #f7fbf5 0%, #f3f8ff 46%, #fff8ed 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.dark-theme {
  --ink: #edf5f7;
  --muted: #a7b6c2;
  --line: rgba(255, 255, 255, 0.14);
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.86);
  background:
    radial-gradient(circle at 14% 10%, rgba(34, 197, 94, 0.14), transparent 28%),
    radial-gradient(circle at 92% 4%, rgba(79, 70, 229, 0.2), transparent 30%),
    linear-gradient(135deg, #07111f 0%, #111827 54%, #172554 100%);
}

.hidden {
  display: none !important;
}

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

button,
a.secondary,
a.primary {
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid transparent;
  min-height: 40px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 750;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

button:hover,
a.secondary:hover,
a.primary:hover {
  transform: translateY(-1px);
}

.primary {
  background: linear-gradient(135deg, #0f766e, #22c55e);
  color: white;
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 14px 28px rgba(15, 118, 110, 0.24);
}

.primary:hover {
  background: linear-gradient(135deg, #115e59, #16a34a);
  color: white;
}

.secondary {
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  border: 1px solid rgba(24, 34, 48, 0.12);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.secondary:hover {
  border-color: rgba(15, 118, 110, 0.32);
  color: var(--primary-2);
  background: white;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(10, 36, 45, 0.95), rgba(18, 46, 63, 0.96)),
    linear-gradient(135deg, #0f766e, #4f46e5);
  color: white;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08);
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #facc15, #fb923c);
  color: #17212b;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(250, 204, 21, 0.22);
}

.brand strong {
  letter-spacing: 0;
}

.brand span,
.import-card span,
.eyebrow,
.section-head span,
label span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  font-weight: 700;
}

.brand span,
.import-card span {
  color: rgba(226, 240, 245, 0.78);
}

.nav-list {
  display: grid;
  gap: 9px;
}

.nav-item {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.1);
  justify-content: flex-start;
  min-height: 44px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.26);
  color: white;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.14);
}

.import-card {
  margin-top: auto;
  display: grid;
  gap: 12px;
  padding: 16px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.06));
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.16);
}

.import-card strong {
  color: white;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-head,
.dialog-head,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.topbar {
  position: relative;
  margin-bottom: 22px;
  padding: 24px;
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.95), rgba(79, 70, 229, 0.78)),
    linear-gradient(45deg, #0f766e, #22c55e);
  color: white;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto -70px -95px auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(250, 204, 21, 0.28);
}

.topbar > * {
  position: relative;
  z-index: 1;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 38px;
  line-height: 1.08;
  font-weight: 850;
}

h2 {
  font-size: 18px;
  font-weight: 820;
}

h3 {
  font-size: 15px;
  font-weight: 820;
}

.hero-copy {
  max-width: 670px;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.82);
}

.topbar .eyebrow,
.topbar .hero-copy {
  color: rgba(255, 255, 255, 0.82);
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.user-badge {
  min-height: 40px;
  padding: 0 13px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  color: white;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 12px;
  font-weight: 850;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.kpi {
  position: relative;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 18px;
  padding: 18px;
  min-height: 128px;
  box-shadow: var(--soft-shadow);
  overflow: hidden;
}

.kpi::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--primary), var(--mint));
}

.kpi-today::before {
  background: linear-gradient(90deg, #0f766e, #22c55e);
}

.kpi-pipeline::before {
  background: linear-gradient(90deg, #4f46e5, #0284c7);
}

.kpi-due::before {
  background: linear-gradient(90deg, #f97316, #facc15);
}

.kpi-won::before {
  background: linear-gradient(90deg, #16a34a, #84cc16);
}

.kpi-icon {
  position: absolute;
  right: 16px;
  top: 16px;
  min-width: 42px;
  height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.95), rgba(79, 70, 229, 0.9));
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.16);
}

.kpi strong {
  display: block;
  font-size: 32px;
  margin-top: 10px;
  letter-spacing: 0;
}

.kpi small {
  color: var(--muted);
  font-weight: 650;
}

.workbench {
  display: grid;
  gap: 16px;
}

.controls {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 18px;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(230px, 1.5fr) repeat(7, minmax(128px, 1fr));
  gap: 12px;
  align-items: end;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(10px);
}

label {
  display: grid;
  gap: 7px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(24, 34, 48, 0.13);
  border-radius: 12px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
  min-height: 42px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}

textarea {
  resize: vertical;
}

.split-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 16px;
  align-items: start;
}

.lead-list,
.notifications {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(10px);
}

body.dark-theme .lead-list,
body.dark-theme .notifications,
body.dark-theme .controls,
body.dark-theme .kpi,
body.dark-theme dialog {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--ink);
}

body.dark-theme table,
body.dark-theme input,
body.dark-theme select,
body.dark-theme textarea,
body.dark-theme .secondary {
  background: #111827;
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.14);
}

body.dark-theme th {
  background: #172033;
  color: #cbd5e1;
}

body.dark-theme tbody tr:hover {
  background: rgba(34, 197, 94, 0.08);
}

body.dark-theme .bulk-toolbar {
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.18), rgba(79, 70, 229, 0.16)),
    rgba(15, 23, 42, 0.86);
  border-color: rgba(255, 255, 255, 0.12);
}

.table-wrap {
  overflow: auto;
  margin-top: 14px;
  border: 1px solid rgba(24, 34, 48, 0.08);
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1160px;
  background: white;
}

.bulk-toolbar {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(236, 253, 245, 0.9), rgba(239, 246, 255, 0.9)),
    white;
  display: grid;
  grid-template-columns: max-content minmax(130px, 1fr) minmax(150px, 1fr) 120px minmax(130px, 1fr) max-content max-content max-content;
  gap: 10px;
  align-items: center;
}

.bulk-toolbar strong {
  color: var(--primary-2);
  white-space: nowrap;
}

.bulk-toolbar select,
.bulk-toolbar input,
.pagination-bar select {
  min-height: 38px;
  border-radius: 10px;
  padding: 8px 10px;
}

.select-col {
  width: 44px;
  text-align: center;
}

.select-col input {
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  box-shadow: none;
  accent-color: var(--primary);
  cursor: pointer;
}

.select-col input:disabled {
  cursor: not-allowed;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.pagination-bar label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-bar select {
  width: 86px;
}

th {
  text-align: left;
  color: #475467;
  font-size: 12px;
  font-weight: 850;
  border-bottom: 1px solid rgba(24, 34, 48, 0.1);
  padding: 13px 12px;
  background: linear-gradient(180deg, #f8fbff, #f3f6f9);
}

td {
  border-bottom: 1px solid rgba(24, 34, 48, 0.07);
  padding: 14px 12px;
  vertical-align: middle;
}

tr {
  cursor: pointer;
}

tbody tr {
  transition: background 0.16s ease, transform 0.16s ease;
}

tbody tr:hover {
  background: #f0fbf7;
}

.buyer {
  display: grid;
  gap: 4px;
}

.buyer strong {
  font-size: 14px;
  font-weight: 830;
}

.buyer span,
.subtext {
  color: var(--muted);
  font-size: 12px;
}

.lead-date-cell {
  min-width: 138px;
}

.lead-date-cell strong,
.lead-date-cell span {
  display: block;
}

.lead-date-cell strong {
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}

.lead-date-cell span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  background: #eef3f2;
  color: var(--primary-2);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.stage-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.75);
}

.stage-new {
  background: #e0f2fe;
  color: #0369a1;
}

.stage-contacted {
  background: #ede9fe;
  color: #5b21b6;
}

.stage-qualified {
  background: #dcfce7;
  color: #166534;
}

.stage-sample-sent {
  background: #fef3c7;
  color: #92400e;
}

.stage-negotiation {
  background: #ffedd5;
  color: #9a3412;
}

.stage-won {
  background: #dcfce7;
  color: #15803d;
}

.stage-lost {
  background: #fee2e2;
  color: #b91c1c;
}

.stage-hold,
.stage-call-back {
  background: #f1f5f9;
  color: #475569;
}

.contact-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.mini-link {
  color: var(--primary);
  background: #ecfdf5;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 999px;
  padding: 5px 10px;
  text-decoration: none;
  font-weight: 850;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.buyer .crm-meta { color: var(--primary); font-weight: 700; }
.buyer .reply-alert { color: #b45309; }

.mini-link:hover {
  color: white;
  background: var(--primary);
}

.mini-link.whatsapp {
  color: #15803d;
  background: #dcfce7;
  border-color: rgba(21, 128, 61, 0.2);
}

.mini-link.whatsapp:hover {
  color: white;
  background: #16a34a;
}

.notification-list {
  margin-top: 14px;
  display: grid;
  gap: 11px;
}

.notification {
  border: 1px solid rgba(24, 34, 48, 0.08);
  border-radius: 14px;
  padding: 13px;
  display: grid;
  gap: 7px;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}

.notification.unread {
  border-color: rgba(249, 115, 22, 0.28);
  background: linear-gradient(135deg, #fff7ed, #ecfeff);
}

.pipeline-mini {
  display: grid;
  gap: 11px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(24, 34, 48, 0.09);
}

.bar-row {
  display: grid;
  grid-template-columns: 96px 1fr 30px;
  gap: 9px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

.bar {
  height: 9px;
  border-radius: 999px;
  background: #e5ebef;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f766e, #f59e0b, #4f46e5);
}

dialog {
  width: min(900px, calc(100vw - 28px));
  border: 0;
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 0;
  background: white;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(4px);
}

.lead-form {
  padding: 22px;
  display: grid;
  gap: 16px;
}

.icon-button {
  width: 40px;
  padding: 0;
  background: white;
  border: 1px solid var(--line);
  color: var(--muted);
}

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

.wide {
  grid-column: 1 / -1;
}

.activity-panel {
  border-top: 1px solid var(--line);
  padding-top: 15px;
  display: grid;
  gap: 10px;
}

.activity-item {
  border-left: 4px solid var(--primary);
  padding: 10px 12px;
  background: linear-gradient(135deg, #f0fdf4, #f8fafc);
  border-radius: 0 12px 12px 0;
}

.activity-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}

.users-list {
  display: grid;
  gap: 10px;
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.user-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

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

.compact-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.danger-button {
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.22);
  background: #fff1f2;
}

.danger-button:hover {
  color: white;
  background: #dc2626;
  border-color: #dc2626;
}

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

body.dark-theme .user-row {
  background: rgba(255, 255, 255, 0.06);
}

.login-body {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  align-items: stretch;
}

.login-hero {
  padding: 54px;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.94), rgba(79, 70, 229, 0.82)),
    linear-gradient(45deg, var(--primary), var(--accent));
}

.login-brand {
  margin-bottom: 46px;
}

.login-hero h1 {
  font-size: 54px;
  max-width: 580px;
}

.login-hero p {
  margin-top: 14px;
  max-width: 620px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 18px;
}

.login-roles {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.login-roles span {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 13px;
  font-weight: 800;
}

.login-panel {
  padding: 34px;
  display: grid;
  align-items: center;
}

.auth-form {
  display: grid;
  gap: 14px;
  padding: 26px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

body.dark-theme .auth-form {
  background: rgba(15, 23, 42, 0.9);
  color: var(--ink);
}

.auth-form h2 {
  font-size: 28px;
}

.auth-message {
  min-height: 20px;
  color: var(--coral);
  font-size: 13px;
  font-weight: 750;
}

.link-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  justify-content: flex-start;
  box-shadow: none;
}

.link-button:hover {
  transform: none;
  color: var(--primary-2);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .import-card {
    margin-top: 0;
    margin-left: auto;
  }

  .controls,
  .split-view,
  .bulk-toolbar,
  .kpis {
    grid-template-columns: 1fr 1fr;
  }

  .notifications {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .section-head,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .controls,
  .split-view,
  .bulk-toolbar,
  .kpis,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .pagination-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-bar label {
    justify-content: space-between;
  }

  .sidebar {
    padding: 16px;
  }

  .import-card {
    width: 100%;
    margin-left: 0;
  }

  h1 {
    font-size: 30px;
  }

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

  .login-hero {
    padding: 30px 20px;
  }

  .login-hero h1 {
    font-size: 34px;
  }

  .login-panel {
    padding: 20px;
  }
}

/* ── Backup dialog ────────────────────────────────────────────────── */

.backup-toggle-label {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.backup-toggle-label span {
  font-weight: 600;
  font-size: 15px;
}

.toggle-switch {
  position: relative;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #cfd8dc;
  border-radius: 28px;
  transition: background 0.3s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary, #009699);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(24px);
}

.backup-status {
  margin-bottom: 16px;
}

.integration-url-row {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.integration-url-row input {
  flex: 1;
  min-width: 0;
}

.integration-url-row button {
  white-space: nowrap;
}

#indiaMartDialog small {
  color: var(--muted);
  line-height: 1.45;
}

.whatsapp-crm-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, #25d366 6%, var(--surface));
}

.whatsapp-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.whatsapp-panel-head h3 { margin: 0; }
.whatsapp-panel-head small.needs-reply { color: #b45309; font-weight: 700; }

.whatsapp-thread {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 300px;
  overflow-y: auto;
  padding: 0.75rem;
  border-radius: 12px;
  background: var(--surface);
}

.whatsapp-bubble {
  max-width: 82%;
  padding: 0.7rem 0.8rem;
  border-radius: 14px 14px 14px 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.whatsapp-bubble.outbound {
  align-self: flex-end;
  border-radius: 14px 14px 4px 14px;
  background: color-mix(in srgb, #25d366 18%, var(--surface));
}

.whatsapp-bubble small { display: block; margin-top: 0.35rem; color: var(--muted); }

.whatsapp-compose {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 0.75rem;
}

.whatsapp-compose .wide { grid-column: 1 / -1; }
.whatsapp-compose button { justify-self: start; align-self: end; }

@media (max-width: 700px) {
  .whatsapp-compose { grid-template-columns: 1fr; }
  .whatsapp-compose .wide { grid-column: auto; }
  .whatsapp-bubble { max-width: 94%; }
}

.whatsapp-inbox-view { min-height: 680px; }
.inbox-shell { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); min-height: 680px; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.inbox-conversations { padding: 1rem; border-right: 1px solid var(--line); background: var(--surface-2); }
.inbox-conversations .search { margin: 0.8rem 0; }
.inbox-conversation-list { display: grid; gap: 0.35rem; max-height: 570px; overflow-y: auto; }
.inbox-conversation { width: 100%; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 0.7rem; padding: 0.75rem; border: 0; border-radius: 12px; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.inbox-conversation:hover, .inbox-conversation.active { background: color-mix(in srgb, #25d366 12%, var(--surface)); }
.conversation-avatar { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: #16a34a; color: white; font-weight: 850; }
.conversation-copy { display: grid; min-width: 0; gap: 2px; }
.conversation-copy strong, .conversation-copy small, .conversation-copy em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-copy small { color: var(--text); }
.conversation-copy em { color: var(--muted); font-size: 11px; font-style: normal; }
.unread-count { display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: #16a34a; color: white; font-size: 11px; }
.reply-dot { width: 10px; height: 10px; border-radius: 50%; background: #f59e0b; }
.inbox-chat-pane { min-width: 0; padding: 1rem; }
.inbox-empty { display: grid; place-items: center; align-content: center; min-height: 600px; color: var(--muted); text-align: center; }
.inbox-chat-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 0.8rem; border-bottom: 1px solid var(--line); }
.inbox-chat-head h2 { margin: 0; }
.inbox-chat-head span { color: var(--muted); font-size: 12px; }
.inbox-lead-context { display: grid; gap: 0.8rem; margin-top: 0.9rem; padding: 1rem; border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--line)); border-radius: 16px; background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.context-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.context-heading > div { display: grid; gap: 0.25rem; }
.context-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
.context-grid > div { display: grid; gap: 0.2rem; padding: 0.7rem; border-radius: 12px; background: var(--surface); }
.context-grid small, .conversation-plan small { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.context-grid strong { font-size: 13px; line-height: 1.4; }
.conversation-plan { padding: 0.75rem 0.85rem; border-left: 4px solid var(--primary); border-radius: 10px; background: var(--surface); }
.conversation-plan p { margin: 0.3rem 0 0; color: var(--text); line-height: 1.5; }
.context-actions { display: grid; grid-template-columns: minmax(150px, 0.8fr) minmax(210px, 1fr) max-content; gap: 0.65rem; align-items: end; }
.inbox-thread { max-height: 430px; min-height: 360px; margin-top: 0.8rem; }
.inbox-compose { border-top: 1px solid var(--line); padding-top: 0.8rem; }

@media (max-width: 900px) {
  .inbox-shell { grid-template-columns: 1fr; }
  .inbox-conversations { border-right: 0; border-bottom: 1px solid var(--line); }
  .inbox-conversation-list { max-height: 280px; }
  .context-grid { grid-template-columns: 1fr; }
  .context-actions { grid-template-columns: 1fr; }
}

.crm-settings-view { min-height: 680px; }
.settings-page-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 1.2rem; }
.settings-page-head h2 { margin: 0.2rem 0; font-size: 28px; }
.settings-page-head p { margin: 0; color: var(--muted); }
.settings-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.settings-module-card { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 1rem; align-items: start; padding: 1.2rem; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.settings-module-card > button { grid-column: 2; justify-self: start; }
.settings-module-card h3 { margin: 0 0 0.35rem; }
.settings-module-card p { margin: 0 0 0.65rem; color: var(--muted); line-height: 1.5; }
.settings-module-card span:not(.settings-module-icon) { color: var(--primary); font-size: 12px; font-weight: 750; }
.settings-module-icon { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 15px; background: color-mix(in srgb, var(--primary) 14%, var(--surface)); color: var(--primary); font-weight: 900; letter-spacing: 0.04em; }
.settings-module-icon.indiamart-icon { background: #e0f2fe; color: #0369a1; }
.settings-module-icon.whatsapp-icon { background: #dcfce7; color: #15803d; }

@media (max-width: 800px) {
  .settings-card-grid { grid-template-columns: 1fr; }
}

.backup-success {
  background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
  border: 1px solid #4caf50;
  border-radius: 10px;
  padding: 14px 18px;
  color: #2e7d32;
  font-size: 14px;
}

.backup-error {
  background: linear-gradient(135deg, #fbe9e7, #fff3e0);
  border: 1px solid #f44336;
  border-radius: 10px;
  padding: 14px 18px;
  color: #c62828;
  font-size: 14px;
}

.backup-info {
  background: linear-gradient(135deg, #e3f2fd, #e8eaf6);
  border: 1px solid #90caf9;
  border-radius: 10px;
  padding: 14px 18px;
  color: #1565c0;
  font-size: 14px;
}

.backup-history-section {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.backup-history-section h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px 0;
  color: var(--ink);
}

.backup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.backup-table thead {
  background: var(--primary, #009699);
  color: #fff;
}

.backup-table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.backup-table th:first-child {
  border-radius: 8px 0 0 0;
}

.backup-table th:last-child {
  border-radius: 0 8px 0 0;
}

.backup-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.backup-table tbody tr:nth-child(even) {
  background: rgba(0, 150, 153, 0.04);
}

.backup-table tbody tr:hover {
  background: rgba(0, 150, 153, 0.08);
}

.backup-empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 24px 0;
}

.backup-history-list {
  max-height: 240px;
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
}

#backupDialog .dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

#testBackup {
  background: linear-gradient(135deg, #e3f2fd, #e8eaf6);
  border: 1px solid #90caf9;
  color: #1565c0;
  font-weight: 600;
}

#testBackup:hover {
  background: linear-gradient(135deg, #bbdefb, #c5cae9);
}

#testBackup:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Dark theme backup overrides */
body.dark-theme .backup-success {
  background: linear-gradient(135deg, #1b3a1d, #1e3926);
  border-color: #388e3c;
  color: #81c784;
}

body.dark-theme .backup-error {
  background: linear-gradient(135deg, #3e1515, #3a1e10);
  border-color: #d32f2f;
  color: #ef9a9a;
}

body.dark-theme .backup-info {
  background: linear-gradient(135deg, #0d1f3c, #121836);
  border-color: #42a5f5;
  color: #90caf9;
}

body.dark-theme .toggle-slider {
  background: #455a64;
}

body.dark-theme #testBackup {
  background: linear-gradient(135deg, #0d1f3c, #121836);
  border-color: #42a5f5;
  color: #90caf9;
}
/* Author display rules must never override native visibility semantics. */
[hidden] { display: none !important; }

/* The fixed sidebar reduces the dashboard's usable width on common laptops. */
@media (max-width: 1600px) and (min-width: 1121px) {
  .controls { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.workbench,
.split-view,
.lead-list,
.notifications { min-width: 0; }
