:root {
  --bg-app: #0e1621;
  --bg-sidebar: #17212b;
  --bg-panel: #1e2c3a;
  --bg-hover: #202b36;
  --bg-incoming: #182533;
  --bg-outgoing: #2b5278;
  --accent: #4ea4f5;
  --accent-strong: #2b5278;
  --text-primary: #e7ecf0;
  --text-muted: #7a8a99;
  --border: #101922;
  --green: #4fbf67;
  --red: #e05c5c;
  --radius-lg: 16px;
  --radius-md: 10px;
}

* { box-sizing: border-box; }

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

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

/* ---------- flash messages ---------- */
.flash-stack {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.flash {
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
.flash-success { background: #1e3a2a; color: #7fe0a0; }
.flash-error { background: #3a1e1e; color: #e79a9a; }

/* ---------- auth screens ---------- */
.auth-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, #17212b 0%, #0e1621 60%);
}
.auth-card {
  width: 340px;
  background: var(--bg-sidebar);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  display: flex;
  flex-direction: column;
}
.auth-logo {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  margin-bottom: 16px;
}
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-sub { color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }
.auth-card label { font-size: 12px; color: var(--text-muted); margin: 10px 0 4px; }
.auth-card input {
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 14px;
}
.auth-card input:focus {
  outline: none;
  border-color: var(--accent);
}
.btn-primary {
  margin-top: 20px;
  background: var(--accent);
  color: #0e1621;
  border: none;
  border-radius: var(--radius-md);
  padding: 11px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }
.auth-switch { margin-top: 16px; font-size: 13px; color: var(--text-muted); text-align: center; }

/* ---------- admin panel ---------- */
.admin-screen { max-width: 720px; margin: 0 auto; padding: 32px 20px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.admin-section { margin-bottom: 28px; }
.admin-section h2 { font-size: 15px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.badge {
  background: var(--accent-strong);
  color: var(--text-primary);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
}
.request-list { display: flex; flex-direction: column; gap: 8px; }
.request-row {
  background: var(--bg-sidebar);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.request-info { display: flex; flex-direction: column; }
.muted { color: var(--text-muted); font-size: 12px; }
.request-actions { display: flex; gap: 8px; }
.btn-approve, .btn-reject {
  border: none; border-radius: var(--radius-md);
  padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-approve { background: var(--green); color: #0e1621; }
.btn-reject { background: transparent; color: var(--red); border: 1px solid var(--red); }
.empty-hint { color: var(--text-muted); font-size: 13px; }
.link-quiet { color: var(--text-muted); font-size: 13px; }

/* ---------- chat app layout ---------- */
.chat-app {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
}
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.me { display: flex; align-items: center; gap: 10px; }
.me-name { font-weight: 600; font-size: 14px; }
.sidebar-actions { display: flex; gap: 10px; }
.icon-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-panel);
  color: var(--text-primary);
  font-size: 14px;
}
.icon-btn:hover { background: var(--bg-hover); }

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

.contact-list { flex: 1; overflow-y: auto; }
.contact-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  position: relative;
}
.contact-row:hover, .contact-row.active { background: var(--bg-hover); }
.contact-info { flex: 1; min-width: 0; }
.contact-name { font-size: 14px; font-weight: 500; }
.contact-status { font-size: 12px; color: var(--text-muted); }
.contact-status.online { color: var(--green); }
.presence-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: transparent;
}
.presence-dot.on { background: var(--green); box-shadow: 0 0 0 2px var(--bg-sidebar); }

.conversation { position: relative; display: flex; flex-direction: column; background: var(--bg-app); }
.conversation-placeholder {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 14px;
}
.conversation-active { display: flex; flex-direction: column; height: 100%; }
.conversation-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
}
.conv-name { font-weight: 600; font-size: 14px; }
.conv-status { font-size: 12px; color: var(--text-muted); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bubble {
  max-width: 60%;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
}
.bubble.in { align-self: flex-start; background: var(--bg-incoming); border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--bg-outgoing); border-bottom-right-radius: 4px; }
.bubble .time { display: block; font-size: 10px; color: var(--text-muted); margin-top: 4px; text-align: right; }

.typing-indicator { font-size: 12px; color: var(--text-muted); padding: 0 20px 6px; height: 16px; }

.composer {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-sidebar);
}
.composer input {
  flex: 1;
  background: var(--bg-panel);
  border: none;
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 14px;
}
.composer input:focus { outline: none; }
.btn-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #0e1621;
  font-size: 16px;
  cursor: pointer;
}
.btn-send:hover { filter: brightness(1.08); }

@media (max-width: 720px) {
  .chat-app { grid-template-columns: 1fr; }
  .sidebar { position: absolute; inset: 0; z-index: 5; }
  .sidebar.hidden { display: none; }
}
