:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f4;
  --text: #17202a;
  --muted: #687382;
  --border: #d8dee6;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #be123c;
  --warning: #b45309;
  --info: #2563eb;
  --radius: 8px;
  --shadow: 0 14px 36px rgba(23, 32, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.16), rgba(37, 99, 235, 0.08)),
    var(--bg);
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.logout-form {
  margin: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 230px;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: #17202a;
  color: #fff;
  font-weight: 800;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.nav a {
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 650;
}

.nav a.active,
.nav a:hover {
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.page-shell {
  width: min(1420px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  display: grid;
  width: min(440px, 100%);
  gap: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: 26px;
}

.login-brand {
  min-width: 0;
}

.login-form {
  padding: 0;
  border: 0;
  box-shadow: none;
}

.alert {
  border: 1px solid #fecdd3;
  border-radius: 7px;
  background: #fff1f2;
  color: var(--danger);
  font-weight: 750;
  padding: 10px 12px;
}

.notice {
  border: 1px solid #bae6fd;
  border-radius: 7px;
  background: #f0f9ff;
  color: #075985;
  font-weight: 750;
  padding: 10px 12px;
}

.page-notice {
  margin: 0 0 14px;
}

.page-notice span {
  display: block;
  margin-top: 4px;
  font-weight: 650;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.05;
}

h2 {
  font-size: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 104px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-weight: 650;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
  line-height: 1;
}

.split-layout,
.work-grid {
  display: grid;
  gap: 18px;
  align-items: start;
}

.split-layout {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.72fr);
}

.work-grid {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  margin-bottom: 18px;
}

.content-column {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.panel {
  padding: 18px;
}

.calendar-panel {
  margin-bottom: 18px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--border);
}

.calendar-weekday,
.calendar-day {
  background: #fff;
}

.calendar-weekday {
  min-height: 34px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.calendar-day {
  min-height: 132px;
  padding: 10px;
}

.calendar-day.is-empty {
  background: #f8fafc;
}

.calendar-day.is-today {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.calendar-date {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
  margin-bottom: 8px;
}

.calendar-date strong {
  font-size: 15px;
}

.calendar-date span {
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  padding: 3px 7px;
}

.calendar-items {
  display: grid;
  gap: 6px;
}

.calendar-item,
.calendar-more {
  display: block;
  min-width: 0;
  border-radius: 7px;
  background: #f8fafc;
  color: var(--text);
  padding: 7px;
}

.calendar-item:hover,
.calendar-more:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.calendar-item strong,
.calendar-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-item strong {
  font-size: 13px;
}

.calendar-item small,
.calendar-more {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.form-panel {
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.readonly-field {
  display: grid;
  min-height: 40px;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #f8fafc;
  padding: 9px 10px;
}

.readonly-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.readonly-field strong {
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 9px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.field-row,
.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.filter-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 9px 14px;
}

.button:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent-strong);
}

.button.warning {
  border-color: #f59e0b;
  background: #fffbeb;
  color: var(--warning);
}

.button.danger {
  border-color: #fecdd3;
  background: #fff1f2;
  color: var(--danger);
}

.button.compact {
  min-height: 34px;
  padding: 7px 10px;
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td strong,
td .muted,
.content-main .muted {
  display: block;
}

.muted,
.hint {
  color: var(--muted);
}

.hint {
  margin: 0;
  font-size: 13px;
}

.empty {
  margin: 0;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #e5e7eb;
  color: #374151;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status.scheduled,
.status.approved {
  background: #dbeafe;
  color: var(--info);
}

.status.published {
  background: #dcfce7;
  color: #166534;
}

.status.failed,
.status.cancelled {
  background: #ffe4e6;
  color: var(--danger);
}

.status.manual_required,
.status.review {
  background: #fef3c7;
  color: var(--warning);
}

.status.publishing {
  background: #ccfbf1;
  color: var(--accent-strong);
}

.platform-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 7px;
  border-radius: 999px;
  background: var(--dot, var(--accent));
  vertical-align: middle;
}

.activity-list,
.content-list,
.stack-list {
  display: grid;
  gap: 10px;
}

.activity,
.content-row,
.stack-list article,
.editable-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.editable-list {
  margin-top: 6px;
}

.editable-row {
  flex-wrap: wrap;
}

.editable-row.is-inactive {
  opacity: 0.72;
}

.editable-row input[name="name"] {
  flex: 1 1 180px;
}

.editable-row input[name="username"] {
  flex: 1 1 130px;
}

.editable-row input[type="password"] {
  flex: 1 1 150px;
}

.editable-row input[name="role"] {
  flex: 1 1 140px;
}

.editable-row input[type="color"] {
  width: 48px;
  min-width: 48px;
  padding: 4px;
}

.check-label {
  display: inline-flex;
  width: auto;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.check-label input {
  width: auto;
  min-height: auto;
}

.employee-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.employee-meta span {
  border-radius: 999px;
  background: var(--surface-2);
  padding: 5px 8px;
}

.row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 7px;
}

.activity p,
.content-main p {
  margin: 4px 0 0;
  color: var(--muted);
}

.file-preview {
  display: grid;
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 850;
}

.file-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.content-main {
  min-width: 0;
  flex: 1;
}

.content-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.content-side {
  display: grid;
  min-width: 92px;
  justify-items: end;
  color: var(--muted);
}

.content-side strong {
  color: var(--text);
  font-size: 22px;
}

.small-link {
  display: block;
  margin-top: 6px;
  font-size: 12px;
}

.table-title-link {
  display: block;
  color: var(--text);
  font-weight: 850;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 18px;
  align-items: start;
}

.detail-main,
.detail-side {
  display: grid;
  gap: 18px;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.detail-grid div {
  display: grid;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #f8fafc;
  padding: 12px;
}

.detail-grid span,
.detail-section h2 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.detail-grid strong {
  font-size: 15px;
}

.detail-section {
  display: grid;
  gap: 8px;
}

.detail-section p {
  margin: 0;
  white-space: pre-wrap;
}

.embed-section {
  justify-items: start;
}

.server-embed-card {
  display: grid;
  width: min(100%, 560px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.server-embed-media,
.server-embed-placeholder {
  width: 100%;
  background: #f8fafc;
}

.server-embed-media {
  display: block;
  height: auto;
  max-height: 720px;
  object-fit: contain;
}

.server-embed-video {
  background: #000;
}

.server-embed-placeholder {
  display: grid;
  min-height: 240px;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.server-embed-body {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.server-embed-body p {
  color: var(--text);
}

.server-embed-provider {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.embed-message {
  color: var(--warning);
  font-size: 13px;
  font-weight: 750;
}

.detail-form {
  padding: 0;
  border: 0;
  box-shadow: none;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(180px, 1.2fr) minmax(180px, 1fr) auto;
  gap: 7px;
  min-width: 620px;
}

.inline-form input,
.inline-form select {
  min-height: 34px;
  padding: 7px 8px;
  font-size: 13px;
}

.line-clamp {
  display: -webkit-box;
  max-width: 420px;
  margin: 7px 0 0;
  overflow: hidden;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.instagram-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.instagram-section {
  margin-bottom: 18px;
}

.compact-filter {
  margin-bottom: 16px;
}

.account-list,
.job-list,
.instagram-media-list,
.comment-list {
  display: grid;
  gap: 10px;
}

.account-row,
.job-row,
.instagram-media-row,
.comment-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 11px;
}

.account-row,
.job-row,
.comment-row {
  justify-content: space-between;
}

.account-row p,
.job-row p,
.comment-row p {
  margin: 4px 0 0;
  color: var(--muted);
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.instagram-media-row {
  align-items: flex-start;
}

.attach-form {
  display: grid;
  grid-template-columns: minmax(180px, 260px) auto;
  gap: 7px;
  margin-left: auto;
}

.comment-row.needs-reply {
  border-color: #fbbf24;
  background: #fffbeb;
}

.comment-status-form {
  display: grid;
  grid-template-columns: minmax(150px, 220px) auto;
  gap: 7px;
  margin-left: auto;
}

@media (max-width: 980px) {
  .topbar,
  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .logout-form {
    position: absolute;
    top: 12px;
    right: 10px;
  }

  .brand {
    min-width: 0;
  }

  .nav {
    overflow-x: auto;
  }

  .split-layout,
  .detail-layout,
  .instagram-grid,
  .work-grid,
  .field-row {
    grid-template-columns: 1fr;
  }

  .calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-weekday {
    display: none;
  }

  .content-row {
    align-items: flex-start;
  }

  .account-row,
  .job-row,
  .instagram-media-row,
  .comment-row,
  .account-actions,
  .attach-form,
  .comment-status-form {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .account-row,
  .job-row,
  .instagram-media-row,
  .comment-row {
    flex-direction: column;
  }

  .attach-form,
  .comment-status-form {
    width: 100%;
    margin-left: 0;
  }

  .account-actions {
    width: 100%;
    justify-content: stretch;
  }

  .account-actions form {
    flex: 1;
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100vw - 20px, 1420px);
  }

  .topbar {
    padding: 12px 10px;
  }

  .panel,
  .metric {
    padding: 14px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-grid {
    grid-template-columns: 1fr;
  }

  .calendar-day.is-empty {
    display: none;
  }
}
