:root {
  --ink: #172033;
  --muted: #657083;
  --line: #d9e0ea;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --page: #eef2f6;
  --teal: #087f8c;
  --teal-dark: #056270;
  --indigo: #4051b5;
  --amber: #c77800;
  --rose: #b4235a;
  --green: #217a45;
  --shadow: 0 18px 40px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--page);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #162032;
  color: #f8fbff;
  overflow-y: auto;
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #2cb1bc;
  color: #08121d;
  font-weight: 900;
}

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

.brand span {
  margin-top: 2px;
  color: #b9c4d3;
  font-size: 0.82rem;
}

.nav-stack {
  display: grid;
  gap: 6px;
  margin-bottom: 28px;
}

.nav-link {
  display: block;
  padding: 11px 12px;
  border-radius: 8px;
  color: #dfe7f2;
  text-decoration: none;
}

.nav-link.active,
.nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.role-panel {
  display: grid;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.role-panel h2 {
  margin: 0;
  font-size: 0.92rem;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.side-nav label {
  color: #c7d1df;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 140, 0.15);
}

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

.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.top-bar h1,
.section-title h2,
.email-band h2 {
  margin: 0;
}

.top-bar h1 {
  max-width: 780px;
  font-size: clamp(1.7rem, 2.2vw, 2.55rem);
  line-height: 1.08;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal-dark);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.top-actions,
.filter-actions,
.email-controls {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.solid-button,
.ghost-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 13px;
  font-weight: 850;
  white-space: nowrap;
}

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

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

.solid-button.secondary {
  background: var(--indigo);
}

.solid-button.secondary:hover {
  background: #2d3e9e;
}

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

.ghost-button:hover {
  border-color: #b9c4d3;
  background: #f9fbfe;
}

.filter-band,
.section-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.filter-band {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
  padding: 18px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 14px;
}

.section-block {
  margin-bottom: 18px;
  padding: 20px;
  scroll-margin-top: 16px;
}

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

.section-title.compact {
  margin-bottom: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 6px 11px;
  background: #edf7f8;
  color: var(--teal-dark);
  font-size: 0.82rem;
  font-weight: 900;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
}

.kpi-card {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  background: var(--surface-soft);
}

.kpi-card strong {
  display: block;
  margin: 8px 0;
  font-size: clamp(1.35rem, 2vw, 2rem);
  line-height: 1.05;
}

.kpi-card span {
  color: var(--muted);
  font-size: 0.86rem;
}

.kpi-tone-teal {
  border-top: 4px solid var(--teal);
}

.kpi-tone-green {
  border-top: 4px solid var(--green);
}

.kpi-tone-amber {
  border-top: 4px solid var(--amber);
}

.kpi-tone-indigo {
  border-top: 4px solid var(--indigo);
}

.kpi-tone-rose {
  border-top: 4px solid var(--rose);
}

.two-column,
.split-analytics {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
}

.funnel-chart {
  display: grid;
  gap: 10px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 86px 74px;
  align-items: center;
  gap: 10px;
}

.funnel-label {
  font-weight: 850;
}

.funnel-track {
  height: 34px;
  border-radius: 8px;
  background: #edf1f6;
  overflow: hidden;
}

.funnel-fill {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 34px;
  height: 100%;
  border-radius: 8px;
  padding-right: 10px;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 900;
}

.insight-panel {
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  padding: 16px;
  background: #fffaf1;
}

.insight-panel h3 {
  margin: 0 0 14px;
}

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

.insight-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(199, 120, 0, 0.22);
  padding-bottom: 10px;
}

.insight-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.insight-item strong {
  display: block;
}

.insight-item span {
  color: var(--muted);
  font-size: 0.84rem;
}

.chart-surface,
.data-summary {
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface-soft);
}

.chart-surface svg {
  display: block;
  width: 100%;
  height: auto;
}

.segmented-control {
  display: inline-flex;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  background: #ffffff;
}

.segmented-control button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 7px 10px;
  color: var(--muted);
  font-weight: 850;
}

.segmented-control button.active {
  background: var(--teal);
  color: #ffffff;
}

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

.bar-row {
  display: grid;
  grid-template-columns: minmax(96px, 160px) 1fr 66px;
  align-items: center;
  gap: 10px;
}

.bar-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.bar-track {
  height: 30px;
  border-radius: 8px;
  background: #e8edf4;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 8px;
  background: var(--indigo);
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
}

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

.summary-table th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.email-band {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(320px, 1.2fr);
  align-items: end;
  gap: 18px;
}

.muted-copy {
  margin: 8px 0 0;
  color: var(--muted);
}

.status-line {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--green);
  font-weight: 850;
}

.table-section {
  padding-bottom: 12px;
}

.table-wrap {
  overflow: 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: 12px 11px;
  text-align: left;
  vertical-align: middle;
}

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

th[data-sort] {
  cursor: pointer;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f5fbfc;
}

.client-cell strong,
.client-cell span {
  display: block;
}

.client-cell span,
.subtle-cell {
  color: var(--muted);
  font-size: 0.84rem;
}

.stage-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 0.76rem;
  font-weight: 900;
  white-space: nowrap;
}

.stage-badge {
  background: #eef4ff;
  color: var(--indigo);
}

.status-finalizat {
  background: #e9f7ef;
  color: var(--green);
}

.status-in-lucru {
  background: #edf7f8;
  color: var(--teal-dark);
}

.status-pierdut {
  background: #fdebf2;
  color: var(--rose);
}

.journey-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 190px;
}

.journey-dot {
  width: 18px;
  height: 18px;
  border: 2px solid #c8d2df;
  border-radius: 50%;
  background: #ffffff;
}

.journey-dot.done {
  border-color: var(--teal);
  background: var(--teal);
}

.journey-dot.current {
  border-color: var(--amber);
  background: var(--amber);
}

.journey-dot.lost {
  border-color: var(--rose);
  background: var(--rose);
}

.details-drawer {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 20px;
  border-left: 1px solid var(--line);
  background: #ffffff;
  overflow-y: auto;
}

.drawer-close {
  float: right;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 1.2rem;
}

.details-drawer h2 {
  margin: 4px 0 8px;
}

.detail-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.detail-stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.detail-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.detail-stat strong {
  display: block;
  margin-top: 4px;
}

.timeline {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.timeline-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
}

.timeline-marker {
  width: 14px;
  height: 14px;
  margin-top: 4px;
  border-radius: 50%;
  background: #c8d2df;
}

.timeline-item.done .timeline-marker {
  background: var(--teal);
}

.timeline-item.current .timeline-marker {
  background: var(--amber);
}

.timeline-item.lost .timeline-marker {
  background: var(--rose);
}

.offer-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.offer-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

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

.offer-row span {
  color: var(--muted);
  font-size: 0.84rem;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 5;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #172033;
  color: #ffffff;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1360px) {
  .app-shell {
    grid-template-columns: 242px minmax(0, 1fr);
  }

  .details-drawer {
    position: fixed;
    inset: auto 18px 18px auto;
    z-index: 4;
    display: none;
    width: min(420px, calc(100vw - 36px));
    height: min(760px, calc(100vh - 36px));
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }

  .details-drawer.open {
    display: block;
  }
}

@media (max-width: 1040px) {
  .app-shell {
    display: block;
  }

  .side-nav {
    position: static;
    height: auto;
  }

  .nav-stack {
    grid-template-columns: repeat(3, 1fr);
  }

  .filter-grid,
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .two-column,
  .split-analytics,
  .email-band {
    grid-template-columns: 1fr;
  }

  .top-bar,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }
}

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

  .filter-grid,
  .kpi-grid,
  .nav-stack {
    grid-template-columns: 1fr;
  }

  .funnel-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

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

  .segmented-control {
    width: 100%;
  }

  .segmented-control button {
    flex: 1;
  }
}
