:root {
  --bg: #f2f4ef;
  --paper: rgba(255, 255, 255, 0.92);
  --paper-strong: #ffffff;
  --line: rgba(16, 24, 16, 0.08);
  --text: #1f2a1f;
  --muted: #687468;
  --green: #2d7b55;
  --green-dark: #1f5a3e;
  --green-soft: #e7f3eb;
  --red-soft: #fbe9e7;
  --red: #b24b38;
  --amber-soft: #fff5dc;
  --amber: #9b7410;
  --shadow: 0 24px 60px rgba(40, 54, 35, 0.12);
  --radius-xl: 10px;
  --radius-lg: 10px;
  --radius-md: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 16px/1.5 "SF Pro Display", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(62, 155, 110, 0.18), transparent 28%),
    linear-gradient(180deg, #f8faf6 0%, #eef1ea 100%);
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.legal-body {
  padding: 24px;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: rgba(244, 247, 242, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  background: linear-gradient(135deg, #1c5037, #56a675);
}

.brand p,
.sidebar-note p,
.muted,
.page-head p,
.hero p,
.stat-card p,
.token-card p,
.list-row p,
.connection-card p,
.connection-card small,
.post-row p,
.target-pill span,
.target-pill small {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.sidebar-logout {
  order: 99;
  margin-top: auto;
}

.sidebar-logout .button {
  width: 100%;
  justify-content: flex-start;
}

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

.inline-form select {
  min-width: 120px;
}

.nav a {
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
}

.nav a.active,
.nav a:hover {
  color: var(--text);
  background: var(--paper-strong);
  box-shadow: var(--shadow);
}

.sidebar-note {
  padding: 18px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
}

.content {
  padding: 12px 28px 28px;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.flash-success {
  background: var(--green-soft);
}

.flash-error {
  background: var(--red-soft);
}

.flash-warning {
  background: var(--amber-soft);
}

.hero,
.page-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  margin-bottom: 24px;
}

.login-shell {
  width: min(100%, 520px);
}

.legal-shell {
  width: min(100%, 960px);
  margin: 0 auto;
}

.login-panel {
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: var(--paper);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.legal-hero,
.legal-card {
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: var(--paper);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.legal-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 22px 24px;
}

.legal-brand {
  display: inline-flex;
  gap: 14px;
  align-items: center;
}

.legal-brand strong,
.legal-brand small {
  display: block;
}

.legal-brand small {
  color: var(--muted);
}

.legal-nav {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.legal-nav a,
.login-links a {
  color: var(--green-dark);
  font-weight: 600;
}

.legal-card {
  padding: 32px;
}

.legal-lead {
  margin-bottom: 24px;
  color: var(--muted);
}

.legal-stack {
  display: grid;
  gap: 24px;
}

.legal-stack section {
  display: grid;
  gap: 10px;
}

.login-copy {
  margin-bottom: 20px;
  color: var(--muted);
}

.login-links {
  display: flex;
  gap: 16px;
  margin-top: 20px;
  flex-wrap: wrap;
}

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

.eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

h1,
h2,
h4,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 4vw, 56px);
  line-height: 1;
  letter-spacing: -0.03em;
  margin-bottom: 10px;
}

h2 {
  font-size: 20px;
}

.stats-grid,
.panel-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 24px;
}

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

.panel-grid {
  grid-template-columns: 1.3fr 1fr;
}

.panel-grid-wide {
  grid-template-columns: 1.2fr 1fr;
}

.panel,
.stat-card {
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: var(--paper);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 22px;
}

.stat-card span {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  font-size: 44px;
  line-height: 1;
  margin-bottom: 10px;
}

.panel {
  padding: 22px;
}

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

.panel-head a,
.panel-head span {
  color: var(--muted);
  font-size: 14px;
}

.button {
  border: 0;
  border-radius: 10px;
  padding: 13px 22px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(31, 42, 31, 0.06);
}

.button-primary {
  color: white;
  background: linear-gradient(135deg, var(--green), #4db37b);
}

.button-ghost {
  background: var(--paper-strong);
  color: var(--text);
  border: 1px solid var(--line);
}

.button-danger {
  background: rgba(178, 75, 56, 0.12);
  color: var(--red);
  border: 1px solid rgba(178, 75, 56, 0.2);
}

.token-list,
.stack,
.posts-table {
  display: grid;
  gap: 14px;
}

.token-card,
.list-row,
.connection-card,
.post-row,
.target-pill,
.account-option {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-strong);
}

.token-card,
.list-row {
  padding: 16px;
}

.connection-card {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 16px;
}

.connection-card-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.badge,
.status {
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.badge-youtube {
  background: #feeceb;
  color: #b3392f;
}

.badge-instagram {
  background: #fff1e6;
  color: #b85d28;
}

.badge-tiktok {
  background: #eaf4fb;
  color: #255d86;
}

.badge-threads {
  background: #eceef2;
  color: #243042;
}

.badge-twitter {
  background: #e9f5ff;
  color: #0f4c81;
}

.badge-facebook {
  background: #e8f0ff;
  color: #1d4ed8;
}

.badge-linkedin {
  background: #e8f3fb;
  color: #0a66c2;
}

.status-published {
  background: var(--green-soft);
  color: var(--green-dark);
}

.status-draft {
  background: #eef0ef;
  color: #58655c;
}

.status-failed,
.status-partial_failed {
  background: var(--red-soft);
  color: var(--red);
}

.status-publishing {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-queued {
  background: #e8eefc;
  color: #31539a;
}

.status-scheduled {
  background: #eef7f2;
  color: #2d7b55;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

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

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

.account-api-fields {
  margin-top: 4px;
  padding-top: 4px;
}

.account-api-fields[hidden] {
  display: none;
}

label span {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

label small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  justify-content: flex-start;
}

.composer-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.4fr) 360px;
}

.composer-main,
.composer-side {
  min-height: min-content;
}

.upload-dropzone {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 280px;
  margin-bottom: 18px;
  padding: 24px;
  border: 2px dashed rgba(45, 123, 85, 0.28);
  border-radius: 10px;
  text-align: center;
  background:
    radial-gradient(circle at center, rgba(77, 179, 123, 0.08), transparent 45%),
    #fbfdfa;
}

.upload-dropzone input {
  display: none;
}

.upload-label {
  font-size: 24px;
  font-weight: 700;
}

.panel-subsection {
  margin-top: 20px;
}

.schedule-field {
  display: grid;
  gap: 8px;
}

.schedule-field small {
  color: var(--muted);
  line-height: 1.45;
}

.account-selector,
.target-pills {
  display: grid;
  gap: 12px;
}

.account-option {
  display: flex;
  gap: 14px;
  padding: 14px;
}

.account-option input {
  width: 20px;
  height: 20px;
  margin-top: 4px;
}

.checklist {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 16px;
  border-radius: 10px;
  background: #f7faf7;
  border: 1px solid var(--line);
  color: var(--muted);
}

.post-row {
  position: relative;
  padding: 18px;
}

.video-posts-head,
.text-posts-head {
  margin-bottom: 28px;
}

.video-posts-head p,
.text-posts-head p {
  max-width: 920px;
  font-size: 17px;
  line-height: 1.65;
}

.video-posts-panel,
.text-posts-panel {
  padding: 0;
  overflow: hidden;
}

.video-post-row,
.text-post-row {
  padding: 40px 40px 28px;
  border-radius: 10px;
}

.video-post-copy,
.post-row-copy {
  max-width: 100%;
  max-height: 300px;
  overflow: hidden auto;
  padding-right: 10px;
}

.video-post-copy,
.post-row-copy {
  width: min(100%, calc(100% - 420px));
}

.video-post-title {
  display: block;
  margin-bottom: 8px;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.video-post-description {
  font-size: 16px;
  line-height: 1.55;
}

.post-row-title {
  display: block;
  margin-bottom: 14px;
  color: #1f2a1f;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  text-transform: none;
}

.post-row-body {
  font-size: 16px;
  line-height: 1.55;
  font-weight: 400;
  color: #273225;
  white-space: pre-wrap;
  word-break: break-word;
}

.post-row-main,
.post-row-meta,
.post-row-actions {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.post-row-status,
.post-row-corner-status {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.post-row-corner-status {
  position: absolute;
  top: 24px;
  right: 24px;
}

.post-row-published-at {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.post-row-meta {
  margin: 14px 0;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
}

.video-post-row .status,
.text-post-row .status {
  flex-shrink: 0;
}

.video-post-row .post-row-meta,
.text-post-row .post-row-meta {
  margin: 28px 0 0;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(16, 24, 16, 0.07);
  font-size: 15px;
}

.video-post-row .status,
.text-post-row .status {
  padding: 8px 14px;
  background: #f0f2ef;
  color: #6c776f;
}

.target-pill {
  padding: 12px 14px;
}

.target-pill-platform {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.target-pill-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.target-pill-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
}

.target-pill-state-published,
.target-pill-state-queued,
.target-pill-state-publishing {
  color: var(--green-dark);
}

.target-pill-state-published .target-pill-state-icon,
.target-pill-state-queued .target-pill-state-icon,
.target-pill-state-publishing .target-pill-state-icon {
  background: rgba(45, 123, 85, 0.12);
}

.target-pill-state-published .target-pill-state-icon::before,
.target-pill-state-queued .target-pill-state-icon::before,
.target-pill-state-publishing .target-pill-state-icon::before {
  content: "✓";
}

.target-pill-state-failed,
.target-pill-state-partial_failed {
  color: var(--red);
}

.target-pill-state-failed .target-pill-state-icon,
.target-pill-state-partial_failed .target-pill-state-icon {
  background: rgba(178, 75, 56, 0.12);
}

.target-pill-state-failed .target-pill-state-icon::before,
.target-pill-state-partial_failed .target-pill-state-icon::before {
  content: "×";
}

.target-pill-state-draft {
  color: #6c776f;
}

.target-pill-state-draft .target-pill-state-icon {
  background: rgba(108, 119, 111, 0.12);
}

.target-pill-state-draft .target-pill-state-icon::before {
  content: "•";
}

.target-pill-error {
  grid-column: 2;
  color: var(--red);
  font-size: 13px;
  line-height: 1.45;
  justify-self: end;
  text-align: right;
}

.video-target-pills,
.text-target-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 18px;
}

.video-target-pills .target-pill,
.text-target-pills .target-pill {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 18px;
  row-gap: 6px;
  min-height: 62px;
  min-width: 320px;
  width: fit-content;
  max-width: 100%;
  padding: 16px 24px;
  border-radius: 10px;
}

.video-target-pills .target-pill strong,
.text-target-pills .target-pill strong {
  font-size: 18px;
}

.video-target-pills .target-pill span,
.text-target-pills .target-pill span {
  font-size: 15px;
}

.video-post-row .post-row-actions,
.text-post-row .post-row-actions {
  margin-top: 28px;
  padding: 24px 4px 4px;
  border-top: 1px solid rgba(16, 24, 16, 0.07);
  justify-content: flex-start;
}

.video-post-row .post-row-actions form,
.text-post-row .post-row-actions form {
  margin: 0;
}

.post-row-actions > a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.video-post-row .button,
.text-post-row .button {
  min-width: 150px;
  padding-inline: 26px;
}

.video-post-row .button-ghost,
.text-post-row .button-ghost {
  background: #fff;
}

.video-post-row .button-danger,
.text-post-row .button-danger {
  color: var(--red);
}

.target-pill-published {
  border-color: rgba(45, 123, 85, 0.2);
}

.target-pill-failed {
  border-color: rgba(178, 75, 56, 0.2);
}

.target-pill-queued,
.target-pill-publishing {
  border-color: rgba(49, 83, 154, 0.2);
}

@media (max-width: 1080px) {
  .shell,
  .composer-layout,
  .panel-grid,
  .panel-grid-wide,
  .stats-grid {
    grid-template-columns: 1fr;
  }

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

  .hero,
  .page-head,
  .legal-hero,
  .post-row-main,
  .post-row-actions {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .content,
  .sidebar {
    padding: 20px;
  }

  .text-post-row {
    padding: 24px 20px 20px;
  }

  .video-posts-head p,
  .text-posts-head p,
  .post-row-body {
    font-size: 16px;
  }

  .video-post-row,
  .text-post-row {
    padding: 24px 20px 20px;
  }

  .post-row-corner-status {
    position: static;
    margin-bottom: 16px;
  }

  .video-post-copy,
  .post-row-copy {
    max-height: 300px;
    width: 100%;
  }

  .video-post-title,
  .post-row-title {
    font-size: 22px;
  }

  .video-target-pills .target-pill,
  .text-target-pills .target-pill {
    padding: 14px 16px;
    grid-template-columns: 1fr;
    min-width: min(100%, 280px);
  }

  .target-pill-state,
  .target-pill-error {
    justify-self: start;
    text-align: left;
  }

  .target-pill-error {
    grid-column: 1;
  }

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