:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fbfc;
  --ink: #17202a;
  --muted: #647181;
  --line: #dde5ec;
  --line-strong: #cbd6df;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #dff4f1;
  --green: #31734d;
  --blue: #2563a8;
  --amber: #9a5a16;
  --warning: #8a4b12;
  --warning-soft: #fff4df;
  --shadow: 0 18px 48px rgba(28, 43, 58, 0.08);
  --shadow-soft: 0 10px 28px rgba(28, 43, 58, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef5f4 0, rgba(238, 245, 244, 0) 260px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

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

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 4px;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

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

.login-form {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

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

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: #ffffff;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: none;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.button.secondary {
  background: #ffffff;
  color: var(--accent);
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.08);
}

.button.secondary:hover {
  background: var(--accent-soft);
}

.button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.button.ghost:hover {
  background: #eef2f5;
}

.alert {
  margin: 18px 0 0;
  border: 1px solid #efc48e;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--warning-soft);
  color: var(--warning);
  font-weight: 700;
}

.dashboard-shell {
  width: min(1260px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  border: 1px solid rgba(221, 229, 236, 0.9);
  border-radius: 8px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

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

.topbar-actions form {
  margin: 0;
}

.summary-grid,
.analytics-grid {
  display: grid;
  gap: 16px;
}

.filters-panel {
  margin-bottom: 16px;
  padding: 16px;
}

.filters-form {
  display: grid;
  grid-template-columns: minmax(210px, 1.35fr) repeat(3, minmax(142px, 1fr));
  gap: 13px;
  align-items: end;
}

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

.filter-actions button,
.filter-actions .button {
  width: 100%;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

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

.wide-panel {
  grid-column: 1 / -1;
}

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

.metric-panel {
  position: relative;
  overflow: hidden;
  padding: 20px;
}

.metric-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.metric-panel span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.metric-panel strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 1.1;
}

.panel {
  padding: 20px;
}

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

.panel-heading h2 {
  color: #111827;
}

.breakdown-list {
  display: grid;
  gap: 13px;
}

.breakdown-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.9rem;
}

.breakdown-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.breakdown-meta strong {
  color: var(--ink);
}

.meter {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef3;
}

.meter span {
  display: block;
  height: 100%;
  min-width: 4px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--green));
}

.trend-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(36px, 1fr));
  align-items: end;
  gap: 12px;
  min-height: 204px;
  overflow-x: auto;
  border-radius: 8px;
  padding: 12px 4px 2px;
  background: linear-gradient(180deg, #fbfcfd, #ffffff);
}

.trend-item {
  display: grid;
  grid-template-rows: 140px auto;
  gap: 8px;
  min-width: 36px;
}

.trend-bar {
  align-self: end;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 10px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--blue), var(--accent));
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 800;
  padding-top: 5px;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.18);
}

.trend-item small {
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
  overflow-wrap: anywhere;
}

.funnel-list {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
  overflow-x: auto;
}

.funnel-row {
  display: grid;
  gap: 12px;
  min-height: 136px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-soft);
}

.funnel-count strong {
  display: block;
  color: var(--ink);
  font-size: 2rem;
  line-height: 1;
}

.funnel-count span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.funnel-rate {
  align-self: end;
  display: grid;
  gap: 3px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
}

.funnel-rate small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

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

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  background: #ffffff;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

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

tbody tr:hover {
  background: #fbfdfd;
}

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

.status-form {
  display: grid;
  gap: 8px;
  min-width: 150px;
}

.status-form select {
  padding: 9px 10px;
  background: var(--panel-soft);
}

.status-form button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.84rem;
}

.lead-detail {
  min-width: 180px;
}

.lead-detail summary {
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
  list-style-position: outside;
}

.lead-detail dl {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
}

.lead-detail dl div {
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

.lead-detail dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.lead-detail dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

td a {
  color: var(--accent);
  font-weight: 700;
  text-underline-offset: 3px;
}

@media (max-width: 760px) {
  .dashboard-shell {
    width: min(100% - 24px, 1260px);
    padding-top: 16px;
  }

  .topbar,
  .topbar-actions {
    display: grid;
    width: 100%;
  }

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

  .topbar {
    padding: 18px;
  }

  .topbar-actions .button,
  .topbar-actions button {
    width: 100%;
  }

  .summary-grid,
  .analytics-grid,
  .filters-form {
    grid-template-columns: 1fr;
  }

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

  .login-panel {
    padding: 24px;
  }
}
