:root {
  --association-red: #ec1c2f;
  --association-blue: #163785;
  --email-navy: #132048;
  --email-dark-teal: #006078;
  --email-gray: #6d7b8f;
  --ink: #132048;
  --muted: #6d7b8f;
  --line: #d8dee9;
  --panel: #ffffff;
  --band: #f5f7fb;
  --primary: #163785;
  --primary-dark: #132048;
  --teal: #006078;
  --red: #ec1c2f;
  --amber: #a86d00;
  --ok: #006078;
  --shadow: 0 12px 30px rgba(19, 32, 72, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: #eef3f2;
  font-family:
    Raleway, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button,
.import-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 12px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input[readonly],
textarea[readonly] {
  background: #eef3fb;
  color: var(--email-gray);
}

button:hover,
.import-btn:hover {
  border-color: var(--association-red);
}

.editor-mode {
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 800;
}

body:not(.view-mode) .editor-mode {
  background: var(--email-dark-teal);
  border-color: var(--email-dark-teal);
}

.view-mode .import-btn {
  cursor: not-allowed;
  opacity: 0.55;
}

.view-mode .content input,
.view-mode .content select,
.view-mode .content textarea {
  background: #f8fafc;
  color: var(--email-gray);
}

.topbar {
  flex: 0 0 auto;
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px;
  background: var(--email-navy);
  color: #fff;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.site-brand {
  display: grid;
  gap: 2px;
  padding: 9px 14px;
  border-left: 3px solid var(--association-red);
  color: #fff;
  text-decoration: none;
}

.site-brand span {
  color: #c9d2e4;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.site-brand strong {
  font-size: 17px;
  line-height: 1.1;
}

.site-brand:hover strong {
  color: #ffffff;
  text-decoration: underline;
  text-decoration-color: var(--association-red);
  text-underline-offset: 4px;
}

.eyebrow {
  margin: 0 0 2px;
  color: #c9d2e4;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 6px;
  font-size: 24px;
}

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

.project-controls {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: min(100%, 420px);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.field-note {
  color: var(--email-dark-teal);
  font-size: 11px;
  font-weight: 700;
  text-transform: none;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.project-controls select {
  width: clamp(210px, 24vw, 320px);
  min-width: 0;
}

.app-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(230px, 22vw, 300px) minmax(0, 1fr);
}

.sidebar {
  min-height: 0;
  overflow: auto;
  padding: 20px;
  border-right: 1px solid var(--line);
  background: #fbfcff;
}

.section-picker {
  margin-bottom: 16px;
}

nav {
  display: grid;
  gap: 6px;
  align-content: start;
}

.nav-item {
  text-align: left;
  min-height: 40px;
  background: transparent;
}

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

.nav-item[data-section="episode-pitch-document"] {
  border-color: rgba(236, 28, 47, 0.42);
  color: var(--association-red);
  font-weight: 800;
}

.nav-item[data-section="episode-pitch-document"].active {
  background: var(--association-red);
  border-color: var(--association-red);
  color: #fff;
}

.utility-panel {
  display: grid;
  gap: 8px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.import-btn {
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
  text-transform: none;
}

.import-btn input {
  display: none;
}

.content {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 24px;
  overflow: auto;
}

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

.section-head p {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.45;
}

.pitch-document-head {
  border-left: 6px solid var(--association-red);
  padding-left: 16px;
}

.pitch-document-head h2 {
  color: var(--association-red);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-pad {
  padding: 18px;
}

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

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

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

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  line-height: 1;
}

.metric.warn strong {
  color: var(--amber);
}

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

.metric.good strong {
  color: var(--ok);
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  max-height: calc(100vh - 210px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--association-blue);
  color: #fff;
  font-size: 12px;
  text-transform: uppercase;
}

td input,
td select,
td textarea {
  width: clamp(120px, 13vw, 220px);
  min-width: 120px;
  border-color: transparent;
  background: #f9fbfb;
  white-space: normal;
  overflow-wrap: anywhere;
}

td input {
  height: auto;
  min-height: 42px;
  text-overflow: clip;
}

td textarea {
  width: clamp(190px, 20vw, 320px);
  min-width: 190px;
  min-height: 86px;
  line-height: 1.4;
  white-space: pre-wrap;
}

td textarea.wide-wrap-input {
  width: clamp(260px, 30vw, 460px);
  min-width: 260px;
  min-height: 96px;
  white-space: pre-wrap;
}

th:last-child,
td:last-child {
  position: sticky;
  right: 0;
  z-index: 1;
  min-width: 105px;
  background: #fff;
  box-shadow: -8px 0 12px rgba(19, 32, 72, 0.08);
}

th:last-child {
  z-index: 3;
  background: var(--association-blue);
  box-shadow: -8px 0 12px rgba(19, 32, 72, 0.18);
}

.section-budget th:nth-child(1),
.section-budget td:nth-child(1),
.section-budget th:nth-child(2),
.section-budget td:nth-child(2),
.section-budget th:nth-child(3),
.section-budget td:nth-child(3) {
  position: sticky;
  z-index: 3;
  background: #fff;
  box-shadow: 6px 0 10px rgba(19, 32, 72, 0.06);
}

.section-budget th:nth-child(1),
.section-budget th:nth-child(2),
.section-budget th:nth-child(3) {
  z-index: 4;
  background: var(--association-blue);
}

.section-budget th:nth-child(1),
.section-budget td:nth-child(1) {
  left: 0;
  width: 150px;
  min-width: 150px;
}

.section-budget th:nth-child(2),
.section-budget td:nth-child(2) {
  left: 150px;
  width: 160px;
  min-width: 160px;
}

.section-budget th:nth-child(3),
.section-budget td:nth-child(3) {
  left: 310px;
  width: 280px;
  min-width: 280px;
}

.section-budget td:nth-child(3) textarea,
.section-budget td:nth-child(3) input {
  width: 250px;
  min-width: 250px;
}

.row-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0 18px;
}

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

.small {
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 5;
  transform: translateY(20px);
  opacity: 0;
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
  padding: 10px 14px;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

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

.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.complete {
  background: #dff0e5;
  color: var(--ok);
}

.status-pill.blocked,
.status-pill.high {
  background: #f8dfdc;
  color: var(--red);
}

.status-pill.progress,
.status-pill.medium {
  background: #fff0d3;
  color: var(--amber);
}

.chart {
  height: 240px;
  display: grid;
  align-items: end;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  padding: 20px 18px 12px;
  border-top: 1px solid var(--line);
}

.bar {
  display: grid;
  align-items: end;
  gap: 8px;
  height: 100%;
  color: var(--muted);
  font-size: 12px;
}

.bar i {
  display: block;
  min-height: 4px;
  border-radius: 5px 5px 0 0;
  background: var(--email-dark-teal);
}

.primary-action {
  background: var(--association-red);
  border-color: var(--association-red);
  color: #fff;
}

.header-danger {
  border-color: rgba(255, 255, 255, 0.35);
  background: transparent;
  color: #fff;
}

.header-danger:hover {
  border-color: var(--association-red);
  background: var(--association-red);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.summary-item {
  border-left: 4px solid var(--association-red);
  background: #fff;
  padding: 12px;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-item strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
}

.section-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

.ai-preview {
  margin-bottom: 18px;
}

.analysis-status {
  display: grid;
  gap: 10px;
  margin: -4px 0 18px;
  border: 1px solid #b9d6dc;
  border-left: 5px solid var(--email-dark-teal);
  border-radius: 8px;
  background: #f1fafb;
  padding: 13px 16px;
}

.analysis-status[hidden] {
  display: none;
}

.analysis-status-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  color: var(--email-navy);
}

.analysis-status-copy strong {
  font-size: 15px;
}

.analysis-status-copy span {
  color: var(--email-gray);
  font-size: 13px;
  font-weight: 700;
}

.analysis-progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #d9e8ec;
}

.analysis-progress i {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--association-blue), var(--email-dark-teal), var(--association-red));
  animation: analysis-slide 1.35s ease-in-out infinite;
}

@keyframes analysis-slide {
  0% {
    transform: translateX(-105%);
  }

  100% {
    transform: translateX(250%);
  }
}

.preview-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  padding: 12px;
}

.preview-block span {
  display: block;
  margin-bottom: 6px;
  color: var(--email-gray);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.preview-block p {
  margin-bottom: 0;
  line-height: 1.45;
}

.preview-subhead {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.confirmed-note {
  display: inline-block;
  margin-bottom: 14px;
  border-left: 4px solid var(--email-dark-teal);
  background: #eef8fa;
  padding: 9px 12px;
  color: var(--email-dark-teal);
  font-weight: 700;
}

.pitch-brief-layout {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.pitch-outline {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 5px;
  max-height: calc(100vh - 170px);
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.pitch-outline a {
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--email-navy);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.pitch-outline a:hover {
  background: #eef3fb;
  color: var(--association-blue);
}

.pitch-brief {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.pitch-brief-section {
  display: grid;
  gap: 10px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.pitch-brief-section:last-child {
  border-bottom: 0;
}

.pitch-brief-section input {
  border: 0;
  border-radius: 0;
  border-bottom: 2px solid var(--association-blue);
  background: transparent;
  padding-left: 0;
  color: var(--association-blue);
  font-size: 20px;
  font-weight: 800;
}

.pitch-brief-section textarea {
  border-color: #e5ebf3;
  background: #fbfcff;
  min-height: 180px;
  line-height: 1.55;
  font-size: 15px;
}

@media (max-width: 860px) {
  .topbar,
  .section-head,
  .pitch-upload {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-block {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .sidebar {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 260px;
    overflow: auto;
  }

  .content {
    overflow: visible;
  }

  .project-controls {
    justify-content: flex-start;
  }

  .project-controls label,
  .project-controls select,
  .project-controls button {
    width: 100%;
  }

  .table-wrap {
    max-height: 60vh;
  }

  .grid.two,
  .grid.three,
  .dashboard-grid,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .pitch-brief-layout {
    grid-template-columns: 1fr;
  }

  .pitch-outline {
    position: static;
    max-height: 190px;
  }
}

@media (max-width: 560px) {
  .topbar,
  .sidebar,
  .content {
    padding: 16px;
  }

  h1 {
    font-size: 25px;
  }

  h2 {
    font-size: 21px;
  }

  nav {
    grid-template-columns: 1fr;
  }
}
