:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d8dee8;
  --nav: #1e2633;
  --accent: #1f7a67;
  --accent-soft: #dff3ec;
  --blue-soft: #e8eef7;
  --amber-soft: #fff0d8;
  --shadow: 0 10px 26px rgba(20, 32, 54, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Segoe UI, Arial, sans-serif;
  letter-spacing: 0;
}

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

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 22px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 0;
}

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

.login-status[data-tone="ok"] {
  color: var(--accent);
}

.login-status[data-tone="warning"] {
  color: #a86714;
}

.sidebar {
  background: var(--nav);
  color: #ffffff;
  padding: 24px 18px;
}

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

.mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #d7f35f;
  color: #16200f;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #aeb7c7;
  font-size: 13px;
  margin-top: 3px;
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  color: #c7d0de;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
}

nav a.active,
nav a:hover {
  background: #2b3545;
  color: #ffffff;
}

main {
  padding: 28px;
  display: grid;
  gap: 18px;
  align-content: start;
}

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

.top-actions {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

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

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
}

p,
small {
  color: var(--muted);
}

.topbar p,
.panel-title p {
  margin-top: 6px;
}

.environment {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

.session-user {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.notice,
.panel,
.metrics article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.notice {
  padding: 16px;
  border-left: 4px solid var(--accent);
}

.notice p {
  margin-top: 4px;
}

.notice [data-tone="ok"] {
  color: var(--accent);
}

.notice [data-tone="warning"] {
  color: #a86714;
}

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

.metrics article {
  padding: 18px;
}

.metrics span,
.metrics small {
  display: block;
}

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

.metrics strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 27px;
}

.panel {
  padding: 18px;
}

.compact-auth {
  max-width: 720px;
}

.panel-title {
  margin-bottom: 16px;
}

.auth-row,
.action-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
  color: var(--text);
  background: #ffffff;
}

select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  color: var(--text);
  background: #ffffff;
}

.auth-row input {
  min-width: 280px;
  flex: 1;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
}

button.secondary {
  background: #eef2f7;
  color: var(--text);
}

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

.template,
.pipeline-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.template {
  display: grid;
  gap: 8px;
  width: 100%;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.template.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.template small {
  display: inline-flex;
  margin-top: 12px;
  min-height: 28px;
  align-items: center;
  justify-self: start;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #315f99;
  font-size: 12px;
  font-weight: 800;
}

.action-row {
  margin-top: 16px;
}

#search-status {
  color: var(--muted);
}

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

.lead-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(120px, 0.8fr) repeat(4, minmax(120px, 0.8fr)) auto auto;
  gap: 10px;
  margin-bottom: 14px;
}

.lead-table-header {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr) minmax(110px, 0.7fr) minmax(110px, 0.7fr) 80px;
  gap: 14px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.lead-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr) minmax(110px, 0.7fr) minmax(110px, 0.7fr) 80px;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.lead-row strong,
.lead-row span,
.lead-row small {
  display: block;
}

.lead-company strong,
.lead-company span,
.lead-company small,
.lead-meta strong,
.lead-meta span {
  display: block;
}

.lead-meta strong {
  text-transform: capitalize;
}

.lead-meta select {
  width: 100%;
  max-width: 170px;
}

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

.lead-actions button {
  min-height: 36px;
}

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

.followup-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.followup-grid h3 {
  margin-bottom: 10px;
}

.followup-row {
  width: 100%;
  display: grid;
  gap: 4px;
  min-height: auto;
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.followup-row strong,
.followup-row span,
.followup-row small {
  display: block;
}

.search-history,
.search-result-list {
  display: grid;
  gap: 10px;
}

.search-results {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.search-card,
.search-result-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) minmax(180px, 0.9fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.search-card strong,
.search-card span,
.search-card small,
.search-result-row strong,
.search-result-row span,
.search-result-row small {
  display: block;
}

.search-card small,
.search-result-row small {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.search-card-stats {
  display: grid;
  gap: 4px;
}

.search-card-stats span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  justify-self: start;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #315f99;
  font-size: 12px;
  font-weight: 800;
}

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

.search-results-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.user-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

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

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

.user-row strong,
.user-row span,
.user-row small {
  display: block;
}

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

.user-actions input {
  min-height: 36px;
  max-width: 180px;
}

.user-actions button {
  min-height: 36px;
}

.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.46);
}

.detail-panel {
  width: min(1080px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  display: grid;
  gap: 16px;
  padding: 20px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

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

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

.detail-grid article,
.detail-notes {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.detail-grid h3,
.detail-notes h3 {
  margin-bottom: 10px;
}

.detail-grid p {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid #eef2f7;
}

.detail-grid p:last-child {
  border-bottom: 0;
}

.detail-grid p strong {
  font-size: 13px;
}

.detail-grid p span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.detail-score strong {
  display: block;
  font-size: 36px;
}

.detail-form,
.note-form {
  display: grid;
  gap: 10px;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  resize: vertical;
  font: inherit;
}

.note-row {
  padding: 10px 0;
  border-bottom: 1px solid #eef2f7;
}

.note-row:last-child {
  border-bottom: 0;
}

.note-row small {
  display: block;
  margin-top: 5px;
}

.score {
  min-width: 74px;
  text-align: right;
}

.score strong {
  font-size: 24px;
}

.score.hot {
  color: #b42318;
}

.score.warm {
  color: #b8640c;
}

.score.cold {
  color: #315f99;
}

.empty {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.template.investor small {
  background: var(--amber-soft);
  color: #a86714;
}

ol,
.roadmap {
  margin: 12px 0 0;
  padding-left: 22px;
  color: var(--muted);
}

li {
  margin: 7px 0;
}

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

  .sidebar {
    padding: 16px;
  }

  nav {
    grid-template-columns: repeat(4, auto);
    justify-content: start;
  }

  .metrics,
  .followup-grid,
  .user-form,
  .lead-filters,
  .template-grid,
  .search-card,
  .search-result-row,
  .pipeline-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .topbar {
    display: grid;
    padding-top: 62px;
  }

  .top-actions {
    left: 16px;
    right: 16px;
    top: 12px;
    justify-content: space-between;
  }

  .metrics,
  .followup-grid,
  .user-form,
  .lead-filters,
  .template-grid,
  .search-card,
  .search-result-row,
  .pipeline-grid,
  nav {
    grid-template-columns: 1fr;
  }

  .lead-row,
  .search-card,
  .search-result-row,
  .user-row,
  .auth-row {
    align-items: stretch;
    display: grid;
  }

  .lead-table-header {
    display: none;
  }

  .user-actions {
    justify-content: stretch;
  }

  .score {
    text-align: left;
  }

  .detail-modal {
    padding: 12px;
  }

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

  .detail-header {
    display: grid;
  }
}
