:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #d9dee5;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --danger: #c62828;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card, .shell {
  width: 100%;
  max-width: 1100px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(0,0,0,.06);
}
.auth-card {
  max-width: 420px;
  padding: 24px;
}
.auth-form, .message-form, .create-user-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-form input, .message-form textarea, .message-form input[type="file"], .create-user-form input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
}
button {
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
  background: var(--primary);
  color: white;
}
button:hover { opacity: .95; }
.secondary-btn {
  background: #eef2ff;
  color: #1d4ed8;
  border: 1px solid #c7d2fe;
}
.danger-btn {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.muted { color: var(--muted); }
.error-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: 10px;
  margin: 12px 0;
}
.auth-links { margin-top: 14px; }
.auth-links a { color: #1d4ed8; text-decoration: none; }
.shell { padding: 16px; margin: 16px auto; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.tab-btn {
  background: #eef2f7;
  color: #334155;
  border: 1px solid var(--line);
}
.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.panel { display: none; }
.panel.active { display: block; }
.message-list {
  min-height: 300px;
  max-height: 55vh;
  overflow-y: auto;
  background: #fafbfd;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.message-item {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.message-text {
  white-space: pre-wrap;
  word-break: break-word;
}
.message-image {
  margin-top: 10px;
}
.message-image img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
}
.form-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.form-row > * { flex: 1; }
.load-more-wrap { margin: 10px 0; }
.private-header, .side-title, .placeholder-box, .admin-actions-row {
  margin-bottom: 10px;
}
.badge {
  display: inline-flex;
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #dc2626;
  color: white;
  font-size: 12px;
  align-items: center;
  justify-content: center;
}
.hidden { display: none !important; }
.split-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}
.side-list {
  border: 1px solid var(--line);
  background: #fafbfd;
  border-radius: 12px;
  padding: 10px;
}
.private-user-btn {
  width: 100%;
  text-align: left;
  background: white;
  color: var(--text);
  border: 1px solid var(--line);
  margin-bottom: 8px;
}
.private-user-btn.active {
  background: #eff6ff;
  border-color: #93c5fd;
}
.placeholder-box {
  background: #fafbfd;
  border: 1px dashed var(--line);
  padding: 16px;
  border-radius: 12px;
}
.create-user-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  align-items: end;
}
.create-user-actions { display: flex; align-items: end; }
.table-wrap { overflow-x: auto; }
.user-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
}
.user-table th, .user-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}
.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
}
.status-active { background: #dcfce7; color: #166534; }
.status-blocked { background: #fee2e2; color: #991b1b; }
.sessions-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.online-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.14);
  flex: 0 0 10px;
}
@media (max-width: 900px) {
  .split-layout { grid-template-columns: 1fr; }
  .create-user-form { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
  .form-row { flex-direction: column; }
}


.shell-user {
  padding-top: 14px;
}
.tabs-user-main {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.tabs-user-main .tab-btn {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}
.tabs-user-main .tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.message-form-user textarea {
  min-height: 128px;
  resize: vertical;
}
.hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.message-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.left-action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}
.action-btn-blue {
  min-width: 110px;
}
.action-btn-blue[disabled],
button[disabled] {
  opacity: .55;
  cursor: not-allowed;
}
.send-btn-green {
  background: #16a34a;
  color: #fff;
  min-width: 140px;
}
.panel-private-dark {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 14px;
}
.private-dark-header {
  background: linear-gradient(180deg, #1e293b 0%, #111827 100%);
  color: #f8fafc;
  border: 1px solid #334155;
  border-left: 4px solid #60a5fa;
  border-radius: 12px;
  padding: 12px 14px;
}
.muted-on-dark {
  color: #94a3b8;
}
.message-list-dark {
  background: #0f172a;
  border-color: #334155;
}
.message-list-dark .message-item {
  background: #1f2937;
  border-color: #374151;
  color: #e5e7eb;
}
.message-list-dark .message-meta {
  color: #93c5fd;
}
.panel-private-dark .message-form textarea {
  background: #0f172a;
  color: #f8fafc;
  border-color: #334155;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.modal-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 18px 40px rgba(0,0,0,.18);
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}
.modal-text {
  color: var(--text);
  margin-bottom: 16px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
@media (max-width: 900px) {
  .tabs-user-main {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .message-actions-row {
    flex-direction: column;
    align-items: stretch;
  }
  .left-action-buttons {
    width: 100%;
  }
  .left-action-buttons > * {
    flex: 1;
  }
  .send-btn-green {
    width: 100%;
  }
}


/* Admin private dialog aligned with group chat styling */
.admin-private-chat-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.admin-private-chat-header {
  background: #fafbfd;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
#admin-private-thread .message-list {
  background: #fafbfd;
}
#admin-private-thread .message-form {
  margin-top: 10px;
}
#admin-private-thread .message-form textarea {
  min-height: 120px;
  resize: vertical;
}
#admin-private-thread .form-row {
  align-items: stretch;
}
.side-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#admin-private-users {
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 2px;
}
.private-user-btn {
  border-radius: 12px;
  padding: 12px;
}
.private-user-btn strong {
  display: inline-block;
  margin-bottom: 4px;
}

.message-sender-admin-private,
.message-sender-admin-private-dialog {
  color: #c62828;
  font-weight: 700;
}

.message-sender-user-private-dialog {
  color: #2e7d32;
  font-weight: 700;
}

.modal-card-wide {
  max-width: 760px;
}
.invite-textarea {
  width: 100%;
  min-height: 420px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.45;
  resize: vertical;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.tab-btn-private {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.private-tab-label {
  display: inline-block;
}
.private-unread-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #ff3b30;
  box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.45);
  animation: privateUnreadPulse 1.2s ease-in-out infinite;
  flex: 0 0 12px;
}
@keyframes privateUnreadPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.45);
  }
  50% {
    transform: scale(1.18);
    box-shadow: 0 0 0 7px rgba(255, 59, 48, 0);
  }
}
.modal-text-lines > div {
  margin-bottom: 4px;
}
.modal-text-spacer {
  height: 6px;
}
.modal-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
  margin-bottom: 16px;
}
.session-history-head,
.session-history-row {
  display: grid;
  grid-template-columns: 82px 54px 54px 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.session-history-head {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  padding: 0 4px;
}
.session-history-list {
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.session-history-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fafbfd;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
}
.session-history-ip {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-history-empty {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 16px;
  color: var(--muted);
  background: #fafbfd;
}
