:root {
  --bg: #f7f8f6;
  --surface: #ffffff;
  --surface-soft: #fbf4f1;
  --surface-sage: #eef6f0;
  --ink: #22252d;
  --muted: #6f7480;
  --border: #e6dfd8;
  --rose: #7b294d;
  --rose-deep: #68213f;
  --sage: #27795b;
  --sage-soft: #dcefe4;
  --blue: #3d78a6;
  --taupe: #a98f7f;
  --terracotta: #b7754d;
  --warning: #c98b24;
  --shadow: 0 18px 45px rgba(35, 32, 28, 0.07);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
  padding: 24px 16px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, #fff 0%, #fbf2f1 58%, #eef7f2 100%);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  align-items: center;
}

.brand strong {
  display: block;
  font-family: Newsreader, Georgia, serif;
  font-size: 22px;
  line-height: 1;
}

.brand small,
.source-box small,
.topbar p,
.panel-header p {
  color: var(--muted);
}

.brand-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border: 1px solid #eadfd8;
  border-radius: 8px;
  background: #fbf7f4;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  color: #3c4149;
  background: transparent;
  font-size: 14px;
  font-weight: 650;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  color: var(--rose-deep);
  background: #ead6d4;
  box-shadow: inset 0 0 0 1px rgba(123, 41, 77, 0.06);
}

.nav-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  padding: 5px;
  border: 1px solid rgba(123, 41, 77, 0.08);
  border-radius: 8px;
  color: var(--taupe);
  background: rgba(255, 255, 255, 0.58);
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.nav button:hover .nav-icon,
.nav button.active .nav-icon {
  color: var(--rose-deep);
  border-color: rgba(123, 41, 77, 0.16);
  background: rgba(255, 255, 255, 0.78);
}

.nav button:hover .nav-icon {
  transform: translateY(-1px);
}

.calendar::before {
  inset: 3px 2px 2px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.calendar::after {
  left: 5px;
  right: 5px;
  top: 7px;
  border-top: 2px solid currentColor;
}

.source-box {
  margin-top: auto;
  padding: 14px;
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.source-box strong {
  display: block;
  font-size: 13px;
}

.source-dot {
  width: 10px;
  height: 10px;
  margin-top: 3px;
  border-radius: 50%;
  background: var(--sage);
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.wordmark {
  width: clamp(142px, 13vw, 210px);
  height: 74px;
  object-fit: contain;
  object-position: center;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(35, 32, 28, 0.04);
}

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

h1,
h2 {
  font-family: Newsreader, Georgia, serif;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 3.4vw, 48px);
  line-height: 0.94;
  overflow-wrap: break-word;
}

h2 {
  font-size: 21px;
  line-height: 1.1;
}

.topbar p {
  margin-top: 8px;
  font-size: 15px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  max-width: 540px;
}

.period-switch,
.status-chip {
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 0 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(35, 32, 28, 0.04);
}

.period-switch {
  display: flex;
  min-width: 0;
  max-width: 100%;
  padding: 3px;
  gap: 3px;
}

.period-switch button {
  flex: 1;
  min-width: 48px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.period-switch button.active {
  color: var(--rose-deep);
  background: #f0dddd;
}

.period-note {
  margin: -8px 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status-chip span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-chip.ok span {
  background: var(--sage);
}

.status-chip.warn span {
  background: var(--warning);
}

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

.view-screen {
  display: none;
}

.view-screen.active {
  display: block;
}

.screen-grid {
  display: grid;
  gap: 14px;
  align-items: start;
}

.overview-layout {
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
}

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

.kpi-card,
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi-card {
  min-height: 132px;
  padding: 17px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--rose-deep);
  background: var(--surface-soft);
  font-weight: 900;
}

.kpi-value {
  margin-top: 14px;
  font-family: Newsreader, Georgia, serif;
  font-size: clamp(24px, 2vw, 30px);
  line-height: 1;
  font-weight: 700;
  overflow-wrap: normal;
}

.kpi-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.kpi-note.positive {
  color: var(--sage);
}

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

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

.panel-header p {
  margin-top: 5px;
  font-size: 13px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bar-key,
.line-key {
  display: inline-block;
  width: 16px;
  height: 8px;
  border-radius: 2px;
  background: rgba(123, 41, 77, 0.42);
}

.line-key {
  height: 3px;
  background: var(--ink);
}

.line-key.sage {
  background: var(--sage);
}

.trend-chart {
  width: 100%;
  min-height: 310px;
}

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

.axis text,
.chart-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.period-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.period-summary div {
  min-width: 0;
}

.period-summary span,
.commercial-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.period-summary strong,
.commercial-card strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.table-wrap {
  overflow-x: auto;
}

.campaign-panel {
  margin-bottom: 14px;
}

.campaign-panel table {
  min-width: 780px;
}

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

th {
  color: var(--muted);
  font-size: 11px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0;
}

td,
th {
  padding: 11px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

td strong {
  display: block;
  max-width: 180px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

td {
  overflow-wrap: anywhere;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--sage);
  font-size: 12px;
  font-weight: 800;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sage);
}

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

.funnel-step {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.funnel-step.measured {
  background: var(--surface-sage);
}

.funnel-step .bubble {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--rose-deep);
  border: 1px solid var(--border);
  font-weight: 900;
}

.funnel-step h3 {
  font-size: 13px;
  margin-bottom: 2px;
}

.funnel-step p {
  color: var(--muted);
  font-size: 12px;
}

.funnel-step strong {
  font-size: 18px;
}

.recommendations {
  display: grid;
  gap: 10px;
}

.recommendation {
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(135deg, #fff 0%, #fff8f7 100%);
}

.recommendation strong {
  display: block;
  color: var(--rose-deep);
  font-size: 14px;
  margin-bottom: 6px;
}

.recommendation p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.recommendation .tag {
  margin-top: 10px;
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--sage);
  background: var(--sage-soft);
  font-size: 11px;
  font-weight: 800;
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.model-grid label {
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.model-grid span {
  display: block;
  min-height: 32px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.model-grid b {
  display: block;
  margin-top: 8px;
  font-size: 16px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--rose);
}

input[type="number"] {
  width: 100%;
  height: 42px;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 11px;
  color: var(--ink);
  background: #fff;
  font-size: 14px;
  font-weight: 750;
  outline: none;
}

input[type="number"]:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(123, 41, 77, 0.11);
}

.revenue-pill {
  white-space: nowrap;
  color: var(--sage);
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--sage-soft);
  font-size: 13px;
}

.commercial-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.commercial-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

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

.compact-kpis .kpi-value {
  font-size: 26px;
}

.revenue-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.revenue-inputs label {
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.revenue-inputs span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.helper-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.roi-table-panel {
  margin-top: 14px;
}

.roi-table-panel table {
  min-width: 980px;
}

.total-row {
  background: var(--surface-sage);
}

.positive-cell {
  color: var(--sage);
  font-weight: 850;
}

.negative-cell {
  color: var(--rose-deep);
  font-weight: 850;
}

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

.content-list,
.health-list {
  display: grid;
  gap: 10px;
}

.health-list.compact {
  gap: 0;
}

.content-item,
.health-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.content-item:last-child,
.health-item:last-child {
  border-bottom: 0;
}

.content-item strong,
.health-item strong {
  display: block;
  font-size: 13px;
}

.content-item p,
.health-item p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 3px;
}

.metric-badge {
  color: var(--sage);
  background: var(--sage-soft);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 850;
}

.metric-badge.warn {
  color: var(--warning);
  background: #fbefd8;
}

.metric-badge.bad {
  color: var(--rose-deep);
  background: #f6dddd;
}

@media (max-width: 1500px) {
  .overview-layout,
  .two-cols {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: relative;
    height: auto;
    padding: 16px;
    overflow: hidden;
    max-width: 100vw;
  }

  .nav {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav button {
    min-width: 120px;
  }

  .source-box {
    display: none;
  }

  main {
    padding: 18px;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .topbar {
    display: grid;
    overflow: hidden;
  }

  .topbar-actions {
    width: 100%;
    max-width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: 30px;
    line-height: 1;
  }

  .topbar p {
    overflow-wrap: anywhere;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .kpi-grid,
  .overview-layout,
  .two-cols,
  .model-grid,
  .commercial-cards,
  .period-summary {
    grid-template-columns: 1fr;
  }

  .topbar,
  .kpi-grid,
  .overview-layout,
  .two-cols {
    width: calc(100vw - 36px);
    max-width: calc(100vw - 36px);
  }

  .period-switch {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    height: auto;
  }

  .period-switch button {
    min-width: 0;
  }

  .status-chip {
    justify-content: center;
  }

  .content-item,
  .health-item {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .metric-badge {
    justify-self: flex-start;
  }
}
