*, *::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-2: #b879ff;
  --accent-hover: #2563eb;
  --alert-red: #ef4444;
  --warning-amber: #f59e0b;
  --success-green: #10b981;
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-dim: #676674;
  --border: #374151;
  --input-bg: #374151;
  --panel-hover: #23222d;
}

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;
  transition: width 0.16s ease, min-width 0.16s ease;
}

.sidebar-brand {
  padding: 20px 16px 18px;
  border-bottom: 1px solid #1a1a1a;
  display: flex;
  align-items: center;
  gap: 10px;
}
.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-toggle {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.sidebar-toggle:hover { color: var(--text-primary); border-color: var(--text-secondary); }

.sidebar-nav { padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.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-icon {
  width: 20px;
  min-width: 20px;
  height: 20px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
}
.nav-item.active .nav-icon { background: rgba(255,255,255,0.18); color: white; }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.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); }

.app.sidebar-collapsed .sidebar {
  width: 64px;
  min-width: 64px;
}
.app.sidebar-collapsed .sidebar-brand {
  padding: 16px 10px;
  justify-content: center;
}
.app.sidebar-collapsed .logo-text,
.app.sidebar-collapsed .logo-sub,
.app.sidebar-collapsed .nav-label,
.app.sidebar-collapsed .sidebar-footer,
.app.sidebar-collapsed .badge {
  display: none;
}
.app.sidebar-collapsed .sidebar-toggle {
  margin-left: 0;
  transform: rotate(180deg);
}
.app.sidebar-collapsed .sidebar-nav {
  padding: 14px 10px;
}
.app.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}

/* 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);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5,7,12,0.72);
}
.modal-overlay.open { display: flex; }
.modal-card {
  width: min(520px, calc(100vw - 32px));
  background: #171b26;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.42);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 18px; font-weight: 900; }
.modal-subtitle { margin-top: 3px; color: var(--text-muted); font-size: 13px; font-weight: 700; }
.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.modal-close:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.modal-status { min-height: 18px; color: var(--text-muted); font-size: 12px; font-weight: 700; }
.form-label { margin-top: 4px; color: var(--text-muted); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.7px; }
.hidden { display: none !important; }
.transfer-coach-select { cursor: pointer; }
.transfer-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 4px;
}
.transfer-summary > div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}
.transfer-summary span {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.transfer-summary strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

/* 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); }

.search-trigger {
  width: 280px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--input-bg);
  color: var(--text-muted);
  padding: 0 10px;
  cursor: pointer;
  font-size: 13px;
}
.search-trigger:hover { border-color: var(--text-secondary); color: var(--text-secondary); }
.search-trigger kbd,
.search-key {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 2px 5px;
}

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(5,7,12,0.72);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 9vh;
}
.search-overlay.open { display: flex; }
.search-box {
  width: min(720px, calc(100vw - 32px));
  max-height: 76vh;
  background: #141823;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.42);
}
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.search-symbol { color: var(--text-muted); font-weight: 900; }
.search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
}
.search-results { max-height: calc(76vh - 56px); overflow-y: auto; padding: 8px; }
.sr-section {
  padding: 10px 8px 6px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.sr:hover { background: rgba(255,255,255,0.055); }
.sr-avatar,
.table-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(135deg,#8b5cf6,#e1306c);
  color: white;
  font-size: 12px;
  font-weight: 900;
  flex-shrink: 0;
}
.sr-avatar img,
.table-avatar img { width: 100%; height: 100%; object-fit: cover; }
.table-avatar.large { width: 44px; height: 44px; font-size: 15px; }
.table-avatar.coach-profile-avatar {
  width: 70px;
  height: 70px;
  font-size: 26px;
  margin-bottom: 12px;
}
.sr-info { min-width: 0; flex: 1; }
.sr-name { font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-meta { font-size: 12px; font-weight: 800; color: var(--text-secondary); white-space: nowrap; }
.search-empty {
  padding: 26px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.note-item {
  position: relative;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.035);
  padding: 12px 34px 12px 12px;
}
.note-date {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 800;
  margin-bottom: 6px;
}
.note-text { font-size: 13px; line-height: 1.45; color: var(--text-secondary); white-space: pre-wrap; }
.note-del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.note-del:hover { color: var(--alert-red); border-color: rgba(239,68,68,0.35); }
.empty-note {
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.035);
  padding: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.manage-card { overflow-x: auto; }
.manage-table th,
.manage-table td { white-space: nowrap; }
.manage-grid { display: flex; flex-direction: column; gap: 10px; }
.manage-coach-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.month-chart {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 8px 0 0;
}
.month-bar-wrap {
  flex: 1;
  min-width: 3px;
  height: 100%;
  display: flex;
  align-items: flex-end;
}
.month-bar {
  position: relative;
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg,#b879ff,#6d4df2);
  cursor: default;
}
.month-bar.empty {
  background: rgba(255,255,255,0.06);
}
.month-bar span {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: #12121a;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  z-index: 2;
}
.month-bar:hover { opacity: 0.82; }
.month-bar:hover span { display: block; }
.month-axis {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

/* 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; }

/* Message attachments (images, videos) */
.message-body { margin-bottom: 6px; }
.message-body:empty { display: none; }
.message-attachments { display: flex; flex-direction: column; gap: 6px; max-width: 280px; }
.attachment-image img { width: 100%; max-width: 280px; max-height: 320px; border-radius: 10px;
  display: block; object-fit: cover; cursor: pointer; }
.attachment-video { width: 100%; max-width: 280px; border-radius: 10px; }
.attachment-audio { width: 100%; }
.attachment-file { display: inline-block; padding: 6px 10px; border-radius: 8px;
  background: var(--card-bg); border: 1px solid var(--border); color: var(--primary);
  text-decoration: none; font-size: 13px; }
.attachment-file:hover { opacity: 0.8; }

/* ── Dashboard ── */
.dash-controls {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}

.toggle-group {
  display: inline-flex; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}

.toggle-btn {
  padding: 7px 16px; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); cursor: pointer; border: none;
  background: transparent; transition: all 0.15s ease; letter-spacing: 0.2px;
}

.toggle-btn:not(:last-child) { border-right: 1px solid var(--border); }
.toggle-btn.active { background: var(--accent); color: white; }

.dash-panels { display: flex; gap: 20px; align-items: flex-start; }
.panel-left { flex: 0 0 60%; min-width: 0; }
.panel-right { flex: 0 0 calc(40% - 20px); min-width: 0; }

.creator-avatar-wrap { transition: transform 0.15s ease; }
.creator-avatar-wrap:hover { transform: translateY(-2px); }

.cv-stat-label {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px;
}

/* ── Calendar ── */
.cal-nav-btn {
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  color: var(--text-secondary); width: 28px; height: 28px; border-radius: 6px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 13px; transition: all 0.12s ease;
}
.cal-nav-btn:hover { background: rgba(255,255,255,0.12); color: var(--text-primary); }

.cal-day {
  aspect-ratio: 1; border-radius: 6px; display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700;
  transition: transform 0.1s ease;
}
.cal-day:hover { transform: scale(1.08); }
.cal-day.future { background: rgba(255,255,255,0.03); color: var(--text-muted); font-weight: 400; font-size: 11px; }
.cal-day.posted-2 { background: rgba(16,185,129,0.75); color: white; box-shadow: 0 0 8px rgba(16,185,129,0.3); }
.cal-day.posted-1 { background: rgba(245,158,11,0.6); color: white; }
.cal-day.missed { background: rgba(239,68,68,0.45); color: rgba(255,255,255,0.7); }

@media (max-width: 560px) {
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
  .transfer-summary { grid-template-columns: 1fr; }
}
