:root {
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --ink: #202522;
  --muted: #667068;
  --line: #dce3dc;
  --accent: #156c5b;
  --accent-2: #d9472b;
  --accent-3: #2e5e9e;
  --warning: #b37700;
  --shadow: 0 18px 50px rgba(28, 39, 34, 0.12);
}

* {
  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;
}

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

button {
  cursor: pointer;
}

.app-loading .app-shell {
  display: none;
}

.login-page {
  background: #1f2b26;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(31, 43, 38, 0.92), rgba(21, 108, 91, 0.82)),
    url("https://images.unsplash.com/photo-1493238792000-8113da705763?auto=format&fit=crop&w=1600&q=80") center / cover;
}

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

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

.login-brand span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.login-panel h1 {
  font-size: 30px;
}

.auth-copy,
.auth-hint {
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 0;
}

.auth-hint {
  font-size: 13px;
}

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

.form-error {
  border: 1px solid #e0a094;
  border-radius: 8px;
  background: #fae8e4;
  color: #8d2d1f;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
  margin: 0;
  padding: 10px 12px;
}

.user-chip {
  align-self: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.sidebar {
  background: #1f2b26;
  color: #f6faf7;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f2c14e;
  color: #1f2b26;
  font-weight: 800;
}

.brand span,
.sidebar-note p,
.eyebrow {
  color: var(--muted);
}

.brand span {
  display: block;
  color: #b8c8bf;
  font-size: 13px;
  margin-top: 2px;
}

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

.nav-item {
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  color: #dfe9e3;
  background: transparent;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.11);
}

.sidebar-note {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: 18px;
}

.sidebar-note span {
  color: #f2c14e;
  font-weight: 700;
}

.sidebar-note p {
  color: #b8c8bf;
  margin: 8px 0 0;
  line-height: 1.45;
}

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

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

.topbar {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 34px;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

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

.button,
.icon-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 750;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.button.ghost {
  background: transparent;
}

.button.wide {
  width: 100%;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat,
.panel,
.lead-card,
.task,
.finder-card,
.table-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat {
  padding: 16px;
}

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

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar {
  margin-bottom: 14px;
}

.activity-filters {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(260px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin: 16px 0;
}

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

.search-field {
  flex: 1;
}

.select-field {
  min-width: 180px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

textarea {
  min-height: 260px;
  line-height: 1.5;
  resize: vertical;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(230px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.column {
  min-width: 230px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.column-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.lead-card {
  padding: 14px;
  display: grid;
  gap: 12px;
  box-shadow: 0 6px 20px rgba(31, 43, 38, 0.05);
}

.lead-card h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.lead-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.pill-row,
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.call-panel {
  display: grid;
  gap: 8px;
}

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

.call-note {
  min-height: 68px;
  font-size: 13px;
}

.pill {
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.pill.consent {
  background: #dff1ea;
  color: var(--accent);
}

.pill.demo {
  background: #e3ecfa;
  color: var(--accent-3);
}

.pill.blocked {
  background: #fae4df;
  color: var(--accent-2);
}

.mini-button {
  border: 1px solid var(--line);
  background: #fbfcfb;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 800;
}

.section-head {
  margin-bottom: 16px;
}

.finder-grid,
.message-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
}

.panel {
  padding: 16px;
  display: grid;
  gap: 14px;
  align-content: start;
}

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

.map-search {
  display: grid;
  gap: 14px;
}

.search-notice {
  border: 1px solid #e4c06e;
  border-radius: 8px;
  background: #fff8e8;
  color: #6f4b00;
  font-size: 13px;
  font-weight: 800;
  padding: 12px 14px;
}

.result-map {
  min-height: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  z-index: 1;
}

.leaflet-popup-content {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.35;
}

.leaflet-popup-content a {
  color: var(--accent);
  font-weight: 800;
}

.data-checklist {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 9px;
}

.data-checklist legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  padding: 0 5px;
}

.data-checklist label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.data-checklist input {
  width: 16px;
  min-height: 16px;
}

.finder-card {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.finder-card.known-card {
  background: #f6f8f6;
}

.finder-card p {
  color: var(--muted);
  margin-bottom: 0;
  font-size: 13px;
}

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

.settings-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
}

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

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

.template-card.active-template {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(21, 108, 91, 0.12);
}

.template-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-line input {
  width: 16px;
  min-height: 16px;
}

.mini-button.danger {
  border-color: #e0a094;
  color: #8d2d1f;
}

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

.clients-map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 14px;
  margin-bottom: 14px;
}

.clients-map,
.map-side {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.clients-map {
  min-height: 280px;
  overflow: hidden;
  z-index: 1;
}

.map-side {
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.map-side h3 {
  font-size: 17px;
  margin-bottom: 0;
}

.map-side p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 0;
}

.clients-table {
  width: 100%;
  min-width: 1240px;
  border-collapse: collapse;
}

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

.clients-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.clients-table tbody tr {
  cursor: pointer;
}

.clients-table tbody tr:hover td,
.clients-table tbody tr.selected-client-row td {
  background: #eef6f1;
}

.clients-table td strong,
.clients-table td span {
  display: block;
}

.clients-table td span,
.contact-cell {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.clients-table a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.table-status {
  min-width: 155px;
}

.importance-select {
  min-width: 140px;
  font-weight: 800;
}

.importance-super_important {
  background: #fff1d6;
  border-color: #d99a22;
  color: #7a3e00;
}

.importance-important {
  background: #e5f3ff;
  border-color: #7fb4e3;
  color: #174f82;
}

.importance-low {
  background: #f3f5f2;
  color: #5d675f;
}

.importance-not_important {
  background: #fae8e4;
  border-color: #e0a094;
  color: #8d2d1f;
}

.importance-row.importance-super_important td {
  background: #fffaf0;
}

.importance-row.importance-important td {
  background: #f5fbff;
}

.importance-row.importance-low td {
  background: #fbfcfb;
}

.importance-row.importance-not_important td {
  opacity: 0.78;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 220px;
}

.offer-cell {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 7px;
  min-width: 220px;
}

.offer-input {
  min-height: 34px;
  padding: 7px 9px;
}

.importance-picker {
  max-width: 220px;
}

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

.task p {
  margin: 4px 0 0;
  color: var(--muted);
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(16, 24, 20, 0.42);
}

.dialog-card {
  padding: 20px;
  display: grid;
  gap: 16px;
}

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

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

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

  .sidebar {
    position: static;
    padding: 16px;
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .sidebar-note {
    display: none;
  }

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

  .finder-grid,
  .message-layout,
  .clients-map-layout,
  .activity-filters,
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .activity-filter-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

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

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

  .topbar-actions,
  .nav,
  .stats-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    display: grid;
  }

  h1 {
    font-size: 28px;
  }
}
