:root {
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-soft: #f9faf7;
  --line: #dfe3dc;
  --line-strong: #c6cec4;
  --text: #1d2628;
  --muted: #667274;
  --accent: #2f8f83;
  --accent-strong: #1d6d63;
  --accent-soft: #e4f3ef;
  --warn: #b98924;
  --danger: #b94b3f;
  --ink: #263237;
  --shadow: 0 18px 45px rgba(31, 40, 40, 0.12);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

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

button {
  align-items: center;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  min-height: 38px;
  padding: 9px 13px;
  white-space: nowrap;
}

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

button svg {
  height: 17px;
  width: 17px;
  stroke-width: 2;
}

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

textarea {
  line-height: 1.45;
  min-height: 94px;
  resize: vertical;
}

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

.hidden {
  display: none !important;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.auth-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.brand-row,
.product-lockup {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.brand-row h1 {
  font-size: 26px;
  line-height: 1.1;
  margin: 0 0 4px;
}

.brand-row p,
.product-lockup span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin: 0;
  overflow-wrap: anywhere;
}

.brand-mark {
  align-items: center;
  background: var(--ink);
  border-radius: 7px;
  color: #fff;
  display: inline-flex;
  font-size: 17px;
  font-weight: 800;
  height: 42px;
  justify-content: center;
  letter-spacing: 0;
  width: 42px;
}

.brand-mark.small {
  flex: 0 0 34px;
  font-size: 14px;
  height: 34px;
  width: 34px;
}

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

.sidebar {
  background: #eef0eb;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px;
}

.product-lockup strong {
  display: block;
  font-size: 15px;
}

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

.nav-tab,
.ghost {
  background: transparent;
  color: var(--ink);
  justify-content: flex-start;
  width: 100%;
}

.nav-tab.active {
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--accent);
}

.logout {
  margin-top: auto;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  align-items: center;
  background: rgba(245, 246, 242, 0.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 78px;
  padding: 16px 22px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h2 {
  font-size: 24px;
  line-height: 1.1;
  margin: 0;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.toolbar {
  align-items: center;
  display: flex;
  gap: 8px;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
}

.secondary {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
}

.secondary:hover,
.ghost:hover {
  background: var(--surface-soft);
}

.danger {
  background: #fff1ef;
  color: var(--danger);
}

.full {
  width: 100%;
}

.view {
  padding: 22px;
}

.screen-grid,
.clients-layout,
.campaign-layout,
.scripts-layout {
  display: grid;
  gap: 16px;
}

.clients-layout {
  grid-template-columns: minmax(230px, 0.85fr) minmax(360px, 1.25fr) minmax(300px, 1fr);
}

.campaign-layout {
  grid-template-columns: minmax(280px, 0.8fr) minmax(520px, 1.4fr);
}

.scripts-layout {
  grid-template-columns: minmax(280px, 0.85fr) minmax(520px, 1.4fr);
}

.economics-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(760px, 1.45fr) minmax(320px, 0.75fr);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}

.panel-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 58px;
  padding: 14px 16px;
}

.panel-head h3 {
  font-size: 16px;
  margin: 0;
}

.panel-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

.inline-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.check-row {
  align-items: center;
  color: var(--text);
  display: flex;
  flex-direction: row;
  font-size: 13px;
  font-weight: 650;
  gap: 8px;
  text-transform: none;
}

.check-row input {
  min-height: 18px;
  width: 18px;
}

.stack-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 170px);
  overflow: auto;
  padding: 12px;
}

.list-button {
  background: var(--surface-soft);
  border: 1px solid transparent;
  color: var(--text);
  display: grid;
  gap: 5px;
  justify-content: stretch;
  min-height: 64px;
  padding: 11px;
  text-align: left;
  white-space: normal;
}

.list-button strong {
  overflow-wrap: anywhere;
}

.list-button span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.list-button.active {
  background: var(--accent-soft);
  border-color: #afd8d0;
}

.detail-grid {
  display: grid;
  gap: 12px;
}

.detail-item {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
}

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

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

.detail-item strong,
.detail-item code,
.detail-item p {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.swatch {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  gap: 8px;
  padding: 5px 9px;
}

.swatch-dot {
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  display: inline-block;
  height: 16px;
  width: 16px;
}

.badge {
  background: #eef2f2;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-size: 12px;
  font-weight: 750;
  padding: 4px 9px;
  width: fit-content;
}

.badge.failed {
  background: #fff1ef;
  border-color: #f1c1ba;
  color: var(--danger);
}

.badge.review {
  background: #fff5df;
  border-color: #e9cb86;
  color: #7a5713;
}

.badge.ready {
  background: var(--accent-soft);
  border-color: #afd8d0;
  color: var(--accent-strong);
}

.table-wrap {
  overflow: auto;
  width: 100%;
}

table {
  border-collapse: collapse;
  min-width: 860px;
  width: 100%;
}

.economics-table {
  min-width: 740px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 7px;
  text-align: left;
  vertical-align: top;
}

tbody tr[data-economics-index] {
  cursor: pointer;
}

.risk-row {
  background: #fff1ef;
}

.selected-row {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

td textarea {
  min-height: 70px;
}

.row-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.script-editor {
  display: grid;
  gap: 12px;
}

.script-editor textarea {
  min-height: 210px;
}

.meta-line {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 8px;
}

.board {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(246px, 1fr));
}

.board-column {
  background: #f0f2ed;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 260px;
  min-width: 0;
}

.board-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 11px 12px;
}

.board-head h3 {
  font-size: 14px;
  margin: 0;
  overflow-wrap: anywhere;
  text-transform: capitalize;
}

.board-cards {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.deliverable-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 9px;
  min-width: 0;
  padding: 12px;
}

.deliverable-card h4 {
  font-size: 14px;
  line-height: 1.28;
  margin: 0;
  overflow-wrap: anywhere;
}

.card-kv {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 4px;
}

.card-kv strong {
  color: var(--text);
  font-weight: 750;
}

.error-box {
  background: #fff5f3;
  border: 1px solid #f0b8b0;
  border-radius: 6px;
  color: #8b3028;
  font-size: 12px;
  line-height: 1.4;
  padding: 8px;
  overflow-wrap: anywhere;
}

.empty-state {
  color: var(--muted);
  padding: 18px;
}

.message {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}

.toast {
  background: var(--ink);
  border-radius: var(--radius);
  bottom: 18px;
  box-shadow: var(--shadow);
  color: #fff;
  left: 50%;
  max-width: min(520px, calc(100vw - 28px));
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 12px);
  transition: 160ms ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

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

@media (max-width: 1180px) {
  .clients-layout,
  .campaign-layout,
  .scripts-layout,
  .economics-layout {
    grid-template-columns: 1fr;
  }

  .stack-list {
    max-height: 360px;
  }
}

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

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

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

  .nav-tab {
    justify-content: center;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar,
  .toolbar button {
    width: 100%;
  }

  .view {
    padding: 14px;
  }

  .form-grid,
  .inline-grid {
    grid-template-columns: 1fr;
  }
}
