:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --panel-soft: rgba(5, 5, 5, 0.035);
  --line: rgba(5, 5, 5, 0.1);
  --line-strong: rgba(5, 5, 5, 0.18);
  --text: #080807;
  --muted: rgba(8, 8, 7, 0.56);
  --dark-text: #050505;
  --gold: #111111;
  --green: #16834a;
  --red: #ff7a7a;
  --orange: #b46a15;
  --accent-panel: #0d0d0d;
  --accent-text: #ffffff;
  --accent-muted: rgba(255, 255, 255, 0.62);
  --accent-bar: #ffffff;
  --radius: 8px;
  --shadow: 0 18px 44px rgba(20, 17, 10, 0.08);
}

body.theme-dark {
  color-scheme: dark;
  --bg: #050505;
  --panel: rgba(17, 17, 17, 0.82);
  --panel-solid: #111111;
  --panel-soft: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f5f5f2;
  --muted: rgba(245, 245, 242, 0.62);
  --gold: #ffffff;
  --green: #72e0a2;
  --red: #ff7a7a;
  --orange: #f6b15d;
  --accent-panel: #ffffff;
  --accent-text: #050505;
  --accent-muted: rgba(5, 5, 5, 0.55);
  --accent-bar: #050505;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: #ffffff;
  color: var(--text);
  font-family: "Manrope", system-ui, sans-serif;
  letter-spacing: 0;
}

body.theme-dark {
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.08), transparent 30rem),
    radial-gradient(circle at 90% 12%, rgba(255, 255, 255, 0.09), transparent 28rem),
    linear-gradient(135deg, #030303 0%, #0c0c0c 42%, #050505 100%);
}

button {
  font: inherit;
}

.ambient {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  filter: blur(36px);
  opacity: 0.42;
}

body:not(.theme-dark) .ambient {
  display: none;
}

.ambient-one {
  width: 34rem;
  height: 18rem;
  top: -9rem;
  left: 18rem;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.035), rgba(255, 255, 255, 0.72));
  transform: rotate(-12deg);
}

.ambient-two {
  right: -8rem;
  bottom: 12rem;
  width: 30rem;
  height: 30rem;
  border: 1px solid rgba(5, 5, 5, 0.08);
  background:
    repeating-linear-gradient(90deg, rgba(5, 5, 5, 0.035) 0 1px, transparent 1px 13px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(0, 0, 0, 0.025));
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 17.5rem minmax(0, 1fr);
  width: min(100%, 1600px);
  min-height: 100vh;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  height: 100vh;
  padding: 1.35rem;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--dark-text);
  font-family: "DM Sans", system-ui, sans-serif;
  font-weight: 800;
}

.brand-mark img {
  display: block;
  width: 1.55rem;
  height: 1.55rem;
  object-fit: contain;
}

.brand strong,
h1,
h2,
.metric-card strong {
  font-family: "DM Sans", system-ui, sans-serif;
}

.brand small {
  display: block;
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.nav-stack {
  display: grid;
  gap: 0.45rem;
}

.nav-item,
.icon-button,
.primary-button,
.secondary-button,
.date-select,
.segmented button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

.nav-item {
  justify-content: flex-start;
  gap: 0.65rem;
  min-height: 2.75rem;
  padding: 0 0.85rem;
  background: transparent;
  color: var(--muted);
}

.nav-item.active,
.nav-item:hover {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

.nav-item svg,
.icon-button svg,
.primary-button svg,
.secondary-button svg,
.funnel-card-head svg {
  width: 1rem;
  height: 1rem;
  stroke-width: 1.8;
}

.source-card {
  margin-top: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.42));
}

.source-card-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.source-card strong {
  display: block;
  margin-top: 0.75rem;
  font-size: 1rem;
}

.source-card p {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.pulse {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(114, 224, 162, 0.12);
}

.dashboard {
  display: grid;
  gap: 1rem;
  padding: 1.35rem;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem 0 0.5rem;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 34rem;
  font-size: clamp(1.45rem, 2.2vw, 2.25rem);
  line-height: 1;
}

h2 {
  font-size: 1.15rem;
  line-height: 1.12;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.65rem;
}

.icon-button {
  width: 2.75rem;
  height: 2.75rem;
  border-color: var(--line);
  background: var(--panel-solid);
  color: var(--text);
}

.primary-button,
.secondary-button,
.date-select {
  gap: 0.45rem;
  min-height: 2.75rem;
  padding: 0 1rem;
  white-space: nowrap;
}

.primary-button {
  border-color: #080807;
  background: #080807;
  color: #ffffff;
  font-weight: 800;
}

body.theme-dark .primary-button,
body.theme-dark .segmented button.active {
  border-color: #ffffff;
  background: #ffffff;
  color: #050505;
}

body.theme-dark .source-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.04));
}

.secondary-button {
  border-color: var(--line);
  background: var(--panel-solid);
  color: var(--text);
}

.date-select {
  border-color: var(--line);
  background: #080807;
  color: #ffffff;
  font-weight: 800;
}

.date-select select {
  min-width: 9.5rem;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  appearance: none;
}

.date-select select option {
  background: #ffffff;
  color: #080807;
}

body.theme-dark .date-select {
  border-color: #ffffff;
  background: #ffffff;
  color: #050505;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.metric-card {
  min-height: 8.8rem;
  padding: 1.05rem;
  background: var(--panel-solid);
}

.metric-card span,
.client-summary span,
.funnel-card span,
.source-item span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 1.25rem;
  font-size: clamp(1.65rem, 2.6vw, 2.55rem);
  line-height: 0.92;
}

.metric-card small {
  display: block;
  margin-top: 0.7rem;
  font-size: 0.78rem;
}

.positive {
  color: var(--green);
}

.warning {
  color: var(--orange);
}

.danger {
  color: var(--red);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(22rem, 0.78fr);
  gap: 0.85rem;
}

.panel {
  padding: 1rem;
  background: var(--panel);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-header.compact {
  align-items: center;
}

.segmented {
  display: flex;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.segmented button {
  min-width: 2.7rem;
  height: 2rem;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.segmented button.active {
  background: #080807;
  color: #ffffff;
}

.client-list {
  display: grid;
  gap: 0.6rem;
}

.client-row {
  display: grid;
  grid-template-columns: minmax(9rem, 1.4fr) repeat(4, minmax(5.8rem, 0.8fr)) auto;
  gap: 0.8rem;
  align-items: center;
  min-height: 5rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.client-row:hover,
.client-row.active {
  border-color: rgba(5, 5, 5, 0.22);
  background: rgba(5, 5, 5, 0.045);
}

.client-name strong {
  display: block;
  font-size: 1rem;
}

.client-name span,
.client-stat span {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.client-stat strong {
  font-size: 0.95rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.8rem;
  padding: 0 0.65rem;
  border: 1px solid rgba(246, 177, 93, 0.45);
  border-radius: 999px;
  background: rgba(246, 177, 93, 0.12);
  color: var(--orange);
  font-size: 0.72rem;
  font-weight: 800;
}

.status-pill.good {
  border-color: rgba(114, 224, 162, 0.4);
  background: rgba(114, 224, 162, 0.12);
  color: var(--green);
}

.status-pill.critical {
  border-color: rgba(255, 122, 122, 0.4);
  background: rgba(255, 122, 122, 0.12);
  color: var(--red);
}

.client-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.client-summary div {
  min-height: 5.4rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
}

.client-summary strong {
  display: block;
  margin-top: 0.95rem;
  font-size: 1.25rem;
}

.funnel-card {
  margin-top: 0.8rem;
  padding: 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--accent-panel);
  color: var(--accent-text);
}

.funnel-card span {
  color: var(--accent-muted);
}

.funnel-card-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.funnel-card-head strong {
  display: block;
  margin-top: 0.25rem;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 1.3rem;
}

.funnel-steps {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.step-row {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) minmax(8rem, 1.25fr) auto;
  gap: 0.75rem;
  align-items: center;
}

.step-label {
  font-size: 0.8rem;
  font-weight: 800;
}

.step-bar {
  height: 0.58rem;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-text) 14%, transparent);
}

.step-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-bar);
}

.step-value {
  font-size: 0.8rem;
  font-weight: 900;
}

.decision-card {
  margin-top: 0.8rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
}

.decision-card span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.decision-card p {
  margin: 0.55rem 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.sources-panel {
  margin-bottom: 1rem;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.65rem;
}

.source-item {
  min-height: 7rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
}

.source-item strong {
  display: block;
  margin-top: 1.2rem;
  font-size: 0.95rem;
}

.source-item em {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
}

.settings-panel {
  margin-bottom: 1rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(16rem, 0.72fr) minmax(0, 1.28fr);
  gap: 0.85rem;
}

.customer-settings-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.settings-card {
  min-height: 13rem;
  padding: 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
}

.settings-card.global {
  background: #080807;
  color: #ffffff;
}

body.theme-dark .settings-card.global {
  background: #ffffff;
  color: #050505;
}

.settings-card-head span,
.settings-row span,
.integration-row span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.settings-card.global .settings-card-head span,
.settings-card.global .settings-row span {
  color: rgba(255, 255, 255, 0.62);
}

body.theme-dark .settings-card.global .settings-card-head span,
body.theme-dark .settings-card.global .settings-row span {
  color: rgba(5, 5, 5, 0.55);
}

.settings-card-head strong {
  display: block;
  margin-top: 0.3rem;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 1.15rem;
}

.settings-card p {
  margin: 1rem 0;
  color: var(--muted);
  line-height: 1.5;
}

.settings-card.global p {
  color: rgba(255, 255, 255, 0.72);
}

body.theme-dark .settings-card.global p {
  color: rgba(5, 5, 5, 0.62);
}

.settings-row,
.integration-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.8rem;
  border-top: 1px solid var(--line);
}

.settings-card.global .settings-row {
  border-top-color: rgba(255, 255, 255, 0.18);
}

body.theme-dark .settings-card.global .settings-row {
  border-top-color: rgba(5, 5, 5, 0.14);
}

.integration-list {
  display: grid;
  margin-top: 0.8rem;
}

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

.integration-row em {
  color: var(--text);
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .source-card {
    margin-top: 0;
  }

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

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

  .settings-grid,
  .customer-settings-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .dashboard,
  .sidebar {
    padding: 1rem;
  }

  .topbar,
  .panel-header {
    flex-direction: column;
  }

  .top-actions,
  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .metric-grid,
  .workspace-grid,
  .source-grid,
  .settings-grid,
  .customer-settings-list,
  .client-summary,
  .nav-stack {
    grid-template-columns: 1fr;
  }

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

  .client-name {
    grid-column: 1 / -1;
  }

  .step-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }
}
