/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0d1117;
  color: #e6edf3;
  min-height: 100vh;
  overflow-x: hidden;
}
::selection { background: #7c6aef44; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 4px; }

/* ─── Login Overlay ───────────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.4s; opacity: 1;
}
.login-overlay.hidden { opacity: 0; pointer-events: none; }
.login-card {
  background: #161b22; border: 1px solid #30363d;
  border-radius: 20px; padding: 48px 40px;
  text-align: center; width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.login-logo { font-size: 48px; margin-bottom: 16px; }
.login-title { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.login-subtitle { color: #8b949e; font-size: 14px; margin-bottom: 28px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-input {
  background: #0d1117; border: 1px solid #30363d;
  border-radius: 12px; padding: 14px 16px;
  color: #e6edf3; font-size: 15px; outline: none;
  transition: border-color 0.2s;
}
.login-input:focus { border-color: #7c6aef; }
.login-btn {
  background: linear-gradient(135deg, #7c6aef, #5b4dc7);
  color: #fff; border: none; border-radius: 12px;
  padding: 14px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.2s;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124,106,239,0.3); }
.login-error { color: #f85149; font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ─── Header ──────────────────────────────────────────────── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px; background: #161b22;
  border-bottom: 1px solid #21262d;
  position: sticky; top: 0; z-index: 50;
}
.header-left { display: flex; align-items: center; }
.logo { display: flex; align-items: center; gap: 14px; }
.logo-icon { font-size: 32px; }
.logo-title { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.logo-subtitle { font-size: 12px; color: #8b949e; font-weight: 500; }
.header-right { display: flex; align-items: center; gap: 14px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: #0d1117; border: 1px solid #30363d;
  border-radius: 10px; padding: 8px 14px;
  transition: border-color 0.2s;
}
.search-box:focus-within { border-color: #7c6aef; }
.search-box svg { color: #8b949e; flex-shrink: 0; }
.search-box input {
  background: none; border: none; color: #e6edf3;
  font-size: 14px; outline: none; width: 200px;
}
.search-box input::placeholder { color: #484f58; }
.refresh-btn {
  background: #21262d; border: 1px solid #30363d;
  border-radius: 10px; padding: 8px; cursor: pointer;
  color: #8b949e; transition: all 0.2s; display: flex;
}
.refresh-btn:hover { background: #30363d; color: #e6edf3; }

/* ─── Main Layout ─────────────────────────────────────────── */
.main { max-width: 1280px; margin: 0 auto; padding: 24px 32px 80px; }

/* ─── KPI Grid ────────────────────────────────────────────── */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 24px;
}
.kpi-card {
  background: #161b22; border: 1px solid #21262d;
  border-radius: 16px; padding: 20px 22px;
  display: flex; align-items: center; gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.kpi-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-icon-purple { background: #7c6aef20; color: #7c6aef; }
.kpi-icon-blue { background: #58a6ff20; color: #58a6ff; }
.kpi-icon-green { background: #3fb95020; color: #3fb950; }
.kpi-icon-amber { background: #d2992220; color: #d29922; }
.kpi-value { font-size: 28px; font-weight: 800; line-height: 1; }
.kpi-label { font-size: 13px; color: #8b949e; margin-top: 4px; }

/* ─── Card ────────────────────────────────────────────────── */
.card {
  background: #161b22; border: 1px solid #21262d;
  border-radius: 16px; overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid #21262d;
}
.card-title { font-size: 16px; font-weight: 700; }
.card-count {
  background: #7c6aef20; color: #7c6aef;
  padding: 4px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
}

/* Filter tabs */
.filter-tabs { display: flex; gap: 4px; }
.filter-tab {
  background: #21262d; border: 1px solid #30363d;
  border-radius: 8px; padding: 5px 12px;
  font-size: 12px; font-weight: 600; color: #8b949e;
  cursor: pointer; transition: all 0.2s;
  white-space: nowrap;
}
.filter-tab:hover { background: #30363d; color: #e6edf3; }
.filter-tab.active { background: #7c6aef20; color: #7c6aef; border-color: #7c6aef40; }

/* ─── Users Table ─────────────────────────────────────────── */
.table-container { max-height: 600px; overflow-y: auto; }
.table-empty { padding: 40px; text-align: center; color: #8b949e; }
.user-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 22px; border-bottom: 1px solid #21262d;
  cursor: pointer; transition: background 0.15s;
}
.user-row:hover { background: #1c2129; }
.user-row:last-child { border-bottom: none; }
.user-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  object-fit: cover; background: #21262d; flex-shrink: 0;
  border: 2px solid #30363d;
}
.user-avatar-placeholder {
  width: 42px; height: 42px; border-radius: 50%;
  background: #21262d; display: flex; align-items: center;
  justify-content: center; font-size: 18px; flex-shrink: 0;
  border: 2px solid #30363d; color: #8b949e;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 12px; color: #8b949e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-provider {
  font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 20px; text-transform: uppercase;
  flex-shrink: 0;
}
.provider-google { background: #3fb95020; color: #3fb950; }
.provider-apple { background: #8b949e20; color: #8b949e; }
.provider-yandex { background: #d2992220; color: #d29922; }
.provider-vk { background: #58a6ff20; color: #58a6ff; }
.user-stats {
  display: flex; gap: 16px; flex-shrink: 0;
}
.user-stat {
  text-align: center;
}
.user-stat-value { font-size: 14px; font-weight: 700; }
.user-stat-label { font-size: 11px; color: #8b949e; }
.user-date { font-size: 12px; color: #484f58; flex-shrink: 0; width: 90px; text-align: right; }

/* Status dots */
.avatar-wrap { position: relative; flex-shrink: 0; }
.status-dot {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.avatar-wrap .status-dot {
  position: absolute; bottom: 0; right: 0;
  border: 2px solid #161b22;
}
.status-dot.online { background: #3fb950; box-shadow: 0 0 8px #3fb95080; }
.status-dot.offline { background: #484f58; }

@keyframes pulse-online {
  0%, 100% { box-shadow: 0 0 0 0 rgba(63,185,80,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(63,185,80,0); }
}
.avatar-wrap .status-dot.online {
  animation: pulse-online 2s infinite;
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,0.5); opacity: 0;
  pointer-events: none; transition: opacity 0.3s;
}
.sidebar-overlay.active { opacity: 1; pointer-events: auto; }
.sidebar {
  position: fixed; top: 0; right: -520px; z-index: 100;
  width: 500px; height: 100vh;
  background: #161b22; border-left: 1px solid #21262d;
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  box-shadow: -10px 0 40px rgba(0,0,0,0.4);
}
.sidebar.active { right: 0; }
.sidebar-close {
  position: absolute; top: 16px; right: 16px; z-index: 10;
  background: #21262d; border: 1px solid #30363d;
  color: #8b949e; width: 36px; height: 36px;
  border-radius: 10px; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.sidebar-close:hover { background: #30363d; color: #e6edf3; }
.sidebar-content { padding: 24px; }

/* Sidebar profile */
.sidebar-profile { text-align: center; margin-bottom: 28px; }
.sidebar-avatar {
  width: 100px; height: 100px; border-radius: 50%;
  object-fit: cover; border: 3px solid #30363d;
  margin-bottom: 14px;
}
.sidebar-avatar-placeholder {
  width: 100px; height: 100px; border-radius: 50%;
  background: #21262d; display: flex; align-items: center;
  justify-content: center; font-size: 40px;
  margin: 0 auto 14px; border: 3px solid #30363d; color: #8b949e;
}
.sidebar-name { font-size: 20px; font-weight: 800; }
.sidebar-email { font-size: 13px; color: #8b949e; margin-top: 4px; }
.sidebar-bio {
  font-size: 13px; color: #b1bac4; margin-top: 10px;
  padding: 12px; background: #0d1117; border-radius: 10px;
  line-height: 1.5;
}
.sidebar-meta {
  display: flex; gap: 12px; justify-content: center; margin-top: 14px; flex-wrap: wrap;
}
.sidebar-tag {
  font-size: 11px; padding: 4px 12px; border-radius: 20px;
  background: #21262d; color: #8b949e; font-weight: 500;
}
.sidebar-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
.btn-danger {
  background: #f8514920; color: #f85149; border: 1px solid #f8514940;
  border-radius: 10px; padding: 8px 16px; font-size: 13px;
  font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-danger:hover { background: #f8514940; }

/* Sidebar activity status */
.sidebar-activity {
  display: flex; align-items: center; gap: 8px;
  justify-content: center; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 14px;
  border-radius: 10px; font-size: 13px;
}
.sidebar-activity.online { background: #3fb95015; color: #3fb950; }
.sidebar-activity.offline { background: #21262d; color: #8b949e; }
.sidebar-activity .status-dot { width: 10px; height: 10px; }
.activity-location { font-size: 12px; opacity: 0.8; }

/* Sidebar books */
.sidebar-section-title {
  font-size: 15px; font-weight: 700;
  margin: 24px 0 12px; padding-bottom: 8px;
  border-bottom: 1px solid #21262d;
}
.sidebar-book {
  display: flex; gap: 12px; padding: 12px;
  background: #0d1117; border-radius: 12px;
  margin-bottom: 10px; transition: background 0.15s;
}
.sidebar-book:hover { background: #1c2129; }
.sidebar-book-cover {
  width: 50px; height: 70px; border-radius: 6px;
  object-fit: cover; background: #21262d; flex-shrink: 0;
}
.sidebar-book-cover-placeholder {
  width: 50px; height: 70px; border-radius: 6px;
  background: #21262d; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; font-size: 20px; color: #484f58;
}
.sidebar-book-info { flex: 1; min-width: 0; }
.sidebar-book-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.sidebar-book-author { font-size: 12px; color: #8b949e; }
.sidebar-book-review {
  font-size: 12px; color: #b1bac4; margin-top: 6px;
  padding: 8px; background: #161b22; border-radius: 8px;
  line-height: 1.4; border-left: 3px solid #7c6aef;
}
.sidebar-book-rating {
  font-size: 11px; margin-top: 4px;
  padding: 2px 8px; border-radius: 12px; display: inline-block;
}
.rating-recommend { background: #3fb95020; color: #3fb950; }
.rating-not_recommend { background: #f8514920; color: #f85149; }
.rating-reading { background: #58a6ff20; color: #58a6ff; }
.sidebar-book-actions { display: flex; gap: 6px; margin-top: 8px; }
.btn-small {
  font-size: 11px; padding: 4px 10px; border-radius: 8px;
  border: 1px solid #30363d; background: #21262d;
  color: #8b949e; cursor: pointer; transition: all 0.15s;
}
.btn-small:hover { background: #30363d; color: #e6edf3; }
.btn-small-danger { border-color: #f8514940; color: #f85149; }
.btn-small-danger:hover { background: #f8514920; }

/* ─── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
  background: #161b22; border: 1px solid #30363d;
  border-radius: 16px; padding: 28px; width: 380px;
  text-align: center;
}
.modal-text { font-size: 15px; margin-bottom: 20px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-btn {
  padding: 10px 24px; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: none; transition: all 0.2s;
}
.modal-btn-cancel { background: #21262d; color: #8b949e; }
.modal-btn-cancel:hover { background: #30363d; color: #e6edf3; }
.modal-btn-danger { background: #f85149; color: #fff; }
.modal-btn-danger:hover { background: #da3633; }

/* ─── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #161b22; border: 1px solid #30363d;
  border-radius: 12px; padding: 12px 24px;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  opacity: 0; transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 300; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: #3fb95060; color: #3fb950; }
.toast.error { border-color: #f8514960; color: #f85149; }

/* ─── Footer ──────────────────────────────────────────────── */
.footer { text-align: center; padding: 20px; color: #484f58; font-size: 12px; }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 16px; }
  .header { padding: 12px 16px; }
  .sidebar { width: 100%; right: -100%; }
  .user-stats { display: none; }
  .user-date { display: none; }
}
