:root {
  --sidebar-width: 260px;
  --sidebar-bg: #1a1f2e;
  --sidebar-text: #a8b2c8;
  --sidebar-active: #4f8ef7;
  --sidebar-hover-bg: rgba(255,255,255,0.07);
  --topbar-h: 60px;
  --accent: #4f8ef7;
  --accent-dark: #3a6fd8;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --surface: #ffffff;
  --bg: #f0f2f8;
  --text: #1e2432;
  --text-muted: #6b7a99;
  --border: #e2e8f0;
  --card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: block;
  height: 120px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  text-decoration: none;
  background-size: 70% !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.nav-section-label {
  padding: 14px 20px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(168,178,200,.5);
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  border-radius: 0;
  transition: background .15s, color .15s;
}

.nav-item a:hover { background: var(--sidebar-hover-bg); color: #fff; }
.nav-item a.active { background: rgba(79,142,247,.18); color: var(--accent); font-weight: 600; }
.nav-item a i { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

/* ── Topbar user block ── */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-left: 1px solid var(--border);
  margin-left: 4px;
}

.topbar-user .avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.topbar-user .user-info { min-width: 0; }
.topbar-user .user-name { color: var(--text); font-size: 13px; font-weight: 600; white-space: nowrap; }
.topbar-user .user-role { color: var(--text-muted); font-size: 11px; }

.topbar-user .logout-btn {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 18px;
  transition: color .15s;
  flex-shrink: 0;
}
.topbar-user .logout-btn:hover { color: var(--danger); }

.topbar-user .tfa-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 18px;
  line-height: 1;
  gap: 2px;
  flex-shrink: 0;
  transition: opacity .15s;
}
.topbar-user .tfa-btn:hover { opacity: 0.75; }
.topbar-user .tfa-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
}

/* ── Main layout ── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s ease;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar .sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.topbar-heading {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
  pointer-events: none;
}

.topbar-app-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.topbar-page-name {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.topbar .topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.content { flex: 1; padding: 24px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.card-header-custom {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header-custom h5 { margin: 0; font-size: 14px; font-weight: 600; }

/* ── Stat cards ── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 20px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
}

.stat-card .stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-card > div:not(.stat-icon) {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.stat-card .stat-value { font-size: 24px; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  background: #f8f9fc;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tfoot tr td {
  padding: 10px 14px;
  background: #eef2fb;
  border-top: 2px solid var(--border);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-main);
}

/* ── Badges ── */
.badge-role-admin { background: #ede9fe; color: #7c3aed; }
.badge-role-user  { background: #dbeafe; color: #1d4ed8; }
.badge-active     { background: #dcfce7; color: #15803d; }
.badge-inactive   { background: #fee2e2; color: #b91c1c; }

/* ── Filters panel ── */
.filters-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}

/* ── Buttons ── */
.btn-accent {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 8px 18px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-accent:hover { background: var(--accent-dark); color: #fff; }

/* ── Alerts ── */
.alert { border-radius: 8px; font-size: 13.5px; }

/* ── Table row hover ── */
.data-table tbody td,
.monitor-table tbody td,
table.table tbody td {
  transition: background-color .12s ease;
}
.data-table tbody td.row-hovered,
.monitor-table tbody td.row-hovered,
table.table tbody td.row-hovered {
  background-color: rgba(134, 239, 172, .28) !important;
}

/* ── Page loading overlay ── */
#page-loader {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 20, 40, .45);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
}
#page-loader.active { display: flex; }

.loader-logo-wrap {
  position: relative;
  width: 220px;
}

.loader-logo-static {
  width: 220px;
  height: auto;
  filter: drop-shadow(0 2px 10px rgba(0,0,0,.5));
}

.loader-heartbeat {
  position: absolute;
  /* Сердце в логотипе: x=6-82 из 420, y=116-195 из 199 */
  left: 1%;
  top: 13%;
  width: 36%;
  height: auto;
  transform-origin: center center;
  animation: heartbeat 1.2s ease-in-out infinite;
  filter: drop-shadow(0 1px 8px rgba(220,30,30,.7));
}
.loader-text {
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .03em;
  opacity: .9;
}
@keyframes heartbeat {
  0%   { transform: scale(1);    }
  14%  { transform: scale(1.18); }
  28%  { transform: scale(1);    }
  42%  { transform: scale(1.12); }
  60%  { transform: scale(1);    }
  100% { transform: scale(1);    }
}

/* dots animation for loader text */
.loader-dots::after {
  content: '';
  display: inline-block;
  width: 1.5em;
  text-align: left;
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  background-color: #1a2a3a;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(6px);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
}

.login-logo-img {
  max-width: 200px;
  max-height: 80px;
  object-fit: contain;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .topbar .sidebar-toggle { display: block; }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 150;
  }
  .sidebar-overlay.show { display: block; }
  .content { padding: 16px; }
  .topbar-user .user-info { display: none; }
  .topbar-user { padding: 6px 0 6px 12px; }
  body::after { display: none; }
}

/* ── Menu settings (drag-and-drop) ── */
.menu-sort-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.menu-sort-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #f8f9fc;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: background .15s, opacity .15s;
  cursor: default;
}

.menu-sort-item.menu-sort-hidden {
  opacity: .5;
}

.menu-sort-item.menu-sort-ghost {
  opacity: .35;
  background: #e8edf8;
}

.menu-sort-item.menu-sort-chosen {
  box-shadow: 0 4px 16px rgba(79,142,247,.2);
  background: #fff;
}

.drag-handle {
  color: var(--text-muted);
  cursor: grab;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }

.menu-sort-icon {
  font-size: 16px;
  color: var(--accent);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.menu-sort-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

.menu-sort-label-input {
  flex: 1;
  min-width: 0;
  max-width: 200px;
  padding: 2px 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border-color: var(--border);
  height: auto;
}

/* Скрытые пункты в сайдбаре (только для админа) */
.nav-item a.nav-hidden-item {
  opacity: .55;
}

.nav-hidden-badge {
  margin-left: auto;
  font-size: 11px;
  opacity: .7;
}

/* ── Utilities ── */
.text-accent { color: var(--accent); }
.text-muted-sm { color: var(--text-muted); font-size: 12px; }
.fw-600 { font-weight: 600; }
.gap-2 { gap: .5rem; }
.no-wrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ── Audit action badges ─────────────────────────────────────── */
.badge-audit-success   { background: #dcfce7; color: #15803d; }
.badge-audit-danger    { background: #fee2e2; color: #b91c1c; }
.badge-audit-warning   { background: #fef9c3; color: #a16207; }
.badge-audit-primary   { background: #dbeafe; color: #1d4ed8; }
.badge-audit-secondary { background: #f1f5f9; color: #475569; }

