:root {
  --bg: #0d0f10;
  --surface: #141618;
  --surface2: #1c1f21;
  --surface3: #232628;
  --border: rgba(255,255,255,0.06);
  --border2: rgba(255,255,255,0.11);
  --green: #25d366;
  --green2: #128c7e;
  --green-dim: rgba(37,211,102,0.12);
  --green-dim2: rgba(37,211,102,0.06);
  --text: #f0f0ee;
  --muted: #8b8b89;
  --muted2: #4e4e4c;
  --red: #ff4d4d;
  --amber: #ffb020;
  --blue: #4d9fff;
  --radius: 12px;
  --radius-sm: 8px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 2px; }

/* SIDEBAR */
.sidebar {
  width: 220px; min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
  transition: transform .25s;
}
.sidebar-logo {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.logo-icon {
  width: 34px; height: 34px;
  background: var(--green); border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { width: 20px; height: 20px; fill: #fff; }
.logo-text { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.logo-text span { color: var(--green); }
.sidebar-section {
  padding: 14px 16px 4px;
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.1em; color: var(--muted2);
  text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin: 1px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer; color: var(--muted);
  font-size: 13px; font-weight: 500;
  transition: all .15s; position: relative;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--green-dim); color: var(--green); }
.nav-item .nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--green); color: #0d0f10;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
}
.nav-badge.red { background: var(--red); color: #fff; }
.sidebar-bottom {
  margin-top: auto; padding: 12px;
  border-top: 1px solid var(--border);
}
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s;
}
.user-row:hover { background: var(--surface2); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--green-dim); border: 1.5px solid var(--green);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--green); flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--muted); }

/* TOPBAR */
.topbar {
  height: 54px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; position: sticky; top: 0; z-index: 40;
}
.page-title { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--muted); transition: all .15s;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.notif-dot { position: relative; }
.notif-dot::after {
  content: ''; position: absolute; top: 6px; right: 6px;
  width: 6px; height: 6px; background: var(--red);
  border-radius: 50%; border: 1.5px solid var(--surface);
}

/* LAYOUT */
.main { margin-left: 220px; flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
.content { padding: 22px; flex: 1; }

/* PANEL */
.panel { display: none; }
.panel.active { display: block; animation: fadeIn .2s ease both; }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px);}to{opacity:1;transform:none;} }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 18px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  transition: border-color .2s;
}
.stat-card:hover { border-color: var(--border2); }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stat-label { font-size: 11px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.stat-icon.green { background: var(--green-dim); }
.stat-icon.blue { background: rgba(77,159,255,0.1); }
.stat-icon.amber { background: rgba(255,176,32,0.1); }
.stat-icon.red { background: rgba(255,77,77,0.1); }
.stat-num { font-size: 24px; font-weight: 700; letter-spacing: -1px; line-height: 1; }
.stat-delta { font-size: 12px; margin-top: 4px; }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* SECTION HEADER */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title { font-size: 15px; font-weight: 700; }

/* BUTTONS */
.btn {
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s; border: none; white-space: nowrap;
}
.btn-primary { background: var(--green); color: #0d0f10; }
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.btn-red { background: rgba(255,77,77,0.1); color: var(--red); border: 1px solid rgba(255,77,77,0.2); }
.btn-sm { padding: 5px 11px; font-size: 12px; }

/* TABLE */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 18px;
}
table { width: 100%; border-collapse: collapse; }
thead { background: var(--surface2); }
th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.015); }

/* TAGS */
.tag { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.tag-green { background: rgba(37,211,102,0.12); color: #25d366; }
.tag-amber { background: rgba(255,176,32,0.1); color: #ffb020; }
.tag-red { background: rgba(255,77,77,0.1); color: #ff4d4d; }
.tag-blue { background: rgba(77,159,255,0.1); color: #4d9fff; }
.tag-gray { background: rgba(255,255,255,0.06); color: var(--muted); }
.tag-purple { background: rgba(160,100,255,0.1); color: #a064ff; }

/* CARDS */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(250px,1fr)); gap: 12px; margin-bottom: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  transition: all .2s; cursor: pointer;
}
.card:hover { border-color: var(--border2); transform: translateY(-2px); }
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.card-desc { font-size: 12px; color: var(--muted); line-height: 1.6; }
.card-footer { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; }
.progress-bar { height: 4px; background: var(--surface3); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 2px; }

/* FORM */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.form-input {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-family: inherit; font-size: 13px; color: var(--text);
  outline: none; transition: border-color .2s; width: 100%;
}
.form-input:focus { border-color: rgba(37,211,102,0.4); }
.form-input::placeholder { color: var(--muted2); }
textarea.form-input { resize: vertical; min-height: 80px; }
select.form-input option { background: var(--surface2); }

/* CHAT */
.chat-layout {
  display: grid; grid-template-columns: 280px 1fr;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; height: 540px;
}
.chat-list { border-right: 1px solid var(--border); overflow-y: auto; display: flex; flex-direction: column; }
.chat-list-header { padding: 13px 15px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.chat-item { padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s; display: flex; gap: 10px; align-items: flex-start; flex-shrink: 0; }
.chat-item:hover { background: var(--surface2); }
.chat-item.active { background: var(--green-dim2); border-left: 2px solid var(--green); }
.chat-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface3); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--muted); flex-shrink: 0; }
.chat-name { font-size: 13px; font-weight: 600; }
.chat-preview { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.chat-time { font-size: 11px; color: var(--muted2); margin-left: auto; flex-shrink: 0; }
.chat-unread { background: var(--green); color: #0d0f10; font-size: 10px; font-weight: 700; width: 17px; height: 17px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-top: 2px; }
.chat-main { display: flex; flex-direction: column; overflow: hidden; }
.chat-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.chat-messages { flex: 1; padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 65%; padding: 9px 13px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.msg-in { background: var(--surface2); border-radius: 4px 12px 12px 12px; align-self: flex-start; }
.msg-out { background: var(--green-dim); border: 1px solid rgba(37,211,102,0.18); border-radius: 12px 4px 12px 12px; align-self: flex-end; }
.msg-time { font-size: 10px; color: var(--muted2); margin-top: 4px; text-align: right; }
.chat-input-row { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.chat-input { flex: 1; background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 9px 16px; font-family: inherit; font-size: 13px; color: var(--text); outline: none; }
.chat-input:focus { border-color: rgba(37,211,102,0.3); }
.send-btn { width: 34px; height: 34px; background: var(--green); border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: opacity .15s; }
.send-btn:hover { opacity: 0.85; }

/* RESPONSIVE */
@media (max-width: 1024px) { .stats-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-list { display: none; }
  .form-grid { grid-template-columns: 1fr; }
}
