:root {
  --sidebar-width: 240px;
  --sidebar-bg: #1a1d21;
  --sidebar-hover: #2c2f35;
  --topbar-height: 56px;
  --accent: #0d6efd;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #f0f2f5;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#sidebar .brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

#sidebar .brand span {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .02em;
}

#sidebar .brand small {
  color: rgba(255,255,255,.4);
  font-size: .7rem;
  margin-left: .4rem;
}

#sidebar .nav-link {
  color: rgba(255,255,255,.65);
  padding: .6rem 1.25rem;
  border-radius: .375rem;
  margin: .1rem .5rem;
  font-size: .875rem;
  transition: background .15s, color .15s;
}

#sidebar .nav-link:hover,
#sidebar .nav-link.active {
  background: var(--sidebar-hover);
  color: #fff;
}

#sidebar .nav-link .bi {
  margin-right: .6rem;
  font-size: 1rem;
  opacity: .8;
}

/* ─── Main content ───────────────────────────────────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

#topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 99;
}

.page-content {
  padding: 1.75rem 1.5rem;
}

/* ─── Stat cards ─────────────────────────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border-radius: .75rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid #e5e7eb;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: .8rem;
  color: #6b7280;
  margin-top: .3rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ─── Online badge ───────────────────────────────────────────────────────────── */
.badge-online {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
}

.badge-online::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse-green 2s infinite;
}

.badge-offline::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  margin-right: .35rem;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ─── Tables ─────────────────────────────────────────────────────────────────── */
.table-card {
  background: #fff;
  border-radius: .75rem;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}

.table-card .table {
  margin-bottom: 0;
}

.table thead th {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #6b7280;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
}

/* ─── Login ──────────────────────────────────────────────────────────────────── */
.login-wrapper {
  position:absolute;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1d21 0%, #2c3e50 100%);
}

.login-card {
  width: 380px;
  background: #fff;
  border-radius: 1rem;
  padding: 2.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

/* ─── Table actions ──────────────────────────────────────────────────────────── */
.table td:last-child {
  white-space: nowrap;
}

/* ─── Sortable headers ───────────────────────────────────────────────────────── */
th.th-sort {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.th-sort:hover {
  color: #374151;
}

th.th-sort .sort-icon {
  font-size: .65rem;
  opacity: .5;
  margin-left: .2rem;
  vertical-align: middle;
}

th.th-sort .bi-chevron-up,
th.th-sort .bi-chevron-down {
  opacity: 1;
  color: var(--accent);
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
#sidebar {
  transition: transform .25s ease;
}

#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
}

#sidebar-backdrop.active {
  display: block;
}

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
    z-index: 100;
  }
  #sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
  }
  #main-content { margin-left: 0; }

  #modal-reader-info .modal-body {
    overflow-x: hidden;
  }
  #modal-reader-info .modal-body .table td {
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  #modal-reader-info .modal-body .table td:first-child {
    white-space: normal;
  }
  #modal-reader-info .modal-body code {
    word-break: break-all;
  }
}
