:root {
  --bg: #f4f6fb;
  --card: #fff;
  --ink: #152033;
  --muted: #6b778c;
  --line: #e6eaf2;
  --pink: #e11d48;
  --blue: #2563eb;
  --green: #16a34a;
  --sidebar: #0f172a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button, input, textarea, select { font: inherit; }
.muted { color: var(--muted); }
.error { color: #b91c1c; }
.hint { font-size: 12px; color: var(--muted); }
.stack { display: grid; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.create { background: var(--pink); color: #fff; border: 0; width: 100%; margin: 12px 0 18px; font-weight: 700; }
.link { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0; }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #0f172a, #1e293b 40%, #e2e8f0);
}
.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.tabs { display: flex; gap: 8px; margin: 16px 0; }
.tab { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px; cursor: pointer; }
.tab.active { background: #eff6ff; border-color: #bfdbfe; color: var(--blue); }
label { display: grid; gap: 6px; font-size: 13px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: #e2e8f0;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
}
.brand { font-weight: 800; letter-spacing: .02em; padding: 8px 10px; }
.sidebar nav { display: grid; gap: 4px; }
.nav {
  text-align: left;
  background: transparent;
  color: #cbd5e1;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.nav.active, .nav:hover { background: rgba(255,255,255,.08); color: #fff; }
.plan-box, .user-box {
  margin-top: auto;
  background: rgba(255,255,255,.06);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}
.bar { height: 6px; background: rgba(255,255,255,.15); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.bar i { display: block; height: 100%; width: 20%; background: linear-gradient(90deg, #22c55e, #3b82f6); }
.main { padding: 28px; }
.panel { display: none; }
.panel.active { display: block; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin: 14px 0;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.stat strong { display: block; font-size: 28px; }
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.content-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  position: relative;
}
.content-card img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #eef2ff; }
.content-card .body { padding: 10px 12px 14px; }
.content-card .pub-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  color: #fff;
  z-index: 2;
}
.content-card .pub-badge.yes { background: #16a34a; }
.content-card .pub-badge.no { background: #64748b; }
.content-card { cursor: pointer; }
.content-card .body .row-actions { margin-top: 8px; }
.content-card .btn-del {
  border-color: #fca5a5;
  color: #b91c1c;
  padding: 6px 10px;
  font-size: 12px;
}

.preview-dialog {
  width: min(960px, calc(100vw - 24px));
  max-width: 960px;
  padding: 0;
  border: 0;
  border-radius: 18px;
  overflow: hidden;
}
.preview-dialog::backdrop { background: rgba(15, 23, 42, .55); }
.preview-layout {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 420px;
}
.preview-media {
  background: #0f172a;
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 16px;
}
.preview-media img,
.preview-media video {
  max-width: 100%;
  max-height: min(70vh, 560px);
  object-fit: contain;
  border-radius: 12px;
  background: #111;
}
.preview-side {
  padding: 18px;
  background: #fff;
}
.preview-side textarea {
  min-height: 220px;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 14px;
}
@media (max-width: 800px) {
  .preview-layout { grid-template-columns: 1fr; }
  .preview-media { min-height: 240px; }
}
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.chip.active { background: #eff6ff; border-color: #93c5fd; color: var(--blue); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.table-wrap { overflow: auto; background: #fff; border-radius: 14px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
td img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; }
.platform-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.status-ok { color: var(--green); font-size: 12px; }

/* —— Content calendar (Predis-style month grid) —— */
.cal-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.cal-top h2 { margin: 0; }
.cal-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cal-nav strong { min-width: 140px; text-align: center; font-size: 18px; }
.cal-arrow {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  font-size: 22px;
  line-height: 1;
}
.cal-modes { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cal-board {
  padding: 0;
  overflow: hidden;
  margin-top: 10px;
}
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}
.cal-weekdays span {
  padding: 10px 8px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-cell {
  min-height: 128px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 6px;
  background: #fff;
  vertical-align: top;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.out { background: #f8fafc; color: #94a3b8; }
.cal-cell.today { background: #fffbeb; }
.cal-daynum {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}
.cal-cell.today .cal-daynum {
  background: var(--blue);
  color: #fff;
}
.cal-posts { display: grid; gap: 6px; }
.cal-post {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: default;
  text-align: left;
  padding: 0;
  width: 100%;
}
.cal-post:hover { border-color: #93c5fd; box-shadow: 0 2px 8px rgba(37,99,235,.12); }
.cal-post-thumb {
  aspect-ratio: 1;
  width: 100%;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
  max-height: 88px;
}
.cal-post-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 6px;
  font-size: 11px;
  color: var(--muted);
  flex-wrap: wrap;
}
.cal-post-meta .plat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  background: #64748b;
}
.cal-post-meta .plat.instagram { background: #e1306c; }
.cal-post-meta .plat.facebook { background: #1877f2; }
.cal-post-meta .plat.threads { background: #111; }
.cal-post-meta .plat.tiktok { background: #111; }
.cal-more {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
  text-align: left;
}
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}
.cal-legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 99px;
  margin-right: 6px;
  vertical-align: middle;
}
.bg-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 32px));
  background: #0f172a;
  color: #f8fafc;
  padding: 14px 16px;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .35);
  font-size: 13px;
  line-height: 1.45;
}
.bg-toast strong { display: block; margin-bottom: 4px; }
.dot.published { background: #16a34a; }
.dot.scheduled { background: #2563eb; }
.dot.failed { background: #dc2626; }
.dot.draft { background: #f59e0b; }
.cal-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 99px;
  flex-shrink: 0;
}
.cal-status-dot.published { background: #16a34a; }
.cal-status-dot.scheduled { background: #2563eb; }
.cal-status-dot.failed { background: #dc2626; }
.cal-status-dot.draft,
.cal-status-dot.rejected { background: #f59e0b; }
.cal-cell.week-mode { min-height: 220px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; }
  .cal-cell { min-height: 96px; }
  .cal-post-thumb { max-height: 56px; }
  .cal-top { justify-content: center; }
}
dialog {
  border: 0;
  border-radius: 16px;
  padding: 20px;
  width: min(420px, calc(100vw - 24px));
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
