:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --sidebar: #152033;
  --sidebar-text: #c5d0e0;
  --accent: #2f6fed;
  --accent-dark: #1f4fbe;
  --success: #2ea44f;
  --danger: #d14343;
  --text: #1a2332;
  --muted: #6b778c;
  --line: #d8e0ea;
  --shadow: 0 10px 30px rgba(21, 32, 51, 0.08);
  --radius: 14px;
  --font: "Manrope", sans-serif;
  --mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, #d9e8ff 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #e7f4ea 0%, transparent 45%),
    var(--bg);
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 240px;
  background: linear-gradient(180deg, #18263d 0%, #101a2b 100%);
  color: var(--sidebar-text);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  font-weight: 700;
  font-size: 22px;
  color: #fff;
  letter-spacing: 0.04em;
  padding: 0 10px;
}

nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }

.sidebar-foot {
  font-size: 12px;
  opacity: 0.55;
  padding: 0 10px;
}

#btn-logout {
  margin-top: auto;
  color: #f0b4b4;
}

#btn-logout:hover {
  background: rgba(209, 67, 67, 0.18);
  color: #fff;
}

.content {
  flex: 1;
  padding: 28px 36px 60px;
  max-width: 1100px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
}

.topbar-right {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 14px;
}

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

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  transition: 0.15s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { background: #fff; color: var(--danger); border-color: #f0c2c2; }
.btn.sm { padding: 6px 10px; font-size: 13px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.panel h2 { margin: 0 0 16px; font-size: 20px; }

.panel label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
}

input, textarea, select {
  font: inherit;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--text);
}

textarea { font-family: var(--mono); font-size: 12px; resize: vertical; }

.hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin-top: 0;
}

.hint code {
  font-family: var(--mono);
  background: #eef3ff;
  padding: 2px 6px;
  border-radius: 6px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.error { color: var(--danger); min-height: 1.2em; font-size: 14px; }

.cards { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  box-shadow: var(--shadow);
}

.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .meta { color: var(--muted); font-size: 13px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #e8eefc;
  color: var(--accent-dark);
}

.badge.active { background: #e5f6ea; color: #1f7a38; }
.badge.stopped, .badge.error { background: #fdecec; color: #b42318; }
.badge.paused { background: #eef2f6; color: #526075; }
.badge.scheduled { background: #fff4da; color: #9a6700; }
.badge.published { background: #e5f6ea; color: #1f7a38; }
.badge.pending { background: #eef2f6; color: #526075; }

.q-actions {
  display: flex;
  gap: 4px;
  white-space: nowrap;
}

.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.icon-btn:hover { background: #f3f6fb; }
.icon-btn.danger { color: #b42318; }

.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 22, 36, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}

.preview-card {
  position: relative;
  width: min(720px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  padding: 20px;
}

.preview-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: #eef2f6;
  cursor: pointer;
  font-size: 14px;
  z-index: 2;
}

.preview-media {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-media img {
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
  border-radius: 12px;
  background: #0f1624;
}

.preview-text {
  margin-top: 14px;
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
}

.hidden { display: none !important; }

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  font-weight: 600;
  font-size: 14px;
}

.seg {
  display: inline-flex;
  background: #eef2f6;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  border: 0;
  background: transparent;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
}

.seg-btn.active {
  background: var(--accent);
  color: #fff;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.checkbox-list label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 500;
}

.times-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.day-col {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  min-height: 160px;
}

.day-col h4 {
  margin: 0 0 8px;
  text-align: center;
  font-size: 13px;
}

.day-col .slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 6px;
  margin-bottom: 6px;
  font-family: var(--mono);
  font-size: 12px;
}

.day-col input[type="time"] {
  width: 100%;
  margin-bottom: 6px;
}

.day-col .copy-day {
  width: 100%;
  margin-top: 8px;
  font-size: 11px;
  padding: 6px 4px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.group-pick {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow: auto;
  margin-top: 12px;
}

.group-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
}

.group-item:hover { background: #f4f7fb; }
.group-item.selected { background: #eaf1ff; border-color: #c9daff; }

.group-item img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #dde3ee;
}

.sub { margin: 24px 0 12px; font-size: 16px; }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th { background: #f7f9fc; color: var(--muted); font-weight: 600; }

.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #152033;
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 50;
  max-width: 360px;
}

@media (max-width: 860px) {
  body { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  nav { flex-direction: row; flex-wrap: wrap; }
  .content { padding: 20px; }
  .times-grid { grid-template-columns: repeat(2, 1fr); }
  .row-2 { grid-template-columns: 1fr; }
}
