/* ============================================================
   AEGIS DESIGN SYSTEM — v3.1
   ============================================================
   Вайб-фон • 4 темы • Command Palette • Skeleton • Утилиты
   Не конфликтует с style.css (подключай после него).
   ============================================================ */

/* ============================================================
   1. TOKENS
   ============================================================ */
:root {
  --a-bg-0: #07070d;
  --a-bg-1: #0d0d16;
  --a-bg-2: #14141f;
  --a-bg-3: #1c1c2a;
  --a-bg-4: #242435;

  --a-border-1: #1e1e2e;
  --a-border-2: #2a2a3d;
  --a-border-3: #3a3a52;

  --a-text-1: #ffffff;
  --a-text-2: #c8c8d6;
  --a-text-3: #8a8a9e;
  --a-text-4: #55556a;

  --a-accent:       #7c6ce8;
  --a-accent-hi:    #8f80f0;
  --a-accent-lo:    #6a5acd;
  --a-accent-soft:  rgba(124, 108, 232, 0.12);
  --a-accent-glow:  rgba(124, 108, 232, 0.35);

  --a-success:      #3ddc84;
  --a-success-soft: rgba(61, 220, 132, 0.12);
  --a-danger:       #ff5c5c;
  --a-danger-soft:  rgba(255, 92, 92, 0.12);
  --a-warning:      #ffb454;
  --a-warning-soft: rgba(255, 180, 84, 0.12);
  --a-info:         #5c9dff;
  --a-info-soft:    rgba(92, 157, 255, 0.12);
  --a-purple:       #c77dff;
  --a-purple-soft:  rgba(199, 125, 255, 0.12);

  --a-r-xs: 6px;
  --a-r-sm: 8px;
  --a-r-md: 12px;
  --a-r-lg: 16px;
  --a-r-xl: 20px;
  --a-r-full: 999px;

  --a-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --a-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --a-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
  --a-shadow-glow: 0 0 24px var(--a-accent-glow);

  --a-t-fast: 120ms ease;
  --a-t-base: 200ms ease;
  --a-t-slow: 320ms cubic-bezier(.4, 0, .2, 1);

  --a-font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  --a-font-mono: ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace;

  --a-topbar-h: 60px;
}

/* ============================================================
   2. THEMES
   ============================================================ */
html[data-theme="midnight"] {
  --a-bg-0: #040408;
  --a-bg-1: #08080f;
  --a-bg-2: #0e0e1a;
  --a-bg-3: #161626;
  --a-bg-4: #1e1e32;
  --a-border-1: #14142a;
  --a-border-2: #1e1e38;
  --a-border-3: #2c2c4a;
  --a-accent:    #5c9dff;
  --a-accent-hi: #7eb1ff;
  --a-accent-lo: #4080dd;
  --a-accent-soft: rgba(92, 157, 255, 0.12);
  --a-accent-glow: rgba(92, 157, 255, 0.4);
}
html[data-theme="midnight"] .aegis::before {
  background:
    radial-gradient(circle at 15% 20%, rgba(92, 157, 255, 0.22), transparent 45%),
    radial-gradient(circle at 85% 15%, rgba(92, 157, 255, 0.10), transparent 45%),
    radial-gradient(circle at 75% 85%, rgba(64, 128, 221, 0.10), transparent 50%),
    radial-gradient(circle at 25% 90%, rgba(61, 220, 132, 0.05), transparent 50%);
  background-size: 200% 200%, 200% 200%, 200% 200%, 200% 200%;
}

html[data-theme="rose"] {
  --a-bg-0: #0d0709;
  --a-bg-1: #160d12;
  --a-bg-2: #1e1219;
  --a-bg-3: #2a1a24;
  --a-bg-4: #36232f;
  --a-border-1: #2a1a24;
  --a-border-2: #3a2532;
  --a-border-3: #4d3344;
  --a-accent:    #f472b6;
  --a-accent-hi: #ff8cc4;
  --a-accent-lo: #d6579a;
  --a-accent-soft: rgba(244, 114, 182, 0.14);
  --a-accent-glow: rgba(244, 114, 182, 0.4);
}
html[data-theme="rose"] .aegis::before {
  background:
    radial-gradient(circle at 15% 20%, rgba(244, 114, 182, 0.22), transparent 45%),
    radial-gradient(circle at 85% 15%, rgba(199, 125, 255, 0.14), transparent 45%),
    radial-gradient(circle at 75% 85%, rgba(255, 92, 92, 0.10), transparent 50%),
    radial-gradient(circle at 25% 90%, rgba(255, 180, 84, 0.08), transparent 50%);
  background-size: 200% 200%, 200% 200%, 200% 200%, 200% 200%;
}

html[data-theme="light"] {
  --a-bg-0: #f4f5f8;
  --a-bg-1: #ffffff;
  --a-bg-2: #ffffff;
  --a-bg-3: #eef0f5;
  --a-bg-4: #e2e6ee;
  --a-border-1: #e2e6ee;
  --a-border-2: #d0d6e0;
  --a-border-3: #b8c0cc;
  --a-text-1: #0d0f16;
  --a-text-2: #2a2e3a;
  --a-text-3: #5a6172;
  --a-text-4: #8a90a0;
  --a-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --a-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --a-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.1);
}
html[data-theme="light"] .aegis::before {
  background:
    radial-gradient(circle at 15% 20%, rgba(124, 108, 232, 0.10), transparent 45%),
    radial-gradient(circle at 85% 15%, rgba(92, 157, 255, 0.08), transparent 45%),
    radial-gradient(circle at 75% 85%, rgba(199, 125, 255, 0.06), transparent 50%),
    radial-gradient(circle at 25% 90%, rgba(61, 220, 132, 0.04), transparent 50%);
  background-size: 200% 200%, 200% 200%, 200% 200%, 200% 200%;
}
html[data-theme="light"] .aegis::after { opacity: 0.02; }

/* ============================================================
   3. BASE + VIBE BACKGROUND
   ============================================================ */
.aegis {
  font-family: var(--a-font);
  background: var(--a-bg-0);
  color: var(--a-text-2);
  line-height: 1.55;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.aegis::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 20%, rgba(124, 108, 232, 0.22), transparent 45%),
    radial-gradient(circle at 85% 15%, rgba(92, 157, 255, 0.14), transparent 45%),
    radial-gradient(circle at 75% 85%, rgba(199, 125, 255, 0.13), transparent 50%),
    radial-gradient(circle at 25% 90%, rgba(61, 220, 132, 0.08), transparent 50%);
  background-size: 200% 200%, 200% 200%, 200% 200%, 200% 200%;
  animation: a-vibe 32s ease-in-out infinite alternate;
  filter: blur(60px) saturate(1.4);
  opacity: 0.85;
  transition: opacity var(--a-t-slow);
}

.aegis::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
}

.aegis > * {
  position: relative;
  z-index: 2;
}

@keyframes a-vibe {
  0%   { background-position: 0% 0%,    100% 0%,   100% 100%, 0% 100%; }
  50%  { background-position: 40% 30%,  60% 20%,   40% 70%,   20% 60%; }
  100% { background-position: 100% 100%,0% 100%,   0% 0%,     100% 0%; }
}

@media (prefers-reduced-motion: reduce) {
  .aegis::before { animation: none; }
}

.aegis *,
.aegis *::before,
.aegis *::after { box-sizing: border-box; }

/* Scrollbar */
.aegis ::-webkit-scrollbar { width: 8px; height: 8px; }
.aegis ::-webkit-scrollbar-track { background: var(--a-bg-1); }
.aegis ::-webkit-scrollbar-thumb {
  background: var(--a-border-2);
  border-radius: var(--a-r-full);
}
.aegis ::-webkit-scrollbar-thumb:hover { background: var(--a-accent-lo); }

/* Typography */
.aegis h1, .aegis h2, .aegis h3, .aegis h4 {
  color: var(--a-text-1);
  font-weight: 700;
  margin: 0 0 12px;
  line-height: 1.25;
  letter-spacing: -0.015em;
}
.aegis h1 { font-size: 26px; }
.aegis h2 { font-size: 18px; }
.aegis h3 { font-size: 15px; }
.aegis h4 {
  font-size: 11px;
  color: var(--a-text-4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 10px;
}
.aegis p { margin: 0 0 12px; }
.aegis a {
  color: var(--a-accent-hi);
  text-decoration: none;
  transition: color var(--a-t-fast);
}
.aegis a:hover { color: var(--a-text-1); }
.aegis img { max-width: 100%; display: block; }

.aegis code {
  font-family: var(--a-font-mono);
  font-size: 0.88em;
  padding: 2px 7px;
  background: var(--a-bg-1);
  border: 1px solid var(--a-border-1);
  border-radius: var(--a-r-xs);
  color: var(--a-accent-hi);
}

.aegis .a-text-2 { color: var(--a-text-2); }
.aegis .a-text-3 { color: var(--a-text-3); }
.aegis .a-text-4 { color: var(--a-text-4); }
.aegis .a-text-success { color: var(--a-success); }
.aegis .a-text-danger  { color: var(--a-danger); }
.aegis .a-text-warning { color: var(--a-warning); }
.aegis .a-text-info    { color: var(--a-info); }

/* Container */
.aegis-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}
@media (max-width: 768px) {
  .aegis-container { padding: 0 14px; }
}

/* ============================================================
   4. LAYOUT HELPERS
   ============================================================ */
.a-row { display: flex; align-items: center; gap: 12px; }
.a-row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.a-col { display: flex; flex-direction: column; gap: 12px; }
.a-wrap { flex-wrap: wrap; }
.a-grow { flex: 1; min-width: 0; }
.a-gap-4  { gap: 4px; }
.a-gap-8  { gap: 8px; }
.a-gap-12 { gap: 12px; }
.a-gap-16 { gap: 16px; }
.a-gap-24 { gap: 24px; }
.a-mt-8  { margin-top: 8px; }
.a-mt-16 { margin-top: 16px; }
.a-mt-24 { margin-top: 24px; }
.a-mb-8  { margin-bottom: 8px; }
.a-mb-16 { margin-bottom: 16px; }
.a-mb-24 { margin-bottom: 24px; }
.a-center { text-align: center; }

/* ============================================================
   5. BUTTONS
   ============================================================ */
.a-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--a-r-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: all var(--a-t-fast);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}
.a-btn:disabled { opacity: .45; cursor: not-allowed; }
.a-btn i { font-size: 12px; }

.a-btn--primary {
  background: linear-gradient(180deg, var(--a-accent) 0%, var(--a-accent-lo) 100%);
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  font-weight: 700 !important;
  border: none;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .18) inset,
    0 0 0 1px var(--a-accent-lo) inset,
    0 4px 14px var(--a-accent-glow),
    0 1px 2px rgba(0, 0, 0, .35);
}
.a-btn--primary i {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}
.a-btn--primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--a-accent-hi) 0%, var(--a-accent) 100%);
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .25) inset,
    0 0 0 1px var(--a-accent) inset,
    0 8px 22px var(--a-accent-glow),
    0 2px 4px rgba(0, 0, 0, .4);
}
.a-btn--primary:active:not(:disabled) {
  transform: translateY(0);
  background: linear-gradient(180deg, var(--a-accent-lo) 0%, var(--a-accent-lo) 100%);
}

.a-btn--secondary {
  background: var(--a-bg-3);
  color: var(--a-text-2);
  border-color: var(--a-border-2);
}
.a-btn--secondary:hover:not(:disabled) {
  background: var(--a-bg-4);
  color: var(--a-text-1);
  border-color: var(--a-border-3);
}

.a-btn--success {
  background: var(--a-success);
  color: #04160a;
}
.a-btn--success:hover:not(:disabled) { background: #4cec95; }

.a-btn--danger {
  background: var(--a-danger);
  color: #fff;
}
.a-btn--danger:hover:not(:disabled) { background: #ff7575; }

.a-btn--ghost {
  background: transparent;
  color: var(--a-text-3);
  border-color: transparent;
}
.a-btn--ghost:hover:not(:disabled) {
  background: var(--a-bg-3);
  color: var(--a-text-1);
}

.a-btn--sm { padding: 6px 12px; font-size: 12.5px; }
.a-btn--lg { padding: 12px 22px; font-size: 14.5px; }
.a-btn--icon { padding: 8px; width: 34px; height: 34px; }
.a-btn--icon.a-btn--sm { width: 28px; height: 28px; padding: 4px; }

/* ============================================================
   6. CARDS
   ============================================================ */
.a-card {
  background: var(--a-bg-2);
  border: 1px solid var(--a-border-1);
  border-radius: var(--a-r-md);
  padding: 22px;
  transition: border-color var(--a-t-base);
}
.a-card:hover { border-color: var(--a-border-2); }
.a-card--accent {
  border-color: var(--a-accent-lo);
  box-shadow: inset 0 0 0 1px var(--a-accent-soft);
}
.a-card--flat { background: var(--a-bg-1); }

.a-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -4px 0 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--a-border-1);
}
.a-card__head h2,
.a-card__head h3 { margin: 0; }
.a-card__head i { color: var(--a-accent); font-size: 16px; }
.a-card__head .a-badge { margin-left: auto; }

/* ============================================================
   7. KPI
   ============================================================ */
.a-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.a-kpi {
  background: var(--a-bg-2);
  border: 1px solid var(--a-border-1);
  border-radius: var(--a-r-md);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--a-t-base);
  position: relative;
  overflow: hidden;
}
.a-kpi::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 40%, var(--a-accent-soft) 200%);
  opacity: 0;
  transition: opacity var(--a-t-base);
}
.a-kpi:hover {
  border-color: var(--a-border-3);
  transform: translateY(-2px);
  box-shadow: var(--a-shadow-md);
}
.a-kpi:hover::before { opacity: 1; }
.a-kpi__icon {
  width: 42px; height: 42px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--a-r-sm);
  background: var(--a-accent-soft);
  color: var(--a-accent-hi);
  font-size: 17px;
  position: relative;
  z-index: 1;
}
.a-kpi--success .a-kpi__icon { background: var(--a-success-soft); color: var(--a-success); }
.a-kpi--danger  .a-kpi__icon { background: var(--a-danger-soft);  color: var(--a-danger);  }
.a-kpi--warning .a-kpi__icon { background: var(--a-warning-soft); color: var(--a-warning); }
.a-kpi--info    .a-kpi__icon { background: var(--a-info-soft);    color: var(--a-info);    }
.a-kpi--purple  .a-kpi__icon { background: var(--a-purple-soft);  color: var(--a-purple);  }
.a-kpi__value {
  font-size: 24px;
  font-weight: 700;
  color: var(--a-text-1);
  line-height: 1.1;
  letter-spacing: -0.02em;
  position: relative;
  z-index: 1;
}
.a-kpi__label {
  font-size: 12.5px;
  color: var(--a-text-3);
  margin-top: 4px;
  position: relative;
  z-index: 1;
}

/* ============================================================
   8. BADGES
   ============================================================ */
.a-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--a-r-full);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.a-badge i { font-size: 10px; }
.a-badge--accent  { background: var(--a-accent-soft);  color: var(--a-accent-hi); }
.a-badge--success { background: var(--a-success-soft); color: var(--a-success); }
.a-badge--danger  { background: var(--a-danger-soft);  color: var(--a-danger);  }
.a-badge--warning { background: var(--a-warning-soft); color: var(--a-warning); }
.a-badge--info    { background: var(--a-info-soft);    color: var(--a-info);    }
.a-badge--purple  { background: var(--a-purple-soft);  color: var(--a-purple);  }
.a-badge--muted {
  background: var(--a-bg-3);
  color: var(--a-text-3);
  border: 1px solid var(--a-border-2);
}

/* ============================================================
   9. FORMS
   ============================================================ */
.a-field { margin-bottom: 16px; }
.a-field:last-child { margin-bottom: 0; }
.a-field > label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--a-text-3);
  margin-bottom: 6px;
}
.a-field > label .a-req { color: var(--a-danger); margin-left: 3px; }

.a-input,
.a-select,
.a-textarea {
  width: 100%;
  padding: 10px 13px;
  background: var(--a-bg-1);
  border: 1px solid var(--a-border-2);
  border-radius: var(--a-r-sm);
  color: var(--a-text-1);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  transition: all var(--a-t-fast);
}
.a-input:hover,
.a-select:hover,
.a-textarea:hover { border-color: var(--a-border-3); }
.a-input:focus,
.a-select:focus,
.a-textarea:focus {
  outline: none;
  border-color: var(--a-accent);
  box-shadow: 0 0 0 3px var(--a-accent-soft);
}
.a-input::placeholder,
.a-textarea::placeholder { color: var(--a-text-4); }

.a-select {
  appearance: none;
  padding-right: 38px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a8a9e' d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.a-textarea { min-height: 84px; resize: vertical; }
.a-hint { font-size: 11.5px; color: var(--a-text-4); margin-top: 5px; }

/* ============================================================
   10. TABLE
   ============================================================ */
.a-table-wrap {
  background: var(--a-bg-2);
  border: 1px solid var(--a-border-1);
  border-radius: var(--a-r-md);
  overflow: hidden;
}
.a-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.a-table thead { background: var(--a-bg-1); }
.a-table th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--a-text-4);
  border-bottom: 1px solid var(--a-border-2);
  white-space: nowrap;
}
.a-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--a-border-1);
  color: var(--a-text-2);
  vertical-align: middle;
}
.a-table tbody tr { transition: background var(--a-t-fast); }
.a-table tbody tr:hover { background: var(--a-bg-3); }
.a-table tbody tr:last-child td { border-bottom: none; }
.a-table .a-td-mono { font-family: var(--a-font-mono); font-size: 12px; }

/* ============================================================
   11. TABS
   ============================================================ */
.a-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--a-bg-2);
  border: 1px solid var(--a-border-1);
  border-radius: var(--a-r-md);
  overflow-x: auto;
  margin-bottom: 16px;
}
.a-tabs::-webkit-scrollbar { height: 0; }
.a-tab {
  padding: 8px 14px;
  border-radius: var(--a-r-sm);
  color: var(--a-text-3);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: all var(--a-t-fast);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
}
.a-tab:hover { color: var(--a-text-1); background: var(--a-bg-3); }
.a-tab--active {
  background: var(--a-accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--a-accent-glow);
}
.a-tab i { font-size: 12px; }

/* ============================================================
   12. SIDEBAR
   ============================================================ */
.a-layout {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-top: 20px;
}
.a-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--a-bg-2);
  border: 1px solid var(--a-border-1);
  border-radius: var(--a-r-md);
  padding: 10px;
  position: sticky;
  top: calc(var(--a-topbar-h) + 16px);
  max-height: calc(100vh - var(--a-topbar-h) - 32px);
  overflow-y: auto;
}
.a-sidebar__head {
  padding: 8px 12px 14px;
  border-bottom: 1px solid var(--a-border-1);
  margin-bottom: 10px;
}
.a-sidebar__head h3 {
  margin: 0;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  color: var(--a-text-1);
}
.a-sidebar__head i { color: var(--a-accent); }

.a-sidebar nav { display: flex; flex-direction: column; gap: 14px; }
.a-nav-group { display: flex; flex-direction: column; gap: 2px; }
.a-nav-title {
  padding: 4px 12px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--a-text-4);
}
.a-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--a-r-sm);
  color: var(--a-text-3);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--a-t-fast);
  border-left: 2px solid transparent;
}
.a-nav-item i {
  width: 16px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
}
.a-nav-item:hover { background: var(--a-bg-3); color: var(--a-text-1); }
.a-nav-item--active {
  background: var(--a-accent-soft);
  color: var(--a-text-1);
  border-left-color: var(--a-accent);
  font-weight: 600;
}
.a-nav-item--active i { color: var(--a-accent); }

.a-sidebar__foot {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--a-border-1);
}
.a-sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--a-bg-1);
  border-radius: var(--a-r-sm);
  border: 1px solid var(--a-border-1);
}
.a-sidebar__user i { color: var(--a-accent); font-size: 18px; flex-shrink: 0; }
.a-sidebar__role { font-size: 12.5px; color: var(--a-text-1); font-weight: 600; line-height: 1.2; }
.a-sidebar__level { font-size: 11px; color: var(--a-text-4); margin-top: 2px; }
.a-content { flex: 1; min-width: 0; }

@media (max-width: 900px) {
  .a-layout { flex-direction: column; }
  .a-sidebar {
    width: 100%;
    position: static;
    max-height: none;
  }
}

/* ============================================================
   13. TOPBAR
   ============================================================ */
.a-topbar {
  background: color-mix(in srgb, var(--a-bg-1) 85%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--a-border-1);
  padding: 10px 0;
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--a-topbar-h);
  display: flex;
  align-items: center;
}

.a-topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.a-topbar__brand-icon {
  font-size: 20px;
  color: var(--a-accent);
  filter: drop-shadow(0 0 8px var(--a-accent-glow));
}
.a-topbar__brand-name {
  font-weight: 700;
  color: var(--a-text-1);
  font-size: 15px;
  line-height: 1.1;
}
.a-topbar__brand-sub {
  color: var(--a-text-4);
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.a-topbar__right { display: flex; align-items: center; gap: 10px; }

/* Theme switch */
.a-theme-switch {
  display: inline-flex;
  gap: 2px;
  background: var(--a-bg-3);
  border: 1px solid var(--a-border-2);
  border-radius: var(--a-r-sm);
  padding: 3px;
}
.a-theme-switch button {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--a-text-3);
  border-radius: var(--a-r-xs);
  cursor: pointer;
  transition: all var(--a-t-fast);
  font-size: 11.5px;
}
.a-theme-switch button:hover { color: var(--a-text-1); background: var(--a-bg-4); }
.a-theme-switch button.active {
  background: var(--a-accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--a-accent-glow);
}

/* ============================================================
   14. PAGE HEADER
   ============================================================ */
.a-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 24px 0 20px;
}
.a-page-head h1 {
  margin: 0;
  font-size: 26px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.a-page-head h1 i { color: var(--a-accent); font-size: 22px; }
.a-page-head .a-sub { margin: 6px 0 0; font-size: 13.5px; color: var(--a-text-3); }
.a-page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   15. SKELETON LOADER
   ============================================================ */
.a-skel {
  display: inline-block;
  background: linear-gradient(
    90deg,
    var(--a-bg-3) 0%,
    var(--a-bg-4) 50%,
    var(--a-bg-3) 100%
  );
  background-size: 200% 100%;
  animation: a-skel 1.4s ease-in-out infinite;
  border-radius: var(--a-r-xs);
  color: transparent !important;
  user-select: none;
  pointer-events: none;
}
@keyframes a-skel {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.a-skel-line { height: 12px; margin: 6px 0; }
.a-skel-line--w-60 { width: 60%; }
.a-skel-line--w-40 { width: 40%; }

/* ============================================================
   16. STATES
   ============================================================ */
.a-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
  color: var(--a-text-3);
}
.a-state__icon { font-size: 36px; opacity: .55; }
.a-state__title { font-size: 14.5px; color: var(--a-text-2); font-weight: 600; }
.a-state__hint  { font-size: 12.5px; color: var(--a-text-4); max-width: 340px; }
.a-state--error { color: var(--a-danger); }
.a-state--error .a-state__title { color: var(--a-danger); }

.a-spinner {
  display: inline-block;
  width: 22px; height: 22px;
  border: 2px solid var(--a-border-2);
  border-top-color: var(--a-accent);
  border-radius: 50%;
  animation: a-spin .8s linear infinite;
}
@keyframes a-spin { to { transform: rotate(360deg); } }

/* ============================================================
   17. TOASTS
   ============================================================ */
.a-toasts {
  position: fixed;
  top: calc(var(--a-topbar-h) + 12px);
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.a-toast {
  min-width: 260px;
  max-width: 400px;
  padding: 13px 18px;
  background: var(--a-bg-3);
  border: 1px solid var(--a-border-2);
  border-left: 3px solid var(--a-accent);
  border-radius: var(--a-r-sm);
  color: var(--a-text-1);
  font-size: 13.5px;
  box-shadow: var(--a-shadow-lg);
  animation: a-toast-in .25s ease;
  pointer-events: auto;
  position: relative;
  overflow: hidden;
}
.a-toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background: currentColor;
  animation: a-toast-progress 3s linear forwards;
  opacity: 0.5;
}
@keyframes a-toast-progress {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}
.a-toast--success { border-left-color: var(--a-success); color: var(--a-success); }
.a-toast--error   { border-left-color: var(--a-danger);  color: var(--a-danger);  }
.a-toast--warning { border-left-color: var(--a-warning); color: var(--a-warning); }
.a-toast--info    { border-left-color: var(--a-info);    color: var(--a-info);    }
.a-toast--success,
.a-toast--error,
.a-toast--warning,
.a-toast--info { color: var(--a-text-1); }
.a-toast--success::after { background: var(--a-success); }
.a-toast--error::after   { background: var(--a-danger);  }
.a-toast--warning::after { background: var(--a-warning); }
.a-toast--info::after    { background: var(--a-info);    }

@keyframes a-toast-in {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ============================================================
   18. MODALS
   ============================================================ */
.a-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(6px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.a-modal--open { display: flex; }

.a-modal__box {
  background: var(--a-bg-2);
  border: 1px solid var(--a-border-2);
  border-radius: var(--a-r-lg);
  padding: 26px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--a-shadow-lg);
  animation: a-modal-in .22s ease;
}
@keyframes a-modal-in {
  from { transform: translateY(12px) scale(.98); opacity: 0; }
  to   { transform: translateY(0)    scale(1);   opacity: 1; }
}
.a-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.a-modal__head h2 { margin: 0; font-size: 18px; }
.a-modal__close {
  background: none;
  border: none;
  color: var(--a-text-3);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--a-r-xs);
  transition: all var(--a-t-fast);
}
.a-modal__close:hover { color: var(--a-text-1); background: var(--a-bg-3); }
.a-modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--a-border-1);
}

/* ============================================================
   19. COMMAND PALETTE (Ctrl+K)
   ============================================================ */
.a-cmdk {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(8px);
  z-index: 1100;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.a-cmdk--open { display: flex; }
.a-cmdk__box {
  width: 100%;
  max-width: 560px;
  background: var(--a-bg-2);
  border: 1px solid var(--a-border-2);
  border-radius: var(--a-r-lg);
  box-shadow: var(--a-shadow-lg), 0 0 60px var(--a-accent-glow);
  overflow: hidden;
  animation: a-cmdk-in .18s ease;
}
@keyframes a-cmdk-in {
  from { transform: translateY(-12px) scale(.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.a-cmdk__input {
  width: 100%;
  padding: 18px 22px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--a-border-1);
  color: var(--a-text-1);
  font-family: inherit;
  font-size: 15px;
}
.a-cmdk__input:focus { outline: none; }
.a-cmdk__input::placeholder { color: var(--a-text-4); }
.a-cmdk__list {
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
}
.a-cmdk__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--a-r-sm);
  color: var(--a-text-2);
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--a-t-fast);
}
.a-cmdk__item i {
  width: 18px;
  text-align: center;
  color: var(--a-text-4);
  font-size: 13px;
}
.a-cmdk__item:hover,
.a-cmdk__item--selected {
  background: var(--a-accent-soft);
  color: var(--a-text-1);
}
.a-cmdk__item--selected i { color: var(--a-accent); }
.a-cmdk__group {
  padding: 10px 14px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--a-text-4);
  font-weight: 700;
}
.a-cmdk__hint {
  padding: 10px 16px;
  border-top: 1px solid var(--a-border-1);
  font-size: 11px;
  color: var(--a-text-4);
  display: flex;
  gap: 12px;
}
.a-cmdk__kbd {
  background: var(--a-bg-4);
  border: 1px solid var(--a-border-2);
  border-radius: var(--a-r-xs);
  padding: 1px 6px;
  font-family: var(--a-font-mono);
  font-size: 10.5px;
  color: var(--a-text-3);
}

/* ============================================================
   20. UTILITY
   ============================================================ */
.a-hr {
  height: 1px;
  background: var(--a-border-1);
  border: 0;
  margin: 18px 0;
}
.a-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--a-bg-1);
  border: 1px solid var(--a-border-1);
  border-radius: var(--a-r-full);
  font-size: 12px;
  color: var(--a-text-3);
}
.a-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--a-text-4);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin: 20px 0;
}
.a-divider::before,
.a-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--a-border-1);
}

/* Responsive */
@media (max-width: 1024px) {
  .a-topbar__brand-name { font-size: 14px; }
  .a-topbar__brand-sub { font-size: 9.5px; }
}
@media (max-width: 768px) {
  .aegis h1 { font-size: 22px; }
  .a-page-head { margin: 18px 0 16px; }
  .a-page-head h1 { font-size: 22px; }
  .a-card { padding: 18px; border-radius: var(--a-r); }
  .a-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .a-toasts { left: 12px; right: 12px; }
  .a-toast { min-width: 0; max-width: none; }
  .a-theme-switch button { width: 26px; height: 26px; }
}
@media (max-width: 480px) {
  .a-kpi-grid { grid-template-columns: 1fr; }
  .a-page-head h1 { font-size: 20px; }
  .a-topbar__brand-sub { display: none; }
}
/* ============================================================
   RULES — стили для страниц правил
   ============================================================ */

.a-page__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.a-page__header h1 {
  margin: 0;
  font-size: 28px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.a-page__header h1 i {
  color: var(--a-accent);
}

.a-page__subtitle {
  margin: 8px 0 0;
  color: var(--a-text-3);
  font-size: 13.5px;
}

/* Список панелей */
.a-grid--panels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.a-card--panel {
  background: var(--a-bg-1);
  border: 1px solid var(--a-border-1);
  border-radius: var(--a-r-md);
  padding: 20px;
  transition: all .25s ease;
}

.a-card--panel:hover {
  border-color: var(--a-accent);
  transform: translateY(-2px);
}

.a-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.a-card__title {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.a-card__title > i {
  color: var(--a-accent-hi);
  font-size: 20px;
  margin-top: 2px;
}

.a-card__title h3 {
  margin: 0 0 4px;
  font-size: 15.5px;
  color: var(--a-text-1);
}

.a-tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--a-bg-2);
  border: 1px solid var(--a-border-2);
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--a-accent-hi);
  font-family: var(--a-font-mono);
}

.a-card__desc {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--a-text-3);
}

.a-card__stats {
  display: flex;
  gap: 18px;
  margin-bottom: 16px;
}

.a-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.a-stat__value {
  font-size: 18px;
  font-weight: 700;
  color: var(--a-text-1);
}

.a-stat__label {
  font-size: 10.5px;
  color: var(--a-text-4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.a-card__footer {
  display: flex;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--a-border-1);
}

/* Пустое состояние */
.a-empty {
  padding: 60px 20px;
  text-align: center;
  background: var(--a-bg-1);
  border: 1px dashed var(--a-border-2);
  border-radius: var(--a-r-md);
}

.a-empty__icon {
  font-size: 48px;
  color: var(--a-text-4);
  margin-bottom: 16px;
}

.a-empty h3 {
  margin: 0 0 8px;
  color: var(--a-text-1);
}

.a-empty p {
  margin: 0 0 20px;
  color: var(--a-text-3);
  font-size: 13.5px;
}

/* Форма */
.a-form {
  max-width: 900px;
}

.a-form__section {
  background: var(--a-bg-1);
  border: 1px solid var(--a-border-1);
  border-radius: var(--a-r-md);
  padding: 24px;
  margin-bottom: 20px;
}

.a-form__section-title {
  margin: 0 0 18px;
  font-size: 16px;
  color: var(--a-text-1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.a-form__section-title i {
  color: var(--a-accent-hi);
}

.a-form__row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.a-form__group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.a-form__group--small {
  max-width: 160px;
}

.a-form__group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--a-text-2);
}

.a-form__hint {
  font-size: 11px;
  color: var(--a-text-4);
}

.a-input,
.a-textarea,
.a-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--a-bg-0);
  border: 1px solid var(--a-border-1);
  border-radius: var(--a-r-sm);
  color: var(--a-text-1);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color .2s ease;
}

.a-input:focus,
.a-textarea:focus,
.a-select:focus {
  outline: none;
  border-color: var(--a-accent);
}

.a-textarea {
  resize: vertical;
  min-height: 80px;
}

.a-color-picker {
  display: flex;
  gap: 8px;
  align-items: center;
}

.a-color-picker input[type="color"] {
  width: 44px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--a-border-1);
  border-radius: var(--a-r-sm);
  cursor: pointer;
  background: transparent;
}

.a-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--a-text-2);
  cursor: pointer;
  margin-bottom: 10px;
  user-select: none;
}

.a-checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--a-accent);
  cursor: pointer;
}

.a-checkbox--inline {
  margin-bottom: 0;
}

/* Embed fields */
.a-fields-list,
.a-sections-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.a-field-item {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--a-bg-0);
  border: 1px solid var(--a-border-1);
  border-radius: var(--a-r-sm);
}

.a-section-card {
  padding: 18px;
  background: var(--a-bg-0);
  border: 1px solid var(--a-border-1);
  border-radius: var(--a-r-md);
  margin-bottom: 12px;
}

.a-section-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--a-border-1);
}

.a-section-card__header strong {
  color: var(--a-accent-hi);
  font-size: 14px;
}

/* Кнопки действий */
.a-form__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--a-border-1);
}

.a-form__status {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--a-r-sm);
  font-size: 13.5px;
}

.a-form__status--success {
  background: var(--a-success-soft);
  border: 1px solid var(--a-success);
  color: var(--a-success);
}

.a-form__status--error {
  background: var(--a-danger-soft);
  border: 1px solid var(--a-danger);
  color: var(--a-danger);
}

/* Кнопки-модификаторы */
.a-btn--success {
  background: var(--a-success);
  color: white;
  border: none;
}

.a-btn--success:hover {
  background: #2fb870;
}

.a-btn--danger-ghost {
  background: transparent;
  border: 1px solid var(--a-danger);
  color: var(--a-danger);
}

.a-btn--danger-ghost:hover {
  background: var(--a-danger-soft);
}

.a-btn--icon {
  padding: 8px 10px;
  min-width: unset;
}