:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #16202a;
  --muted: #627284;
  --line: #d6dde6;
  --accent: #0f766e;
  --accent-2: #115e59;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --error-bg: #fee2e2;
  --error-text: #991b1b;
  --idle-bg: #e2e8f0;
  --idle-text: #334155;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #eef4f4 0%, var(--bg) 100%);
  color: var(--text);
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 56px;
}

.hero,
.status-row,
.filter-row,
.summary-grid,
.table-section {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(214, 221, 230, 0.9);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 40px;
  line-height: 1.05;
}

.subcopy {
  margin: 12px 0 0;
  max-width: 720px;
  color: var(--muted);
  line-height: 1.6;
}

.primary-button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  min-width: 152px;
  height: 44px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.secondary-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-width: 168px;
  height: 44px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.secondary-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.secondary-button[disabled],
.primary-button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.save-button {
  border: 0;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  min-width: 72px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.save-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

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

.primary-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  margin-top: 16px;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 16px 20px;
  margin-top: 16px;
}

.filter-presets {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.preset-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  min-height: 34px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.preset-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.filter-field select,
.filter-field input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 0 10px;
}

.filter-field-wide {
  min-width: 0;
}

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

.summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.95);
  padding: 14px 16px;
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-value {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.status-badge.idle {
  background: var(--idle-bg);
  color: var(--idle-text);
}

.status-badge.loading {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-badge.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.status-badge.error {
  background: var(--error-bg);
  color: var(--error-text);
}

.summary-text {
  color: var(--muted);
  font-size: 14px;
}

.muted-inline {
  color: var(--muted);
  font-size: 12px;
}

.table-section {
  margin-top: 18px;
  padding: 20px;
}

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

.analysis-sort-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.sort-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  min-height: 34px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.sort-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.table-header h2 {
  margin: 0;
  font-size: 18px;
}

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

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

.material-workbench {
  margin-top: 8px;
}

.workbench-copy {
  margin: 0 0 16px;
}

.material-editor {
  display: grid;
  grid-template-columns: minmax(0, 720px) minmax(340px, 420px);
  align-items: start;
  gap: 24px;
  margin-top: 16px;
}

.poster-preview-panel {
  position: sticky;
  top: 24px;
}

.poster-preview-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.poster-preview-header strong {
  font-size: 16px;
  color: var(--text);
}

.poster-preview-header span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.poster-stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(15, 23, 42, 0.04)),
    #e2e8f0;
  overflow: hidden;
  aspect-ratio: 4 / 5;
  min-height: 640px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

.poster-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 2;
}

.poster-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: #475569;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.14), rgba(15, 23, 42, 0.08)),
    linear-gradient(135deg, #f8fafc, #dbeafe);
  z-index: 1;
}

.poster-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.poster-stage.is-ready {
  border-color: rgba(15, 118, 110, 0.5);
  box-shadow: 0 22px 48px rgba(15, 118, 110, 0.18);
}

.poster-text-layer {
  position: absolute;
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: #0f172a;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
  cursor: grab;
  pointer-events: auto;
  user-select: none;
}

.poster-text-layer.dragging {
  cursor: grabbing;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.22);
}

.poster-text-layer[data-layer="headline"] {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.12;
}

.poster-text-layer[data-layer="subheadline"] {
  font-size: 15px;
  line-height: 1.45;
}

.poster-text-layer[data-layer="points"] {
  font-size: 14px;
  line-height: 1.5;
}

.poster-text-layer[data-layer="cta"] {
  font-size: 14px;
  font-weight: 700;
  background: rgba(15, 118, 110, 0.9);
  color: #ffffff;
}

.editor-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.editor-upload {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.editor-upload input {
  width: 100%;
}

.upload-progress-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.upload-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 13px;
}

.upload-progress-meta strong {
  color: var(--text);
}

.upload-progress-meta span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.upload-progress-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe4ec;
}

.upload-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #1d4ed8);
  transition: width 120ms ease;
}

.workbench-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.editor-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.editor-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.editor-field input,
.editor-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}

.editor-field textarea {
  min-height: 88px;
  resize: vertical;
}

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

.material-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.compact-button {
  min-width: 108px;
  height: 40px;
}

.material-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.material-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.material-block strong {
  display: block;
  font-size: 13px;
}

.material-block pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  font: inherit;
  color: var(--text);
}

.material-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.outreach-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 260px;
}

.material-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text);
}

.empty-materials {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

.result-count {
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

th,
td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: top;
}

td select,
td input[type="date"] {
  width: 100%;
  min-width: 120px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 0 8px;
}

.notes-input,
.status-select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.notes-input {
  min-width: 180px;
  padding: 8px 10px;
  resize: vertical;
}

.status-select {
  height: 34px;
  padding: 0 8px;
  margin-top: 8px;
}

.status-editor {
  min-width: 120px;
}

th {
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 28px 16px;
}

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

a:hover {
  text-decoration: underline;
}

.tier-badge,
.tag-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.tier-badge {
  min-width: 28px;
  justify-content: center;
}

.tier-A {
  background: #dcfce7;
  color: #166534;
}

.tier-B {
  background: #dbeafe;
  color: #1d4ed8;
}

.tier-C {
  background: #f3e8ff;
  color: #7e22ce;
}

.tag-chip {
  margin: 2px 6px 2px 0;
  background: #e2e8f0;
  color: #334155;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 20px 14px 36px;
  }

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

  h1 {
    font-size: 32px;
  }

  .primary-button {
    width: 100%;
  }

  .status-row,
  .table-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .materials-grid {
    grid-template-columns: 1fr;
  }

  .material-editor {
    grid-template-columns: 1fr;
  }

  .poster-preview-panel {
    position: static;
  }

  .poster-preview-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .poster-stage {
    min-height: 360px;
  }
}
