:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3347;
  --text: #e4e6f0;
  --text-muted: #8b8fa3;
  --primary: #6366f1;
  --primary-hover: #5558e6;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  font-weight: 600;
  font-size: 1.1rem;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-logout { color: var(--danger) !important; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-header h1 { font-size: 1.5rem; font-weight: 600; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card h2 { font-size: 1.1rem; margin-bottom: 1rem; }

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

/* Stats */
.stats-grid {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value { font-size: 1.75rem; font-weight: 700; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group small {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group { flex: 1; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.btn:hover { background: var(--border); }

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

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

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

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

.btn-full { width: 100%; }

.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.content-preview {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
}

.badge-draft { background: var(--surface2); color: var(--text-muted); }
.badge-pending_approval { background: #78350f; color: var(--warning); }
.badge-approved { background: #14532d; color: var(--success); }
.badge-scheduled { background: #1e3a5f; color: #60a5fa; }
.badge-published { background: #14532d; color: var(--success); }
.badge-failed { background: #450a0a; color: var(--danger); }
.badge-rejected { background: #450a0a; color: var(--danger); }
.badge-active { background: #14532d; color: var(--success); }
.badge-inactive { background: var(--surface2); color: var(--text-muted); }

/* Login */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.login-card h1 { text-align: center; margin-bottom: 0.25rem; }
.login-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; }

/* Chat */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px - 5rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.message { display: flex; }

.message-user { justify-content: flex-end; }

.message-bubble {
  max-width: 70%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--surface2);
}

.message-user .message-bubble {
  background: var(--primary);
}

.message-bubble strong {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.message-user .message-bubble strong { color: rgba(255,255,255,0.7); }

.message-bubble p {
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-input {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.chat-input input {
  flex: 1;
  padding: 0.625rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
}

.chat-input input:focus { outline: none; border-color: var(--primary); }

/* Streaming cursor */
.stream-target::after { content: '●'; animation: blink 1s step-end infinite; }
.stream-target.done::after { display: none; }
@keyframes blink { 50% { opacity: 0; } }

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.alert-error {
  background: #450a0a;
  color: var(--danger);
  border: 1px solid #7f1d1d;
}

/* Approval cards */
.approval-card {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.approval-card:last-child { border-bottom: none; }

.approval-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.approval-content p {
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.approval-actions { display: flex; gap: 0.5rem; }

.text-muted { color: var(--text-muted); font-size: 0.8rem; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.edit-form {
  padding: 1rem 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* Active nav link */
.nav-active { color: var(--text) !important; background: var(--surface2); }

/* Calendar */
.cal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.cal-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  min-width: 220px;
  text-align: center;
}

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

.cal-weekdays div {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0.5rem 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cal-cell {
  background: var(--surface);
  min-height: 90px;
  padding: 0.375rem;
  display: flex;
  flex-direction: column;
}

.cal-cell.cal-empty { background: var(--bg); }

.cal-cell.cal-today { background: var(--surface2); }

.cal-day-num {
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: var(--text-muted);
}

.cal-today .cal-day-num {
  color: var(--primary);
  font-weight: 700;
}

.cal-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.cal-chip {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.4;
}

.cal-more {
  font-size: 0.6rem;
  color: var(--text-muted);
  padding: 1px 2px;
}

/* Calendar modal */
.cal-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.cal-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
}

.cal-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.cal-modal-header h2 { font-size: 1.1rem; }

.cal-post-card {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.cal-post-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.cal-post-content {
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}

.cal-post-feedback {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
}

.cal-modal-actions {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.cal-chat {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.cal-chat-messages {
  max-height: 250px;
  overflow-y: auto;
  padding: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cal-save-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.75rem;
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.cal-save-bar select {
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
}

.cal-save-bar select:focus {
  outline: none;
  border-color: var(--primary);
}

@media (max-width: 640px) {
  .cal-cell { min-height: 60px; padding: 0.25rem; }
  .cal-day-num { font-size: 0.7rem; }
  .cal-chip { font-size: 0.55rem; }
  .cal-header h1 { font-size: 1.1rem; min-width: auto; }
}
