:root {
  --bg: #eef3fb;
  --bg-accent: #dce8ff;
  --panel: #ffffff;
  --ink: #0b1f3f;
  --muted: #5a6b86;
  --line: #d3dfef;
  --brand: #0b3d91;
  --brand-2: #0066cc;
  --brand-3: #00a3e0;
  --accent: #ff6a00;
  --accent-soft: #fff1e6;
  --magenta: #ff4cce;
  --magenta-deep: #d92b6a;
  --ok: #0f9d58;
  --warn: #e37400;
  --danger: #d93025;
  --shadow: 0 14px 40px rgba(11, 61, 145, 0.08);
  --radius: 16px;
  --sidebar: 248px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: "Manrope", Inter, system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 0% 0%, #d9e8ff 0%, transparent 38%),
    radial-gradient(circle at 100% 0%, #ffe8d4 0%, transparent 32%),
    var(--bg);
}

a {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #082f72 0%, #0b3d91 55%, #0a4ca8 100%);
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-lockup {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ff6a00, #ff9a3d);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.brand-lockup h1 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.brand-lockup p {
  margin: 2px 0 0;
  font-size: 0.78rem;
  opacity: 0.82;
}

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

.side-nav a {
  text-decoration: none;
  color: #eaf2ff;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.side-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.side-nav a.active {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
  font-weight: 700;
}

.side-card {
  margin-top: auto;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 14px;
  font-size: 0.82rem;
  line-height: 1.45;
}

.main {
  padding: 24px;
}

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

.page-header h2 {
  margin: 0;
  font-size: 1.65rem;
}

.page-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat-card .label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .value {
  margin-top: 6px;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand);
}

.content-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
}

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

.panel h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.panel-sub {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.field-hint.ok {
  color: #0f766e;
}

.field-hint.warn {
  color: #b45309;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

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

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

.brief-section {
  margin: 8px 0 0;
  font-size: 0.95rem;
}

.imagery-grid input[type="file"] {
  padding: 8px;
  background: #f8fbff;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  color: #334155;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #c5d4ea;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #7aa6ef;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.12);
}

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

.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  color: #fff;
}

.btn.secondary {
  background: #edf3ff;
  color: var(--brand);
  border: 1px solid #bfd1f8;
}

.btn.warn {
  background: linear-gradient(90deg, #ff6a00, #ff8f3d);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

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

.project-list {
  display: grid;
  gap: 12px;
}

.project-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(180deg, #fbfdff, #f4f8ff);
}

.project-card h4 {
  margin: 0;
  font-size: 1rem;
}

.project-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid #c4d2ee;
  background: #edf3ff;
  color: #174089;
}

.chip-draft { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.chip-generating { background: #fff7ed; color: #c2410c; border-color: #fdba74; }
.chip-preview { background: #ecfeff; color: #0e7490; border-color: #67e8f9; }
.chip-approved { background: #ecfdf3; color: #047857; border-color: #86efac; }

.pipeline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.pipeline-step {
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  color: #64748b;
}

.pipeline-step.done {
  background: #ecfdf3;
  border-style: solid;
  border-color: #86efac;
  color: #047857;
}

.preview-panel iframe {
  width: 100%;
  min-height: 620px;
  border: 1px solid #cad6ea;
  border-radius: 14px;
  background: #fff;
}

.status-line {
  margin-top: 10px;
  font-size: 0.84rem;
  color: #38517a;
}

.session-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 0.84rem;
}

.session-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

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

.integration-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fbfdff;
}

.integration-card h4 {
  margin: 0 0 8px;
}

.integration-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.integration-status.on { color: var(--ok); }
.integration-status.off { color: var(--muted); }

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #e8eef7;
}

.toggle-row:last-child {
  border-bottom: 0;
}

#toastRoot {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  z-index: 1000;
}

.toast {
  background: #0b1f3f;
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s ease;
  max-width: 360px;
  font-size: 0.88rem;
}

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

.toast-error { background: #7f1d1d; }
.toast-success { background: #065f46; }

.empty-state {
  text-align: center;
  padding: 28px 12px;
  color: var(--muted);
}

/* Project workspace */
.workspace-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.workspace-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.workspace-top-left {
  display: flex;
  gap: 16px;
  align-items: center;
}

.workspace-topbar h1 {
  margin: 0;
  font-family: "Sora", Manrope, sans-serif;
  font-size: 1.15rem;
}

.back-link {
  text-decoration: none;
  font-weight: 700;
  color: var(--brand);
  font-size: 0.9rem;
}

.workspace-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}

.workspace-chat,
.workspace-preview {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 110px);
  padding: 0;
  overflow: hidden;
}

.workspace-chat-head,
.preview-toolbar {
  padding: 16px 16px 0;
}

.workspace-chat-head h3,
.preview-toolbar h3 {
  margin: 0;
}

.brand-kit-strip {
  padding: 8px 16px 0;
}

.brand-kit-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
}

.brand-kit-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.92rem;
}

.brand-kit-logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.brand-kit-logos img {
  height: 28px;
  width: auto;
  background: #eef3fb;
  border-radius: 6px;
  padding: 4px 8px;
}

.swatch-row {
  display: inline-flex;
  gap: 4px;
  margin-left: auto;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  display: inline-block;
}

.brand-guidelines {
  margin: 8px 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.chat-thread {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
  display: grid;
  gap: 10px;
  align-content: start;
  background:
    linear-gradient(180deg, rgba(238, 243, 251, 0.4), transparent 40%),
    #f7faff;
}

.chat-empty,
.asset-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 20px 8px;
  text-align: center;
}

.chat-bubble {
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
  max-width: 95%;
}

.chat-bubble header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.chat-bubble p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 0.92rem;
}

.chat-bubble.role-user {
  justify-self: end;
  background: #edf3ff;
  border-color: #bfd1f8;
}

.chat-bubble.role-assistant {
  justify-self: start;
  background: #fff;
}

.chat-bubble.role-system {
  justify-self: center;
  background: #f8fafc;
  color: #475569;
  font-size: 0.86rem;
}

.asset-tray {
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  background: #fff;
}

.asset-grid {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.asset-chip {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #f8fafc;
  text-decoration: none;
  flex: 0 0 auto;
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
  padding: 4px;
}

.asset-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-composer {
  border-top: 1px solid var(--line);
  padding: 12px 16px 16px;
  display: grid;
  gap: 10px;
  background: #fff;
}

.composer-tools,
.composer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.file-btn {
  display: inline-flex;
  align-items: center;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.viewport-select,
.viewport-input {
  width: auto;
  min-width: 78px;
  padding: 7px 9px;
  border-radius: 10px;
}

.workspace-preview .panel-sub {
  padding: 0 16px;
  margin: 8px 0 10px;
}

.preview-stage {
  position: relative;
  flex: 1;
  margin: 0 16px 16px;
  border: 1px solid #cad6ea;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  min-height: 520px;
}

.preview-stage iframe {
  width: 1280px;
  height: 760px;
  border: 0;
  background: #fff;
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
  display: block;
}

.preview-overlay {
  position: absolute;
  inset: auto;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 1280px;
  height: 760px;
  cursor: crosshair;
  background: rgba(11, 61, 145, 0.06);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .stats-grid,
  .content-grid,
  .integration-grid,
  .form-grid.two,
  .workspace-grid,
  .workspace-grid-3 {
    grid-template-columns: 1fr;
  }

  .workspace-chat,
  .workspace-preview {
    min-height: 70vh;
  }
}

/* Campaign wizard */
.wizard-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.wizard-tab {
  border: 1px solid var(--line);
  background: #f8fbff;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}

.wizard-tab.active {
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-color: transparent;
  color: #fff;
}

.wizard-step {
  display: none;
}

.wizard-step.active {
  display: block;
}

.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.slug-preview {
  margin: 10px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.slug-preview code {
  color: var(--magenta-deep);
  font-weight: 700;
  word-break: break-all;
}

.form-grid .span-2 {
  grid-column: 1 / -1;
}

.schedule-details {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #f8fbff;
}

.schedule-details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--brand);
}

.admin-only {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

/* Users admin */
.user-list {
  display: grid;
  gap: 10px;
}

.user-row {
  display: grid;
  grid-template-columns: 1fr 160px auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
}

.user-role-label,
.user-active-label {
  margin: 0;
}

/* Craft / proposals / versions */
.craft-chip {
  border-color: #f9a8d4;
  background: #fff1f8;
  color: var(--magenta-deep);
}

.craft-chip.craft-pass {
  border-color: #86efac;
  background: #ecfdf3;
  color: #047857;
}

.craft-chip.craft-fail {
  border-color: #fdba74;
  background: #fff7ed;
  color: #c2410c;
}

.craft-panel {
  margin: 0 16px 8px;
  padding: 12px;
  border: 1px solid #f9a8d4;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff7fb, #fff);
}

.craft-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 10px;
}

.proposal-list {
  display: grid;
  gap: 10px;
}

.proposal-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}

.proposal-card p {
  margin: 8px 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

.proposal-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.workspace-grid-3 {
  grid-template-columns: minmax(280px, 360px) 1fr minmax(220px, 280px);
}

.workspace-versions {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 110px);
  padding: 0;
  overflow: hidden;
}

.version-list {
  flex: 1;
  overflow: auto;
  padding: 12px 16px 16px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.version-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fbfdff;
  display: grid;
  gap: 8px;
}

@media (max-width: 1280px) {
  .workspace-grid-3 {
    grid-template-columns: minmax(280px, 360px) 1fr;
  }

  .workspace-versions {
    grid-column: 1 / -1;
    min-height: 240px;
  }
}

@media (max-width: 1100px) {
  .user-row {
    grid-template-columns: 1fr;
  }
}
