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

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-hover: #222633;
  --bg-input: #151820;
  --border: #2a2e3d;
  --text: #e4e6ed;
  --text-dim: #8b8fa3;
  --accent: #6c5ce7;
  --accent-hover: #7e6ff0;
  --green: #00b894;
  --red: #e74c3c;
  --orange: #f39c12;
  --blue: #3498db;
  --pink: #fd79a8;
  --sidebar-w: 260px;
  --topbar-h: 56px;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Layout */
.app { display: flex; height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header .logo {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.nav-section {
  padding: 8px 20px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 14px;
  color: var(--text-dim);
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-hover); color: var(--text); border-right: 3px solid var(--accent); }
.nav-item .badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }

/* Main content */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}

.topbar h2 { font-size: 16px; font-weight: 600; }

.topbar .account-switcher {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.account-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  transition: all 0.15s;
}

.account-pill:hover { border-color: var(--accent); color: var(--text); }
.account-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.content { flex: 1; overflow-y: auto; padding: 24px; }

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: border-color 0.15s;
  cursor: pointer;
}

.card:hover { border-color: var(--accent); }

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

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

.card-title { font-weight: 600; font-size: 15px; }
.card-subtitle { font-size: 12px; color: var(--text-dim); }

.card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat { text-align: center; }
.stat-value { font-size: 20px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.stat-value.green { color: var(--green); }
.stat-value.orange { color: var(--orange); }
.stat-value.blue { color: var(--blue); }

/* Chat layout */
.chat-layout { display: flex; height: 100%; overflow: hidden; }

.chat-list {
  width: 320px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.chat-list-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.chat-list-header input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.chat-list-header input:focus { border-color: var(--accent); }

.chat-list-items {
  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(--bg-hover); }
.chat-item.active { background: var(--bg-hover); border-left: 3px solid var(--accent); }

.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name { font-size: 14px; font-weight: 600; }
.chat-item-preview {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-meta {
  text-align: right;
  flex-shrink: 0;
}

.chat-item-time { font-size: 11px; color: var(--text-dim); }
.chat-item .unread-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  margin-left: auto;
  margin-top: 4px;
}

.chat-item .spend-tag {
  font-size: 10px;
  color: var(--green);
  font-weight: 600;
}

/* Chat messages area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

.msg {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.msg.fan {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg.creator {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.ai-suggestion {
  align-self: flex-end;
  background: transparent;
  border: 2px dashed var(--accent);
  color: var(--text);
  border-bottom-right-radius: 4px;
  position: relative;
}

.msg.ai-suggestion::after {
  content: 'AI';
  position: absolute;
  top: -8px;
  right: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.msg-time {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}

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

.chat-input-area textarea {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  min-height: 44px;
  max-height: 120px;
}

.chat-input-area textarea:focus { border-color: var(--accent); }

.btn {
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn-outline:hover { border-color: var(--accent); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Fan profile panel */
.fan-panel {
  width: 340px;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
  flex-shrink: 0;
  background: var(--bg-card);
}

.fan-panel-header {
  text-align: center;
  margin-bottom: 20px;
}

.fan-panel-header .avatar {
  width: 64px;
  height: 64px;
  font-size: 24px;
  margin: 0 auto 12px;
}

.fan-panel-header h3 { font-size: 16px; }
.fan-panel-header .username { font-size: 13px; color: var(--text-dim); }

.fan-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.fan-stat-card {
  background: var(--bg);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.fan-stat-card .value { font-size: 18px; font-weight: 700; }
.fan-stat-card .label { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 10px;
  margin-top: 16px;
}

.notes-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  font-size: 13px;
  resize: vertical;
  min-height: 80px;
  outline: none;
  font-family: inherit;
}

.notes-textarea:focus { border-color: var(--accent); }

.vault-state-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.tg-history-card {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}

.tg-history-card .meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.tg-history-card .msg-preview {
  font-size: 12px;
  color: var(--text);
}

/* AI Queue */
.queue-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.queue-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.queue-item-fan { font-weight: 600; }
.queue-item-creator { font-size: 12px; color: var(--text-dim); }

.queue-item-message {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  margin-bottom: 8px;
}

.queue-item-suggestion {
  background: rgba(108, 92, 231, 0.1);
  border: 1px solid rgba(108, 92, 231, 0.3);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  margin-bottom: 10px;
}

.queue-actions { display: flex; gap: 8px; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  gap: 8px;
}

.empty-state .icon { font-size: 48px; }

/* Status dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--red); }

/* Table */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

tr:hover td { background: var(--bg-hover); }

/* Loading */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 13px;
  z-index: 1000;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Vault */
.vault-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-dim);
  transition: all 0.1s;
  margin-bottom: 2px;
}

.vault-filter:hover { background: var(--bg-hover); color: var(--text); }
.vault-filter.active { background: var(--bg-hover); color: var(--text); font-weight: 600; }

.vault-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
}

.label-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.vault-item {
  background: var(--bg-card);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  overflow: hidden;
}

.vault-item:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

/* Queue tabs */
.queue-tab {
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.queue-tab:hover { color: var(--text); }
.queue-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Vault in Chat */
.vault-toggle-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  position: relative;
}

.vault-toggle-btn:hover { border-color: var(--accent); background: var(--bg-hover); }
.vault-toggle-btn.active { border-color: var(--accent); background: rgba(108, 92, 231, 0.15); }
.vault-toggle-btn.has-items::after {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  position: absolute;
  top: 6px;
  right: 6px;
}

.vault-chat-panel {
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  max-height: 280px;
  overflow-y: auto;
}

.vault-panel-inner { padding: 12px 16px; }

.vault-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.vault-panel-title {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.vault-panel-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vault-progress-bar {
  width: 80px;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.vault-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}

.vault-progress-text {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.vault-next-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vault-next-item {
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.vault-next-item.next-up {
  border: 1px solid var(--accent);
  background: rgba(108, 92, 231, 0.05);
}

.vault-next-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.vault-label-badge {
  font-size: 10px;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.vault-seq-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.vault-send-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.vault-price-input {
  width: 90px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text);
  font-size: 12px;
  outline: none;
}

.vault-price-input:focus { border-color: var(--accent); }

.vault-send-btn { white-space: nowrap; }

.msg.vault-msg {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border: none;
}

.vault-msg-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}

/* Inline media in messages */
.msg-media { cursor: pointer; margin-top: 6px; }
.msg-media-img {
  max-width: 240px;
  max-height: 200px;
  border-radius: 10px;
  object-fit: cover;
  cursor: pointer;
  display: block;
}
.msg-media-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.6);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  pointer-events: none;
}
.msg-media-duration {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}
.msg-media-placeholder {
  margin-top: 6px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}
.msg.creator .msg-media-placeholder {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.8);
}

/* PPV badge */
.ppv-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}
.ppv-paid {
  background: rgba(0,184,148,0.15);
  color: var(--green);
}
.ppv-unpaid {
  background: rgba(243,156,18,0.15);
  color: var(--orange);
}
.ppv-price { font-weight: 700; }
.ppv-status { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; }

/* PPV message border */
.msg.ppv-msg { border-left: 3px solid var(--orange); }
.msg.creator.ppv-msg { border-left: none; border-right: 3px solid var(--orange); }

/* Sender attribution */
.msg-sender {
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 3px;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Spend tag in chat list - inline with name */
.chat-item-name .spend-tag {
  font-size: 10px;
  color: var(--green);
  font-weight: 600;
  margin-left: 6px;
}

/* Fan Profile Header Bar */
.fan-header-bar {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  gap: 0;
  flex-shrink: 0;
  min-height: 48px;
  flex-wrap: wrap;
}

.fan-header-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 14px;
  min-width: 0;
}

.fan-header-item:first-child { padding-left: 0; }

.fan-header-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  font-weight: 600;
}

.fan-header-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.fan-header-spend {
  color: var(--green);
  font-size: 14px;
}

.fan-header-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  flex-shrink: 0;
}

.fan-header-name-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  display: inline-block;
}

.fan-header-name-text:hover { color: var(--accent); }

.fan-header-edit-icon {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 4px;
}

.fan-header-name-text:hover .fan-header-edit-icon { color: var(--accent); }

.fan-header-name-input {
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  outline: none;
  width: 180px;
  font-family: inherit;
}

.fan-header-notes-item {
  flex: 1;
  min-width: 120px;
}

.fan-header-notes-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  width: 100%;
  font-family: inherit;
  transition: border-color 0.15s;
}

.fan-header-notes-input:hover { border-color: var(--border); }
.fan-header-notes-input:focus { border-color: var(--accent); background: var(--bg-input); }

.fan-header-last-purchase {
  cursor: pointer;
}

.fan-header-last-purchase:hover .fan-header-value { color: var(--accent); }

.fan-header-expand-icon {
  font-size: 9px;
  color: var(--text-dim);
  margin-left: 4px;
}

/* Purchase History Dropdown */
.fan-header-history {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  max-height: 240px;
  overflow-y: auto;
}

.fan-header-history-list {
  padding: 8px 16px;
}

.fan-header-history-row {
  display: flex;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(42, 46, 61, 0.5);
  font-size: 12px;
  gap: 12px;
}

.fan-header-history-row:last-child { border-bottom: none; }

.fan-header-history-date {
  color: var(--text-dim);
  width: 100px;
  flex-shrink: 0;
}

.fan-header-history-type {
  flex: 1;
  color: var(--text);
  font-weight: 500;
}

.fan-header-history-amount {
  color: var(--green);
  font-weight: 700;
  flex-shrink: 0;
}

.fan-header-history-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

/* Unread highlight */
.chat-item.has-unread .chat-item-name { color: #fff; }
.chat-item.has-unread .chat-item-preview { color: var(--text); }
