:root {
  color-scheme: light;
  --bg: #f3f8fd;
  --surface: #ffffff;
  --surface-soft: #edf6ff;
  --navy: #10233d;
  --muted: #607084;
  --line: #d9e5ef;
  --blue: #2563eb;
  --blue-soft: #dceeff;
  --green: #089981;
  --green-soft: #e4f8f2;
  --orange: #f97316;
  --orange-soft: #fff1df;
  --red: #e11d48;
  --red-soft: #ffe8ec;
  --shadow: 0 14px 40px rgba(16, 35, 61, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--navy);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  background: rgba(255, 255, 255, 0.86);
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #0f2742, #2563eb);
  color: white;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
}

.brand p,
.eyebrow {
  color: var(--muted);
  font-size: 13px;
}

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

.nav-item {
  border: 0;
  background: transparent;
  color: #334155;
  text-align: left;
  border-radius: 14px;
  padding: 13px 14px;
  font-weight: 650;
}

.nav-item.active,
.nav-item:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.main {
  min-width: 0;
}

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 248, 253, 0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h2 {
  font-size: 26px;
}

.view {
  padding: 28px 30px 48px;
  max-width: 1320px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.card.soft-blue {
  background: linear-gradient(180deg, #ffffff, var(--surface-soft));
}

.card.soft-green {
  background: linear-gradient(180deg, #ffffff, var(--green-soft));
}

.card.soft-red {
  background: linear-gradient(180deg, #ffffff, var(--red-soft));
}

.card h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.metric {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.big {
  font-size: 34px;
  font-weight: 850;
  line-height: 1.1;
  margin: 6px 0;
}

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

.primary-btn,
.ghost-btn,
.small-btn,
.icon-btn {
  border-radius: 12px;
  border: 1px solid transparent;
  min-height: 38px;
  padding: 0 14px;
  font-weight: 700;
}

.primary-btn {
  background: var(--blue);
  color: white;
}

.ghost-btn {
  background: white;
  color: var(--navy);
  border-color: var(--line);
}

.small-btn {
  min-height: 32px;
  padding: 0 10px;
  background: var(--surface-soft);
  color: var(--blue);
}

.icon-btn {
  min-width: 38px;
  padding: 0;
  background: transparent;
  color: var(--navy);
  font-size: 24px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stack {
  display: grid;
  gap: 12px;
}

.campaign-card {
  display: grid;
  gap: 14px;
}

.campaign-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.campaign-title h3 {
  margin: 0;
  font-size: 22px;
}

.status {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--blue);
  background: var(--blue-soft);
}

.status.managing {
  color: var(--green);
  background: var(--green-soft);
}

.status.completed {
  color: #475569;
  background: #e2e8f0;
}

.status.invalid {
  color: var(--red);
  background: var(--red-soft);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 10px;
  background: #eef4fb;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.chip.good {
  background: var(--green-soft);
  color: var(--green);
}

.chip.bad {
  background: var(--orange-soft);
  color: var(--orange);
}

.rule {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
}

.rule strong {
  overflow-wrap: anywhere;
}

.timeline {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.timeline-item {
  border-left: 3px solid var(--blue);
  padding: 10px 12px;
  background: #f8fbff;
  border-radius: 12px;
}

.timeline-item p {
  margin: 6px 0;
}

.chart-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
}

.chart-panel {
  min-height: 620px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.chart-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chart-controls input,
.chart-controls select {
  max-width: 150px;
}

canvas {
  width: 100%;
  min-height: 520px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #ffffff;
}

label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #ffffff;
  color: var(--navy);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.modal {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(620px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgba(15, 39, 66, 0.34);
}

.modal-card {
  max-height: min(86vh, 780px);
  overflow: auto;
  display: grid;
  gap: 14px;
  padding: 20px;
  border-radius: 22px;
  background: white;
  box-shadow: 0 28px 90px rgba(16, 35, 61, 0.24);
}

.modal-header,
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-header h3 {
  margin: 0;
}

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

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch-row input {
  width: auto;
}

.empty {
  padding: 24px;
  border: 1px dashed #b7c7d8;
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--navy);
  color: white;
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 20;
}

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

  .sidebar {
    height: auto;
    position: sticky;
    bottom: 0;
    top: auto;
    z-index: 10;
    order: 2;
    padding: 10px;
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .brand {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
  }

  .nav-item {
    text-align: center;
    padding: 10px 4px;
    font-size: 12px;
  }

  .main {
    order: 1;
  }

  .topbar {
    padding: 18px;
  }

  .view {
    padding: 18px 18px 92px;
  }

  .grid.two,
  .grid.three,
  .chart-layout {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    display: none;
  }

  canvas {
    min-height: 420px;
  }
}
