:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9dee8;
  --brand: #1463ff;
  --brand-strong: #0d47c4;
  --ok: #0f8a5f;
  --warn: #b35b00;
  --bad: #bc2727;
  --soft-blue: #eaf1ff;
  --soft-green: #e8f7f0;
  --soft-yellow: #fff6d8;
  --soft-red: #ffebeb;
  --shadow: 0 12px 32px rgba(20, 34, 66, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--text);
  font-weight: 700;
}

.check-row input {
  width: auto;
  min-height: auto;
}

button {
  border: 0;
  cursor: pointer;
}

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

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 34px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 800;
}

.brand-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.1;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px clamp(14px, 4vw, 30px) 48px;
}

.login-wrap {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(20, 99, 255, 0.08), transparent 40%),
    linear-gradient(315deg, rgba(15, 138, 95, 0.08), transparent 38%),
    var(--bg);
}

.login-panel {
  width: min(430px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0;
  font-size: 26px;
}

.login-panel p {
  margin: 8px 0 20px;
  color: var(--muted);
  line-height: 1.45;
}

.demo-logins {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tab {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 13px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  background: var(--brand);
  color: #fff;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0;
}

.toolbar-stack {
  display: grid;
  gap: 4px;
}

.toolbar h2 {
  margin: 0;
  font-size: 24px;
}

.toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

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

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

.panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.panel-title h3 {
  margin: 0;
  font-size: 17px;
}

.stat {
  display: grid;
  gap: 6px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.stat strong {
  font-size: 26px;
}

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

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

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

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

.subadmin-layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.superadmin-layout {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.account-layout {
  align-items: start;
}

.account-create-card {
  align-content: start;
  gap: 10px;
  border-color: #cfd8ea;
  background: linear-gradient(180deg, #ffffff, #fbfcff);
}

.account-create-card .panel-title {
  margin-bottom: 4px;
}

.account-create-card .field {
  display: grid;
  gap: 5px;
}

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

.form-actions span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.auto-stats {
  margin-bottom: 14px;
}

.auto-stats .stat {
  border-color: #c9d8ff;
  background: linear-gradient(180deg, #ffffff, #f7faff);
}

.auto-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.35fr) minmax(280px, 0.8fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.auto-panel {
  border-color: #b9cdfd;
  box-shadow: 0 14px 34px rgba(20, 99, 255, 0.08);
}

.caller-pick {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

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

.caller-pick-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.caller-pick-item input {
  width: 16px;
  min-height: 16px;
  margin-top: 2px;
  accent-color: var(--brand);
}

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

.caller-pick-item small,
.load-row span,
.repo-row span {
  color: var(--muted);
}

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

.load-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.load-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.data-repository .panel-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.repo-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(150px, 1fr) minmax(120px, 0.8fr) minmax(220px, auto);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.repo-row > div:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.repo-assignee {
  color: #344054;
  font-weight: 800;
}

.repo-actions {
  justify-content: flex-end;
}

.repo-row .inline-edit {
  grid-column: 1 / -1;
}

.target-user-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding-right: 2px;
}

.target-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 700;
}

.info-manager {
  margin-bottom: 14px;
}

.info-list {
  margin-top: 12px;
}

.caller-help-layout {
  align-items: start;
}

.caller-help-create {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.caller-help-create > .panel-title,
.caller-help-create > .language-fields,
.caller-help-create > .target-box,
.caller-help-create > .form-actions {
  grid-column: 1 / -1;
}

.caller-help-create > .field:nth-of-type(3),
.caller-help-create > .field:nth-of-type(4) {
  grid-column: 1 / -1;
}

.caller-help-create textarea {
  min-height: 78px;
}

.caller-help-create .language-fields textarea {
  min-height: 72px;
}

.inline-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}

.inline-checks .check-row {
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.caller-help-create > .check-row {
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.subadmin-create,
.superadmin-create {
  position: sticky;
  top: 12px;
}

.subadmin-list-panel {
  min-width: 0;
}

.subadmin-card-head {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) 120px;
  gap: 12px;
  align-items: end;
}

.admin-credential-head {
  grid-template-columns: repeat(3, minmax(150px, 1fr)) 120px;
}

.permission-field {
  min-width: 0;
}

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

.permission-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  min-height: 40px;
  align-items: start;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #344054;
  line-height: 1.25;
}

.permission-grid .permission-item input,
.subadmin-active input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
  margin-top: 2px;
  accent-color: var(--brand);
}

.permission-item span {
  min-width: 0;
}

.subadmin-active {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.super-summary {
  margin-top: 14px;
}

.super-admin-summary {
  grid-template-columns: minmax(180px, 1fr) minmax(240px, 1.4fr) auto;
  align-items: center;
}

.mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-stats span {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #475467;
  font-size: 13px;
}

.permission-chip {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #667085;
  font-size: 13px;
}

.permission-chip.on {
  border-color: #9bd4b4;
  background: #ecfdf3;
  color: #027a48;
}

.readonly-permissions {
  margin-top: 10px;
}

.danger-badge {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b42318;
}

.danger-text {
  color: #b42318;
  font-weight: 700;
}

.danger-zone {
  margin: 14px 0;
  border-color: #fda29b;
  background: #fff7f6;
}

.danger-confirm {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.danger-confirm input {
  min-width: 0;
}

.user-delete-confirm {
  margin-top: 0;
}

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

.reminder-panel {
  margin-bottom: 14px;
  border-color: #f6c56b;
  background: #fff8e7;
  color: #7a4b00;
}

.caller-help-panel {
  margin-bottom: 14px;
  background: #f7fbff;
}

.language-switch {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.language-switch .btn {
  min-height: 34px;
  padding: 6px 10px;
}

.language-fields {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid #b8d5f2;
  border-radius: 8px;
  background: #f5faff;
}

.language-fields .panel-title {
  margin-bottom: 0;
}

[lang="hi"] {
  line-height: 1.55;
}

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

.help-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.help-head {
  display: grid;
  gap: 3px;
}

.help-head strong {
  color: #101828;
}

.help-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.help-card p {
  margin: 0;
  color: #344054;
  line-height: 1.45;
  white-space: pre-wrap;
}

.info-category {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.info-category h3 {
  margin: 0;
  font-size: 15px;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e9f5ff;
  color: #175cd3;
  font-size: 12px;
  font-weight: 700;
}

.danger-badge {
  background: #fee4e2;
  color: #b42318;
}

.blocked-card {
  border-color: #fecdca;
  background: #fffbfa;
}

.mapping-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px dashed #98a2b3;
  border-radius: 8px;
  background: #f8fafc;
}

.mapping-preview {
  max-height: 260px;
}

.import-valid,
.import-errors {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.import-valid strong {
  color: #067647;
}

.import-errors strong {
  color: #b42318;
}

.scheduled-import-panel {
  margin-top: 14px;
}

.warning-note {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #7c2d12;
  padding: 10px 12px;
}

.warning-note code {
  background: #ffedd5;
  border-radius: 4px;
  padding: 2px 5px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.status-strip span {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
}

.sample-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 12px 0;
  padding: 12px;
}

.sample-box pre {
  margin: 8px 0 0;
  overflow: auto;
  white-space: pre-wrap;
}

.compact-title {
  margin-top: 12px;
}

.success-text {
  color: #067647;
  font-weight: 700;
}

.whatsapp-render-preview {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef8f1;
  color: #102a1d;
  font-size: 14px;
  line-height: 1.45;
}

.whatsapp-render-preview::before {
  content: "Preview";
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.reminder-due {
  color: #b42318;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(20, 99, 255, 0.12);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border-radius: 8px;
  background: #eef2f7;
  color: #1d2939;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.btn.compact {
  width: auto;
  min-width: 96px;
  min-height: 36px;
  padding: 0 14px;
}

.btn.primary {
  background: var(--brand);
  color: #fff;
}

.btn.primary:hover {
  background: var(--brand-strong);
}

.btn.success {
  background: var(--soft-green);
  color: var(--ok);
}

.btn.warning {
  background: var(--soft-yellow);
  color: var(--warn);
}

.btn.danger {
  background: var(--soft-red);
  color: var(--bad);
}

.btn.ghost {
  background: #fff;
  border: 1px solid var(--line);
}

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

.lead-card {
  display: grid;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.lead-name {
  margin: 0;
  font-size: 18px;
}

.lead-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.badge.new,
.badge.pending {
  background: var(--soft-blue);
  color: var(--brand-strong);
}

.badge.follow-up {
  background: var(--soft-yellow);
  color: var(--warn);
}

.badge.hot {
  background: #ffe8cc;
  color: #9a3412;
}

.badge.converted,
.badge.done {
  background: var(--soft-green);
  color: var(--ok);
}

.badge.not-interested,
.badge.unanswered,
.badge.not-received {
  background: var(--soft-red);
  color: var(--bad);
}

.lead-details {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

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

.lead-actions .btn {
  width: 100%;
  padding-inline: 8px;
  white-space: normal;
}

.inline-edit {
  display: grid;
  gap: 8px;
  padding-top: 2px;
}

.manager-alerts {
  margin: 14px 0;
}

.alert-card {
  display: grid;
  gap: 6px;
  min-height: 92px;
  padding: 12px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
}

.alert-card strong {
  color: #92400e;
  font-size: 15px;
  line-height: 1.25;
}

.alert-card span {
  color: #78350f;
  font-size: 12px;
}

.pitch-assistant {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.pitch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 10px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #fff;
}

.pitch-row p {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

th {
  color: #344054;
  background: #f3f6fb;
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.empty {
  padding: 28px 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  text-align: center;
}

.notice {
  margin: 12px 0;
  padding: 11px 12px;
  border-radius: 8px;
  background: var(--soft-blue);
  color: var(--brand-strong);
  font-weight: 700;
}

.error {
  background: var(--soft-red);
  color: var(--bad);
}

.csv-box {
  width: 100%;
  min-height: 180px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .subadmin-layout,
  .superadmin-layout,
  .auto-layout {
    grid-template-columns: 1fr;
  }

  .subadmin-create,
  .superadmin-create {
    position: static;
  }
}

@media (max-width: 860px) {
  .grid.two,
  .grid.three,
  .grid.four,
  .grid.five,
  .help-grid,
  .form-grid.two,
  .form-grid.three,
  .form-grid.four {
    grid-template-columns: 1fr;
  }

  .subadmin-card-head {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .super-admin-summary {
    grid-template-columns: 1fr;
  }

  .super-user-row {
    grid-template-columns: 1fr;
  }

  .caller-pick-grid,
  .target-user-grid,
  .repo-row {
    grid-template-columns: 1fr;
  }

  .repo-actions {
    justify-content: flex-start;
  }

  .danger-confirm {
    grid-template-columns: 1fr;
  }

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

  .toolbar .btn-row,
  .toolbar .btn {
    width: 100%;
  }
}

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .top-actions .btn,
  .user-pill {
    width: 100%;
  }

  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .main {
    padding-top: 14px;
  }

  .tabs {
    margin-inline: -2px;
  }

  .lead-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .form-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-actions .btn {
    width: auto;
  }

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

/* ============================================================================
   Added components: search, toasts, filters, bulk bar, history timeline,
   WhatsApp picker, archive tag, attempt badge, selection state
   ============================================================================ */

.search-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 14px 0;
}

.search-bar input[type="search"] {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
}

.search-bar input[type="search"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(20, 99, 255, 0.15);
}

.toasts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 14px 0;
}

.toasts:empty {
  display: none;
}

.toasts .notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
}

.toast-close {
  background: transparent;
  color: inherit;
  font-size: 22px;
  line-height: 1;
  padding: 0 6px;
  border-radius: 6px;
  opacity: 0.6;
}

.toast-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.05);
}

.filter-panel {
  padding: 14px 16px;
  margin: 0 0 14px 0;
}

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--soft-blue);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 0 0 14px 0;
  flex-wrap: wrap;
}

.bulk-count {
  font-size: 14px;
  color: var(--ink);
}

.bulk-count strong {
  color: var(--brand-strong);
  font-size: 18px;
  margin-right: 4px;
}

.bulk-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.bulk-actions select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

.lead-head-left {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
}

.lead-check {
  margin-top: 4px;
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--brand);
}

.lead-card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(20, 99, 255, 0.18), var(--shadow);
}

.attempt-badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  background: var(--soft-yellow);
  color: var(--warn);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

.archived-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(102, 112, 133, 0.12);
  border-radius: 6px;
  padding: 2px 8px;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

/* WhatsApp template picker */
.whatsapp-picker {
  display: grid;
  gap: 14px;
}

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

.whatsapp-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  padding: 10px 12px;
  background: var(--soft-green);
  border: 1px solid #c8e7d8;
  border-radius: 10px;
  color: var(--ink);
  white-space: normal;
  width: 100%;
}

.whatsapp-option:hover {
  background: #d6f0e2;
}

.whatsapp-option strong {
  font-weight: 600;
  color: var(--ok);
  font-size: 13px;
}

.whatsapp-preview {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

.whatsapp-custom {
  width: 100%;
  min-height: 70px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  background: var(--panel);
  color: var(--ink);
  margin-bottom: 8px;
}

/* Per-lead history timeline */
.history-loading {
  padding: 16px;
  color: var(--muted);
  font-style: italic;
}

.history-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

.history-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  padding: 10px;
  background: var(--soft-blue);
  border-radius: 10px;
  border: 1px solid #d8e3fa;
}

.history-time {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.history-text {
  font-size: 14px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-text strong {
  font-weight: 600;
}

.history-meta {
  font-size: 12px;
  color: var(--muted);
  margin-left: 6px;
  font-weight: 400;
}

.history-note {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  margin-top: 2px;
}

@media (max-width: 620px) {
  .history-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

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

  .bulk-actions {
    width: 100%;
  }

  .bulk-actions .btn,
  .bulk-actions select {
    flex: 1;
    min-width: 100px;
  }
}
