:root {
  --bg: #0e0f12;
  --bg-elevated: #17181d;
  --bg-hover: #202127;
  --border: #2a2b32;
  --text: #eaeaef;
  --text-dim: #9a9ba5;
  --accent: #6c5ce7;
  --accent-hover: #5a4bd1;
  --danger: #e74c3c;
  --success: #2ecc71;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); }

.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

.card h1 {
  font-size: 1.4rem;
  margin: 0 0 4px;
}

.card p.subtitle {
  color: var(--text-dim);
  margin: 0 0 24px;
  font-size: 0.9rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 14px 0 6px;
}

input[type="text"], input[type="email"], input[type="password"], textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

input:focus, textarea:focus {
  border-color: var(--accent);
}

textarea { resize: vertical; font-family: inherit; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s;
}

.btn-primary {
  width: 100%;
  padding: 11px;
  margin-top: 20px;
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-small {
  padding: 6px 14px;
  font-size: 0.85rem;
}
.btn-accept { background: var(--success); color: #0e0f12; }
.btn-reject { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg-hover); }

.msg {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
}
.msg-error { background: rgba(231,76,60,0.15); color: #ff8a80; border: 1px solid rgba(231,76,60,0.3); }
.msg-success { background: rgba(46,204,113,0.15); color: #7ee2a3; border: 1px solid rgba(46,204,113,0.3); }

.footer-link {
  text-align: center;
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ===== Branding ===== */
.brand-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.brand-logo {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
  color: var(--accent);
  transform: rotate(90deg) scaleX(1.1);
  display: inline-block;
}
.brand-name {
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.2px;
}
.conn-dot {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #555;
  transition: background 0.2s;
}
.conn-dot.online { background: var(--success); box-shadow: 0 0 6px rgba(46,204,113,0.6); }
.conn-dot.offline { background: var(--danger); }

.auth-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
}
.auth-brand .brand-logo { font-size: 1.3rem; }
.auth-brand .brand-name { font-size: 1.2rem; }

/* ===== App layout ===== */
.app-shell {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 300px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

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

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-hover);
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  flex-shrink: 0;
}
.avatar.large { width: 72px; height: 72px; font-size: 1.2rem; }

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  position: relative;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.badge {
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 10px;
  margin-left: 4px;
}

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

.list-item {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.list-item:hover { background: var(--bg-hover); }
.list-item.selected { background: var(--bg-hover); }

.list-item-info { flex: 1; min-width: 0; }
.list-item-name { font-size: 0.9rem; font-weight: 600; }
.list-item-sub { font-size: 0.78rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.request-actions { display: flex; gap: 6px; margin-top: 6px; }

.list-item-unread-dot {
  background: var(--accent);
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}
.list-item.has-unread .list-item-name { color: var(--text); }
.list-item.has-unread .list-item-sub { color: var(--text); }

.bubble-row { display: flex; flex-direction: column; max-width: 60%; }
.bubble-row.mine { align-self: flex-end; align-items: flex-end; }
.bubble-row.theirs { align-self: flex-start; align-items: flex-start; }
.bubble-time { font-size: 0.68rem; color: var(--text-dim); margin-top: 3px; padding: 0 4px; }

.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
}

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

.bubble {
  max-width: 100%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-wrap: break-word;
}
.bubble.mine { align-self: flex-end; background: var(--accent); color: white; border-bottom-right-radius: 3px; }
.bubble.theirs { align-self: flex-start; background: var(--bg-elevated); border: 1px solid var(--border); border-bottom-left-radius: 3px; }

.chat-input-bar {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}
.chat-input-bar input {
  flex: 1;
}
.chat-input-bar button {
  padding: 0 20px;
  background: var(--accent);
  color: white;
}

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  flex-direction: column;
  gap: 10px;
  text-align: center;
  padding: 20px;
}

.profile-card {
  padding: 24px;
  text-align: center;
}
.profile-card textarea, .profile-card input { text-align: left; }

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

/* scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
th { color: var(--text-dim); font-weight: 600; }

.status-pill { padding: 2px 8px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.status-pending { background: rgba(241,196,15,0.15); color: #f1c40f; }
.status-approved { background: rgba(46,204,113,0.15); color: #2ecc71; }
.status-rejected { background: rgba(231,76,60,0.15); color: #e74c3c; }
