:root {
  --bg: #f4f7fb;
  --sidebar: #ffffff;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #dbe3ee;
  --ink: #111827;
  --muted: #64748b;
  --soft: #94a3b8;
  --green: #10b981;
  --cyan: #0ea5e9;
  --amber: #f59e0b;
  --purple: #8b5cf6;
  --red: #ef4444;
  --blue: #2563eb;
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef7ff 0%, #f7fbf7 48%, #fff7ed 100%);
}

.login-card {
  width: min(460px, 100%);
  display: grid;
  gap: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 34px;
}

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

.logo-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #dcfce7;
  color: #047857;
  font-weight: 950;
}

.logo-row small,
.sidebar-footer small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.overline,
.panel-kicker {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-size: 34px;
  line-height: 1.05;
}

h2 {
  margin-bottom: 4px;
  font-size: 28px;
  line-height: 1.15;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
}

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

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

input,
select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

input:focus,
select:focus {
  outline: 3px solid rgba(37, 99, 235, 0.14);
  border-color: var(--blue);
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 850;
  padding: 0 16px;
}

.secondary-button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 34px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 28px 16px;
}

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

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-start;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item span {
  width: 18px;
  text-align: center;
  color: inherit;
}

.nav-item.active {
  background: #eff6ff;
  color: var(--blue);
}

.nav-item.locked {
  display: none;
}

.sidebar-footer {
  display: grid;
  gap: 14px;
  margin-top: auto;
}

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

.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 32px;
}

.agent-title {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
}

.topbar-tools,
.filters-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-periods {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.quick-periods button {
  min-height: 32px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
}

.quick-periods button.active {
  background: #eff6ff;
  color: var(--blue);
}

.connection-pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 0 12px;
}

.connection-pill.ok {
  color: #047857;
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.connection-pill.error {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 34px 32px 22px;
}

.date-filter {
  width: 156px;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

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

.date-filter input {
  width: 100%;
  min-height: 34px;
  border: 0;
  padding: 0;
  background: transparent;
}

.search-input {
  width: min(320px, 32vw);
}

.month-input {
  width: 150px;
}

.conversion-filter {
  width: 160px;
}

.period-controls {
  display: flex;
  align-items: end;
  gap: 10px;
}

.period-controls label {
  min-width: 140px;
}

.view,
.alert-panel {
  margin: 0 32px;
}

.alert-panel {
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fef2f2;
  color: #991b1b;
  padding: 16px;
  margin-bottom: 18px;
}

.alert-panel p {
  margin: 8px 0 0;
  color: #b91c1c;
  font-size: 13px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.pipeline-panel {
  padding: 26px 24px 22px;
}

.pipeline {
  display: grid;
  justify-items: center;
  gap: 22px;
  padding: 12px 0 4px;
}

.funnel-row {
  height: 52px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  border-radius: 8px;
  clip-path: polygon(2% 0, 98% 0, 94% 100%, 6% 100%);
}

.funnel-row small {
  font-size: 12px;
  opacity: 0.9;
  margin-right: 12px;
  text-transform: uppercase;
}

.funnel-row strong {
  font-size: 17px;
}

.funnel-row.leads {
  width: 96%;
  background: var(--cyan);
}

.funnel-row.answered {
  width: 84%;
  background: var(--amber);
}

.funnel-row.qualified {
  width: 66%;
  background: var(--green);
}

.funnel-row.scheduled {
  width: 56%;
  background: var(--purple);
}

.funnel-row.r2 {
  width: 28%;
  background: #14b8a6;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

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

.metric-card {
  min-height: 132px;
  display: grid;
  align-content: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.metric-card strong {
  color: var(--green);
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0;
}

.metric-card strong.purple {
  color: var(--purple);
}

.metric-card strong.red {
  color: var(--red);
}

.metric-card strong.blue {
  color: var(--blue);
}

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

.panel-header {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.panel-header.inline-header {
  border-bottom: 0;
  padding-bottom: 0;
}

.panel-header p {
  margin: 4px 0 0;
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 11px;
  text-transform: uppercase;
}

td {
  color: #334155;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  font-weight: 850;
  padding: 3px 9px;
}

.badge.good {
  background: #dcfce7;
  color: #047857;
}

.badge.blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge.warn {
  background: #fef3c7;
  color: #b45309;
}

.badge.red {
  background: #fee2e2;
  color: #b91c1c;
}

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

.chart-card {
  min-height: 314px;
  padding: 24px;
}

.wide-card,
.finance-chart-card {
  grid-column: 1 / -1;
}

.finance-chart-card {
  margin: 20px 0;
}

.marketing-panel {
  margin-top: 20px;
}

.marketing-inputs {
  display: flex;
  align-items: end;
  gap: 10px;
}

.marketing-inputs label {
  min-width: 150px;
}

.marketing-grid {
  margin: 0;
  padding: 18px;
}

.bar-chart {
  display: grid;
  gap: 14px;
  margin-top: 26px;
}

.bar-row {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.bar-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 18px;
  overflow: hidden;
  border-radius: 5px;
  background: #edf2f7;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 5px;
  background: var(--green);
}

.heatmap {
  display: grid;
  grid-template-columns: 48px repeat(12, minmax(34px, 1fr));
  gap: 6px;
  margin-top: 24px;
}

.heatmap-24 {
  grid-template-columns: 48px repeat(24, minmax(28px, 1fr));
  overflow-x: auto;
}

.heatmap-axis,
.heatmap-day {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.heatmap-day {
  display: grid;
  place-items: center;
  text-align: right;
}

.heat-cell {
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #eef2f7;
  color: #0f172a;
  font-size: 11px;
  font-weight: 800;
}

.heat-cell.level-1 {
  background: #dbeafe;
}

.heat-cell.level-2 {
  background: #bfdbfe;
}

.heat-cell.level-3 {
  background: #93c5fd;
}

.heat-cell.level-4 {
  background: #60a5fa;
  color: #fff;
}

.heat-cell.level-5 {
  background: #2563eb;
  color: #fff;
}

.revenue-chart {
  min-height: 220px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: end;
  gap: 18px;
  padding: 20px 12px 4px;
}

.revenue-bar {
  display: grid;
  justify-items: center;
  align-items: end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.revenue-column {
  width: min(52px, 70%);
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(180deg, var(--blue), var(--cyan));
}

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

.combo-chart,
.stage-chart {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.combo-row,
.stage-bar {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 150px;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.combo-track,
.stage-track {
  position: relative;
  height: 24px;
  overflow: hidden;
  border-radius: 7px;
  background: #eef2f7;
}

.combo-track i,
.stage-track i {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: 7px;
}

.combo-leads {
  background: #bfdbfe;
}

.combo-conversion {
  height: 8px !important;
  top: 8px !important;
  background: var(--green);
}

.combo-row strong,
.stage-bar b {
  color: var(--ink);
  font-size: 12px;
  text-align: right;
}

.stage-bar {
  grid-template-columns: 170px minmax(0, 1fr) 64px;
}

.stage-label {
  display: grid;
  gap: 2px;
}

.stage-label strong {
  color: var(--ink);
  font-size: 12px;
}

.stage-label span {
  color: var(--muted);
  font-size: 11px;
}

.stage-track i {
  background: var(--green);
}

.followup-section {
  margin-top: 18px;
  margin-bottom: 18px;
}

.empty-state {
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

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

  .analysis-grid,
  .finance-grid {
    grid-template-columns: 1fr;
  }
}

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

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

  .page-head,
  .topbar,
  .filters-row {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input,
  .date-filter,
  .month-input,
  .conversion-filter,
  .quick-periods,
  .period-controls,
  .period-controls label {
    width: 100%;
  }

  .quick-periods {
    flex-wrap: wrap;
  }

  .period-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .marketing-inputs {
    align-items: stretch;
    flex-direction: column;
  }

  .marketing-inputs label {
    width: 100%;
  }

  .view,
  .alert-panel {
    margin: 0 18px;
  }

  .page-head,
  .topbar {
    padding-left: 18px;
    padding-right: 18px;
  }

  .metric-grid,
  .metric-grid.compact,
  .revenue-chart {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 110px minmax(0, 1fr) 32px;
  }

  .heatmap {
    overflow-x: auto;
    grid-template-columns: 42px repeat(12, 42px);
  }

  .heatmap-24 {
    grid-template-columns: 42px repeat(24, 38px);
  }

  .combo-row,
  .stage-bar {
    grid-template-columns: 1fr;
  }

  .combo-row strong,
  .stage-bar b {
    text-align: left;
  }
}
