:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #16211c;
  --muted: #69746f;
  --line: #dce2dc;
  --brand: #1f7a5a;
  --brand-dark: #145941;
  --accent: #d69d35;
  --danger: #b84d42;
  --soft: #eaf3ee;
  --shadow: 0 18px 40px rgba(22, 33, 28, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

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

button {
  cursor: pointer;
}

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

.sidebar {
  background: #17251f;
  color: #f3f7f4;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #1b1810;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-name {
  font-size: 22px;
  font-weight: 800;
}

.brand-subtitle,
.eyebrow {
  color: #98a8a0;
  font-size: 12px;
  letter-spacing: 0;
}

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

.nav-item {
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  text-align: left;
  color: #dce6e0;
  background: transparent;
  display: grid;
  gap: 4px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-item span {
  font-weight: 850;
}

.nav-item small {
  color: #9caf9f;
  line-height: 1.35;
}

.nav-item.active small,
.nav-item:hover small {
  color: #dce6e0;
}

.sidebar-panel {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 16px;
  color: #dbe7df;
  line-height: 1.55;
}

.panel-label {
  color: var(--accent);
  font-weight: 800;
  margin-bottom: 8px;
}

.main {
  padding: 22px;
  display: grid;
  gap: 16px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

h1 {
  margin-bottom: 6px;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.15;
  letter-spacing: 0;
}

.page-subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

h2 {
  margin-bottom: 10px;
  font-size: 20px;
  letter-spacing: 0;
}

.topbar-actions,
.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-btn,
.ghost-btn,
.icon-btn,
.danger-btn {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 750;
}

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

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

.ghost-btn,
.icon-btn {
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

.danger-btn {
  background: #fff2f0;
  border-color: #f0c6c1;
  color: var(--danger);
}

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

.metric-card,
.lead-panel,
.detail-panel,
.import-panel,
.beta-panel,
.auth-panel,
dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 14px;
  display: grid;
  gap: 6px;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
}

.metric-card strong {
  font-size: 28px;
}

.analytics-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 16px;
}

.analytics-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.analytics-header h2,
.analytics-grid h3 {
  margin: 0 0 6px;
}

.analytics-header p {
  margin: 0;
  color: var(--muted);
}

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

.analytics-actions > strong {
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--soft);
  color: var(--brand-dark);
  white-space: nowrap;
}

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

.analytics-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

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

.analytics-row {
  width: 100%;
  border: 0;
  padding: 0;
  text-align: left;
  background: transparent;
  color: inherit;
  display: grid;
  gap: 6px;
}

.analytics-row:hover strong {
  color: var(--brand-dark);
}

.analytics-row:focus-visible {
  outline: 2px solid rgba(31, 122, 90, 0.35);
  outline-offset: 3px;
}

.analytics-row-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.analytics-row-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-row-head span,
.analytics-row small {
  color: var(--muted);
  font-size: 12px;
}

.analytics-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1ed;
}

.analytics-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.sales-plan-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.sales-plan-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.sales-plan-header h2,
.sales-plan-header p {
  margin: 0;
}

.sales-plan-header p {
  color: var(--muted);
}

.sales-plan-list {
  display: grid;
  gap: 10px;
}

.sales-plan-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, auto);
  gap: 14px;
  align-items: start;
  background: #fbfcfa;
}

.plan-card-main {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.plan-card-topline,
.plan-meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.sales-plan-card h3 {
  margin: 0;
  font-size: 16px;
}

.sales-plan-card p {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
}

.plan-meta-row span,
.plan-next-action {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.plan-meta-row span {
  border: 1px solid #e3e9e4;
  border-radius: 999px;
  padding: 4px 8px;
  background: #fff;
}

.plan-next-action {
  border-left: 3px solid var(--brand);
  padding: 7px 9px;
  border-radius: 0 8px 8px 0;
  background: #eef4ed;
  color: #30483e;
}

.plan-type {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 850;
  background: var(--soft);
  color: var(--brand-dark);
}

.plan-type.due {
  background: #fff2f0;
  color: var(--danger);
}

.plan-type.fresh {
  background: #e5f6ea;
  color: #1f6b3a;
}

.plan-type.hot {
  background: #fff6df;
  color: #8a5a0f;
}

.plan-type.quote {
  background: #eef4ff;
  color: #315a98;
}

.plan-type.missing {
  background: #f1edf8;
  color: #615182;
}

.plan-priority {
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 8px;
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 850;
}

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

.plan-actions button {
  padding: 8px 10px;
  font-size: 13px;
}

.pipeline-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.pipeline-header h2,
.pipeline-header p {
  margin: 0;
}

.pipeline-header p {
  color: var(--muted);
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.pipeline-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  min-width: 180px;
  padding: 10px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.pipeline-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pipeline-column-header span {
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--brand-dark);
  font-weight: 850;
}

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

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

.pipeline-card-main {
  border: 0;
  padding: 0;
  background: transparent;
  text-align: left;
  color: inherit;
  display: grid;
  gap: 4px;
}

.pipeline-card-main strong,
.pipeline-card-main span,
.pipeline-card-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-card-main span,
.pipeline-card-main small {
  color: var(--muted);
  font-size: 12px;
}

.pipeline-card-main:hover strong {
  color: var(--brand-dark);
}

.pipeline-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pipeline-card-foot button {
  padding: 7px 9px;
  font-size: 12px;
}

.pipeline-done {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.queue-tabs {
  padding: 14px 16px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.queue-tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.queue-tab:hover,
.queue-tab.active {
  border-color: rgba(31, 122, 90, 0.38);
  background: var(--soft);
  color: var(--brand-dark);
}

.queue-tab span {
  min-width: 24px;
  border-radius: 999px;
  padding: 2px 7px;
  text-align: center;
  background: rgba(31, 122, 90, 0.1);
  color: var(--brand-dark);
  font-size: 12px;
}

.toolbar {
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px 160px auto auto;
  gap: 10px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}

.bulk-toolbar {
  padding: 12px 16px;
  display: grid;
  grid-template-columns: auto 150px auto minmax(180px, 1fr) auto 150px auto auto auto;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.bulk-toolbar strong {
  white-space: nowrap;
}

.bulk-toolbar input,
.bulk-toolbar select {
  min-height: 42px;
}

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

label,
.field-block {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
}

textarea {
  resize: vertical;
}

.lead-table-wrap {
  overflow-x: auto;
}

.lead-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.lead-table th,
.lead-table td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.lead-table th {
  color: var(--muted);
  font-size: 12px;
}

.lead-row {
  background: white;
}

.lead-row:hover {
  background: #fbfcfa;
}

.lead-row.selected {
  background: var(--soft);
}

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

.select-col input,
.select-cell input {
  width: 18px;
  height: 18px;
  padding: 0;
}

.company-cell strong {
  display: block;
}

.company-cell small,
.muted-text,
.contact-counts,
.followup-date {
  color: var(--muted);
}

.contact-counts {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 800;
}

.followup-date {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 800;
}

.followup-date.due {
  color: var(--danger);
}

.score-pill,
.status-pill,
.tag-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}

.score-pill {
  background: #eaf3ee;
  color: var(--brand-dark);
}

.status-pill {
  background: #eef1ed;
  color: #34413b;
}

.status-pill.interested {
  background: #fff1d8;
  color: #7a4e0b;
}

.status-pill.quoted {
  background: #e9f0ff;
  color: #294f9f;
}

.status-pill.won {
  background: #e5f6ea;
  color: #1f6b3a;
}

.status-pill.invalid {
  background: #fff2f0;
  color: var(--danger);
}

.detail-panel {
  padding: 18px;
  min-height: 460px;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: hidden;
}

.detail-empty {
  height: 100%;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none;
}

.detail-content {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.detail-content.hidden {
  display: none;
}

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

.detail-header h2 {
  margin-bottom: 0;
  line-height: 1.25;
}

.detail-tabs {
  margin-top: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f7f3;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.detail-tab {
  border: 0;
  border-radius: 6px;
  padding: 8px 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  cursor: pointer;
}

.detail-tab:hover,
.detail-tab.active {
  background: #fff;
  color: var(--brand-dark);
  box-shadow: 0 1px 6px rgba(21, 54, 43, 0.08);
}

.detail-tab-body {
  min-height: 0;
  overflow: hidden;
}

.detail-tab-panel {
  max-height: calc(100vh - 238px);
  overflow: auto;
  padding-top: 12px;
  padding-right: 4px;
}

.detail-tab-panel[hidden] {
  display: none;
}

.contact-actions {
  margin-top: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.customer-profile-card + .contact-actions {
  margin-top: 12px;
}

.customer-profile-card {
  border: 1px solid #d9e6dd;
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
  display: grid;
  gap: 12px;
}

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

.customer-profile-head h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.customer-profile-head p,
.profile-section p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.customer-profile-head > span {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 10px;
  background: #eef1ed;
  color: #34413b;
  font-size: 12px;
  font-weight: 900;
}

.customer-profile-head > span.hot {
  background: #e5f6ea;
  color: #1f6b3a;
}

.customer-profile-head > span.warm {
  background: #fff1d8;
  color: #7a4e0b;
}

.customer-profile-head > span.cold {
  background: #fff2f0;
  color: var(--danger);
}

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

.profile-metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  display: grid;
  gap: 3px;
}

.profile-metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.profile-metric strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.profile-section {
  border-left: 3px solid var(--brand);
  padding: 7px 9px;
  border-radius: 0 8px 8px 0;
  background: #eef4ed;
  display: grid;
  gap: 4px;
}

.profile-section strong,
.profile-list-grid strong {
  font-size: 13px;
}

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

.profile-chip-list {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.profile-chip {
  border-radius: 999px;
  border: 1px solid #e1e7e2;
  background: #fff;
  color: #40564c;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.profile-chip.risk {
  border-color: #efd1cc;
  background: #fff4f1;
  color: var(--danger);
}

.profile-chip.good {
  border-color: #cfe2d3;
  background: #eef8f1;
  color: #1f6b3a;
}

.contact-actions button {
  padding: 8px 10px;
  font-size: 13px;
}

.contact-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tag-actions {
  margin: -4px 0 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag-actions button {
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  background: #fbfcfa;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.detail-list div {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

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

.detail-edit-grid label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-edit-grid input {
  margin-top: 6px;
}

.contact-candidate-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
  display: grid;
  gap: 12px;
}

.candidate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.candidate-head strong {
  color: var(--ink);
  font-size: 13px;
}

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

.candidate-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.candidate-pill {
  max-width: 100%;
  min-height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 5px 9px;
  background: white;
  color: #2d493d;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-pill.active {
  border-color: rgba(31, 122, 90, 0.45);
  background: var(--soft);
  color: var(--brand-dark);
}

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

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

dd {
  margin: 3px 0 0;
  word-break: break-word;
}

.field-block {
  margin-top: 12px;
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-actions {
  margin-top: 14px;
}

.detail-save-bar {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.quick-actions {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-actions button {
  padding: 8px 10px;
  font-size: 13px;
}

.score-insight-panel {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  display: grid;
  gap: 12px;
}

.detail-tab-panel .score-insight-panel {
  margin-top: 0;
}

.score-insight-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.score-insight-header h3 {
  margin: 0;
  font-size: 16px;
}

.score-insight-header span {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 900;
  background: #eef1ed;
  color: #34413b;
}

.score-insight-header span.hot {
  background: #e5f6ea;
  color: #1f6b3a;
}

.score-insight-header span.warm {
  background: #fff1d8;
  color: #7a4e0b;
}

.score-insight-header span.cold {
  background: #fff2f0;
  color: var(--danger);
}

.score-factor-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  list-style: none;
}

.score-factor-list li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 2px 8px;
  align-items: start;
}

.score-factor-list li > span {
  grid-row: span 2;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
}

.score-factor-list li.plus > span {
  background: #e5f6ea;
  color: #1f6b3a;
}

.score-factor-list li.todo > span {
  background: #fff1d8;
  color: #7a4e0b;
}

.score-factor-list li.minus > span {
  background: #fff2f0;
  color: var(--danger);
}

.score-factor-list strong,
.next-best-action strong {
  font-size: 13px;
}

.score-factor-list small,
.next-best-action p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.next-best-action {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: grid;
  gap: 4px;
}

.email-draft-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
}

.timeline-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
}

.detail-tab-panel .email-draft-panel,
.detail-tab-panel .timeline-panel {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

#emailDraft {
  min-height: 190px;
}

.email-draft-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 12px;
  align-items: start;
}

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

.email-draft-header h3,
.timeline-header h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.email-draft-header p,
.timeline-header p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.activity-composer {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 10px;
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 8px;
}

.activity-composer textarea {
  grid-column: 1 / -1;
  resize: vertical;
}

.activity-composer button {
  grid-column: 2;
  justify-self: end;
  padding: 8px 10px;
}

.timeline-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  list-style: none;
}

.timeline-item {
  position: relative;
  padding-left: 18px;
  display: grid;
  gap: 3px;
  border-left: 2px solid var(--line);
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--brand);
}

.timeline-item strong {
  font-size: 13px;
}

.timeline-item span,
.timeline-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

#emailDraft {
  min-height: 240px;
  line-height: 1.5;
  font-size: 13px;
}

.import-panel {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.csv-import-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 12px;
  background: #fbfcfa;
}

.csv-import-box h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.csv-import-box p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.csv-import-actions {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.csv-preview {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 8px;
}

.csv-preview.hidden {
  display: none;
}

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

.csv-preview-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
  display: grid;
  gap: 3px;
}

.csv-preview-grid strong {
  font-size: 20px;
}

.csv-preview-grid span,
.csv-preview p {
  color: var(--muted);
  font-size: 12px;
}

.csv-preview p {
  margin: 0;
  line-height: 1.45;
}

.cloud-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(240px, 1fr);
  gap: 12px;
}

.beta-panel {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.beta-header,
.beta-setup-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.beta-header h2,
.beta-header p,
.beta-setup-card p,
.beta-detail-grid h3 {
  margin: 0;
}

.beta-header p,
.beta-setup-card p,
.beta-status-grid small,
.beta-list-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.beta-setup-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

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

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

.beta-status-grid article,
.beta-detail-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.beta-status-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.beta-status-grid strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 24px;
}

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

.beta-check-list,
.beta-list {
  display: grid;
  gap: 8px;
}

.beta-check,
.beta-list-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 10px;
}

.beta-check {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.beta-check span {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
}

.beta-check.ok span {
  background: #e5f6ea;
  color: #1f6b3a;
}

.beta-check.warn span {
  background: #fff1d8;
  color: #7a4e0b;
}

.beta-list-row {
  display: grid;
  gap: 3px;
}

.beta-list-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-panel {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.auth-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.auth-header h2,
.auth-header p,
.auth-card h3 {
  margin: 0;
}

.auth-header p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.auth-status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff2f0;
  color: var(--danger);
  font-size: 12px;
  font-weight: 900;
}

.auth-status-pill.signed-in {
  background: #e5f6ea;
  color: #1f6b3a;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

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

.auth-token-card {
  grid-column: span 2;
}

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

.auth-session-list {
  margin: 0;
  display: grid;
  gap: 10px;
}

.auth-session-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 10px;
}

.auth-session-list dd {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.auth-token-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

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

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

.auth-token-row span {
  color: var(--muted);
  font-size: 12px;
}

.status-line {
  min-height: 22px;
  color: var(--brand-dark);
  font-weight: 750;
}

dialog {
  width: min(760px, calc(100vw - 32px));
  border: 0;
  padding: 0;
}

dialog::backdrop {
  background: rgba(8, 14, 11, 0.5);
}

.lead-form {
  padding: 20px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

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

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

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

  .sidebar {
    position: static;
  }

  .workspace-grid,
  .metrics-grid,
  .analytics-grid,
  .beta-status-grid,
  .beta-detail-grid,
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .analytics-header {
    display: grid;
  }

  .beta-header,
  .beta-setup-card,
  .auth-header {
    display: grid;
  }

  .beta-setup-actions {
    justify-content: flex-start;
  }

  .sales-plan-card {
    grid-template-columns: 1fr;
  }

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

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .bulk-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .detail-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .detail-content {
    height: auto;
  }

  .detail-tab-panel {
    max-height: none;
    overflow: visible;
  }

  .profile-list-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar {
    display: grid;
  }

  .sales-plan-header {
    display: grid;
  }

  .toolbar,
  .bulk-toolbar,
  .email-draft-header,
  .activity-composer,
  .csv-import-actions,
  .csv-preview-grid,
  .form-grid,
  .cloud-grid,
  .detail-edit-grid {
    grid-template-columns: 1fr;
  }

  .activity-composer button {
    grid-column: 1;
    justify-self: stretch;
  }
}
