:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #d8e0eb;
  --line-strong: #bfccda;
  --text: #102033;
  --muted: #66758b;
  --brand: #1d8f83;
  --brand-strong: #166f67;
  --blue: #2f80d8;
  --warn: #b7791f;
  --danger: #b42318;
  --ok: #157347;
  --shadow: 0 10px 28px rgba(15, 32, 51, 0.08);
  font-family:
    Inter, "Noto Sans SC", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background: #eef2f6;
}

.login-panel {
  width: min(420px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-brand {
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.login-brand strong,
.login-brand span {
  display: block;
}

.login-brand strong {
  color: var(--brand);
  font-size: 22px;
}

.login-brand span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.login-panel form {
  display: grid;
  gap: 16px;
  padding: 26px;
}

.login-panel form .btn {
  width: 100%;
  margin-top: 2px;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fff;
}

.brand {
  height: 78px;
  display: grid;
  align-content: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}

.brand strong {
  display: block;
  color: var(--brand);
  font-size: 22px;
  line-height: 1.1;
}

.brand span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.nav {
  padding: 16px 12px;
  overflow: auto;
}

.nav-group {
  margin-bottom: 14px;
}

.nav-title {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.nav a {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0;
  padding: 8px 12px;
  border-radius: 8px;
  color: #2f4057;
  font-size: 14px;
}

.nav a:hover,
.nav a.active {
  color: var(--brand-strong);
  background: #e8f5f2;
}

.main {
  min-width: 0;
}

.topbar {
  height: 78px;
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 4;
}

.topbar-title {
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-user {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.page {
  width: calc(100% - 40px);
  max-width: none;
  margin: 0 auto;
  padding: 24px 0 42px;
}

.desktop-page {
  min-width: 0;
}

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

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

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

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

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

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

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

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

.panel,
.metric,
.hero {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.hero {
  padding: 22px 24px;
  background: #17495a;
  color: #fff;
}

.hero a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hero strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.hero span {
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
}

.metric {
  padding: 15px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.toolbar,
.panel-head,
.row-actions,
.tabs,
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

.filters {
  align-items: end;
  margin-bottom: 12px;
}

.posts-filter-panel {
  padding: 16px;
}

.posts-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.posts-filter-button {
  width: 100%;
}

.posts-table-panel {
  margin-top: 16px;
  padding: 0;
  overflow: hidden;
}

.posts-table-panel .table-wrap {
  border: 0;
  border-radius: 0;
}

.posts-pagination {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.posts-pagination strong {
  min-width: 86px;
  color: var(--text);
  text-align: center;
  font-size: 13px;
}

.posts-pagination .btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.posts-data-table {
  min-width: 1500px;
  table-layout: fixed;
}

.posts-data-table th,
.posts-data-table td {
  padding: 9px 10px;
  vertical-align: middle;
}

.posts-data-table th {
  white-space: nowrap;
}

.posts-data-table th:nth-child(1) { width: 92px; }
.posts-data-table th:nth-child(2) { width: 110px; }
.posts-data-table th:nth-child(3) { width: 88px; }
.posts-data-table th:nth-child(4) { width: 96px; }
.posts-data-table th:nth-child(5) { width: 112px; }
.posts-data-table th:nth-child(6) { width: 165px; }
.posts-data-table th:nth-child(7) { width: 430px; }
.posts-data-table th:nth-child(n+8):nth-child(-n+12) { width: 70px; }
.posts-data-table th:nth-child(13) { width: 120px; }

.posts-data-table td:nth-child(5),
.posts-data-table td:nth-child(6),
.posts-data-table td:nth-child(n+8) {
  white-space: nowrap;
}

.post-list-content {
  min-width: 0;
}

.post-list-content > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.post-list-content .post-detail-link {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-list-content small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #8290a5;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 86px;
  padding: 10px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29, 143, 131, 0.12);
}

.btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
}

.btn.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.btn.warn {
  border-color: #f4d69b;
  background: #fff9e8;
  color: var(--warn);
}

.btn.danger {
  border-color: #f5c2bd;
  background: #fff1f0;
  color: var(--danger);
}

.pill,
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef3f8;
  color: #506177;
  font-size: 12px;
  font-weight: 700;
}

.tag.success,
.tag.active {
  background: #e7f6ee;
  color: var(--ok);
}

.tag.failed {
  background: #fff1f0;
  color: var(--danger);
}

.tag.cancelled {
  background: #f1f3f5;
  color: #667085;
}

.tag.running,
.tag.queued {
  background: #eef6ff;
  color: var(--blue);
}

.tag.pending,
.tag.needs_config {
  background: #fff8e6;
  color: var(--warn);
}

.account-status-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 92px;
}

.account-status-cell small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.site-account-count {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 104px;
}

.site-account-count strong {
  font-size: 14px;
}

.site-account-count small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 13px;
}

.accounts-table {
  min-width: 1120px;
}

.accounts-table th:nth-last-child(-n+4),
.accounts-table td:nth-last-child(-n+4) {
  white-space: nowrap;
}

.account-status-filter {
  position: relative;
  display: flex;
  align-items: center;
  width: max-content;
  padding-right: 12px;
  cursor: pointer;
}

.account-status-filter::after {
  position: absolute;
  top: 50%;
  right: 1px;
  width: 0;
  height: 0;
  border-top: 4px solid #718096;
  border-right: 3px solid transparent;
  border-left: 3px solid transparent;
  content: "";
  transform: translateY(-35%);
}

.account-status-filter select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  opacity: 0;
  cursor: pointer;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

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

td a {
  color: var(--brand-strong);
}

.url-cell {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  min-height: 92px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

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

.quick-card {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eaf7f4;
}

.quick-card.planned {
  background: #fff9e8;
  border-color: #f2dda0;
}

.quick-card strong {
  font-size: 16px;
}

.quick-card span {
  color: var(--muted);
  font-size: 12px;
}

.chart {
  min-height: 220px;
  display: flex;
  align-items: end;
  gap: 10px;
  padding: 16px 6px 0;
  border-top: 1px solid var(--line);
  justify-content: flex-start;
}

.bar {
  flex: 1;
  min-width: 26px;
  max-width: 80px;
  display: grid;
  align-items: end;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.bar i {
  display: block;
  min-height: 8px;
  border-radius: 6px 6px 0 0;
  background: #2f80d8;
}

.analytics-controls {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.analytics-loading {
  align-self: center;
  color: var(--muted);
  font-size: 13px;
}

.analytics-periods {
  display: flex;
  align-items: center;
  gap: 8px;
}

.segmented {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.segmented .btn {
  border-color: transparent;
  background: transparent;
}

.segmented .btn.primary {
  background: var(--brand);
  color: #fff;
}

.compact-filters {
  justify-content: flex-end;
  margin-bottom: 0;
}

.compact-filters label {
  min-width: 132px;
}

.secondary-metrics {
  margin-top: 14px;
}

.schedule-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.schedule-strip > div {
  min-width: 0;
  padding: 14px 16px;
  background: #fff;
}

.schedule-strip span,
.schedule-strip strong {
  display: block;
}

.schedule-strip span {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.schedule-strip strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.success-notice {
  margin-top: 14px;
  border-color: #b8ddd4;
  background: #eef9f6;
  color: #166f67;
}

.error-text {
  max-width: 240px;
  margin-top: 5px;
  overflow: hidden;
  color: var(--danger);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-detail-link {
  font-weight: 700;
}

.external-link {
  margin-left: 4px;
  font-size: 15px;
}

.post-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.post-detail-main,
.post-detail-side {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.post-detail-main > .panel,
.post-detail-side > .panel {
  min-width: 0;
}

.post-detail-main .table-wrap {
  max-width: 100%;
}

.post-overview {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 20px;
  min-height: 220px;
}

.post-media {
  width: 150px;
  aspect-ratio: 9 / 16;
  align-self: start;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111827;
}

.post-media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.post-media.empty-media {
  display: grid;
  place-items: center;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
}

.post-copy {
  min-width: 0;
  padding: 4px 0;
}

.post-meta-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
}

.original-post-link {
  display: block;
  margin-top: 12px;
  overflow-wrap: anywhere;
  color: var(--brand-strong);
  font-size: 13px;
}

.post-title {
  margin-top: 16px;
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.detail-hashtags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.detail-hashtag {
  padding: 4px 7px;
  border-radius: 4px;
  background: #eaf4fb;
  color: #27648b;
  font-size: 12px;
}

.source-badge {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  background: #eee5ff;
  color: #7c3aed;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.post-music {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.detail-pairs {
  display: grid;
  gap: 11px;
}

.detail-pair {
  display: grid;
  grid-template-columns: minmax(90px, 0.8fr) minmax(0, 1.4fr);
  gap: 12px;
  align-items: start;
  font-size: 13px;
}

.detail-pair span {
  color: var(--muted);
}

.detail-pair strong {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
  font-weight: 500;
}

.detail-pair a {
  color: var(--brand-strong);
}

.detail-divider {
  height: 1px;
  margin: 16px 0;
  background: var(--line);
}

.detail-caption {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.comment-list {
  display: grid;
}

.comment-row {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.comment-row:first-child {
  padding-top: 0;
}

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

.comment-row > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comment-row p {
  margin-top: 7px;
  line-height: 1.6;
}

.comment-row > span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.split {
  display: grid;
  grid-template-columns: minmax(340px, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.split > * {
  min-width: 0;
}

.split > form.panel {
  position: sticky;
  top: 94px;
}

.split > .panel .filters label {
  flex: 1 1 150px;
}

.notice {
  padding: 12px;
  border: 1px solid #f2dda0;
  border-radius: 8px;
  background: #fffaf0;
  color: #7a5200;
  font-size: 13px;
}

.permission-panel {
  max-width: 620px;
}

.permission-panel .btn {
  margin-top: 18px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #102033;
  color: #fff;
  box-shadow: var(--shadow);
}

.mobile-menu {
  display: none;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

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

  .nav {
    display: none;
  }

  .nav-open .nav {
    display: grid;
  }

  .mobile-menu {
    display: inline-flex;
  }

  .cols-5,
  .cols-4,
  .cols-3,
  .cols-2,
  .split,
  .quick-grid,
  .post-detail-layout {
    grid-template-columns: 1fr;
  }

  .split > form.panel {
    position: static;
  }

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

  .compact-filters {
    justify-content: stretch;
  }

  .compact-filters label {
    flex: 1 1 180px;
  }

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

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

@media (max-width: 620px) {
  .page {
    width: calc(100% - 20px);
    padding-top: 16px;
  }

  .topbar {
    padding: 0 12px;
  }

  h1 {
    font-size: 22px;
  }

  .segmented {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .schedule-strip {
    grid-template-columns: 1fr;
  }

  .post-overview {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 14px;
    min-height: 0;
  }

  .post-media {
    width: 96px;
  }
}
