:root {
  --bg: #0A1628;
  --surface: #0F1E35;
  --surface-raised: #152540;
  --accent: #00C9A7;
  --accent-dark: #009E84;
  --text: #FFFFFF;
  --muted: #8A9BB0;
  --subtle: #4A5A6B;
  --border: rgba(255,255,255,0.06);
  --display: 'Clash Display', system-ui, sans-serif;
  --body: 'Satoshi', system-ui, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body { font-family: var(--body); background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.5; font-size: 15px; }
img, svg { display: block; max-width: 100%; }
img { -webkit-user-drag: none; user-select: none; pointer-events: none; }
a img, button img { pointer-events: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
::selection { background: var(--accent); color: var(--bg); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-raised); border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 28px 18px; position: sticky; top: 0; height: 100vh; }
.sidebar-logo { padding: 4px 14px 36px; }
.sidebar-logo img { width: 110px; height: auto; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-nav a { position: relative; display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 10px; color: var(--muted); font-size: 14px; font-weight: 500; transition: color 0.25s ease, background-color 0.25s ease; }
.sidebar-nav a:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.sidebar-nav a.is-active { color: var(--text); background: rgba(0,201,167,0.08); }
.sidebar-nav a.is-active::before { content: ''; position: absolute; left: -18px; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.sidebar-nav svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-user { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-top: 1px solid var(--border); margin-top: 12px; padding-top: 18px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: rgba(0,201,167,0.08); border: 1.5px solid var(--accent); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; letter-spacing: 0.05em; color: var(--text); }
.avatar.lg { width: 40px; height: 40px; font-size: 13px; }
.sidebar-user-info { flex: 1; min-width: 0; line-height: 1.2; }
.sidebar-user-name { font-size: 13px; font-weight: 500; color: var(--text); }
.sidebar-user-role { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.sidebar-user-caret { color: var(--muted); }
.sidebar-user-caret svg { width: 16px; height: 16px; }

.main { padding: 28px 36px 60px; }
.topbar { display: flex; align-items: center; gap: 24px; margin-bottom: 28px; }
.search { flex: 1; max-width: 540px; position: relative; }
.search input { width: 100%; padding: 14px 18px 14px 46px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: var(--text); font: inherit; font-size: 14px; outline: none; transition: border-color 0.2s ease, background-color 0.2s ease; }
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: rgba(0,201,167,0.4); background: var(--surface-raised); }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.topbar-spacer { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--muted); transition: color 0.25s ease, background-color 0.25s ease; position: relative; }
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.icon-btn svg { width: 18px; height: 18px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; }
.card-pad { padding: 24px 28px; }
.card-title { font-size: 12px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); margin-bottom: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 10px;
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, opacity 0.25s ease;
}
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { background: #00DDB8; }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-outline { border: 1px solid rgba(255,255,255,0.14); color: var(--text); }
.btn-outline:hover { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.24); }
.btn-danger { color: #ff9a9a; border: 1px solid rgba(255,138,138,0.3); }
.btn-danger:hover { background: rgba(255,138,138,0.06); border-color: rgba(255,138,138,0.5); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn svg { width: 14px; height: 14px; }

.field-group { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea {
  padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font: inherit; font-size: 14px; outline: none;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.field textarea { resize: vertical; min-height: 96px; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: rgba(0,201,167,0.45); background: var(--surface-raised); }

.muted { color: var(--muted); font-size: 14px; }
.flash { padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.flash.ok { background: rgba(0,201,167,0.08); color: var(--accent); border: 1px solid rgba(0,201,167,0.25); }
.flash.err { background: rgba(255,138,138,0.08); color: #ff8a8a; border: 1px solid rgba(255,138,138,0.25); }

.player-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.player-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px; cursor: pointer; transition: border-color 0.2s ease, background-color 0.2s ease;
  display: flex; flex-direction: column; gap: 14px;
}
.player-card:hover { border-color: rgba(0,201,167,0.3); }
.player-card-head { display: flex; gap: 12px; align-items: center; }
.player-card-head .avatar-img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.player-card-name { font-weight: 600; font-size: 16px; }
.player-card-meta { font-size: 13px; color: var(--muted); }
.position-pill {
  display: inline-flex; padding: 4px 10px; border-radius: 999px;
  border: 1px solid rgba(0,201,167,0.3); color: var(--accent);
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600;
}

.video-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.video-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column;
}
.video-thumb {
  position: relative; aspect-ratio: 16/9; background: #061021;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-thumb .badge {
  position: absolute; top: 8px; left: 8px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  background: rgba(10,22,40,0.7); border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(6px);
}
.video-thumb .badge.stream { color: var(--accent); border-color: rgba(0,201,167,0.3); }
.video-tile-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.video-tile-title { font-weight: 600; font-size: 14px; }
.video-tile-meta { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.video-tile-actions { display: flex; gap: 8px; margin-top: 4px; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(4,10,20,0.72); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px;
  width: 100%; max-width: 520px;
  max-height: 92vh; overflow: auto;
}
.modal h2 { font-size: 22px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

.profile-avatar-large {
  width: 96px; height: 96px; border-radius: 50%;
  background: rgba(0,201,167,0.06); border: 1.5px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.profile-avatar-large img { width: 100%; height: 100%; object-fit: cover; }
.avatar-img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }

.nav-badge {
  margin-left: auto; padding: 2px 8px; border-radius: 999px;
  background: var(--accent); color: var(--bg); font-size: 11px; font-weight: 700;
}
.status-badge {
  display: inline-flex; padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: var(--muted);
}
.status-badge.ok { background: rgba(0,201,167,0.1); color: var(--accent); border-color: rgba(0,201,167,0.3); }
.status-badge.warn { background: rgba(255,200,80,0.1); color: #ffd07a; border-color: rgba(255,200,80,0.3); }
.status-badge.bad { background: rgba(255,138,138,0.1); color: #ff8a8a; border-color: rgba(255,138,138,0.3); }

/* MESSAGES */
.messages-shell {
  display: grid; grid-template-columns: 320px 1fr;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  height: 70vh; min-height: 480px; overflow: hidden;
}
.messages-list { border-right: 1px solid var(--border); overflow-y: auto; }
.messages-thread { display: flex; flex-direction: column; }
.conv-row {
  display: flex; gap: 12px; align-items: center;
  padding: 14px 18px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s ease;
}
.conv-row:hover { background: rgba(255,255,255,0.02); }
.conv-row.is-active { background: rgba(0,201,167,0.05); }
.conv-info { flex: 1; min-width: 0; }
.conv-name { font-size: 14px; font-weight: 600; }
.conv-meta { font-size: 12px; color: var(--muted); }
.conv-last { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.conv-time { font-size: 11px; color: var(--subtle); }
.conv-unread {
  display: inline-flex; padding: 2px 7px; border-radius: 999px; margin-left: 6px;
  background: var(--accent); color: var(--bg); font-size: 11px; font-weight: 700;
}

.thread-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.thread-body { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 8px; }
.bubble-row { display: flex; flex-direction: column; max-width: 75%; }
.bubble-row.mine { align-self: flex-end; align-items: flex-end; }
.bubble-row.theirs { align-self: flex-start; align-items: flex-start; }
.bubble {
  padding: 10px 14px; border-radius: 14px; font-size: 14.5px; line-height: 1.45;
  white-space: pre-wrap; word-wrap: break-word;
}
.bubble-row.mine .bubble { background: var(--accent); color: var(--bg); border-bottom-right-radius: 4px; }
.bubble-row.theirs .bubble { background: var(--surface-raised); color: var(--text); border-bottom-left-radius: 4px; }
.bubble-time { font-size: 10px; color: var(--subtle); margin-top: 4px; padding: 0 4px; }

.thread-compose {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 14px 18px; border-top: 1px solid var(--border);
}
.thread-compose textarea {
  flex: 1; resize: none; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font: inherit; font-size: 14px;
  outline: none; transition: border-color 0.2s ease;
}
.thread-compose textarea:focus { border-color: rgba(0,201,167,0.45); }

@media (max-width: 800px) {
  .messages-shell { grid-template-columns: 1fr; height: auto; }
  .messages-list { max-height: 280px; }
}

.autocomplete {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 18px 40px -10px rgba(0,0,0,0.5);
  max-height: 280px; overflow-y: auto;
}
.autocomplete-item {
  padding: 10px 14px; font-size: 14px; cursor: pointer;
  transition: background-color 0.15s ease;
}
.autocomplete-item:hover { background: rgba(0,201,167,0.08); color: var(--accent); }

.empty {
  padding: 48px 24px; text-align: center;
  color: var(--muted); font-size: 14px;
  border: 1px dashed rgba(255,255,255,0.08); border-radius: 14px;
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px; }
  .field-group { grid-template-columns: 1fr; }
}
