:root {
  --bg: #f3f5f2;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: #ffffff;
  --text: #253d35;
  --muted: #617468;
  --line: rgba(43, 68, 55, 0.12);
  --accent: #245b42;
  --accent-dark: #21553e;
  --success: #1e7a52;
  --error: #9b2c2c;
  --queued: #7b5e00;
  --running: #9a4b15;
  --completed: #1e7a52;
  --failed: #9b2c2c;
  --cancelled: #617468;
  --duplicate: #8b5a12;
  --shadow: 0 2px 8px rgba(23, 57, 38, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.topbar,
.grid,
.login-card {
  width: min(1200px, calc(100% - 32px));
}

.topbar {
  margin: 0 auto;
  padding: 28px 0 20px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.muted {
  color: var(--muted);
}

.grid {
  margin: 0 auto 32px;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
}

.span-2 {
  grid-column: span 2;
}

.panel,
.login-card {
  background: var(--surface);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head-block {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-body {
  display: block;
}

.is-collapsed .panel-body {
  display: none;
}

.is-collapsed .section-head {
  margin-bottom: 0;
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(36, 91, 66, 0.1);
  color: var(--accent-dark);
  font-size: 13px;
}

.stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

input,
textarea,
button,
select {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(43, 68, 55, 0.18);
  border-radius: 14px;
  background: rgba(252, 253, 251, 0.88);
  padding: 12px 14px;
  color: var(--text);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent-dark) 50%),
    linear-gradient(135deg, var(--accent-dark) 50%, transparent 50%),
    linear-gradient(to right, rgba(43, 68, 55, 0.08), rgba(43, 68, 55, 0.08));
  background-position:
    calc(100% - 22px) 50%,
    calc(100% - 16px) 50%,
    calc(100% - 46px) 50%;
  background-size:
    6px 6px,
    6px 6px,
    1px 56%;
  background-repeat: no-repeat;
  padding-right: 58px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(36, 91, 66, 0.44);
  box-shadow: 0 0 0 4px rgba(36, 91, 66, 0.08);
  outline: none;
}

textarea {
  resize: vertical;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--accent) 0%, #31684e 100%);
  color: white;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

button.secondary {
  background: rgba(43, 68, 55, 0.08);
  color: var(--text);
}

button.small-button {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
}

.sites-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.site-card {
  min-height: 230px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-strong);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.site-card h3 {
  margin-bottom: 14px;
  font-size: 20px;
}

.site-card p {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.site-card-body {
  min-height: 138px;
}

.site-card-footer {
  margin-top: 14px;
}

.card-link-button {
  display: inline-flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  padding: 12px 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, #31684e 100%);
  color: white;
  text-decoration: none;
}

.site-table-name {
  font-weight: 700;
  margin-bottom: 4px;
}

.site-table-url {
  overflow-wrap: anywhere;
}

.breadcrumbs {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--muted);
}

.breadcrumbs a {
  color: var(--accent-dark);
  text-decoration: none;
}

.workspace-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.workspace-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(36, 91, 66, 0.1);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.workspace-pill.active {
  background: rgba(36, 91, 66, 0.16);
}

.workspace-pill.muted-pill {
  background: rgba(43, 68, 55, 0.06);
  color: var(--muted);
}

.overview-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.overview-stat {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-strong);
}

.overview-stat strong {
  display: block;
  overflow-wrap: anywhere;
}

.stat-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.details-block {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(252, 253, 251, 0.72);
  overflow: hidden;
}

.details-block summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 700;
}

.details-block summary::-webkit-details-marker {
  display: none;
}

.details-block[open] summary {
  border-bottom: 1px solid var(--line);
}

.details-form {
  padding: 16px;
}

.compact-details {
  margin-top: 0;
  flex: 1;
}

.compact-details summary {
  padding: 11px 14px;
}

.site-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.site-edit-details {
  min-width: 0;
}

.site-edit-details[open] + .delete-confirm {
  display: none;
}

.delete-confirm {
  flex: 0 0 auto;
  margin: 0;
}

.delete-confirm[open] {
  flex-basis: 100%;
}

.delete-confirm summary {
  height: 43px;
  padding: 0 14px;
  border: 1px solid rgba(155, 44, 44, 0.14);
  border-radius: 14px;
  background: rgba(155, 44, 44, 0.07);
  color: rgba(155, 44, 44, 0.82);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.delete-confirm summary::-webkit-details-marker {
  display: none;
}

.delete-confirm[open] summary {
  background: rgba(155, 44, 44, 0.13);
}

.delete-confirm-box {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  border: 1px solid rgba(155, 44, 44, 0.16);
  border-radius: 16px;
  background: rgba(252, 253, 251, 0.96);
  box-shadow: none;
}

.delete-confirm-box p {
  margin-bottom: 8px;
}

.delete-confirm-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.delete-confirm-actions button {
  flex: 1;
  padding: 10px 12px;
}

.danger-button {
  height: 43px;
  padding: 0 14px;
  border: 1px solid rgba(155, 44, 44, 0.14);
  background: rgba(155, 44, 44, 0.07);
  color: rgba(155, 44, 44, 0.82);
  box-shadow: none;
}

.danger-button:hover {
  background: rgba(155, 44, 44, 0.13);
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.form-actions button {
  flex: 1;
}

.add-site-wrap {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.add-site-details {
  width: min(560px, 100%);
}

.add-site-details summary {
  text-align: center;
}

.settings-note {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(36, 91, 66, 0.08);
}

.settings-note code {
  padding: 3px 7px;
  border-radius: 8px;
  background: rgba(252, 253, 251, 0.9);
}

.schedule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.topic-generator-form {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(252, 253, 251, 0.72);
}

.topic-generator-wide {
  grid-column: span 2;
}

.topic-generation-feedback {
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid rgba(36, 91, 66, 0.14);
  border-radius: 18px;
  background: rgba(255, 248, 239, 0.82);
}

.topic-feedback-list {
  display: grid;
  gap: 10px;
}

.topic-feedback-item {
  padding: 12px 14px;
  border: 1px solid rgba(36, 91, 66, 0.12);
  border-radius: 14px;
  background: rgba(252, 253, 251, 0.92);
}

.topic-feedback-item p:last-child {
  margin-bottom: 0;
}

.posts-filter-form {
  display: grid;
  grid-template-columns: 220px 240px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 16px;
}

.filter-search {
  min-width: 0;
}

.filter-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(43, 68, 55, 0.08);
  color: var(--text);
  text-decoration: none;
}

.table-sort-button {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  box-shadow: none;
  text-align: left;
}

.table-sort-button:hover {
  transform: none;
  color: var(--accent-dark);
}

.table-sort-button::after {
  content: "";
  margin-left: 6px;
  opacity: 0.45;
}

.table-sort-button.is-asc::after {
  content: "↑";
  opacity: 1;
}

.table-sort-button.is-desc::after {
  content: "↓";
  opacity: 1;
}

.jobs-table-wrap {
  overflow-x: auto;
}

.jobs-table {
  width: 100%;
  border-collapse: collapse;
}

.content-table-wrap {
  overflow-x: auto;
}

.content-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.content-table thead th {
  padding-top: 0;
  padding-bottom: 14px;
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.content-table tbody tr:nth-child(even) {
  background: rgba(43, 68, 55, 0.025);
}

.content-table tbody tr:hover {
  background: rgba(36, 91, 66, 0.06);
}

.categories-table th:nth-child(1),
.categories-table td:nth-child(1) {
  width: 34%;
}

.categories-table th:nth-child(2),
.categories-table td:nth-child(2) {
  width: 46%;
}

.categories-table th:nth-child(3),
.categories-table td:nth-child(3) {
  width: 20%;
}

.categories-table td:nth-child(2) {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.posts-table th:first-child,
.posts-table td:first-child {
  width: 36%;
}

.posts-table th:nth-child(2),
.posts-table td:nth-child(2) {
  width: 20%;
}

.posts-table th:nth-child(3),
.posts-table td:nth-child(3),
.posts-table th:nth-child(4),
.posts-table td:nth-child(4),
.posts-table th:nth-child(5),
.posts-table td:nth-child(5) {
  width: 14%;
}

.posts-table td:first-child,
.posts-table td:first-child a {
  overflow-wrap: anywhere;
}

.jobs-table th,
.jobs-table td,
.content-table th,
.content-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 16px;
  line-height: 1.45;
}

.sites-table th:nth-child(2),
.sites-table td:nth-child(2),
.sites-table th:nth-child(3),
.sites-table td:nth-child(3),
.sites-table th:nth-child(4),
.sites-table td:nth-child(4) {
  white-space: nowrap;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:focus-visible {
  outline: 2px solid rgba(36, 91, 66, 0.4);
  outline-offset: -2px;
}

.jobs-table th:last-child,
.jobs-table td:last-child {
  min-width: 82px;
  white-space: nowrap;
}

.error-cell {
  max-width: 360px;
  word-break: break-word;
}

.schedule-note {
  display: grid;
  gap: 4px;
  font-size: 14px;
}

.schedule-note strong {
  color: var(--accent-dark);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.schedule-note span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.post-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.post-category-chip {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(36, 91, 66, 0.1);
  color: var(--accent-dark);
  font-size: 12px;
  line-height: 1.2;
}

.icon-actions {
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
}

.icon-button {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  background: rgba(43, 68, 55, 0.06);
  color: rgba(31, 27, 23, 0.72);
  font-size: 15px;
  line-height: 1;
  box-shadow: none;
}

.icon-button.danger {
  background: rgba(155, 44, 44, 0.07);
  color: rgba(155, 44, 44, 0.78);
}

.icon-button:hover {
  background: rgba(36, 91, 66, 0.12);
}

.icon-button.danger:hover {
  background: rgba(155, 44, 44, 0.13);
}

.status {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-queued {
  background: rgba(123, 94, 0, 0.12);
  color: var(--queued);
}

.status-running {
  background: rgba(154, 75, 21, 0.12);
  color: var(--running);
}

.status-completed {
  background: rgba(30, 122, 82, 0.12);
  color: var(--completed);
}

.status-failed {
  background: rgba(155, 44, 44, 0.12);
  color: var(--failed);
}

.status-cancelled {
  background: rgba(107, 98, 87, 0.12);
  color: var(--cancelled);
}

.status-possible_duplicate {
  background: rgba(139, 90, 18, 0.12);
  color: var(--duplicate);
}

.status-empty,
.status-ready,
.status-uploaded {
  background: rgba(30, 122, 82, 0.12);
  color: var(--completed);
}

.status-generating,
.status-uploading {
  background: rgba(154, 75, 21, 0.12);
  color: var(--running);
}

.setup-status-row,
.setup-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.setup-form {
  margin-top: 14px;
}

.favicon-preview {
  width: 96px;
  height: 96px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-strong);
}

.favicon-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.setup-report {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(252, 253, 251, 0.88);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.duplicate-note {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(139, 90, 18, 0.08);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.duplicate-note span {
  display: inline-flex;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(139, 90, 18, 0.12);
  color: var(--duplicate);
  font-weight: 700;
}

.duplicate-meta {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.alert {
  padding: 12px 14px;
  border-radius: 14px;
  margin-bottom: 16px;
}

.alert-success {
  background: rgba(30, 122, 82, 0.12);
  color: var(--success);
}

.alert-error {
  background: rgba(155, 44, 44, 0.12);
  color: var(--error);
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px 0;
}

.login-card {
  max-width: 460px;
  padding: 28px;
}

a {
  color: var(--accent-dark);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 18px;
}

.pagination a,
.pagination .current-page {
  min-width: 36px;
  padding: 8px 11px;
  border-radius: 999px;
  text-align: center;
  text-decoration: none;
  border: 1px solid var(--line);
}

.pagination a {
  background: rgba(252, 253, 251, 0.72);
}

.pagination .current-page {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .topbar {
    flex-direction: column;
  }

  .sites-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-head {
    align-items: flex-start;
  }

  .overview-stats {
    grid-template-columns: 1fr;
  }

  .schedule-grid {
    grid-template-columns: 1fr;
  }

  .topic-generator-wide {
    grid-column: span 1;
  }

  .posts-filter-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .sites-list {
    grid-template-columns: 1fr;
  }

  .sites-table th,
  .sites-table td {
    white-space: normal;
  }

}
