/* =============================================================================
   Братец Admin — Design Tokens
   Профессиональная система: cool forest ops UI поверх живого луга.
   ============================================================================= */

:root {
  /* —— Color · brand —— */
  --brand-50: #e8f7ee;
  --brand-100: #c5ebd4;
  --brand-200: #8fd4ad;
  --brand-300: #5bbb89;
  --brand-400: #3aa56e;
  --brand-500: #2d8a5a;
  --brand-600: #24704a;
  --brand-700: #1c5639;
  --brand-800: #143d2a;
  --brand-900: #0c261a;

  /* —— Color · neutral (cool slate-green) —— */
  --neutral-0: #f4f7f5;
  --neutral-50: #e6ece8;
  --neutral-100: #c8d4cd;
  --neutral-200: #9aada3;
  --neutral-300: #6f8479;
  --neutral-400: #51665c;
  --neutral-500: #3a4c44;
  --neutral-600: #2a3832;
  --neutral-700: #1c2722;
  --neutral-800: #131b17;
  --neutral-900: #0a100d;
  --neutral-950: #050805;

  /* —— Color · semantic —— */
  --success-400: #4ade80;
  --success-500: #22c55e;
  --warning-400: #fbbf24;
  --warning-500: #d97706;
  --danger-400: #fb7185;
  --danger-500: #e11d48;
  --info-400: #67e8f9;
  --info-500: #0891b2;

  /* —— Surface (glass over scene) —— */
  --surface-void: transparent;
  --surface-base: color-mix(in srgb, var(--neutral-900) 78%, transparent);
  --surface-raised: color-mix(in srgb, var(--neutral-800) 82%, transparent);
  --surface-overlay: color-mix(in srgb, var(--neutral-700) 88%, transparent);
  --surface-sunken: color-mix(in srgb, var(--neutral-950) 72%, transparent);
  --surface-sidebar: color-mix(in srgb, var(--neutral-900) 86%, transparent);
  --surface-hover: color-mix(in srgb, var(--brand-500) 10%, transparent);
  --surface-active: color-mix(in srgb, var(--brand-500) 16%, transparent);

  /* —— Text —— */
  --text-primary: var(--neutral-0);
  --text-secondary: var(--neutral-200);
  --text-tertiary: var(--neutral-300);
  --text-disabled: var(--neutral-400);
  --text-inverse: var(--neutral-900);
  --text-accent: var(--brand-200);
  --text-link: var(--brand-300);

  /* —— Border —— */
  --border-subtle: color-mix(in srgb, var(--brand-100) 10%, transparent);
  --border-default: color-mix(in srgb, var(--brand-100) 16%, transparent);
  --border-strong: color-mix(in srgb, var(--brand-200) 28%, transparent);
  --border-focus: color-mix(in srgb, var(--brand-300) 55%, transparent);

  /* —— Accent controls —— */
  --accent: var(--brand-400);
  --accent-hover: var(--brand-300);
  --accent-pressed: var(--brand-500);
  --accent-muted: var(--brand-700);
  --accent-contrast: var(--neutral-950);

  /* —— Space scale (4px base) —— */
  --space-0: 0;
  --space-1: 0.25rem; /* 4 */
  --space-2: 0.5rem; /* 8 */
  --space-3: 0.75rem; /* 12 */
  --space-4: 1rem; /* 16 */
  --space-5: 1.25rem; /* 20 */
  --space-6: 1.5rem; /* 24 */
  --space-8: 2rem; /* 32 */
  --space-10: 2.5rem; /* 40 */
  --space-12: 3rem; /* 48 */
  --space-16: 4rem; /* 64 */

  /* —— Radius —— */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* —— Elevation —— */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.42);
  --shadow-glow: 0 0 0 3px color-mix(in srgb, var(--brand-400) 22%, transparent);

  /* —— Typography —— */
  --font-display: "Sora", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.125rem;
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --tracking-wide: 0.06em;

  /* —— Motion —— */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
  --dur-fast: 120ms;
  --dur-med: 220ms;
  --dur-slow: 480ms;

  /* —— Layout —— */
  --sidebar-w: 268px;
  --content-max: 1120px;

  /* —— Scene parallax —— */
  --px: 0;
  --py: 0;

  /* legacy aliases used in markup */
  --ink: var(--text-primary);
  --muted: var(--text-secondary);
  --line: var(--border-default);
  --brass: var(--accent);
  --brass-dim: var(--brand-500);
  --forest: var(--brand-400);
  --danger: var(--danger-400);
  --ok: var(--success-400);
  --radius: var(--radius-md);
  --shadow: var(--shadow-lg);
  --bg0: var(--neutral-950);
  --bg1: var(--neutral-900);
  --bg2: var(--neutral-800);
  --copper: var(--warning-500);
}

/* =============================================================================
   Base
   ============================================================================= */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #06140e;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  position: relative;
  z-index: 2;
  min-height: 100vh;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

a:hover {
  color: var(--brand-200);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* =============================================================================
   Scene · living meadow / forest / field (CSS 3D)
   ============================================================================= */

.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  perspective: 1200px;
  transform-style: preserve-3d;
  background: #06140e;
}

.scene__sky {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      180deg,
      #1a3a4a 0%,
      #2a5a52 18%,
      #3d7a5c 42%,
      #5a9a68 62%,
      #7ab070 78%,
      #a8c888 100%
    );
  transform: translate3d(calc(var(--px) * -8px), calc(var(--py) * -4px), -200px) scale(1.08);
  animation: sky-shift 48s var(--ease-in-out) infinite alternate;
}

.scene__glow {
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(ellipse 60% 40% at 72% 18%, rgba(255, 220, 140, 0.35), transparent 55%),
    radial-gradient(ellipse 50% 35% at 28% 30%, rgba(120, 200, 180, 0.18), transparent 50%);
  transform: translate3d(calc(var(--px) * -12px), calc(var(--py) * -6px), -160px);
  animation: glow-breathe 16s var(--ease-in-out) infinite alternate;
}

.scene__sun {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  right: 18%;
  top: 12%;
  background:
    radial-gradient(circle at 40% 40%, #fff8dc 0%, #ffe08a 28%, #f0b84a 55%, transparent 72%);
  box-shadow:
    0 0 60px 20px rgba(255, 210, 120, 0.35),
    0 0 120px 40px rgba(255, 180, 80, 0.18);
  transform: translate3d(calc(var(--px) * -20px), calc(var(--py) * -10px), -140px);
  animation: sun-pulse 12s var(--ease-in-out) infinite alternate;
}

.scene__rays {
  position: absolute;
  inset: 0;
  background: repeating-conic-gradient(
    from 210deg at 78% 18%,
    rgba(255, 236, 180, 0.07) 0deg 3deg,
    transparent 3deg 14deg
  );
  mask-image: radial-gradient(ellipse 55% 50% at 78% 18%, #000 0%, transparent 70%);
  opacity: 0.55;
  transform: translate3d(calc(var(--px) * -16px), calc(var(--py) * -8px), -120px);
  animation: rays-rotate 90s linear infinite;
}

.scene__cloud {
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  filter: blur(2px);
  box-shadow:
    28px 8px 0 -6px rgba(255, 255, 255, 0.16),
    -24px 10px 0 -8px rgba(255, 255, 255, 0.12),
    0 0 40px rgba(255, 255, 255, 0.12);
}

.scene__cloud--a {
  width: 160px;
  height: 42px;
  top: 14%;
  left: 8%;
  animation: cloud-drift 70s linear infinite;
  transform: translate3d(calc(var(--px) * -24px), 0, -100px);
}

.scene__cloud--b {
  width: 220px;
  height: 50px;
  top: 22%;
  left: 42%;
  opacity: 0.7;
  animation: cloud-drift 95s linear infinite reverse;
  transform: translate3d(calc(var(--px) * -30px), 0, -90px);
}

.scene__cloud--c {
  width: 120px;
  height: 34px;
  top: 10%;
  left: 68%;
  opacity: 0.55;
  animation: cloud-drift 110s linear infinite;
  transform: translate3d(calc(var(--px) * -18px), 0, -80px);
}

.scene__ridge {
  position: absolute;
  left: -5%;
  right: -5%;
  height: 38%;
  bottom: 28%;
  transform-origin: 50% 100%;
}

.scene__ridge--far {
  bottom: 34%;
  height: 32%;
  background: linear-gradient(180deg, #2f5a48 0%, #1e3d32 100%);
  clip-path: polygon(
    0% 70%,
    8% 55%,
    16% 62%,
    24% 40%,
    34% 52%,
    42% 28%,
    52% 48%,
    62% 22%,
    72% 44%,
    82% 30%,
    92% 50%,
    100% 38%,
    100% 100%,
    0% 100%
  );
  opacity: 0.75;
  transform: translate3d(calc(var(--px) * -14px), calc(var(--py) * 4px), -70px) scale(1.05);
  filter: blur(0.4px);
}

.scene__ridge--mid {
  bottom: 26%;
  height: 36%;
  background: linear-gradient(180deg, #356b4e 0%, #234836 100%);
  clip-path: polygon(
    0% 60%,
    10% 48%,
    18% 58%,
    28% 35%,
    38% 50%,
    48% 30%,
    58% 46%,
    68% 26%,
    78% 42%,
    88% 32%,
    100% 48%,
    100% 100%,
    0% 100%
  );
  transform: translate3d(calc(var(--px) * -22px), calc(var(--py) * 6px), -40px) scale(1.04);
}

.scene__forest {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22%;
  height: 34%;
  transform: translate3d(calc(var(--px) * -28px), calc(var(--py) * 8px), -10px);
}

.scene__tree-row {
  position: absolute;
  inset: 0;
  transform: translateY(var(--row-y, 0));
}

.scene__tree {
  position: absolute;
  bottom: 0;
  width: calc(28px * var(--h, 1));
  height: calc(90px * var(--h, 1));
  transform-origin: 50% 100%;
  animation: tree-sway var(--sway, 4s) var(--ease-in-out) infinite alternate;
  animation-delay: var(--delay, 0s);
}

.scene__tree::before,
.scene__tree::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.scene__tree--pine::before {
  bottom: 18%;
  width: 0;
  height: 0;
  border-left: calc(16px * var(--h, 1)) solid transparent;
  border-right: calc(16px * var(--h, 1)) solid transparent;
  border-bottom: calc(72px * var(--h, 1)) solid #1a3d2c;
  filter: drop-shadow(0 2px 0 #0f281c);
}

.scene__tree--pine::after {
  bottom: 0;
  width: calc(5px * var(--h, 1));
  height: calc(22px * var(--h, 1));
  background: #3a2a18;
  border-radius: 2px;
}

.scene__tree--oak::before {
  bottom: 16%;
  width: calc(36px * var(--h, 1));
  height: calc(40px * var(--h, 1));
  background: radial-gradient(circle at 50% 55%, #2a5a3e 0%, #173528 80%);
  border-radius: 50% 50% 46% 46%;
}

.scene__tree--oak::after {
  bottom: 0;
  width: calc(6px * var(--h, 1));
  height: calc(28px * var(--h, 1));
  background: #3d2c18;
  border-radius: 2px;
}

.scene__tree--broad::before {
  bottom: 14%;
  width: calc(42px * var(--h, 1));
  height: calc(34px * var(--h, 1));
  background: radial-gradient(ellipse at 50% 60%, #326848 0%, #1a3f2c 85%);
  border-radius: 42% 42% 40% 40%;
}

.scene__tree--broad::after {
  bottom: 0;
  width: calc(7px * var(--h, 1));
  height: calc(26px * var(--h, 1));
  background: #422e16;
  border-radius: 2px;
}

.scene__field {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42%;
  transform: translate3d(calc(var(--px) * -36px), calc(var(--py) * 10px), 20px)
    rotateX(18deg);
  transform-origin: 50% 100%;
  transform-style: preserve-3d;
}

.scene__grass {
  display: block;
  width: 100%;
  height: 100%;
}

.scene__pollen {
  position: absolute;
  inset: 0;
  transform: translate3d(calc(var(--px) * -10px), calc(var(--py) * -6px), 40px);
}

.scene__mote {
  position: absolute;
  width: var(--size, 2px);
  height: var(--size, 2px);
  border-radius: 50%;
  background: rgba(230, 255, 220, 0.65);
  box-shadow: 0 0 6px rgba(200, 255, 180, 0.45);
  animation: mote-float var(--dur, 14s) var(--ease-in-out) infinite;
  animation-delay: var(--delay, 0s);
}

.scene__haze {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 35%, rgba(6, 20, 14, 0.35) 70%, rgba(6, 20, 14, 0.78) 100%),
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(40, 90, 55, 0.25), transparent 60%);
  z-index: 1;
}

.scene__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 75% 70% at 50% 40%, transparent 40%, rgba(2, 8, 5, 0.55) 100%);
  z-index: 2;
}

@keyframes sky-shift {
  from {
    filter: hue-rotate(-6deg) saturate(1);
  }
  to {
    filter: hue-rotate(8deg) saturate(1.08);
  }
}

@keyframes glow-breathe {
  from {
    opacity: 0.85;
  }
  to {
    opacity: 1;
  }
}

@keyframes sun-pulse {
  from {
    transform: translate3d(calc(var(--px) * -20px), calc(var(--py) * -10px), -140px) scale(1);
  }
  to {
    transform: translate3d(calc(var(--px) * -20px), calc(var(--py) * -10px), -140px) scale(1.06);
  }
}

@keyframes rays-rotate {
  to {
    transform: translate3d(calc(var(--px) * -16px), calc(var(--py) * -8px), -120px) rotate(12deg);
  }
}

@keyframes cloud-drift {
  from {
    translate: 0 0;
  }
  to {
    translate: 40vw 0;
  }
}

@keyframes tree-sway {
  from {
    transform: rotate(-1.4deg);
  }
  to {
    transform: rotate(1.8deg);
  }
}

@keyframes mote-float {
  0% {
    transform: translate3d(0, 0, 0);
    opacity: 0;
  }
  15% {
    opacity: 0.8;
  }
  85% {
    opacity: 0.5;
  }
  100% {
    transform: translate3d(var(--drift, 60px), -80px, 0);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scene__sky,
  .scene__glow,
  .scene__sun,
  .scene__rays,
  .scene__cloud,
  .scene__tree,
  .scene__mote {
    animation: none !important;
  }
}

/* =============================================================================
   Controls
   ============================================================================= */

.btn {
  appearance: none;
  border: 1px solid var(--border-default);
  background: var(--surface-raised);
  color: var(--text-primary);
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow);
}

.btn-primary {
  background: linear-gradient(180deg, var(--brand-300), var(--brand-500));
  border-color: color-mix(in srgb, var(--brand-200) 50%, transparent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.btn-primary:hover {
  background: linear-gradient(180deg, var(--brand-200), var(--brand-400));
  border-color: var(--brand-200);
}

.btn-danger {
  border-color: color-mix(in srgb, var(--danger-400) 40%, transparent);
  color: var(--danger-400);
}

.btn-ghost {
  background: transparent;
}

/* =============================================================================
   Shell / Nav
   ============================================================================= */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.side {
  border-right: 1px solid var(--border-subtle);
  background: var(--surface-sidebar);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  padding: var(--space-6) var(--space-4) var(--space-8);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 650;
  letter-spacing: -0.03em;
  margin: var(--space-1) 0;
  color: var(--text-primary);
}

.brand-sub {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-bottom: var(--space-6);
  font-weight: 500;
}

.nav a {
  display: block;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  margin-bottom: 2px;
  border: 1px solid transparent;
  font-size: var(--text-sm);
  font-weight: 500;
  transition:
    color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}

.nav a:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.nav a.active {
  color: var(--text-primary);
  background: var(--surface-active);
  border-color: var(--border-strong);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav .group {
  margin-top: var(--space-5);
  margin-bottom: var(--space-2);
  padding-left: 0.7rem;
  font-size: 0.68rem;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 600;
}

.main {
  padding: var(--space-6) var(--space-8) var(--space-12);
  max-width: calc(var(--content-max) + var(--space-16));
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 650;
  letter-spacing: -0.03em;
  margin: 0 0 var(--space-2);
  line-height: var(--leading-tight);
}

.page-lead {
  color: var(--text-secondary);
  margin: 0 0 var(--space-6);
  max-width: 42rem;
  font-size: var(--text-md);
}

/* =============================================================================
   Data surfaces
   ============================================================================= */

.grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  margin-bottom: var(--space-6);
}

.stat {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color var(--dur-med) var(--ease-out);
}

.stat:hover {
  border-color: var(--border-strong);
}

.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-top: var(--space-1);
  color: var(--text-primary);
}

.stat span {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.panel {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-4);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-4);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

th {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  font-weight: 600;
}

tr:hover td {
  background: var(--surface-hover);
}

.badge {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-default);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.badge.ready {
  border-color: color-mix(in srgb, var(--success-400) 40%, transparent);
  color: var(--success-400);
  background: color-mix(in srgb, var(--success-500) 12%, transparent);
}

.badge.warn {
  border-color: color-mix(in srgb, var(--warning-400) 40%, transparent);
  color: var(--warning-400);
  background: color-mix(in srgb, var(--warning-500) 12%, transparent);
}

.badge.danger {
  border-color: color-mix(in srgb, var(--danger-400) 40%, transparent);
  color: var(--danger-400);
  background: color-mix(in srgb, var(--danger-500) 12%, transparent);
}

.form-grid {
  display: grid;
  gap: var(--space-3);
}

.form-grid label {
  display: grid;
  gap: var(--space-1);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  background: var(--surface-sunken);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

.form-grid textarea {
  min-height: 110px;
  resize: vertical;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-glow);
}

.modal-back {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--neutral-950) 62%, transparent);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: var(--space-4);
  z-index: 20;
  animation: fade var(--dur-med) var(--ease-out);
}

.modal {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-lg);
  animation: rise var(--dur-med) var(--ease-out);
  backdrop-filter: blur(20px);
}

.modal h3 {
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-4);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
  animation: rise var(--dur-slow) var(--ease-out);
  backdrop-filter: blur(22px) saturate(1.2);
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 650;
  letter-spacing: -0.03em;
  margin: 0 0 var(--space-2);
}

.login-card p {
  color: var(--text-secondary);
  margin: 0 0 var(--space-5);
}

.err {
  color: var(--danger-400);
  margin: var(--space-2) 0;
  font-size: var(--text-sm);
}

.mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.clip {
  max-width: 28rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-user {
  border-left: 3px solid var(--accent);
  padding-left: var(--space-3);
}

.msg-assistant {
  border-left: 3px solid var(--brand-600);
  padding-left: var(--space-3);
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* =============================================================================
   Анализ и выводы / облако знаний
   ============================================================================= */

.insight-cloud {
  position: relative;
  padding: 1.25rem 1rem 1.5rem;
  border-radius: var(--radius-md);
  background:
    radial-gradient(ellipse at 50% 42%, color-mix(in oklab, var(--accent) 18%, transparent), transparent 55%),
    var(--surface-hover);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.insight-cloud__core {
  width: fit-content;
  margin: 0 auto 1.25rem;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  background: color-mix(in oklab, var(--accent) 22%, var(--surface-active));
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 28px color-mix(in oklab, var(--accent) 20%, transparent);
  animation: rise 0.7s var(--ease-out) both;
}

.insight-orbit {
  margin-bottom: 1rem;
}

.insight-orbit__label {
  font-size: 0.68rem;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 600;
  margin-bottom: 0.45rem;
  padding-left: 0.2rem;
}

.insight-orbit__nodes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.insight-node {
  --w: 5;
  appearance: none;
  cursor: pointer;
  text-align: left;
  border: 1px solid var(--border-subtle);
  background: var(--surface-sidebar);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: calc(0.35rem + (var(--w) * 0.04rem)) calc(0.55rem + (var(--w) * 0.05rem));
  max-width: 16rem;
  transition:
    transform var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
  animation: rise 0.55s var(--ease-out) both;
}

.insight-node:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  background: var(--surface-active);
}

.insight-node b {
  display: block;
  font-size: calc(0.78rem + var(--w) * 0.035rem);
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.insight-node span {
  display: block;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  line-height: 1.3;
}

.insight-orbit--core .insight-node {
  border-color: color-mix(in oklab, var(--accent) 40%, var(--border-subtle));
}

.insight-orbit--far .insight-node {
  opacity: 0.88;
}

.insight-detail {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface-sidebar);
  animation: rise 0.35s var(--ease-out) both;
}

.insight-detail p {
  margin: 0.45rem 0 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.insight-list {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.insight-list li {
  margin-bottom: 0.4rem;
}

.insight-md {
  white-space: pre-wrap;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-secondary);
  max-height: 28rem;
  overflow: auto;
  margin: 0;
}

.empty {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  padding: 0.5rem 0;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .side {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
  .main {
    padding: var(--space-5) var(--space-4) var(--space-10);
  }
  .scene__field {
    transform: translate3d(0, 0, 0) rotateX(8deg);
  }
}
