:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --line: #ded8ce;
  --text: #24211d;
  --muted: #706a62;
  --accent: #9f2d28;
  --accent-strong: #7f1f1c;
  --ok: #226b43;
  --warn: #9a5b11;
  --shadow: 0 10px 28px rgba(31, 28, 24, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}

.nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav a {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
}

.nav a.active,
.nav a:hover {
  background: #f2ebe2;
  color: var(--text);
  text-decoration: none;
}

.logout-form {
  margin-left: auto;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 28px auto 56px;
}

.auth-panel {
  width: min(420px, 100%);
  margin: 80px auto;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.page-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.compact-head {
  margin-bottom: 14px;
}

.compact-head .muted {
  margin-bottom: 0;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

h1 {
  font-size: 32px;
  line-height: 1.15;
  margin-bottom: 0;
}

h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

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

.grid.compact {
  margin-top: 18px;
}

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

.form-stack {
  display: grid;
  gap: 16px;
}

.form-stack.wide {
  display: grid;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf9;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  padding: 10px 12px;
}

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

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(159, 45, 40, 0.2);
  border-color: var(--accent);
}

.checks-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.checks-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.checks-row input {
  width: auto;
  min-height: auto;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

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

.primary-button:hover {
  background: var(--accent-strong);
  color: #fff;
  text-decoration: none;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.secondary-button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.secondary-button,
.icon-button {
  background: #f2ebe2;
  color: var(--text);
  border-color: var(--line);
}

.secondary-button:hover,
.icon-button:hover {
  background: #e9dfd2;
  text-decoration: none;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.settings-form {
  display: grid;
  gap: 0;
}

.autofill-form {
  display: grid;
  gap: 0;
}

.status-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.status-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #eee7dd;
  padding-bottom: 10px;
}

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

.ok,
.warn,
.bad {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

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

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

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.alert {
  border-radius: 6px;
  padding: 12px 14px;
  font-weight: 700;
}

.alert.error {
  color: #7a1d18;
  background: #fbe7e4;
  border: 1px solid #edc3bd;
}

.alert.success {
  color: #164f30;
  background: #e4f4ea;
  border: 1px solid #bddfc9;
}

.warn-box {
  color: #6f420c;
  background: #fff3dd;
  border: 1px solid #e7c38d;
}

.small-link,
.muted {
  color: var(--muted);
  font-size: 14px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid #eee7dd;
  padding: 12px 10px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge,
.chips span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff8ef;
  color: var(--text);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}

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

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

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

.asset-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
}

.asset-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #eee7dd;
}

.asset-card div {
  padding: 14px;
}

.production-grid {
  display: grid;
  gap: 18px;
}

.detail-tabs {
  position: sticky;
  top: 72px;
  z-index: 5;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: -8px 0 18px;
  padding: 10px 0;
  background: var(--bg);
}

.detail-tabs a {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf9;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  padding: 9px 14px;
}

.detail-tabs a:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.tab-panel {
  scroll-margin-top: 142px;
}

.next-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  border: 1px solid #e7c38d;
  border-radius: 8px;
  background: #fffaf1;
  padding: 16px;
}

.next-action h3,
.next-action p {
  margin: 0;
}

.next-action p {
  margin-top: 6px;
  color: var(--muted);
}

.ai-merge-box {
  display: grid;
  gap: 4px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.ai-merge-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.summary-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
  padding: 14px;
}

.summary-grid strong,
.summary-grid span {
  display: block;
}

.summary-grid strong {
  font-size: 28px;
  line-height: 1;
}

.summary-grid span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.calendar-month {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.calendar-day,
.kanban-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
  padding: 12px;
}

.calendar-day strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

.calendar-chip,
.kanban-card {
  display: block;
  margin-top: 6px;
  border-radius: 6px;
  padding: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.calendar-chip:hover,
.kanban-card:hover {
  text-decoration: none;
}

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

.status-ok {
  background: #e4f4ea;
  border-color: #bddfc9;
  color: #164f30;
}

.status-warn {
  background: #fff3dd;
  border-color: #e7c38d;
  color: #6f420c;
}

.status-neutral {
  background: #f2ebe2;
  border-color: var(--line);
  color: var(--text);
}

.week-group {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.production-card {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
  padding: 14px;
}

.post-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.post-preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eee7dd;
}

.post-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.post-preview video {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: contain;
  background: #111;
}

.preview-placeholder,
.slide-placeholder {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--muted);
  font-weight: 800;
}

.instagram-preview {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  font-size: 12px;
}

.ig-bar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 900;
}

.ig-media {
  display: grid;
  place-items: center;
  min-height: 180px;
  background: #111;
  color: #fff;
}

.ig-media img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.instagram-preview.mode-reel .ig-media img,
.instagram-preview.mode-stories .ig-media img {
  aspect-ratio: 9 / 16;
}

.instagram-preview p {
  margin: 0;
  padding: 10px 12px 12px;
  color: var(--text);
}

.slide-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.slide-strip figure {
  margin: 0;
}

.slide-strip img,
.slide-placeholder {
  width: 100%;
  aspect-ratio: 4 / 5;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  background: #eee7dd;
}

.slide-strip figcaption {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.storyboard-alert {
  margin-top: 12px;
  border: 1px solid #edc3bd;
  border-radius: 6px;
  background: #fff5f2;
  padding: 12px;
  color: #6c2b24;
  font-size: 13px;
}

.storyboard-alert ol {
  margin-bottom: 0;
  padding-left: 18px;
}

.pending-box {
  margin-top: 12px;
  border: 1px solid #e7c38d;
  border-radius: 6px;
  background: #fffaf1;
  padding: 12px;
  color: #6f420c;
  font-size: 13px;
}

.pending-box ul,
.warn-box ul {
  margin-bottom: 0;
}

.pending-box li {
  margin: 6px 0;
}

.compact-list {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
}

.compact-list li {
  margin: 3px 0;
}

.resolved {
  text-decoration: line-through;
  color: var(--muted);
}

.multiline-copy {
  white-space: pre-line;
}

.comments-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf9;
  padding: 12px;
  font-size: 13px;
}

.comments-box ul {
  margin-bottom: 0;
}

.post-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.copy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.edit-drawer {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf4;
  padding: 10px 12px;
}

.edit-drawer summary {
  cursor: pointer;
  font-weight: 900;
}

.edit-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

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

.edit-form textarea {
  min-height: 82px;
}

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

.inline-form input {
  width: 210px;
}

.advanced-panel summary {
  cursor: pointer;
  font-weight: 900;
}

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

.agent-flow {
  display: flex;
  align-items: stretch;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.agent-node {
  display: grid;
  grid-template-columns: 34px minmax(150px, 1fr);
  align-items: center;
  gap: 10px;
  width: 230px;
  min-height: 82px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  padding: 12px;
  text-align: left;
}

.agent-node:hover,
.agent-node.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(159, 45, 40, 0.12);
}

.agent-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.agent-node strong,
.agent-node small {
  display: block;
  overflow-wrap: anywhere;
}

.agent-node small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.flow-arrow {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  font-size: 24px;
  font-weight: 900;
  flex: 0 0 auto;
}

.agent-detail[hidden] {
  display: none;
}

.handoff-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.handoff-card {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
  padding: 14px;
}

.handoff-card p {
  overflow-wrap: anywhere;
}

.subhead {
  margin-top: 16px;
}

.trace-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #eee7dd;
}

.trace-json {
  max-height: 240px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: 6px;
  background: #211f1c;
  color: #f6f0e7;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.file-list {
  display: grid;
  gap: 8px;
  margin-bottom: 0;
  padding-left: 18px;
}

.file-list li {
  overflow-wrap: anywhere;
}

.file-list span {
  display: block;
  font-weight: 800;
}

.file-list code {
  color: var(--muted);
  font-size: 12px;
}

.evidence {
  margin-top: 16px;
  margin-bottom: 0;
}

.json-block {
  max-height: 520px;
  overflow: auto;
  padding: 16px;
  border-radius: 6px;
  background: #211f1c;
  color: #f6f0e7;
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 14px 18px;
  }

  .nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .grid.two,
  .form-grid,
  .cards,
  .asset-grid,
  .handoff-grid,
  .summary-grid,
  .calendar-month,
  .kanban-board,
  .production-card {
    grid-template-columns: 1fr;
  }

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

  .head-actions {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .next-action {
    align-items: stretch;
    flex-direction: column;
  }

  .agent-node {
    width: 210px;
  }
}
