/* ============================================================
   ALBION BATTLE TRACKER — "War Room" design system
   Тёмный тактический центр: графит, сталь, золото Kill Fame.
   ============================================================ */

/* ---------- 1. Design tokens ---------- */
:root {
  color-scheme: dark;

  /* palette */
  --bg-primary: #090d12;
  --bg-secondary: #0f151d;
  --surface: #151d27;
  --surface-elevated: #1b2531;
  --surface-input: rgba(5, 8, 12, .55);
  --border: rgba(255, 255, 255, .08);
  --border-soft: rgba(255, 255, 255, .05);
  --border-strong: rgba(255, 255, 255, .15);
  --border-gold: rgba(217, 170, 82, .3);
  --text-primary: #f4f1e8;
  --text-secondary: #9ba7b4;
  --text-muted: #66717e;
  --gold: #d9aa52;
  --gold-bright: #f3c96b;
  --gold-tint: rgba(217, 170, 82, .1);
  --ember: #e56943;
  --success: #55c2a8;
  --success-bright: #7cd8c2;
  --danger: #ef626c;
  --danger-bright: #f68f96;
  --info: #6d9fd3;

  /* typography */
  --font-ui: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --fs-xs: 11px;
  --fs-sm: 12.5px;
  --fs-base: 14px;
  --fs-md: 16px;
  --fs-lg: 19px;
  --fs-kicker: 10.5px;

  /* spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* radii */
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 9px;
  --radius-xs: 7px;

  /* elevation */
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, .45), 0 4px 16px rgba(0, 0, 0, .3);
  --shadow: 0 14px 40px rgba(0, 0, 0, .32);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, .25);
  --glow-gold: 0 8px 28px rgba(217, 170, 82, .22);
  --inner-light: inset 0 1px 0 rgba(255, 255, 255, .055);

  /* motion */
  --t-fast: .16s;
  --t: .26s;
  --t-slow: .5s;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.45, .5, 1);
}

/* ---------- 2. Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scrollbar-color: #333d49 var(--bg-primary); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text-primary);
  background: var(--bg-primary);
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* тактическая сетка + вертикальный градиент глубины */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, .016) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .016) 1px, transparent 1px),
    linear-gradient(180deg, #0b1017 0%, var(--bg-primary) 340px);
  background-size: 68px 68px, 68px 68px, 100% 100%;
  mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .35) 55%, rgba(0, 0, 0, .15) 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .35) 55%, rgba(0, 0, 0, .15) 100%);
}
/* лёгкая зернистость */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: .3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
button, input, textarea, select { font: inherit; }
button, select, summary { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: var(--font-display); font-weight: 600; }
[hidden] { display: none !important; }
::selection { color: #1c1408; background: var(--gold-bright); }
:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 3px; border-radius: 4px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* атмосферные всполохи: золото штаба + жар сражения */
.ambient {
  position: fixed;
  z-index: -1;
  width: 640px;
  height: 640px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(30px);
  opacity: .1;
  animation: ambient-drift 22s var(--ease) infinite alternate;
}
.ambient-one { top: -340px; left: -200px; background: radial-gradient(circle, var(--gold), transparent 66%); }
.ambient-two { right: -300px; top: 30%; background: radial-gradient(circle, var(--ember), transparent 66%); animation-delay: -10s; opacity: .07; }

/* ---------- 3. Командная панель (topbar) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-6);
  min-height: 72px;
  padding: 10px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-primary) 82%, transparent);
  background: rgba(9, 13, 18, .82);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.topbar::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent 8%, rgba(243, 201, 107, .4) 50%, transparent 92%);
  opacity: .5;
  pointer-events: none;
}

.brand { display: inline-flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  color: var(--gold-bright);
  background: linear-gradient(150deg, rgba(217, 170, 82, .17), rgba(217, 170, 82, .03));
  box-shadow: var(--inner-light), 0 6px 20px rgba(217, 170, 82, .1);
  transition: transform var(--t-slow) var(--ease-spring), box-shadow var(--t-slow) var(--ease);
}
.brand:hover .brand-mark { transform: rotate(-5deg) scale(1.05); box-shadow: var(--inner-light), var(--glow-gold); }
.brand-mark svg { width: 24px; height: 24px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1; }
.brand-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-primary);
}
.brand-kicker {
  margin-top: 4px;
  color: var(--gold);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .34em;
  text-transform: uppercase;
}

.main-nav { display: flex; align-self: stretch; align-items: center; justify-content: center; gap: 4px; min-width: 0; }
.nav-tab {
  position: relative;
  height: 42px;
  padding: 0 15px;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: transparent;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  transition: color var(--t-fast), background var(--t-fast);
}
.nav-tab::after {
  content: "";
  position: absolute;
  right: 15px;
  bottom: 3px;
  left: 15px;
  height: 2px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  box-shadow: 0 0 10px rgba(217, 170, 82, .5);
  opacity: 0;
  transform: scaleX(.3);
  transition: opacity var(--t-fast), transform var(--t) var(--ease);
}
.nav-tab:hover { color: var(--text-primary); background: rgba(255, 255, 255, .035); }
.nav-tab.active { color: var(--gold-bright); background: var(--gold-tint); }
.nav-tab.active::after { opacity: 1; transform: scaleX(1); }

.topbar-controls { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }
.server-pill, .player-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, .03);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.server-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(85, 194, 168, .14); }
.player-badge svg { width: 15px; height: 15px; }
.player-badge #player-count { color: var(--text-primary); font-weight: 700; font-variant-numeric: tabular-nums; }

.preset-picker select, .stats-picker select {
  min-width: 170px;
  height: 40px;
  padding: 0 34px 0 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ba7b4' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center,
    var(--bg-secondary);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.preset-picker select:hover, .stats-picker select:hover { border-color: var(--border-strong); }
.preset-picker select:focus-visible, .stats-picker select:focus-visible { outline: none; border-color: var(--border-gold); box-shadow: 0 0 0 3px rgba(217, 170, 82, .12); }

.language-toggle {
  display: flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(5, 8, 12, .4);
}
.language-toggle button {
  width: 34px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: var(--text-muted);
  background: transparent;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  transition: color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.language-toggle button:hover { color: var(--text-primary); }
.language-toggle button.active {
  color: #211906;
  background: linear-gradient(140deg, var(--gold-bright), var(--gold));
  box-shadow: 0 3px 10px rgba(217, 170, 82, .25);
}

/* ---------- 4. Кнопки и элементы управления ---------- */
.btn, .icon-text-btn, .text-button, .icon-btn {
  border: 0;
  color: inherit;
  transition: transform var(--t) var(--ease), border-color var(--t-fast), background var(--t-fast), color var(--t-fast), box-shadow var(--t);
}
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 18px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: var(--fs-sm);
  white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.98); }
.btn svg { width: 17px; height: 17px; }

.btn-primary {
  color: #201808;
  border-color: var(--gold-bright);
  background: linear-gradient(140deg, var(--gold-bright), var(--gold) 78%);
  box-shadow: var(--glow-gold), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 12px 34px rgba(217, 170, 82, .32), inset 0 1px 0 rgba(255, 255, 255, .55); }
.btn-glow {
  position: absolute;
  top: -80%;
  left: -35%;
  width: 24%;
  height: 260%;
  background: rgba(255, 255, 255, .5);
  transform: rotate(22deg) translateX(-180%);
  pointer-events: none;
}
.btn-primary:hover .btn-glow { animation: button-sweep .7s var(--ease); }
.btn-primary > *:not(.btn-glow) { position: relative; }

.btn-secondary { border-color: rgba(217, 170, 82, .28); background: rgba(217, 170, 82, .09); color: var(--gold-bright); }
.btn-secondary:hover:not(:disabled) { border-color: rgba(243, 201, 107, .5); background: rgba(217, 170, 82, .15); }
.btn-ghost { border-color: var(--border); background: rgba(255, 255, 255, .028); color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { color: var(--text-primary); border-color: var(--border-strong); background: rgba(255, 255, 255, .06); }
.btn-danger {
  color: #fff !important;
  border-color: rgba(239, 98, 108, .55) !important;
  background: linear-gradient(140deg, #f0747d, var(--danger)) !important;
  box-shadow: 0 8px 26px rgba(239, 98, 108, .25) !important;
}
.btn-sm { min-height: 36px; padding: 0 13px; border-radius: var(--radius-xs); font-size: var(--fs-xs); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
}
.icon-btn:hover { color: var(--text-primary); background: rgba(255, 255, 255, .06); }
.icon-btn.danger:hover { color: var(--danger-bright); border-color: rgba(239, 98, 108, .3); background: rgba(239, 98, 108, .1); }

.icon-text-btn, .text-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  background: transparent;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .02em;
}
.icon-text-btn:hover, .text-button:hover { color: var(--gold-bright); background: var(--gold-tint); }
.icon-text-btn.danger { color: var(--text-secondary); }
.icon-text-btn.danger:hover { color: var(--danger-bright); background: rgba(239, 98, 108, .1); }

kbd {
  margin-left: 4px;
  padding: 2px 6px;
  border: 1px solid rgba(28, 20, 8, .3);
  border-radius: 5px;
  color: rgba(28, 20, 8, .7);
  background: rgba(255, 255, 255, .22);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
}

input[type="text"], input[type="search"], textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: 0;
  color: var(--text-primary);
  background: var(--surface-input);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input[type="text"] { height: 40px; padding: 0 13px; }
input[type="text"]:focus, input[type="search"]:focus, textarea:focus {
  border-color: var(--border-gold);
  box-shadow: 0 0 0 3px rgba(217, 170, 82, .09);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }

/* ---------- 5. Каркас страницы ---------- */
.container { width: min(1440px, calc(100% - 40px)); margin: 0 auto; padding: 38px 0 90px; }
.app-section { animation: section-in var(--t-slow) var(--ease) both; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--gold);
  font-family: var(--font-ui);
  font-size: var(--fs-kicker);
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.eyebrow > span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-gold);
  border-radius: 50%;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 6. Экран анализа битвы ---------- */
.analysis-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(240px, .72fr) minmax(0, 1.45fr);
  gap: clamp(28px, 4vw, 64px);
  padding: clamp(26px, 4vw, 48px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(ellipse 60% 80% at 6% 10%, rgba(217, 170, 82, .1), transparent 60%),
    radial-gradient(ellipse 40% 60% at 100% 100%, rgba(229, 105, 67, .05), transparent 60%),
    linear-gradient(150deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .006) 55%),
    var(--bg-secondary);
  box-shadow: var(--shadow-lg), var(--inner-light);
  animation: panel-in .65s var(--ease) both;
}
.analysis-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 40px;
  width: 160px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-bright), transparent);
  box-shadow: 0 0 16px var(--gold);
}
.analysis-intro { display: flex; flex-direction: column; justify-content: space-between; gap: var(--sp-6); }
.analysis-intro h1 {
  max-width: 440px;
  margin: 14px 0 12px;
  font-size: clamp(32px, 3.2vw, 50px);
  line-height: 1.03;
  letter-spacing: -.02em;
}
.analysis-intro p { max-width: 380px; margin: 0; color: var(--text-secondary); font-size: var(--fs-base); }

.analysis-workspace { min-width: 0; }
.selected-squad-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: 10px;
  padding: 0 3px;
  color: var(--text-secondary);
  font-size: var(--fs-kicker);
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.selected-squad-line strong {
  max-width: 58%;
  overflow: hidden;
  color: var(--gold-bright);
  font-size: var(--fs-sm);
  letter-spacing: .03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.input-shell {
  position: relative;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: var(--radius-lg);
  background: var(--surface-input);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .25);
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.input-shell:focus-within {
  border-color: rgba(243, 201, 107, .45);
  box-shadow: 0 0 0 4px rgba(217, 170, 82, .08), inset 0 2px 8px rgba(0, 0, 0, .2);
  transform: translateY(-1px);
}
#battle-input {
  display: block;
  width: 100%;
  min-height: 118px;
  padding: 17px 19px 11px;
  resize: vertical;
  border: 0;
  outline: 0;
  color: var(--text-primary);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.input-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: 44px;
  padding: 6px 8px 6px 18px;
  border-top: 1px solid var(--border-soft);
}
.parse-line { min-width: 0; color: var(--text-secondary); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.input-placeholder { color: var(--text-muted); }
.parse-ok { color: var(--success-bright); font-weight: 700; }
.parse-bad { color: var(--danger-bright); }

.analysis-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: var(--sp-4); }
.analysis-progress {
  height: 6px;
  margin-top: var(--sp-3);
  border-radius: 999px;
  background: rgba(243, 201, 107, .12);
  overflow: hidden;
}
.analysis-progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  transition: width var(--t) var(--ease);
}
.load-status { display: inline-flex; align-items: center; gap: 8px; min-height: 22px; color: var(--text-secondary); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(243, 201, 107, .18);
  border-top-color: var(--gold-bright);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* история анализов */
.history-wrap { position: relative; }
#history-btn {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
}
#history-btn::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform var(--t-fast);
}
#history-btn[aria-expanded="true"]::after { transform: translateY(2px) rotate(225deg); }
.history-menu {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: min(300px, 42vh);
  overflow: hidden;
  border: 0;
  border-top: 1px solid var(--border-soft);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: rgba(255, 255, 255, .025);
  box-shadow: inset 0 10px 24px rgba(0, 0, 0, .14);
  transform-origin: top;
  animation: menu-in var(--t-fast) var(--ease) both;
}
.history-menu[hidden] { display: none; }
.history-list {
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 6px 8px 8px;
}
.history-item {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  background: transparent;
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 600;
}
.history-item:hover, .history-item:focus-visible { background: var(--gold-tint); }
.history-item .meta {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-empty { padding: 20px; color: var(--text-secondary); text-align: center; font-size: var(--fs-xs); }
.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, .025);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .12);
}
.history-toolbar strong {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.history-clear {
  padding: 7px 9px;
  border: 0;
  border-radius: var(--radius-xs);
  color: var(--danger-bright);
  background: transparent;
  font-size: var(--fs-xs);
  font-weight: 700;
}
.history-clear:hover, .history-clear:focus-visible { background: rgba(239, 98, 108, .1); }

/* предупреждение о частичном импорте */
.banner {
  margin: var(--sp-4) 0 0;
  padding: 13px 16px;
  border-radius: var(--radius);
  font-size: var(--fs-xs);
  line-height: 1.6;
  overflow-wrap: anywhere;
  animation: panel-in .35s var(--ease);
}
.banner-warn {
  border: 1px solid rgba(229, 105, 67, .3);
  color: #f0b3a0;
  background: rgba(229, 105, 67, .09);
}
.banner strong { color: #f6c9ba; }
.retry-btn {
  margin-left: 8px;
  padding: 5px 10px;
  border: 1px solid rgba(240, 179, 160, .3);
  border-radius: var(--radius-xs);
  color: #f6c9ba;
  background: rgba(255, 255, 255, .05);
  font-weight: 700;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.retry-btn:hover { background: rgba(255, 255, 255, .1); border-color: rgba(240, 179, 160, .5); }

/* ---------- 7. Пустое состояние ---------- */
.empty-state {
  position: relative;
  display: grid;
  grid-template-columns: 160px minmax(220px, 1fr) minmax(400px, 1.35fr);
  align-items: center;
  gap: clamp(24px, 4vw, 56px);
  margin-top: var(--sp-6);
  padding: clamp(26px, 4vw, 44px);
  border: 1px dashed rgba(255, 255, 255, .12);
  border-radius: var(--radius-xl);
  background: rgba(15, 21, 29, .5);
  animation: panel-in .65s .08s var(--ease) both;
}
.empty-visual { position: relative; display: grid; place-items: center; width: 132px; height: 132px; margin: auto; color: var(--gold); }
.empty-visual svg { z-index: 2; width: 42px; height: 42px; }
.radar-ring { position: absolute; inset: 8px; border: 1px solid rgba(217, 170, 82, .22); border-radius: 50%; animation: radar 3.4s ease-out infinite; }
.ring-two { inset: 26px; animation-delay: -1.7s; }
.empty-copy h2 { margin: 10px 0 9px; font-size: clamp(22px, 2vw, 30px); line-height: 1.15; letter-spacing: -.01em; }
.empty-copy p { max-width: 430px; margin: 0; color: var(--text-secondary); }
.empty-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.empty-steps > div {
  min-height: 120px;
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .018);
  transition: transform var(--t) var(--ease), border-color var(--t), background var(--t);
}
.empty-steps > div:hover { transform: translateY(-4px); border-color: var(--border-gold); background: rgba(217, 170, 82, .04); }
.empty-steps span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-bottom: 12px;
  border-radius: var(--radius-xs);
  color: var(--gold-bright);
  background: var(--gold-tint);
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.empty-steps p { margin: 0; color: var(--text-secondary); font-size: var(--fs-xs); }
.empty-steps strong { display: block; margin-bottom: 3px; color: var(--text-primary); font-size: var(--fs-sm); }
.compact-empty { grid-template-columns: 1fr; min-height: 220px; text-align: center; }

/* ---------- 8. Результаты сессии ---------- */
.results { margin-top: var(--sp-6); }
.results > * { animation: panel-in .55s var(--ease) both; }
.results > :nth-child(2) { animation-delay: .06s; }
.results > :nth-child(3) { animation-delay: .12s; }
.results > :nth-child(4) { animation-delay: .18s; }

.session-strip {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-6);
  margin-bottom: var(--sp-4);
  padding: 0 4px;
}
.session-strip h2 { margin: 7px 0 0; color: var(--text-secondary); font-family: var(--font-ui); font-size: var(--fs-md); font-weight: 600; }
.session-strip h2 span { color: var(--text-primary); font-weight: 700; }
.battle-chips { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.battle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, .02);
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.battle-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.battle-chip:hover, .battle-chip:focus-visible {
  border-color: var(--border-gold);
  color: var(--gold-bright);
  background: var(--gold-tint);
  transform: translateY(-1px);
}
.battle-chip.existing { border-color: rgba(109, 159, 211, .28); color: #a5c6e6; background: rgba(109, 159, 211, .07); }
.battle-chip.existing::before { background: var(--info); }
.battle-chip.failed { color: var(--danger-bright); border-color: rgba(239, 98, 108, .24); }
.battle-chip.failed::before { background: var(--danger); }
.battle-chip.failed:hover, .battle-chip.failed:focus-visible { border-color: rgba(239, 98, 108, .42); color: var(--danger-bright); background: rgba(239, 98, 108, .1); }
.battle-chip.chip-action {
  cursor: pointer;
  border-color: var(--border-gold);
  color: var(--gold);
  background: rgba(217, 170, 82, .05);
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
}
.battle-chip.chip-action::before { display: none; }
.battle-chip.chip-action:hover, .battle-chip.chip-action:focus-visible { color: var(--gold-bright); background: var(--gold-tint); }

.result-view-switcher {
  display: grid;
  grid-template-columns: repeat(2, minmax(112px, 1fr));
  width: min(300px, 100%);
  margin: 0 0 var(--sp-4) 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(5, 8, 12, .55);
  box-shadow: var(--inner-light);
}
.result-view-switcher button {
  min-height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: calc(var(--radius-sm) - 3px);
  color: var(--text-secondary);
  background: transparent;
  font-size: var(--fs-xs);
  font-weight: 750;
  letter-spacing: .03em;
  transition: color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.result-view-switcher button:hover { color: var(--text-primary); }
.result-view-switcher button[aria-selected="true"] {
  color: var(--gold-bright);
  background: linear-gradient(145deg, rgba(217, 170, 82, .17), rgba(217, 170, 82, .07));
  box-shadow: inset 0 0 0 1px rgba(217, 170, 82, .22), 0 4px 12px rgba(0, 0, 0, .18);
}
.result-view-switcher button:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }

.alliance-view { display: grid; gap: var(--sp-4); }
.alliance-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-5);
  padding: var(--sp-5);
  overflow: hidden;
  background:
    radial-gradient(ellipse 45% 140% at 95% 0%, rgba(217, 170, 82, .13), transparent 70%),
    var(--surface);
}
.alliance-hero h2 { margin: 7px 0 0; color: var(--gold-bright); font-size: clamp(25px, 3vw, 38px); letter-spacing: -.025em; }
.alliance-hero p { margin: 0; color: var(--text-secondary); text-align: right; }
.alliance-hero p strong { display: block; margin: 5px 0 2px; color: var(--text-primary); font-size: 25px; font-variant-numeric: tabular-nums; }
.alliance-hero p small { color: var(--text-muted); }
.alliance-summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 0; }
.analysis-summary-grid .stat-box, .alliance-summary-grid .stat-box { min-height: 118px; }
.alliance-comparison-panel { overflow: hidden; }
.alliance-comparison-rows { border-top: 1px solid var(--border); }
.contribution-row, .comparison-row { padding: 19px 22px; }
.contribution-row + .contribution-row, .comparison-row { border-top: 1px solid var(--border); }
.contribution-head { display: grid; grid-template-columns: minmax(130px, 1fr) auto 70px; align-items: baseline; gap: var(--sp-4); }
.contribution-head span { color: var(--text-primary); font-size: var(--fs-sm); font-weight: 700; }
.contribution-head strong { color: var(--text-secondary); font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600; }
.contribution-head b { color: var(--gold-bright); text-align: right; font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.contribution-track { height: 7px; margin-top: 12px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, .055); }
.contribution-track i { display: block; width: var(--share); height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--gold-bright)); box-shadow: 0 0 14px rgba(217, 170, 82, .3); }
.contribution-legend { display: flex; justify-content: space-between; margin-top: 7px; color: var(--text-muted); font-size: 10px; }
.comparison-row { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(100px, .6fr) 1px minmax(100px, .6fr); align-items: center; gap: var(--sp-5); }
.comparison-row > span { color: var(--text-primary); font-size: var(--fs-sm); font-weight: 700; }
.comparison-row > i { width: 1px; height: 38px; background: var(--border); }
.comparison-row div { display: grid; gap: 3px; }
.comparison-row small { color: var(--text-muted); font-size: 10px; }
.comparison-row strong { color: var(--text-primary); font-size: 21px; font-variant-numeric: tabular-nums; }
.comparison-row div:first-of-type strong { color: var(--gold-bright); }

/* KPI: bento-сетка, Kill Fame — герой */
.summary-grid { display: grid; grid-template-columns: 1.5fr repeat(3, minmax(150px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.stat-box {
  position: relative;
  min-width: 0;
  min-height: 134px;
  padding: var(--sp-5);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(150deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .007)), var(--surface);
  box-shadow: var(--shadow-sm), var(--inner-light);
  transition: transform var(--t) var(--ease), border-color var(--t), box-shadow var(--t);
}
.stat-box:hover { z-index: 2; transform: translateY(-4px); border-color: var(--border-gold); box-shadow: var(--shadow), var(--inner-light); }
.stat-box::after {
  content: "";
  position: absolute;
  right: -36px;
  bottom: -58px;
  width: 128px;
  height: 128px;
  border: 1px solid rgba(255, 255, 255, .04);
  border-radius: 50%;
}
.stat-primary {
  border-color: var(--border-gold);
  background:
    radial-gradient(ellipse 70% 90% at 85% 8%, rgba(217, 170, 82, .18), transparent 55%),
    linear-gradient(150deg, rgba(217, 170, 82, .07), rgba(255, 255, 255, .01)),
    var(--surface);
}
.stat-box .label {
  position: relative;
  z-index: 1;
  color: var(--text-secondary);
  font-size: var(--fs-kicker);
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.stat-box .value {
  position: relative;
  z-index: 1;
  margin-top: var(--sp-4);
  overflow: hidden;
  color: var(--text-primary);
  font-size: clamp(26px, 2.2vw, 38px);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.stat-primary .value { color: var(--gold-bright); font-size: clamp(34px, 3vw, 48px); text-shadow: 0 0 32px rgba(217, 170, 82, .35); }
.stat-box .value.green { color: var(--success-bright); }
.stat-box .value.red { color: var(--danger-bright); }
.stat-box .value.gold { color: var(--gold-bright); }
.stat-box .sub {
  position: relative;
  z-index: 1;
  margin-top: 9px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- 9. Панели и таблицы ---------- */
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 312px; align-items: start; gap: var(--sp-4); min-width: 0; }
.dashboard-grid > *, .table-panel, .insight-column { min-width: 0; }
.table-panel { overflow: hidden; }
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: linear-gradient(165deg, rgba(255, 255, 255, .02), transparent 40%), rgba(15, 21, 29, .92);
  box-shadow: var(--shadow-sm), var(--inner-light);
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); padding: 22px 22px 17px; }
.panel-head h2 { margin: 6px 0 0; font-size: 21px; letter-spacing: -.01em; }
.panel-head p { margin: 7px 0 0; color: var(--text-secondary); font-size: var(--fs-xs); }
.panel-head.compact { align-items: center; }
.table-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.table-filterbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-4);
  padding: 0 22px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 190px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: var(--surface-input);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search-box:focus-within { border-color: var(--border-gold); box-shadow: 0 0 0 3px rgba(217, 170, 82, .08); }
.search-box input { min-width: 0; width: 100%; border: 0; outline: 0; box-shadow: none; color: var(--text-primary); background: transparent; font-size: var(--fs-sm); }

.table-scroll { width: 100%; max-height: 660px; overflow: auto; overscroll-behavior: contain; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
th, td { height: 50px; padding: 0 var(--sp-3); border-bottom: 1px solid rgba(255, 255, 255, .045); text-align: right; white-space: nowrap; }
th {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 42px;
  color: var(--text-muted);
  background: #131a24;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}
th.sortable { cursor: pointer; user-select: none; transition: color var(--t-fast); }
th.sortable:hover, th.sorted { color: var(--gold-bright); }
.sort-arrow { display: inline-block; min-width: 9px; color: var(--gold); }
tbody tr { animation: row-in .4s var(--ease) both; }
tbody tr:nth-child(2) { animation-delay: .025s; }
tbody tr:nth-child(3) { animation-delay: .05s; }
tbody tr:nth-child(4) { animation-delay: .075s; }
tbody tr:nth-child(5) { animation-delay: .1s; }
td { color: var(--text-secondary); transition: background-color var(--t-fast); }
tbody tr:hover td { background-color: rgba(217, 170, 82, .045); }
.col-rank { width: 52px; text-align: center; }
.rank-medal {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  background: rgba(255, 255, 255, .04);
  font-size: var(--fs-xs);
  font-weight: 800;
}
.rank-medal.top-1 { color: #241a06; background: linear-gradient(135deg, #f5d47f, #c69334); box-shadow: 0 4px 14px rgba(217, 170, 82, .28); }
.rank-medal.top-2 { color: #1f242b; background: linear-gradient(135deg, #dde1e7, #8e97a4); }
.rank-medal.top-3 { color: #26160c; background: linear-gradient(135deg, #d99b6a, #8f5a35); }
.col-name {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 190px;
  max-width: 230px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  color: var(--text-primary);
  background-color: #10161f;
  font-weight: 700;
}
th.col-name { z-index: 6; background: #131a24; }
.player-name-cell { display: flex; align-items: center; min-width: 0; gap: 9px; }
.player-name-cell > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weapon-icon {
  flex: 0 0 auto;
  width: 27px;
  height: 27px;
  margin: -5px 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .45));
}
td.kills { color: var(--success-bright); }
td.deaths { color: var(--danger-bright); }
td.kd { color: var(--text-primary); font-weight: 700; }
td.kd-high { color: var(--gold-bright); }
td.fame { position: relative; isolation: isolate; color: var(--gold-bright); font-weight: 700; }
.fame-bar {
  position: absolute;
  z-index: -1;
  inset: 11px 5px 11px auto;
  width: var(--bar, 0%);
  max-width: calc(100% - 10px);
  border-radius: 5px;
  background: linear-gradient(90deg, transparent, rgba(217, 170, 82, .14));
}
.table-empty { padding: 44px 20px; color: var(--text-secondary); text-align: center; }

/* сигналы сессии */
.insight-column { display: grid; gap: var(--sp-4); }
.insight-list { display: grid; gap: 9px; padding: 0 var(--sp-4) 17px; }
.insight-card {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 11px;
  min-height: 68px;
  padding: 11px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .018);
  transition: transform var(--t) var(--ease), border-color var(--t), background var(--t);
}
.insight-card:hover { transform: translateX(-3px); border-color: var(--border-gold); background: rgba(217, 170, 82, .04); }
.insight-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(217, 170, 82, .2);
  border-radius: var(--radius-sm);
  color: var(--gold-bright);
  background: var(--gold-tint);
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
}
.insight-copy { min-width: 0; }
.insight-copy small {
  display: block;
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.insight-copy strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-primary);
  font-size: var(--fs-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.insight-value { color: var(--gold-bright); font-size: var(--fs-sm); font-weight: 800; font-variant-numeric: tabular-nums; }
.insight-empty { padding: 36px 15px; color: var(--text-secondary); text-align: center; font-size: var(--fs-xs); }

/* ---------- 10. Заголовки разделов ---------- */
.section-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-8);
  margin-bottom: var(--sp-5);
  padding: 30px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(ellipse 40% 90% at 92% 0, rgba(217, 170, 82, .11), transparent 55%),
    linear-gradient(150deg, rgba(255, 255, 255, .025), transparent 45%),
    var(--bg-secondary);
  box-shadow: var(--shadow-sm), var(--inner-light);
}
.section-hero h1 { margin: 12px 0 8px; font-size: clamp(30px, 3.4vw, 44px); letter-spacing: -.015em; line-height: 1.05; }
.section-hero p { max-width: 640px; margin: 0; color: var(--text-secondary); font-size: var(--fs-sm); line-height: 1.6; }

/* ---------- 11. Управление сквадами ---------- */
.management-grid { display: grid; grid-template-columns: minmax(250px, 330px) minmax(0, 1fr); align-items: start; gap: var(--sp-4); }
.squad-list-panel, .roster-editor { overflow: hidden; }
.squad-list { display: grid; gap: 7px; padding: 0 var(--sp-4) 17px; }
.squad-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  min-height: 58px;
  padding: 9px var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  background: rgba(255, 255, 255, .018);
  text-align: left;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.squad-list-item:hover { transform: translateX(2px); border-color: var(--border-gold); }
.squad-list-item.active {
  border-color: rgba(217, 170, 82, .4);
  background: rgba(217, 170, 82, .08);
  box-shadow: inset 2px 0 0 var(--gold);
}
.squad-list-item span { min-width: 0; }
.squad-list-item strong, .squad-list-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.squad-list-item strong { color: var(--text-primary); font-size: var(--fs-sm); }
.squad-list-item small { margin-top: 4px; color: var(--text-muted); font-size: 10px; }
.squad-list-item i { color: var(--gold-bright); font-style: normal; font-weight: 700; }
.management-actions { display: flex; flex-wrap: wrap; gap: 7px; padding: var(--sp-4); border-top: 1px solid var(--border-soft); }

.roster-editor-head { border-bottom: 1px solid var(--border-soft); }
.roster-editor-head h2 { overflow-wrap: anywhere; }
.roster-editor-head .table-actions { flex-wrap: wrap; justify-content: flex-end; }
.built-in-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 9px;
  padding: 5px 9px;
  border: 1px solid rgba(217, 170, 82, .3);
  border-radius: var(--radius-pill);
  background: rgba(217, 170, 82, .08);
  color: var(--gold-bright);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
}
.squad-list-item .built-in-lock { color: var(--gold-bright); font-size: 10px; }
.roster-tools input:disabled, .roster-tools textarea:disabled { cursor: not-allowed; opacity: .5; }
.roster-tools {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(280px, 1.6fr);
  gap: var(--sp-3);
  padding: var(--sp-4) 22px;
  border-bottom: 1px solid var(--border-soft);
}
.roster-tools .search-box { width: 100%; }
.roster-tools .add-row { margin: 0; }
.add-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }

.roster-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(5, 8, 12, .28);
}
.roster-list.large { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 520px; margin: 18px 22px; }
.roster-list.large .roster-row:nth-child(odd) { border-right: 1px solid rgba(255, 255, 255, .045); }
.roster-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 4px 6px 4px var(--sp-3);
  border-bottom: 1px solid rgba(255, 255, 255, .04);
}
.roster-row:last-child { border-bottom: 0; }
.roster-row > span { min-width: 0; overflow: hidden; color: var(--text-primary); font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }
.roster-row .icon-btn { width: 32px; height: 32px; }
.row-actions { display: flex; flex: 0 0 auto; gap: 3px; opacity: .55; transition: opacity var(--t-fast); }
.roster-row:hover .row-actions, .roster-row:focus-within .row-actions { opacity: 1; }
.roster-empty { padding: 30px 14px; color: var(--text-secondary); text-align: center; font-size: var(--fs-xs); }

.bulk-details { margin: 18px 22px 22px; padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-secondary); }
.bulk-details summary { color: var(--text-primary); font-size: var(--fs-sm); font-weight: 700; }
.bulk-details summary:hover { color: var(--gold-bright); }
.bulk-details textarea { width: 100%; margin: var(--sp-3) 0 8px; padding: 10px 12px; resize: vertical; }

/* ---------- 12. Статистика групп ---------- */
.stats-picker {
  display: grid;
  gap: 7px;
  min-width: 245px;
  color: var(--text-secondary);
  font-size: var(--fs-kicker);
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.stats-picker select { min-width: 0; height: 42px; }
.stats-summary-grid { grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr)); }
.stats-summary-grid .stat-primary { order: -1; }

.leaders-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); margin: var(--sp-4) 0; }
.leader-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
  padding: var(--sp-4);
  transition: transform var(--t) var(--ease), border-color var(--t);
}
.leader-card:hover { transform: translateY(-3px); border-color: var(--border-gold); }
.leader-card:nth-child(1) .insight-icon { color: var(--gold-bright); border-color: rgba(217, 170, 82, .3); background: rgba(217, 170, 82, .12); }
.leader-card:nth-child(2) .insight-icon { color: var(--success-bright); border-color: rgba(85, 194, 168, .28); background: rgba(85, 194, 168, .1); }
.leader-card:nth-child(3) .insight-icon { color: var(--danger-bright); border-color: rgba(239, 98, 108, .26); background: rgba(239, 98, 108, .09); }
.leader-card span:nth-child(2) { min-width: 0; }
.leader-card small, .leader-card strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-card small { color: var(--text-muted); font-size: 9.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.leader-card strong { margin-top: 5px; color: var(--text-primary); font-size: var(--fs-base); }
.leader-card b { color: var(--gold-bright); font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.leader-card:nth-child(2) b { color: var(--success-bright); }
.leader-card:nth-child(3) b { color: var(--danger-bright); }

.stats-dashboard { grid-template-columns: minmax(0, 1fr) minmax(300px, 390px); }
.recorded-battles { padding: 0 var(--sp-4); }
.recorded-battle {
  display: grid;
  grid-template-columns: auto 1fr 34px;
  align-items: center;
  row-gap: 3px;
  column-gap: 10px;
  min-height: 54px;
  padding: 9px 3px 9px 10px;
  border-bottom: 1px solid var(--border-soft);
  transition: background var(--t-fast);
}
.recorded-battle:hover { background: rgba(255, 255, 255, .02); }
.recorded-battle strong, .recorded-battle small, .recorded-battle span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recorded-battle strong { color: var(--gold-bright); font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 700; }
.recorded-battle small { color: var(--text-muted); font-size: 10px; text-align: right; }
.recorded-battle span { grid-column: 1 / 3; grid-row: 2; color: var(--text-secondary); font-size: 10.5px; text-align: left; font-variant-numeric: tabular-nums; }
.recorded-battle .icon-btn { grid-column: 3; grid-row: 1 / 3; }
.recorded-battle span b { font-weight: 800; }
.recorded-battle span b.kills { color: var(--success-bright); }
.recorded-battle span b.deaths { color: var(--danger-bright); }
.recorded-battle .row-actions, .recorded-battle .icon-btn { opacity: .5; transition: opacity var(--t-fast); }
.recorded-battle:hover .icon-btn, .recorded-battle .icon-btn:focus-visible { opacity: 1; }

.battle-pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 9px;
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  border-top: 1px solid var(--border-soft);
}
.battle-pagination button:first-child { justify-self: start; }
.battle-pagination button:last-child { justify-self: end; }
.battle-pagination span { color: var(--text-secondary); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.battle-pagination button:disabled { opacity: .32; }

/* ---------- 13. Модальные окна и тосты ---------- */
dialog { color: var(--text-primary); }
dialog::backdrop { background: rgba(4, 6, 10, .72); backdrop-filter: blur(6px); }
.modal {
  width: min(460px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, .04), transparent 45%),
    var(--surface-elevated);
  box-shadow: var(--shadow-lg);
}
.modal[open] { animation: modal-in var(--t) var(--ease-spring) both; }
.modal form { padding: 26px; }
.modal h2 { margin: 10px 0 8px; font-size: 24px; letter-spacing: -.01em; }
.modal p { color: var(--text-secondary); font-size: var(--fs-sm); line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; }
.modal input[type="text"] { width: 100%; }
.modal-option {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: var(--sp-4);
  padding: 11px var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: rgba(255, 255, 255, .018);
  cursor: pointer;
  font-size: var(--fs-xs);
  line-height: 1.4;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.modal-option:hover { border-color: var(--border-gold); color: var(--text-primary); }
.modal-option input { flex: 0 0 auto; width: 16px; height: 16px; margin: 0; accent-color: var(--gold); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.modal-actions { justify-content: flex-end; margin-top: var(--sp-5); }

.toasts {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 9px;
  width: min(380px, calc(100vw - 40px));
  pointer-events: none;
}
.toast {
  position: relative;
  padding: 13px 15px 13px 42px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-left-color: var(--info);
  border-radius: var(--radius);
  color: var(--text-primary);
  background: rgba(27, 37, 49, .97);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  line-height: 1.5;
  overflow-wrap: anywhere;
  animation: toast-in .4s var(--ease-spring) both;
}
.toast::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 17px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--info);
  box-shadow: 0 0 0 4px rgba(109, 159, 211, .12);
}
.toast.success { border-left-color: var(--success); }
.toast.success::before { background: var(--success); box-shadow: 0 0 0 4px rgba(85, 194, 168, .12); }
.toast.error { border-left-color: var(--danger); }
.toast.error::before { background: var(--danger); box-shadow: 0 0 0 4px rgba(239, 98, 108, .12); }
.toast.hide { animation: toast-out .26s ease both; }

/* ---------- 14. Анимации ---------- */
@keyframes ambient-drift { to { transform: translate3d(70px, 45px, 0) scale(1.1); } }
@keyframes panel-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes section-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes row-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes menu-in { from { opacity: 0; transform: translateY(-5px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(28px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(35px) scale(.96); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes button-sweep { to { transform: rotate(22deg) translateX(700%); } }
@keyframes radar { 0% { opacity: 0; transform: scale(.5); } 35% { opacity: .6; } 100% { opacity: 0; transform: scale(1.1); } }

/* ---------- 15. Адаптивность ---------- */
@media (max-width: 1240px) {
  .topbar { flex-wrap: wrap; }
  .main-nav { order: 3; flex: 1 1 100%; justify-content: flex-start; overflow-x: auto; padding-top: 4px; border-top: 1px solid var(--border-soft); }
  .topbar-controls { margin-left: auto; }
  .stats-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-summary-grid .stat-primary { grid-column: span 3; }
}

@media (max-width: 1180px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-grid .stat-primary { grid-column: span 2; }
  .empty-state { grid-template-columns: 130px 1fr; }
  .empty-steps { grid-column: 1 / -1; }
}

@media (max-width: 980px) {
  .analysis-card { grid-template-columns: 1fr; }
  .analysis-intro { display: block; }
  .analysis-intro h1 { max-width: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .insight-column { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
  .management-grid, .stats-dashboard { grid-template-columns: 1fr; }
  .section-hero { align-items: flex-start; flex-direction: column; padding: 24px 20px; }
  .section-hero .btn, .stats-picker { width: 100%; }
  .leaders-grid { grid-template-columns: 1fr; }
  .roster-tools { grid-template-columns: 1fr; }
  .stats-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-summary-grid .stat-primary { grid-column: span 2; }
  .alliance-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .container { width: min(100% - 24px, 1440px); padding-top: 20px; }
  .topbar { gap: var(--sp-3); min-height: auto; padding: 11px 13px; }
  .brand-mark { width: 38px; height: 38px; }
  .brand-title { font-size: 15px; letter-spacing: .16em; }
  .brand-kicker { letter-spacing: .22em; }
  .topbar-controls { flex: 1 1 100%; flex-wrap: wrap; gap: 7px; width: 100%; margin: 0; }
  .server-pill { display: none; }
  .preset-picker { flex: 1; }
  .preset-picker select { width: 100%; min-width: 0; }
  .language-toggle { margin-left: auto; }
  .main-nav { gap: 2px; }
  .nav-tab { flex: 0 0 auto; min-height: 44px; padding: 0 11px; font-size: var(--fs-xs); }
  .analysis-card { gap: var(--sp-6); padding: 22px 17px; border-radius: var(--radius-lg); }
  .analysis-intro h1 { margin-top: 11px; font-size: 31px; }
  .input-meta { align-items: flex-start; padding-left: 13px; }
  .analysis-actions .btn-primary { flex: 1 1 100%; }
  kbd { display: none; }
  .empty-state { grid-template-columns: 1fr; padding: 26px 18px; text-align: center; }
  .empty-visual { width: 110px; height: 110px; }
  .empty-copy p { margin-inline: auto; }
  .empty-steps { grid-template-columns: 1fr; text-align: left; }
  .empty-steps > div { min-height: 0; }
  .session-strip { align-items: flex-start; flex-direction: column; }
  .battle-chips { justify-content: flex-start; }
  .result-view-switcher { width: 100%; margin-left: 0; }
  .alliance-hero { align-items: flex-start; flex-direction: column; }
  .alliance-hero p { text-align: left; }
  .contribution-row, .comparison-row { padding: 17px 16px; }
  .contribution-head { grid-template-columns: 1fr auto; gap: 6px var(--sp-3); }
  .contribution-head b { grid-column: 2; grid-row: 1; }
  .contribution-head strong { grid-column: 1 / -1; }
  .comparison-row { grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
  .comparison-row > span { grid-column: 1 / -1; }
  .comparison-row > i { display: none; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-box { min-height: 112px; padding: var(--sp-4); }
  .stat-box .value { font-size: 26px; }
  .stat-primary { grid-column: span 2; }
  .stat-primary .value { font-size: 37px; }
  .panel { border-radius: var(--radius-lg); }
  .panel-head { padding: 18px 16px 14px; }
  .table-actions .icon-text-btn { min-width: 44px; min-height: 40px; }
  .table-filterbar { align-items: stretch; flex-direction: column; padding: 0 15px 14px; }
  .search-box { width: 100%; }
  .insight-column { grid-template-columns: 1fr; }
  .roster-list.large { grid-template-columns: 1fr; margin: 14px; }
  .roster-list.large .roster-row:nth-child(odd) { border-right: 0; }
  .roster-editor-head { align-items: flex-start; flex-direction: column; }
  .roster-editor-head .table-actions { justify-content: flex-start; }
  .row-actions { opacity: 1; }
  .recorded-battle .icon-btn { opacity: 1; }
  .stats-picker { min-width: 0; }
  .bulk-details { margin: 14px; }
  .toasts { right: 12px; bottom: 12px; }
}

@media (max-width: 460px) {
  .brand-copy { max-width: 165px; }
  .preset-picker { order: 1; flex: 1 1 calc(100% - 80px); }
  .language-toggle { order: 2; }
  .player-badge { display: none; }
  .summary-grid { gap: var(--sp-2); }
  .stat-box { min-height: 104px; padding: 13px; }
  .stat-box .label { font-size: 9.5px; }
  .stat-box .value { font-size: 23px; }
  .stat-primary .value { font-size: 31px; }
  .stats-summary-grid { grid-template-columns: 1fr 1fr; }
  .btn-row .btn { flex: 1 1 calc(50% - 4px); }
  .modal form { padding: 20px; }
}

/* ---------- 16. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .ambient, .radar-ring { animation: none; }
}
