:root {
  --bg-0: #0f1115;
  --bg-1: #171a21;
  --bg-2: #1e222b;
  --bg-3: #262b36;
  --line: #2c313d;
  --line-soft: #22262f;
  --text-0: #eef1f6;
  --text-1: #aab2c0;
  --text-2: #6c7688;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --accent-2: #2fd3c7;
  --led-on: #3ddc84;
  --led-off: #566072;
  --led-admin: #ffb020;
  --danger: #ff5470;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-1: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font-display: "Be Vietnam Pro", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--line); }

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

input, textarea, select {
  font-family: inherit;
}

/* ---------- Flash / Toast notifications ---------- */
.flash-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 360px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.flash {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 34px 16px 14px;
  border-radius: var(--radius-md);
  background: rgba(30, 34, 43, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 2px 10px rgba(0, 0, 0, 0.3);
  font-size: 13.5px;
  color: var(--text-0);
  overflow: hidden;
  pointer-events: auto;
  animation: flash-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.flash.flash-hide {
  animation: flash-out 0.35s cubic-bezier(0.4, 0, 1, 1) forwards;
}
@keyframes flash-in {
  from { opacity: 0; transform: translateX(36px) scale(0.94); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes flash-out {
  from { opacity: 1; transform: translateX(0) scale(1); max-height: 120px; }
  to { opacity: 0; transform: translateX(36px) scale(0.92); max-height: 0; padding-top: 0; padding-bottom: 0; margin-bottom: -10px; }
}
.flash-icon {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 700;
}
.flash-body { flex: 1; line-height: 1.5; padding-top: 3px; word-break: break-word; }
.flash-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: none;
  color: var(--text-2);
  font-size: 10.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.flash-close:hover { background: var(--bg-3); color: var(--text-0); }
.flash-progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.07);
}
.flash-progress { height: 100%; width: 100%; }

.flash-danger { border-color: rgba(255, 84, 112, 0.35); }
.flash-danger .flash-icon { background: rgba(255, 84, 112, 0.15); color: var(--danger); }
.flash-danger .flash-progress { background: var(--danger); }

.flash-success { border-color: rgba(61, 220, 132, 0.35); }
.flash-success .flash-icon { background: rgba(61, 220, 132, 0.15); color: var(--led-on); }
.flash-success .flash-progress { background: var(--led-on); }

.flash-warning { border-color: rgba(255, 176, 32, 0.35); }
.flash-warning .flash-icon { background: rgba(255, 176, 32, 0.15); color: var(--led-admin); }
.flash-warning .flash-progress { background: var(--led-admin); }

.flash-info { border-color: rgba(91, 140, 255, 0.35); }
.flash-info .flash-icon { background: var(--accent-soft); color: var(--accent); }
.flash-info .flash-progress { background: var(--accent); }

@media (max-width: 500px) {
  .flash-container { top: 12px; right: 12px; left: 12px; width: auto; }
}

@keyframes slideIn {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ================= AUTH PAGES ================= */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: radial-gradient(circle at 15% 20%, #171d29 0%, var(--bg-0) 55%);
}

.auth-side {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px;
  overflow: hidden;
  border-right: 1px solid var(--line-soft);
}

.auth-side::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 30% 30%, black, transparent 70%);
  opacity: 0.6;
}

.auth-eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-2);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
  z-index: 1;
}
.auth-eyebrow .led { width: 8px; height: 8px; border-radius: 50%; background: var(--led-on); box-shadow: 0 0 8px var(--led-on); animation: pulse 2s infinite; }

.auth-title {
  font-size: 44px;
  font-weight: 800;
  line-height: 1.15;
  max-width: 480px;
  z-index: 1;
  margin: 0 0 18px;
}
.auth-title span { color: var(--accent); }

.auth-desc {
  color: var(--text-1);
  max-width: 420px;
  line-height: 1.7;
  z-index: 1;
  font-size: 15px;
}

.auth-stats {
  display: flex;
  gap: 32px;
  margin-top: 48px;
  z-index: 1;
}
.auth-stat-num { font-family: var(--font-mono); font-size: 26px; font-weight: 700; color: var(--text-0); }
.auth-stat-label { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-1);
}

.auth-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
}
.auth-card .sub { color: var(--text-2); font-size: 13.5px; margin-bottom: 28px; }

.field {
  margin-bottom: 18px;
}
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--text-1);
  margin-bottom: 7px;
  font-weight: 500;
}
.field .input-wrap {
  position: relative;
}
.field input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-0);
  font-size: 14.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field .toggle-pw {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  color: var(--text-2);
  font-size: 12px;
}
.field textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-0);
  font-size: 14.5px;
  font-family: var(--font-display);
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.btn-primary {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #4570e0);
  color: white;
  font-weight: 600;
  font-size: 14.5px;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 6px 18px rgba(91, 140, 255, 0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(91, 140, 255, 0.35); }
.btn-primary:active { transform: translateY(0); }

.auth-hint {
  margin-top: 20px;
  font-size: 12.5px;
  color: var(--text-2);
  text-align: center;
  line-height: 1.6;
}
.auth-hint code {
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  color: var(--accent-2);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}

/* ================= CHAT LAYOUT ================= */
.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
  background: var(--bg-0);
}

.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-header {
  padding: 20px 18px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #0f1115;
  flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--text-2); font-family: var(--font-mono); }

.me-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
}
.me-info { flex: 1; min-width: 0; }
.me-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-role { font-size: 11px; color: var(--text-2); font-family: var(--font-mono); }
.me-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--bg-3);
  color: var(--text-1);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
  font-size: 14px;
  text-decoration: none;
}
.icon-btn:hover { background: var(--line); color: var(--text-0); }
.icon-btn.notif-on { color: #22c55e; }

.search-box {
  margin: 14px 18px 6px;
  position: relative;
}
.search-box input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px 10px 34px;
  color: var(--text-0);
  font-size: 13.5px;
}
.search-box input:focus { outline: none; border-color: var(--accent); }
.search-box .icn { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-2); font-size: 13px; }

.list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 16px;
}

.list-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  padding: 14px 8px 6px;
  font-family: var(--font-mono);
}

.conv-item, .general-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}
.conv-item:hover, .general-item:hover { background: var(--bg-2); }
.conv-item.active, .general-item.active { background: var(--accent-soft); }

.avatar {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #10131a;
  flex-shrink: 0;
  position: relative;
}
.avatar.general-avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b0e13;
  font-size: 15px;
}
.led-dot {
  position: absolute;
  bottom: -2px; right: -2px;
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 2px solid var(--bg-1);
  background: var(--led-off);
}
.led-dot.online { background: var(--led-on); box-shadow: 0 0 6px var(--led-on); }

.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.conv-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 10.5px; color: var(--text-2); font-family: var(--font-mono); flex-shrink: 0; }
.conv-last { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.unread-badge {
  background: var(--accent);
  color: #0b0e13;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
  font-family: var(--font-mono);
}

.empty-note {
  padding: 20px 10px;
  color: var(--text-2);
  font-size: 12.5px;
  text-align: center;
}

/* ------------- Main chat panel -------------- */
.chat-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background:
    radial-gradient(circle at 100% 0%, rgba(91,140,255,0.05), transparent 40%),
    var(--bg-0);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(23, 26, 33, 0.6);
  backdrop-filter: blur(6px);
}
.chat-header .avatar { width: 38px; height: 38px; font-size: 13px; }
.header-clickable { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; border-radius: 8px; }
.header-clickable.clickable { cursor: pointer; }
.header-clickable.clickable:hover .chat-header-name { color: var(--accent); }
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-weight: 700; font-size: 14.5px; }
.chat-header-status { font-size: 11.5px; color: var(--text-2); font-family: var(--font-mono); }
.chat-header-status.typing { color: var(--accent-2); }

.messages-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.load-more-wrap { text-align: center; margin-bottom: 12px; }
.load-more-btn {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text-1);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 999px;
}
.load-more-btn:hover { color: var(--text-0); border-color: var(--accent); }

.day-divider {
  text-align: center;
  color: var(--text-2);
  font-size: 11px;
  font-family: var(--font-mono);
  margin: 16px 0 10px;
  position: relative;
}

.msg-row {
  display: flex;
  gap: 10px;
  max-width: 72%;
  margin-bottom: 10px;
  animation: msgIn 0.22s ease;
}
.msg-row.mine { margin-left: auto; flex-direction: row-reverse; }
.msg-row .avatar { width: 30px; height: 30px; font-size: 11px; border-radius: 9px; align-self: flex-end; }

.msg-bubble-wrap { display: flex; flex-direction: column; min-width: 0; }
.msg-sender-name { font-size: 11.5px; color: var(--text-2); margin-bottom: 3px; padding: 0 4px; }
.msg-bubble {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  padding: 10px 14px;
  border-radius: 16px 16px 16px 4px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.msg-row.mine .msg-bubble {
  background: linear-gradient(135deg, var(--accent), #4570e0);
  color: #f5f8ff;
  border: none;
  border-radius: 16px 16px 4px 16px;
}
.msg-row.system .msg-bubble {
  background: var(--accent-soft);
  border: 1px dashed rgba(255, 176, 32, 0.4);
  color: #ffd48a;
  font-size: 12.5px;
  border-radius: 10px;
}
.msg-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--text-2);
  margin-top: 3px;
  padding: 0 4px;
  font-family: var(--font-mono);
}
.msg-row.mine .msg-meta { justify-content: flex-end; }
.msg-image { max-width: 260px; border-radius: 12px; display: block; margin-top: 4px; cursor: zoom-in; }
.msg-file {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.15);
  padding: 8px 12px;
  border-radius: 10px;
  margin-top: 4px;
  font-size: 12.5px;
  text-decoration: none;
  color: inherit;
}

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

.typing-indicator {
  display: flex; gap: 4px; align-items: center;
  padding: 8px 14px;
}
.typing-indicator span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-2);
  animation: typingBounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.composer {
  border-top: 1px solid var(--line-soft);
  padding: 14px 22px 18px;
  background: var(--bg-1);
}
.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 8px 8px 8px 14px;
  transition: border-color 0.15s;
}
.composer-inner:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-inner textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-0);
  font-size: 14px;
  line-height: 1.5;
  max-height: 120px;
  padding: 8px 0;
}
.composer-inner textarea::placeholder { color: var(--text-2); }

.attach-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--bg-3);
  color: var(--text-1);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.attach-btn:hover { color: var(--text-0); background: var(--line); }

.send-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b0e13;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: transform 0.12s;
  position: relative;
  overflow: hidden;
}
.send-btn:hover { transform: scale(1.06); }
.send-btn:active { transform: scale(0.96); }
.send-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%);
  transform: translateX(-100%);
}
.send-btn:hover::after { animation: sweep 0.7s ease; }
@keyframes sweep { to { transform: translateX(100%); } }

.pending-file {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--text-1);
}
.pending-file button { background: none; color: var(--danger); font-size: 13px; }

.welcome-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  gap: 10px;
  padding: 40px;
  text-align: center;
}
.welcome-state .glyph {
  width: 64px; height: 64px;
  border-radius: 20px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  margin-bottom: 6px;
}

/* Toast for socket connection status */
.conn-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 999;
}
.conn-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.conn-toast .led { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.conn-toast.ok .led { background: var(--led-on); }

@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0; z-index: 50; transform: translateX(0); transition: transform 0.25s; }
  .sidebar.hidden-mobile { transform: translateX(-100%); }
  .chat-panel { width: 100%; }
  .back-btn { display: inline-flex !important; }
}
.back-btn { display: none; }

/* ================= ADMIN ================= */
.admin-shell { min-height: 100vh; background: var(--bg-0); }
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-1);
}
.admin-topbar .brand { margin: 0; }
.admin-body { padding: 26px 28px 60px; max-width: 1200px; margin: 0 auto; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 18px;
}
.stat-num { font-family: var(--font-mono); font-size: 26px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.stat-card.accent .stat-num { color: var(--accent-2); }
.stat-card.warn .stat-num { color: var(--led-admin); }
.stat-card.danger .stat-num { color: var(--danger); }

.panel {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 20px;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.panel-header h3 { margin: 0; font-size: 16px; }

.broadcast-row { display: flex; gap: 10px; }
.broadcast-row textarea {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  padding: 10px 12px;
  font-size: 13.5px;
  resize: none;
  min-height: 44px;
}
.btn-small {
  background: var(--accent);
  color: #0b0e13;
  font-weight: 600;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.btn-small.ghost { background: var(--bg-3); color: var(--text-1); }
.btn-small.danger-btn { background: var(--danger); color: #fff; }

table.user-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.user-table th {
  text-align: left; color: var(--text-2); font-weight: 500; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 8px 10px; border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-mono);
}
table.user-table td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.user-table tr:hover td { background: var(--bg-2); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.role-admin { background: rgba(255,176,32,0.15); color: var(--led-admin); }
.badge.role-user { background: rgba(255,255,255,0.06); color: var(--text-1); }
.badge.status-active { background: rgba(61,220,132,0.12); color: var(--led-on); }
.badge.status-locked { background: rgba(255,84,112,0.12); color: var(--danger); }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-btn {
  background: var(--bg-3);
  color: var(--text-1);
  font-size: 11.5px;
  padding: 5px 9px;
  border-radius: 6px;
}
.mini-btn:hover { color: var(--text-0); background: var(--line); }

.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.pagination button {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text-1);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
}
.pagination button.active { background: var(--accent); color: #0b0e13; border-color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination-ellipsis { color: var(--text-1); padding: 6px 4px; font-size: 12.5px; user-select: none; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------- Profile page ---------------- */
.profile-header-panel { padding: 24px; }
.profile-hero { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile-avatar {
  width: 68px; height: 68px;
  border-radius: 18px;
  font-size: 24px;
}
.profile-hero-info { flex: 1; min-width: 200px; }
.profile-hero-name { font-size: 20px; font-weight: 700; color: var(--text-0); }
.profile-hero-sub { font-size: 13px; color: var(--text-2); font-family: var(--font-mono); margin-top: 4px; }

.profile-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.profile-info-item { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 12px 14px; }
.profile-info-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); font-family: var(--font-mono); }
.profile-info-value { font-size: 14px; color: var(--text-0); margin-top: 5px; word-break: break-word; }

.profile-bio-text { font-size: 14px; color: var(--text-1); line-height: 1.6; white-space: pre-wrap; }

.skill-badge { background: var(--accent-soft); color: var(--accent); }

.profile-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 20px;
}

@media (max-width: 700px) {
  .profile-info-grid, .profile-form-grid { grid-template-columns: 1fr; }
  .profile-hero { flex-direction: column; align-items: flex-start; }
}

/* ---------------- Modal ---------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.6);
  backdrop-filter: blur(2px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: var(--shadow-1);
}
.modal-box h3 { margin: 0 0 4px; font-size: 17px; }
.modal-box .modal-sub { color: var(--text-2); font-size: 12.5px; margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-close-x {
  position: absolute; top: 16px; right: 16px;
  background: none; color: var(--text-2); font-size: 16px;
}

/* ---------------- Icon picker ---------------- */
.icon-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.icon-picker button {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-size: 17px;
  display: flex; align-items: center; justify-content: center;
}
.icon-picker button.selected { border-color: var(--accent); background: var(--accent-soft); }

/* ---------------- Member picker ---------------- */
.member-picker-search { margin-bottom: 10px; }
.member-picker-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}
.member-picker-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.member-picker-item:last-child { border-bottom: none; }
.member-picker-item:hover { background: var(--bg-2); }
.member-picker-item .avatar { width: 30px; height: 30px; font-size: 11px; }
.member-picker-item .mp-name { flex: 1; font-size: 13.5px; }
.member-picker-item .mp-sub { font-size: 11px; color: var(--text-2); }
.member-picker-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

.member-chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.member-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 4px 6px 4px 10px;
  font-size: 12.5px;
}
.member-chip button { background: none; color: var(--text-2); font-size: 13px; padding: 2px; }
.member-chip button:hover { color: var(--danger); }

.group-avatar-cell { display: flex; align-items: center; gap: 10px; }
.group-avatar-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

/* ---------------- Group chat: pinned banner & messages ---------------- */
.pinned-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  background: rgba(255, 176, 32, 0.08);
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.pinned-banner-icon { flex-shrink: 0; }
.pinned-banner-text {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-1);
}
.pinned-banner-toggle {
  background: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.pinned-list {
  max-height: 220px;
  overflow-y: auto;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-1);
}
.pinned-list-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.pinned-list-item:last-child { border-bottom: none; }
.pinned-list-item .plt-body { flex: 1; min-width: 0; }
.pinned-list-item .plt-sender { font-weight: 600; color: var(--text-0); font-size: 12.5px; }
.pinned-list-item .plt-content { color: var(--text-1); margin-top: 2px; word-break: break-word; }
.pinned-list-item .plt-unpin { background: none; color: var(--text-2); font-size: 11.5px; flex-shrink: 0; }
.pinned-list-item .plt-unpin:hover { color: var(--danger); }

.msg-row { position: relative; }
.msg-pin-btn {
  display: none;
  position: absolute;
  top: -6px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 999px;
}
.msg-row:hover .msg-pin-btn { display: inline-flex; align-items: center; gap: 3px; }
.msg-row.mine .msg-pin-btn { right: 4px; }
.msg-row:not(.mine) .msg-pin-btn { left: 48px; }
.msg-pin-btn.pinned { color: var(--led-admin); display: inline-flex; }

.msg-pinned-flag { font-size: 10.5px; color: var(--led-admin); margin-bottom: 2px; }
