:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e0e8;
  --primary: #0f766e;
  --primary-dark: #0a5f59;
  --accent: #b45309;
  --blue: #2563eb;
  --yellow: #d69e2e;
  --green: #159947;
  --red: #dc2626;
  --shadow: 0 16px 38px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

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

a {
  color: inherit;
  text-decoration: none;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #101828;
  color: #ffffff;
  padding: 22px 18px;
}

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

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

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

.brand small {
  color: rgba(255, 255, 255, 0.68);
}

.main-nav {
  display: grid;
  gap: 6px;
  margin-top: 34px;
}

.main-nav a {
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.76);
  padding: 11px 12px;
}

.main-nav a:hover,
.main-nav a.active {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

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

.sidebar-footer span,
.sidebar-footer small {
  display: block;
}

.sidebar-footer small {
  color: rgba(255, 255, 255, 0.64);
  text-transform: capitalize;
}

.content {
  width: 100%;
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.topbar h1,
.record-header h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.18;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.notification-pill,
.phase-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  padding: 0 12px;
  white-space: nowrap;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  padding: 8px 13px;
  text-align: center;
}

.button.primary {
  background: var(--primary);
  color: #ffffff;
}

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

.button.secondary {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.button.ghost {
  border-color: transparent;
  background: #eef3f5;
  color: #213044;
}

.button.full {
  width: 100%;
}

.flash {
  margin: 0 0 16px;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 700;
}

.flash.success {
  background: #e7f8ef;
  color: #116034;
}

.flash.error {
  background: #fff1f1;
  color: #a11111;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel,
.record-header {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  min-height: 106px;
  align-content: center;
  gap: 6px;
  padding: 18px;
}

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

.metric strong {
  display: block;
  font-size: 26px;
  line-height: 1.1;
}

.two-columns,
.three-columns {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

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

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

.panel {
  min-width: 0;
  padding: 18px;
}

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

.panel-heading h2,
.form-section h3,
.map-side h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.filters,
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.form-grid.compact {
  grid-template-columns: repeat(2, minmax(150px, 1fr));
}

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

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(15, 118, 110, 0.14);
}

.form-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.prospect-form {
  display: grid;
  gap: 20px;
}

.form-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.form-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  vertical-align: middle;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

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

.status-badge,
.qualification {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  padding: 4px 9px;
  white-space: nowrap;
}

.status-open {
  background: #eaf1ff;
  color: #1d4ed8;
}

.status-demo {
  background: #fff5d6;
  color: #8a5a00;
}

.status-active {
  background: #ddf7e8;
  color: #0f6b36;
}

.status-refused {
  background: #ffe7e7;
  color: #b42318;
}

.qualification.hot {
  background: #ffe8cc;
  color: #b45309;
}

.qualification.warm {
  background: #fff6bf;
  color: #886400;
}

.qualification.cold {
  background: #e5e7eb;
  color: #4b5563;
}

.empty {
  margin: 0;
  color: var(--muted);
}

.conversion-row {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.conversion-row div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.conversion-row span {
  color: var(--muted);
  font-weight: 700;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

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

.notification-list article {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.notification-list article.unread {
  border-color: rgba(15, 118, 110, 0.35);
  background: #ecfdf9;
}

.notification-list span,
.notification-list small {
  color: var(--muted);
}

.record-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px;
}

.record-header p,
.back-link {
  color: var(--muted);
}

.back-link {
  display: inline-flex;
  margin-bottom: 8px;
  font-weight: 700;
}

.record-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.details {
  display: grid;
  gap: 12px;
  margin: 0;
}

.details div {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  gap: 12px;
}

.details dt {
  color: var(--muted);
  font-weight: 800;
}

.details dd {
  margin: 0;
}

.notes {
  margin: 0;
  color: #344054;
  line-height: 1.6;
}

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

.mini-metrics .metric {
  min-height: 92px;
  box-shadow: none;
}

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

.ranking-list article {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.rank {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: #101828;
  color: #ffffff;
  font-weight: 900;
}

.ranking-list small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.map-panel {
  padding-bottom: 18px;
}

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

.map-canvas {
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eaf0f4;
}

.map-side {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}

.legend {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.dot.blue {
  background: var(--blue);
}

.dot.yellow {
  background: var(--yellow);
}

.dot.green {
  background: var(--green);
}

.dot.red {
  background: var(--red);
}

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

.map-list article {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.map-list article span {
  color: var(--muted);
}

.leaflet-popup-content {
  min-width: 230px;
}

.popup-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.popup-form input {
  min-height: 34px;
  padding: 7px 8px;
}

.popup-form .button {
  min-height: 34px;
}

.login-body {
  background: #101828;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
}

.login-panel {
  display: grid;
  align-content: center;
  gap: 24px;
  background: #ffffff;
  padding: 42px;
}

.login-brand .brand-mark {
  background: #101828;
}

.login-brand small {
  color: var(--muted);
}

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

.demo-logins {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 14px;
}

.demo-logins strong {
  color: var(--ink);
}

.login-side {
  display: grid;
  align-content: center;
  max-width: 820px;
  color: #ffffff;
  padding: 64px;
}

.login-side h1 {
  max-width: 680px;
  margin: 0;
  font-size: 54px;
  line-height: 1.04;
}

.login-side p {
  max-width: 620px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 18px;
  line-height: 1.6;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .three-columns,
  .map-layout {
    grid-template-columns: 1fr;
  }

  .map-canvas {
    min-height: 520px;
  }
}

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

  .sidebar {
    position: relative;
    height: auto;
  }

  .main-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 18px;
  }

  .sidebar-footer {
    display: none;
  }

  .content {
    padding: 18px;
  }

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

  .two-columns,
  .filters,
  .form-grid,
  .form-grid.compact,
  .mini-metrics,
  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-side {
    display: none;
  }
}

@media (max-width: 620px) {
  .content,
  .login-panel {
    padding: 16px;
  }

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

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

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

  .notification-pill,
  .top-actions .button {
    width: 100%;
  }

  .details div {
    grid-template-columns: 1fr;
  }
}
