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

:root {
  --sidebar-bg: #0f0f0f;
  --main-bg: #111827;
  --card-bg: #1f2937;
  --card-hover: #263547;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --alert-red: #ef4444;
  --warning-amber: #f59e0b;
  --success-green: #10b981;
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border: #374151;
  --input-bg: #374151;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--main-bg);
  color: var(--text-primary);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.app { display: flex; width: 100%; height: 100%; }

/* Sidebar */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid #1a1a1a;
}

.sidebar-brand { padding: 24px 20px 20px; border-bottom: 1px solid #1a1a1a; }
.logo-text { font-size: 18px; font-weight: 700; }
.logo-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.8px; }

.sidebar-nav { padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  color: var(--text-secondary); text-decoration: none; font-size: 14px;
}
.nav-item:hover { background: #1a1a2e; color: var(--text-primary); }
.nav-item.active { background: var(--accent); color: white; }

.badge {
  background: var(--alert-red); color: white; font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: 10px; margin-left: auto;
}
.badge:empty { display: none; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid #1a1a1a;
}
.sync-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.sync-dot.online { background: var(--success-green); }
.sync-dot.offline { background: var(--alert-red); }

/* Content */
.content { flex: 1; padding: 24px; overflow-y: auto; }
.loading { color: var(--text-muted); text-align: center; padding: 60px; }

/* Cards */
.card {
  background: var(--card-bg); border-radius: 12px; padding: 16px;
  border: 1px solid var(--border);
}

/* Page header */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.page-header h2 { font-size: 20px; font-weight: 600; }

/* Creator table */
.creator-table { width: 100%; border-collapse: collapse; }
.creator-table th { text-align: left; padding: 12px; color: var(--text-muted); font-size: 12px; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.creator-table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.creator-table tr:hover { background: var(--card-hover); cursor: pointer; }

/* Stage badges */
.stage-badge { padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.stage-joined { background: #374151; }
.stage-contracted { background: #1e3a5f; color: #93c5fd; }
.stage-handles_requested { background: #4c1d95; color: #c4b5fd; }
.stage-warming_up { background: #78350f; color: #fbbf24; }
.stage-warmed { background: #065f46; color: #34d399; }
.stage-active { background: #1e40af; color: #93c5fd; }

/* Alerts */
.alert-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--border); }
.alert-item:last-child { border-bottom: none; }
.alert-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.alert-dot.red { background: var(--alert-red); }
.alert-dot.amber { background: var(--warning-amber); }
.alert-dot.flash { background: var(--alert-red); animation: flash 1s infinite; }
@keyframes flash { 50% { opacity: 0.3; } }

/* Buttons */
.btn {
  padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; transition: background 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-danger { background: var(--alert-red); color: white; }
.btn-outline { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--text-secondary); color: var(--text-primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-success { background: var(--success-green); color: white; }

/* Inputs */
.input {
  background: var(--input-bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 12px; color: var(--text-primary); font-size: 14px; width: 100%;
}
.input:focus { outline: none; border-color: var(--accent); }
.input::placeholder { color: var(--text-muted); }

/* Chat layout */
.chat-layout { display: flex; height: calc(100vh - 48px); gap: 0; }

.chat-list-panel {
  width: 320px; min-width: 320px;
  background: var(--card-bg); border-right: 1px solid var(--border);
  border-radius: 12px 0 0 12px;
  display: flex; flex-direction: column; overflow: hidden;
}

.chat-list-header {
  padding: 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 16px;
}

.chat-list { flex: 1; overflow-y: auto; }

.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.chat-item:hover { background: var(--card-hover); }
.chat-item.active { background: var(--accent); background: rgba(59, 130, 246, 0.15); border-left: 3px solid var(--accent); }

.chat-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; flex-shrink: 0;
}

.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name { font-weight: 500; font-size: 14px; }
.chat-item-preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-item-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

.chat-detail-panel {
  flex: 1; display: flex; flex-direction: column;
  background: var(--card-bg); border-radius: 0 12px 12px 0; overflow: hidden;
}

.chat-detail-header {
  padding: 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.chat-detail-name { font-weight: 600; font-size: 16px; }
.chat-detail-sub { font-size: 12px; color: var(--text-muted); }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px;
}

.message-row { display: flex; flex-direction: column; max-width: 70%; }
.message-row.from-team { align-self: flex-end; align-items: flex-end; }
.message-row.from-creator { align-self: flex-start; align-items: flex-start; }

.message-sender { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; padding: 0 8px; }

.message-bubble {
  padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.4;
  word-wrap: break-word; max-width: 100%;
}
.from-team .message-bubble { background: var(--accent); color: white; border-bottom-right-radius: 4px; }
.from-creator .message-bubble { background: #374151; color: var(--text-primary); border-bottom-left-radius: 4px; }

.message-time { font-size: 10px; color: var(--text-muted); margin-top: 2px; padding: 0 8px; }

.chat-input-area {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center;
}
.chat-input-area .input { flex: 1; }

.chat-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 14px;
}

/* Pipeline board */
.pipeline-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.pipeline-column { min-width: 200px; flex: 1; }
.pipeline-column-header {
  font-size: 12px; color: var(--text-muted); text-transform: uppercase;
  margin-bottom: 8px; font-weight: 600; letter-spacing: 0.5px;
}
.pipeline-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; margin-bottom: 8px; cursor: pointer; transition: border-color 0.15s;
}
.pipeline-card:hover { border-color: var(--accent); }
.pipeline-card-name { font-weight: 500; font-size: 14px; }
.pipeline-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Settings */
.settings-section { margin-bottom: 24px; }
.settings-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.settings-row { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 12px; }
.settings-field { flex: 1; }
.settings-field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }

/* Check-in */
.checkin-list { display: flex; flex-direction: column; gap: 8px; }
.checkin-item {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px;
}
.checkin-item input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.checkin-info { flex: 1; }
.checkin-name { font-weight: 500; font-size: 14px; }
.checkin-last { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Stats cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; text-align: center;
}
.stat-value { font-size: 32px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; }
