:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17212f;
  --muted: #647084;
  --line: #dde3ea;
  --blue: #0a66c2;
  --blue-dark: #064b91;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #f59e0b;
  --shadow: 0 18px 40px rgba(20, 36, 64, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 26px;
  background: #111827;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-size: 21px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--blue);
  font-weight: 900;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a {
  padding: 12px 14px;
  border-radius: 8px;
  color: #cbd5e1;
  font-weight: 650;
}

.nav a:hover,
.nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar-user {
  margin-top: auto;
  display: grid;
  gap: 5px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.sidebar-user span {
  color: #cbd5e1;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.sidebar-user a {
  margin-top: 8px;
  color: #93c5fd;
}

.logout-form {
  margin-top: 8px;
}

.logout-form button {
  border: 0;
  padding: 0;
  background: transparent;
  color: #93c5fd;
  font: inherit;
  cursor: pointer;
}

.logout-form button:hover {
  color: #bfdbfe;
}

.main {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 34px;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.15;
}

h2 {
  font-size: 22px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

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

.btn.primary:hover {
  background: var(--blue-dark);
}

.btn.secondary {
  background: #e8f1fb;
  color: var(--blue-dark);
}

.btn.ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.btn.danger {
  background: var(--red);
  color: #fff;
}

.btn.disabled {
  opacity: 0.58;
  pointer-events: none;
}

.auth-card,
.info-panel,
.calendar-wrap,
.detail-card,
.dashboard-panel,
.dashboard-hero,
.cron-result,
.linkedin-connect-panel,
.preview-card,
.editor-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card {
  max-width: 470px;
  margin: 8vh auto 0;
  padding: 34px;
}

.cron-result {
  max-width: 720px;
  margin: 9vh auto 0;
  padding: 34px;
}

.cron-result p:not(.eyebrow) {
  color: var(--muted);
}

.auth-card p {
  color: var(--muted);
}

.auth-switch {
  margin: 18px 0 0;
}

.form,
.editor-form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 14px;
  font-weight: 750;
}

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

textarea {
  resize: vertical;
  min-height: 220px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(10, 102, 194, 0.15);
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 700;
}

.alert.error {
  background: #fee2e2;
  color: #991b1b;
}

.alert.success {
  background: #dcfce7;
  color: #166534;
}

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

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 26px;
  align-items: stretch;
  margin-bottom: 22px;
  padding: 30px;
  background: #ffffff;
}

.hero-copy {
  display: grid;
  align-content: center;
  gap: 14px;
}

.hero-text {
  max-width: 620px;
  color: var(--muted);
  font-size: 17px;
}

.hero-status {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 20px;
  border: 1px solid #c9dcf1;
  border-radius: 8px;
  background: #f4f9ff;
}

.hero-status span {
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}

.hero-status strong {
  font-size: 34px;
}

.hero-status p {
  margin-bottom: 0;
  color: var(--muted);
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.dashboard-main,
.dashboard-side {
  display: grid;
  gap: 18px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  display: block;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 46px rgba(20, 36, 64, 0.13);
}

.stat-card:focus-visible {
  outline: 3px solid rgba(10, 102, 194, 0.24);
  outline-offset: 3px;
}

.stat-card.draft,
.stat-card.scheduled,
.stat-card.published,
.stat-card.failed {
  color: #fff;
}

.stat-card.draft span,
.stat-card.scheduled span,
.stat-card.published span,
.stat-card.failed span,
.stat-card.draft small,
.stat-card.scheduled small,
.stat-card.published small,
.stat-card.failed small {
  color: rgba(255, 255, 255, 0.82);
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: #8b95a1;
}

.stat-card.draft::before {
  background: #8b95a1;
}

.stat-card.scheduled::before {
  background: var(--blue);
}

.stat-card.published::before {
  background: var(--green);
}

.stat-card.failed::before {
  background: var(--red);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-weight: 750;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 42px;
}

.stat-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
}

.dashboard-panel {
  padding: 22px;
}

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

.panel-head h2,
.next-card h2 {
  margin-bottom: 0;
}

.panel-head strong {
  font-size: 32px;
}

.progress-track {
  height: 12px;
  margin: 18px 0 12px;
  border-radius: 999px;
  background: #e6edf5;
  overflow: hidden;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.next-card p {
  color: var(--muted);
  line-height: 1.55;
}

.quick-actions {
  display: grid;
  gap: 10px;
}

.quick-actions a {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-weight: 800;
}

.quick-actions a::after {
  content: ">";
  color: var(--blue);
}

.linkedin-connect-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 28px;
  margin-bottom: 18px;
}

.linkedin-connect-panel h2 {
  margin-bottom: 8px;
}

.linkedin-connect-panel p {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.linkedin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.linkedin-login-btn {
  gap: 8px;
}

.linkedin-btn-mark {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: #fff;
  color: var(--blue);
  font-size: 14px;
  font-weight: 900;
}

.linkedin-setup-note {
  margin-bottom: 18px;
}

.linkedin-setup-note p {
  color: var(--muted);
  line-height: 1.55;
}

.info-panel {
  margin-top: 18px;
  padding: 24px;
}

.info-panel p {
  color: var(--muted);
}

code {
  display: inline-block;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  background: #eef2f7;
  overflow-wrap: anywhere;
}

.calendar-wrap {
  padding: 20px;
}

.calendar-controls {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.legend span,
.legend-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-filter {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  opacity: 0.56;
}

.legend-filter.active {
  border-color: #b8c6d8;
  color: var(--text);
  opacity: 1;
}

.legend i,
.legend-filter i {
  width: 11px;
  height: 11px;
  border-radius: 999px;
}

.all,
.status-pill.all { background: #111827; }
.draft,
.status-pill.draft { background: #8b95a1; }
.scheduled,
.status-pill.scheduled { background: var(--blue); }
.publishing,
.status-pill.publishing { background: var(--orange); }
.published,
.status-pill.published { background: var(--green); }
.failed,
.status-pill.failed { background: var(--red); }
.cancelled,
.status-pill.cancelled { background: #374151; }

.fc .fc-button-primary {
  border-color: var(--blue);
  background: var(--blue);
}

.fc .fc-toolbar-title {
  font-size: 24px;
}

.fc-event {
  border-radius: 6px;
  cursor: pointer;
}

.fc-event.event-status-published,
.fc-event.event-status-cancelled {
  cursor: default;
}

.calendar-message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.calendar-message[data-type="success"] {
  color: var(--green);
}

.calendar-message[data-type="error"] {
  color: var(--red);
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 20px;
  align-items: start;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.settings-help p {
  color: var(--muted);
  line-height: 1.55;
}

.settings-help code {
  margin-bottom: 18px;
}

.editor-form {
  padding: 24px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.counter {
  margin-top: -8px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.media-uploader {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 112px;
  padding: 18px;
  border: 2px dashed #b8c6d8;
  border-radius: 8px;
  background: #f8fafc;
}

.media-uploader.dragging {
  border-color: var(--blue);
  background: #edf6ff;
}

.media-uploader input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.media-upload-copy {
  display: grid;
  gap: 5px;
}

.media-upload-copy strong {
  font-size: 16px;
}

.media-upload-copy span,
.selected-media-name {
  color: var(--muted);
  font-size: 14px;
}

.selected-media-name {
  margin-top: -6px;
  font-weight: 700;
}

.preview-card {
  position: sticky;
  top: 24px;
  padding: 22px;
}

.preview-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.preview-head span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
}

#previewText,
.post-content {
  white-space: pre-wrap;
  line-height: 1.55;
}

.preview-media {
  margin-top: 18px;
  padding: 10px;
  border: 1px dashed #b7c4d3;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.preview-media img,
.post-media img {
  display: block;
  width: 100%;
  border-radius: 8px;
  object-fit: cover;
}

.preview-media img {
  max-height: 320px;
}

.preview-media span {
  display: block;
  margin-top: 8px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.post-media {
  margin: 24px 0;
}

.post-media img {
  max-width: 760px;
  max-height: 560px;
}

.post-media figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.hidden {
  display: none;
}

.detail-card {
  padding: 26px;
}

.status-line {
  margin-bottom: 18px;
}

.status-pill {
  display: inline-flex;
  padding: 7px 11px;
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}

.detail-list {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 12px 18px;
  margin: 24px 0;
}

.detail-list dt {
  color: var(--muted);
  font-weight: 800;
}

.detail-list dd {
  margin: 0;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    gap: 16px;
  }

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

  .sidebar-user {
    margin-top: 0;
  }

  .main {
    padding: 22px;
  }

  .page-header,
  .editor-grid,
  .settings-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

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

  .dashboard-hero,
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .linkedin-connect-panel {
    display: grid;
  }

  .linkedin-actions {
    justify-content: start;
  }

  .preview-card {
    position: static;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 16px;
  }

  .sidebar {
    padding: 18px;
  }

  .nav,
  .stats-grid,
  .form-row,
  .metric-row,
  .detail-list {
    grid-template-columns: 1fr;
  }

  .metric-row {
    display: grid;
  }

  h1 {
    font-size: 28px;
  }

  .dashboard-hero {
    padding: 22px;
  }

  .media-uploader {
    grid-template-columns: 1fr;
  }

  .auth-card {
    margin-top: 20px;
    padding: 22px;
  }

  .fc .fc-toolbar {
    display: grid;
    gap: 10px;
  }
}

.system-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
}

.system-log-list,
.system-log-viewer {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.system-log-list {
  display: grid;
  align-content: start;
  overflow: hidden;
}

.system-log-list a {
  display: grid;
  gap: 5px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.system-log-list a:hover,
.system-log-list a.active {
  background: #e8f1fb;
}

.system-log-list span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.system-log-viewer {
  min-width: 0;
  padding: 22px;
}

.empty-log {
  margin-bottom: 0;
  color: var(--muted);
}

.log-output {
  max-height: 68vh;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #dbeafe;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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