/**
 * QA Sentinel — Future Theme (design tokens + base surface)
 * Layered AFTER app.css. Stages 2+ extend this file.
 * Do not remove app.css until the redesign is complete.
 */

:root {
  /* Surfaces */
  --qa-bg-deep: #020914;
  --qa-bg-main: #06111f;
  --qa-bg-panel: #081625;
  --qa-bg-panel-soft: #0b1b2d;
  --qa-bg-elevated: #0d2033;
  --qa-bg-hover: #10283d;

  /* Borders */
  --qa-border: rgba(105, 151, 197, 0.22);
  --qa-border-strong: rgba(104, 171, 229, 0.38);
  --qa-divider: rgba(132, 167, 199, 0.14);

  /* Text */
  --qa-text-main: #d9e8f6;
  --qa-text-soft: #9eb4c9;
  --qa-text-muted: #6f879e;
  --qa-text-disabled: #4d6072;

  /* Accents */
  --qa-violet: #8f4dff;
  --qa-violet-bright: #a95cff;
  --qa-purple: #c64dff;
  --qa-cyan: #19d8ff;
  --qa-blue: #278cff;
  --qa-pink: #ff4fa3;
  --qa-red: #ff556d;
  --qa-orange: #ff9d2e;
  --qa-yellow: #ffc84a;
  --qa-green: #43e57a;
  --qa-mint: #2ce6b7;

  /* Semantic */
  --qa-success: #43e57a;
  --qa-danger: #ff556d;
  --qa-warning: #ffad32;
  --qa-info: #19d8ff;
  --qa-critical: #ff4f91;

  /* Geometry */
  --qa-radius-sm: 6px;
  --qa-radius-md: 10px;
  --qa-radius-lg: 14px;
  --qa-sidebar-width: 100px;

  /* Elevation / glow */
  --qa-shadow-panel:
    0 14px 40px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.025);

  --qa-glow-violet: 0 0 18px rgba(143, 77, 255, 0.28);
  --qa-glow-cyan: 0 0 18px rgba(25, 216, 255, 0.22);
  --qa-glow-pink: 0 0 18px rgba(255, 79, 163, 0.22);

  --qa-transition: 160ms ease;

  --qa-font: "Segoe UI", "IBM Plex Sans", "Helvetica Neue", system-ui, sans-serif;
  --qa-mono: "Consolas", "IBM Plex Mono", ui-monospace, monospace;

  /* Bridge: remap legacy app.css tokens so existing components pick up the new palette */
  --bg: var(--qa-bg-main);
  --bg-elevated: var(--qa-bg-elevated);
  --bg-panel: var(--qa-bg-panel);
  --bg-sidebar: transparent;
  --border: var(--qa-border);
  --text: var(--qa-text-main);
  --text-muted: var(--qa-text-muted);
  --accent: var(--qa-violet);
  --accent-hover: var(--qa-violet-bright);
  --danger: var(--qa-danger);
  --warning: var(--qa-warning);
  --success: var(--qa-success);
  --radius: var(--qa-radius-md);
  --font: var(--qa-font);
  --mono: var(--qa-mono);
}

html {
  color-scheme: dark;
  background-color: var(--qa-bg-deep);
}

body {
  position: relative;
  isolation: isolate;
  font-family: var(--qa-font);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--qa-text-main);
  background-color: var(--qa-bg-deep);
  background-image:
    radial-gradient(circle at 70% 0%, rgba(69, 49, 132, 0.12), transparent 34%),
    radial-gradient(circle at 10% 90%, rgba(0, 153, 255, 0.07), transparent 28%),
    linear-gradient(180deg, #020914 0%, #04101c 55%, #030b15 100%);
  background-attachment: fixed;
  min-height: 100%;
}

/* Subtle tech grid — low opacity, CSS-only, no images */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(132, 167, 199, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(132, 167, 199, 0.035) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.85;
  mask-image: radial-gradient(ellipse at 50% 20%, #000 0%, transparent 75%);
}

a {
  color: var(--qa-cyan);
}

a:hover {
  color: var(--qa-violet-bright);
}

.muted,
.hint,
.field-hint {
  color: var(--qa-text-muted);
}

.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;
}

.mono {
  font-family: var(--qa-mono);
}

/* Auth page shares the same deep surface (layout unchanged in stage 1) */
body.auth-body {
  background-color: var(--qa-bg-deep);
  background-image:
    radial-gradient(circle at 70% 0%, rgba(69, 49, 132, 0.14), transparent 36%),
    radial-gradient(circle at 15% 85%, rgba(25, 216, 255, 0.08), transparent 30%),
    linear-gradient(180deg, #020914 0%, #04101c 55%, #030b15 100%);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}

/* =========================================================
   Stage 2 — Shell layout (narrow rail sidebar + topbar)
   ========================================================= */

:root {
  --sidebar-width: var(--qa-sidebar-width);
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

.shell-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.sidebar {
  width: var(--qa-sidebar-width);
  background:
    linear-gradient(
      180deg,
      rgba(10, 28, 46, 0.18) 0%,
      rgba(6, 17, 31, 0.08) 55%,
      rgba(2, 9, 20, 0.04) 100%
    );
  border-right: 1px solid rgba(105, 151, 197, 0.1);
  box-shadow: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  height: auto;
  align-self: stretch;
  position: relative;
  top: auto;
}

.sidebar-brand {
  display: none !important;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background:
    linear-gradient(145deg, rgba(143, 77, 255, 0.28), rgba(25, 216, 255, 0.12));
  border: 1px solid rgba(169, 92, 255, 0.45);
  color: var(--qa-cyan);
  box-shadow: var(--qa-glow-violet);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  flex: 0 0 auto;
}

.brand-mark svg {
  display: block;
}

.brand-copy,
.brand-text,
.brand-tag {
  display: none !important;
}

.sidebar-nav {
  padding: 1.2rem 0.45rem 0.55rem;
  gap: 0.48rem;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 66px;
  padding: 0.55rem 0.4rem;
  border-radius: 10px;
  color: var(--qa-text-muted);
  position: relative;
  background: rgba(13, 32, 51, 0.28);
  border: 1px solid rgba(105, 151, 197, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition:
    background var(--qa-transition),
    color var(--qa-transition),
    border-color var(--qa-transition),
    box-shadow var(--qa-transition);
}

.nav-link:hover {
  background: rgba(16, 40, 61, 0.42);
  color: var(--qa-text-soft);
  text-decoration: none;
}

.nav-link.active {
  color: #f2f7ff;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 2px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

/* Soft alternating accents — adjacent tones stay distinct */
.nav-link.nav-tone-violet {
  color: #c9b0ff;
  border-color: rgba(143, 77, 255, 0.28);
  background:
    radial-gradient(circle at 50% 0%, rgba(143, 77, 255, 0.16), transparent 62%),
    rgba(13, 32, 51, 0.22);
}
.nav-link.nav-tone-violet:hover,
.nav-link.nav-tone-violet.active {
  color: #efe6ff;
  border-color: rgba(169, 92, 255, 0.55);
  background:
    radial-gradient(circle at 50% 0%, rgba(143, 77, 255, 0.28), transparent 64%),
    rgba(20, 28, 52, 0.4);
  box-shadow: 0 0 16px rgba(143, 77, 255, 0.22);
}

.nav-link.nav-tone-cyan {
  color: #8fe9ff;
  border-color: rgba(25, 216, 255, 0.26);
  background:
    radial-gradient(circle at 50% 0%, rgba(25, 216, 255, 0.14), transparent 62%),
    rgba(13, 32, 51, 0.22);
}
.nav-link.nav-tone-cyan:hover,
.nav-link.nav-tone-cyan.active {
  color: #e7fbff;
  border-color: rgba(25, 216, 255, 0.52);
  background:
    radial-gradient(circle at 50% 0%, rgba(25, 216, 255, 0.26), transparent 64%),
    rgba(10, 36, 48, 0.4);
  box-shadow: 0 0 16px rgba(25, 216, 255, 0.2);
}

.nav-link.nav-tone-blue {
  color: #8fbaff;
  border-color: rgba(39, 140, 255, 0.28);
  background:
    radial-gradient(circle at 50% 0%, rgba(39, 140, 255, 0.14), transparent 62%),
    rgba(13, 32, 51, 0.22);
}
.nav-link.nav-tone-blue:hover,
.nav-link.nav-tone-blue.active {
  color: #e8f1ff;
  border-color: rgba(39, 140, 255, 0.55);
  background:
    radial-gradient(circle at 50% 0%, rgba(39, 140, 255, 0.26), transparent 64%),
    rgba(12, 28, 52, 0.4);
  box-shadow: 0 0 16px rgba(39, 140, 255, 0.2);
}

.nav-link.nav-tone-pink {
  color: #ff8fd0;
  border-color: rgba(232, 64, 180, 0.3);
  background:
    radial-gradient(circle at 50% 0%, rgba(232, 64, 180, 0.15), transparent 62%),
    rgba(13, 32, 51, 0.22);
}
.nav-link.nav-tone-pink:hover,
.nav-link.nav-tone-pink.active {
  color: #ffe6f5;
  border-color: rgba(232, 64, 180, 0.56);
  background:
    radial-gradient(circle at 50% 0%, rgba(232, 64, 180, 0.28), transparent 64%),
    rgba(46, 14, 40, 0.42);
  box-shadow: 0 0 16px rgba(232, 64, 180, 0.22);
}

.nav-link.nav-tone-red {
  color: #ff7a7a;
  border-color: rgba(255, 58, 58, 0.32);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 58, 58, 0.15), transparent 62%),
    rgba(13, 32, 51, 0.22);
}
.nav-link.nav-tone-red:hover,
.nav-link.nav-tone-red.active {
  color: #ffe8e8;
  border-color: rgba(255, 58, 58, 0.6);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 58, 58, 0.28), transparent 64%),
    rgba(48, 14, 18, 0.44);
  box-shadow: 0 0 16px rgba(255, 58, 58, 0.24);
}

.nav-link.nav-tone-orange {
  color: #ffc083;
  border-color: rgba(255, 157, 46, 0.28);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 157, 46, 0.14), transparent 62%),
    rgba(13, 32, 51, 0.22);
}
.nav-link.nav-tone-orange:hover,
.nav-link.nav-tone-orange.active {
  color: #fff1df;
  border-color: rgba(255, 157, 46, 0.55);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 157, 46, 0.26), transparent 64%),
    rgba(46, 28, 12, 0.4);
  box-shadow: 0 0 16px rgba(255, 157, 46, 0.2);
}

.nav-link.nav-tone-green {
  color: #8ff0b0;
  border-color: rgba(67, 229, 122, 0.28);
  background:
    radial-gradient(circle at 50% 0%, rgba(67, 229, 122, 0.14), transparent 62%),
    rgba(13, 32, 51, 0.22);
}
.nav-link.nav-tone-green:hover,
.nav-link.nav-tone-green.active {
  color: #e8fff0;
  border-color: rgba(67, 229, 122, 0.55);
  background:
    radial-gradient(circle at 50% 0%, rgba(67, 229, 122, 0.26), transparent 64%),
    rgba(12, 40, 28, 0.4);
  box-shadow: 0 0 16px rgba(67, 229, 122, 0.2);
}

.nav-link.nav-tone-teal {
  color: #7fead4;
  border-color: rgba(44, 230, 183, 0.28);
  background:
    radial-gradient(circle at 50% 0%, rgba(44, 230, 183, 0.14), transparent 62%),
    rgba(13, 32, 51, 0.22);
}
.nav-link.nav-tone-teal:hover,
.nav-link.nav-tone-teal.active {
  color: #e6fffa;
  border-color: rgba(44, 230, 183, 0.55);
  background:
    radial-gradient(circle at 50% 0%, rgba(44, 230, 183, 0.26), transparent 64%),
    rgba(10, 40, 38, 0.4);
  box-shadow: 0 0 16px rgba(44, 230, 183, 0.2);
}

.nav-icon {
  display: inline-flex;
  color: inherit;
}

.nav-label {
  display: block;
  width: auto;
  max-width: calc(100% - 4px);
  box-sizing: border-box;
  margin: 0 auto;
  padding: 0;
  font-size: 8.2px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.sidebar-footer {
  display: none;
}

.sidebar-core {
  margin-top: auto;
  border-top: 1px solid rgba(132, 167, 199, 0.1);
  padding: 0.85rem 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  background: transparent;
}

.core-radar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(25, 216, 255, 0.35);
  box-shadow:
    inset 0 0 0 6px rgba(8, 22, 37, 0.9),
    inset 0 0 0 7px rgba(143, 77, 255, 0.35),
    0 0 14px rgba(25, 216, 255, 0.18);
  background:
    radial-gradient(circle at 50% 50%, rgba(25, 216, 255, 0.35) 0 2px, transparent 3px),
    conic-gradient(from 210deg, transparent 0 70%, rgba(143, 77, 255, 0.35) 0 78%, transparent 0);
}

.core-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.12rem;
  text-align: center;
}

.core-title {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--qa-text-soft);
  font-weight: 700;
}

.core-status {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 10px;
  color: var(--qa-mint);
}

.core-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--qa-green);
  box-shadow: 0 0 8px rgba(67, 229, 122, 0.7);
}

.core-version {
  font-size: 9px;
  color: var(--qa-text-disabled);
  letter-spacing: 0.04em;
}

.topbar {
  display: flex;
  align-items: center;
  min-height: 64px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 1.35rem;
  background: rgba(8, 22, 37, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--qa-border);
  gap: 0.85rem;
  position: sticky;
  top: 0;
  z-index: 50;
  flex: 0 0 auto;
}

.topbar-brand-slot {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
}

.topbar-title-block {
  display: none;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0 0 1.1rem;
}

.page-heading,
.page-title {
  margin: 0;
  font-family: var(--qa-font);
  font-size: 1.25rem;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: 0.01em;
  color: var(--qa-text-main);
}

.page-subtitle,
.overview-sub {
  margin: 0.35rem 0 0;
  font-family: var(--qa-font);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--qa-text-muted);
  max-width: 42rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-left: 0.15rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--qa-divider);
  align-self: center;
}

.user-chip {
  max-width: 180px;
  color: var(--qa-text-soft);
  font-size: 12px;
}

.content {
  padding: 1.5rem 1.65rem 2rem;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--qa-border);
  border-radius: var(--qa-radius-sm);
  color: var(--qa-text-soft);
}

.sidebar-backdrop {
  background: rgba(2, 9, 20, 0.62);
  backdrop-filter: blur(2px);
}

/* Primary action in topbar — accent only; size from .topbar-control */
.topbar-actions .btn-primary,
.overview-run-form .btn-primary {
  background: linear-gradient(135deg, #7a3dff 0%, #5a2fd4 55%, #2f6dff 100%);
  border: 1px solid rgba(169, 92, 255, 0.55);
  color: #f4ecff;
  box-shadow: var(--qa-glow-violet);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 12px;
  font-weight: 650;
}

.topbar-actions .btn-primary:hover,
.overview-run-form .btn-primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 0 22px rgba(143, 77, 255, 0.4);
}

.topbar-actions .compact-select {
  height: var(--qa-topbar-control-h, 42px);
  min-height: var(--qa-topbar-control-h, 42px);
  min-width: 160px;
  background: var(--qa-bg-panel-soft);
  border: 1px solid var(--qa-border);
  color: var(--qa-text-main);
  border-radius: var(--qa-topbar-control-radius, 8px);
  padding: 0 0.95rem;
  box-sizing: border-box;
}

@media (max-width: 800px) {
  .sidebar {
    width: min(240px, 84vw);
    transform: translateX(-105%);
    transition: transform var(--qa-transition);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.35);
    background:
      linear-gradient(
        180deg,
        rgba(8, 22, 37, 0.78) 0%,
        rgba(4, 14, 26, 0.72) 100%
      );
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-brand {
    display: none !important;
  }

  .brand-copy,
  .brand-text,
  .brand-tag {
    display: none !important;
  }

  .sidebar-nav {
    padding-top: 1rem;
  }

  .nav-link {
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.75rem;
    min-height: 48px;
    padding: 0.65rem 0.85rem;
  }

  .nav-link.active::before {
    top: 20%;
    bottom: 20%;
  }

  .nav-label {
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: none;
  }

  .sidebar-core {
    flex-direction: row;
    justify-content: flex-start;
    padding: 0.85rem 1rem;
  }

  .core-meta {
    align-items: flex-start;
    text-align: left;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .topbar {
    min-height: 64px;
    padding: 0.65rem 0.85rem;
    flex-wrap: wrap;
  }

  .topbar-user {
    border-left: none;
    padding-left: 0;
    width: 100%;
    order: 5;
    justify-content: space-between;
  }

  .content {
    padding: 1rem;
  }

  html,
  body {
    overflow-x: hidden;
  }
}

@media (min-width: 1100px) {
  /* brand tagline lives in topbar only */
}

/* =========================================================
   Stage 3 — Panels / futuristic frames
   ========================================================= */

.panel,
.qa-panel {
  position: relative;
  background:
    linear-gradient(180deg, rgba(13, 32, 51, 0.92) 0%, rgba(8, 22, 37, 0.96) 100%);
  border: 1px solid var(--qa-border);
  border-radius: 12px;
  padding: 1.15rem 1.2rem;
  box-shadow: var(--qa-shadow-panel);
  overflow: hidden;
}

.panel::before,
.qa-panel::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 8px;
  width: 12px;
  height: 12px;
  border-left: 1.5px solid rgba(25, 216, 255, 0.55);
  border-top: 1.5px solid rgba(25, 216, 255, 0.55);
  opacity: 0.8;
  pointer-events: none;
}

.panel::after,
.qa-panel::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 12px;
  height: 12px;
  border-right: 1.5px solid rgba(143, 77, 255, 0.45);
  border-bottom: 1.5px solid rgba(143, 77, 255, 0.45);
  opacity: 0.75;
  pointer-events: none;
}

.qa-panel--violet::before { border-color: rgba(169, 92, 255, 0.75); }
.qa-panel--cyan::before { border-color: rgba(25, 216, 255, 0.75); }
.qa-panel--pink::before { border-color: rgba(255, 79, 163, 0.75); }
.qa-panel--orange::before { border-color: rgba(255, 157, 46, 0.75); }
.qa-panel--green::before { border-color: rgba(67, 229, 122, 0.75); }

.panel-header {
  margin-bottom: 0.9rem;
  gap: 0.75rem;
}

.panel-header h2 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--qa-text-main);
}

.panel-header h2::before {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--qa-violet-bright), var(--qa-cyan));
  box-shadow: 0 0 8px rgba(143, 77, 255, 0.45);
}

.qa-panel-interactive:hover,
a.qa-panel:hover {
  border-color: var(--qa-border-strong);
  transform: translateY(-1px);
  transition: border-color var(--qa-transition), transform var(--qa-transition);
}

/* =========================================================
   Stage 4 — KPI cards
   ========================================================= */

.stats-grid.kpi-strip {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 1rem;
}

.stat-card {
  position: relative;
  min-height: 56px;
  height: 100%;
  padding: 8px 12px;
  border-radius: 9px;
  background: linear-gradient(160deg, rgba(13, 32, 51, 0.95), rgba(8, 22, 37, 0.98));
  border: 1px solid var(--qa-border);
  box-shadow: var(--qa-shadow-panel);
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  opacity: 0.85;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
}

.stat-card-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.stat-icon {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid currentColor;
  background: rgba(255, 255, 255, 0.03);
  opacity: 0.95;
}

.stat-icon svg {
  width: 15px;
  height: 15px;
}

.stat-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.stat-label {
  color: var(--qa-text-muted);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
  text-align: left;
}

.stat-card.tone-blue,
.stat-card.kpi-projects {
  color: var(--qa-violet-bright);
  border-color: rgba(143, 77, 255, 0.35);
  background:
    radial-gradient(circle at 100% 0%, rgba(143, 77, 255, 0.14), transparent 46%),
    linear-gradient(160deg, rgba(13, 32, 51, 0.95), rgba(8, 22, 37, 0.98));
}
.stat-card.kpi-projects .stat-value { color: #d7c2ff; }

.stat-card.tone-neutral,
.stat-card.kpi-runs {
  color: var(--qa-cyan);
  border-color: rgba(25, 216, 255, 0.32);
  background:
    radial-gradient(circle at 100% 0%, rgba(25, 216, 255, 0.12), transparent 46%),
    linear-gradient(160deg, rgba(13, 32, 51, 0.95), rgba(8, 22, 37, 0.98));
}
.stat-card.kpi-runs .stat-value { color: #b8f4ff; }

.stat-card.tone-slate,
.stat-card.kpi-new {
  color: #ff5fb3;
  border-color: rgba(255, 79, 163, 0.38);
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 79, 163, 0.14), transparent 46%),
    linear-gradient(160deg, rgba(13, 32, 51, 0.95), rgba(8, 22, 37, 0.98));
}
.stat-card.kpi-new .stat-value { color: #ffc2e2; }

.stat-card.tone-danger,
.stat-card.kpi-critical {
  color: #ff4d63;
  border-color: rgba(255, 55, 80, 0.42);
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 45, 75, 0.16), transparent 46%),
    linear-gradient(160deg, rgba(13, 32, 51, 0.95), rgba(8, 22, 37, 0.98));
}
.stat-card.kpi-critical .stat-value { color: #ffb0ba; }

.stat-card.tone-amber,
.stat-card.kpi-progress {
  color: #ff9a2e;
  border-color: rgba(255, 140, 30, 0.4);
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 140, 30, 0.14), transparent 46%),
    linear-gradient(160deg, rgba(13, 32, 51, 0.95), rgba(8, 22, 37, 0.98));
}
.stat-card.kpi-progress .stat-value { color: #ffd2a0; }

.stat-card.tone-warning,
.stat-card.kpi-retest {
  color: #f0c53a;
  border-color: rgba(232, 190, 40, 0.4);
  background:
    radial-gradient(circle at 100% 0%, rgba(240, 197, 58, 0.14), transparent 46%),
    linear-gradient(160deg, rgba(13, 32, 51, 0.95), rgba(8, 22, 37, 0.98));
}
.stat-card.kpi-retest .stat-value { color: #ffe7a0; }

.stat-card.tone-success,
.stat-card.kpi-resolved {
  color: #3ee57a;
  border-color: rgba(55, 220, 120, 0.38);
  background:
    radial-gradient(circle at 100% 0%, rgba(55, 220, 120, 0.14), transparent 46%),
    linear-gradient(160deg, rgba(13, 32, 51, 0.95), rgba(8, 22, 37, 0.98));
}
.stat-card.kpi-resolved .stat-value { color: #b5f5cb; }

.stat-card.tone-rose,
.stat-card.kpi-reopened {
  color: #3f8fff;
  border-color: rgba(55, 130, 255, 0.4);
  background:
    radial-gradient(circle at 100% 0%, rgba(55, 130, 255, 0.14), transparent 46%),
    linear-gradient(160deg, rgba(13, 32, 51, 0.95), rgba(8, 22, 37, 0.98));
}
.stat-card.kpi-reopened .stat-value { color: #b5d4ff; }

/* Desktop ≥1200px: всегда 1 ряд × 8 колонок (перебивает app.css 1280/1400) */
@media (min-width: 1200px) {
  .stats-grid.kpi-strip,
  .kpi-strip {
    display: grid !important;
    grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .stats-grid.kpi-strip .stat-card {
    min-height: 56px !important;
    max-height: 60px;
    padding: 8px 12px !important;
  }
}

@media (max-width: 1199px) and (min-width: 1100px) {
  .stats-grid.kpi-strip,
  .kpi-strip {
    grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
}

@media (max-width: 1099px) and (min-width: 800px) {
  .stats-grid.kpi-strip,
  .kpi-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 799px) and (min-width: 520px) {
  .stats-grid.kpi-strip,
  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 519px) {
  .stats-grid.kpi-strip,
  .kpi-strip {
    grid-template-columns: 1fr !important;
  }
}

/* =========================================================
   Stage 5 — Overview composition helpers
   ========================================================= */

.overview-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.15rem;
  flex-wrap: wrap;
}

.overview-hero .page-title,
.overview-hero .page-heading {
  margin: 0;
}

.overview-hero .overview-lead {
  margin: 0;
  color: #ffffff;
  font-family: var(--qa-font);
  font-size: 1.28rem;
  font-weight: 560;
  line-height: 1.35;
  letter-spacing: 0.01em;
  max-width: 46rem;
}

.overview-hero h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 650;
  color: var(--qa-text-main);
}

.overview-sub {
  display: none;
}

.period-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 36px;
  padding: 0 0.75rem;
  border-radius: var(--qa-radius-sm);
  border: 1px solid var(--qa-border);
  background: var(--qa-bg-panel-soft);
  color: var(--qa-text-soft);
  font-size: 12px;
}

.overview-main-grid,
.overview-lower-grid,
.panels-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.15rem;
  margin-bottom: 1.15rem;
}

@media (max-width: 1024px) {
  .overview-main-grid,
  .overview-lower-grid,
  .panels-grid {
    grid-template-columns: 1fr;
  }
}

.data-table {
  font-size: 12.75px;
}

.data-table th {
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--qa-text-muted);
  border-bottom: 1px solid var(--qa-divider);
}

.data-table td {
  border-bottom: 1px solid var(--qa-divider);
  height: 42px;
  vertical-align: middle;
}

.data-table tbody tr:hover td {
  background: rgba(16, 40, 61, 0.45);
}

.table-link-row td:last-child {
  width: 28px;
  color: var(--qa-text-muted);
}

.badge {
  border-radius: 6px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 0.45rem;
  font-size: 10.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.03);
}

.badge-failed,
.badge-error {
  color: #ffb0bf;
  border-color: rgba(255, 85, 109, 0.45);
  background: rgba(255, 85, 109, 0.1);
  box-shadow: 0 0 10px rgba(255, 85, 109, 0.12);
}

.badge-passed,
.badge-success {
  color: #9ff0bc;
  border-color: rgba(67, 229, 122, 0.4);
  background: rgba(67, 229, 122, 0.1);
}

.badge-running {
  color: #ffd59a;
  border-color: rgba(255, 173, 50, 0.4);
  background: rgba(255, 173, 50, 0.1);
}

.badge-queued,
.badge-pending {
  color: #9eecff;
  border-color: rgba(25, 216, 255, 0.35);
  background: rgba(25, 216, 255, 0.08);
}

.unstable-list,
.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.unstable-item,
.rank-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem 0.85rem;
  align-items: center;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--qa-divider);
}

.unstable-name,
.rank-name {
  font-size: 13px;
  color: var(--qa-text-main);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spark-bar {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 16px;
}

.spark-bar span {
  width: 4px;
  border-radius: 1px;
  background: var(--qa-violet);
  opacity: 0.25;
}

.spark-bar span.on {
  opacity: 0.9;
  background: linear-gradient(180deg, var(--qa-pink), var(--qa-violet));
}

.rank-track {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.rank-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--qa-pink), var(--qa-violet));
}

.overview-status-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.35rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--qa-border);
  border-radius: 12px;
  background: rgba(8, 22, 37, 0.88);
}

.status-metric {
  min-width: 0;
}

.status-metric .label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--qa-text-muted);
  margin-bottom: 0.2rem;
}

.status-metric .value {
  font-size: 12.5px;
  color: var(--qa-text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1024px) {
  .overview-status-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  .overview-status-bar {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   Stage 6–7 — Tables polish, buttons, forms
   ========================================================= */

.btn {
  border-radius: var(--qa-radius-sm);
  transition: background var(--qa-transition), border-color var(--qa-transition), box-shadow var(--qa-transition), filter var(--qa-transition);
}

.btn-primary,
.qa-btn-primary {
  background: linear-gradient(135deg, #7a3dff 0%, #5b36d8 60%, #2f6dff 100%);
  border: 1px solid rgba(169, 92, 255, 0.5);
  color: #f6f0ff;
  box-shadow: var(--qa-glow-violet);
}

.btn-secondary,
.qa-btn-secondary {
  background: rgba(11, 27, 45, 0.9);
  border: 1px solid var(--qa-border);
  color: var(--qa-text-soft);
}

.btn-secondary:hover,
.qa-btn-secondary:hover {
  border-color: var(--qa-border-strong);
  color: var(--qa-cyan);
}

.btn-danger,
.qa-btn-danger {
  background: rgba(255, 85, 109, 0.12);
  border: 1px solid rgba(255, 85, 109, 0.45);
  color: #ffc0cb;
}

.btn-ghost,
.qa-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--qa-text-soft);
}

.btn-ghost:hover,
.qa-btn-ghost:hover {
  background: rgba(16, 40, 61, 0.7);
}

.btn-sm { min-height: 30px; }
.btn:not(.btn-sm):not(.btn-block) { min-height: 38px; }

.field span {
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--qa-text-muted);
}

.field input,
.field select,
.field textarea,
.filters-form input,
.filters-form select,
.compact-select,
.compact-input {
  background: #071725;
  border: 1px solid var(--qa-border);
  color: var(--qa-text-main);
  border-radius: var(--qa-radius-sm);
  min-height: 38px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.filters-form input:focus,
.filters-form select:focus,
.compact-select:focus,
.compact-input:focus {
  outline: none;
  border-color: rgba(25, 216, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(143, 77, 255, 0.15);
}

.alert-error {
  background: rgba(255, 85, 109, 0.1);
  border: 1px solid rgba(255, 85, 109, 0.4);
  color: #ffc2cd;
}

.alert-success {
  background: rgba(67, 229, 122, 0.1);
  border: 1px solid rgba(67, 229, 122, 0.35);
  color: #b8f5cd;
}

.alert-info {
  background: rgba(25, 216, 255, 0.08);
  border: 1px solid rgba(25, 216, 255, 0.3);
  color: #b8f4ff;
}

/* =========================================================
   Stage 8 — Login
   ========================================================= */

body.auth-body {
  display: block;
  min-height: 100vh;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.85fr);
  min-height: 100vh;
  width: 100%;
}

.auth-visual {
  position: relative;
  padding: 2.5rem 2.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.5rem;
  border-right: 1px solid var(--qa-border);
  overflow: hidden;
}

.auth-visual::before {
  content: "";
  position: absolute;
  inset: 12% auto auto 12%;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  border: 1px solid rgba(25, 216, 255, 0.2);
  box-shadow:
    inset 0 0 0 40px rgba(2, 9, 20, 0.35),
    inset 0 0 0 41px rgba(143, 77, 255, 0.2);
  pointer-events: none;
}

.auth-visual-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
  z-index: 1;
}

.auth-visual h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: 0.02em;
}

.auth-visual-lead {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 28rem;
  color: var(--qa-text-soft);
  font-size: 14px;
}

.auth-points {
  position: relative;
  z-index: 1;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.auth-points li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--qa-text-soft);
  font-size: 13px;
}

.auth-points li::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--qa-cyan);
  box-shadow: 0 0 10px rgba(25, 216, 255, 0.55);
}

.auth-card {
  width: min(420px, 92vw);
  margin: auto;
  background: rgba(8, 22, 37, 0.88);
  border: 1px solid var(--qa-border-strong);
  border-radius: 14px;
  padding: 1.5rem 1.4rem 1.35rem;
  box-shadow: var(--qa-shadow-panel), var(--qa-glow-violet);
  position: relative;
}

.auth-card::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(169, 92, 255, 0.7), rgba(25, 216, 255, 0.55), transparent);
}

.auth-brand { text-align: left; margin-bottom: 1rem; }
.auth-brand h1 { margin: 0.35rem 0 0.2rem; font-size: 1.2rem; }
.auth-form .btn-primary { min-height: 42px; }

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-card { margin: 2rem auto; }
}

/* =========================================================
   Stages 9–12 — Domain pages via existing classes
   ========================================================= */

.breadcrumbs {
  color: var(--qa-text-muted);
  font-size: 12px;
  margin-bottom: 0.85rem;
}

.step-card {
  background: rgba(11, 27, 45, 0.92);
  border: 1px solid var(--qa-border);
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.step-num {
  background: rgba(143, 77, 255, 0.18);
  color: #e4d2ff;
  border: 1px solid rgba(143, 77, 255, 0.35);
}

.run-scenario {
  background: rgba(11, 27, 45, 0.92);
  border: 1px solid var(--qa-border);
  border-radius: 10px;
}

.timeline {
  border-left: 2px solid rgba(104, 171, 229, 0.25);
}

.timeline li::before {
  background: var(--qa-cyan);
  box-shadow: 0 0 8px rgba(25, 216, 255, 0.45);
}

.status-form,
.assign-form,
.filters-panel {
  background: rgba(8, 22, 37, 0.9);
  border: 1px solid var(--qa-border);
  border-radius: 10px;
}

.shot-preview,
.video-preview,
.code-block {
  border-color: var(--qa-border);
  background: #06111f;
}

.danger-zone {
  border-top: 1px solid rgba(255, 85, 109, 0.28);
}

/* =========================================================
   Stage 13 — Micro-interactions (reduced-motion safe)
   ========================================================= */

@media (prefers-reduced-motion: no-preference) {
  .nav-link,
  .btn,
  .stat-card,
  .panel {
    transition: background var(--qa-transition), border-color var(--qa-transition),
      box-shadow var(--qa-transition), transform var(--qa-transition), color var(--qa-transition);
  }

  .core-dot {
    animation: qa-pulse 2.4s ease-in-out infinite;
  }

  .badge-running {
    animation: qa-pulse 1.8s ease-in-out infinite;
  }
}

@keyframes qa-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
  .core-dot,
  .badge-running {
    animation: none !important;
  }
}

/* =========================================================
   Stage 14 — Responsive polish
   ========================================================= */

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.app-shell {
  width: 100%;
  max-width: 100vw;
}

.main-wrap {
  min-width: 0;
  max-width: 100%;
}

.content {
  min-width: 0;
  max-width: 100%;
}

.page-header .page-heading,
.page-header .page-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 100%;
}

.topbar-title-block {
  display: none;
}

.topbar-actions {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.topbar-actions .compact-select {
  max-width: min(220px, 36vw);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.form-actions,
.inline-run-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

/* Laptop 1366×768 band */
@media (max-width: 1400px) and (min-width: 801px) {
  :root {
    --qa-sidebar-width: 84px;
  }

  .topbar {
    min-height: 60px;
    padding: 0 0.9rem 0 0.75rem;
  }

  .topbar-actions .compact-select {
    min-width: 140px;
    max-width: 180px;
  }

  .user-chip {
    max-width: 140px;
  }

  .qa-panel,
  .panel {
    max-height: none;
  }

  .stats-grid.kpi-strip {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

/* Tablet band handled by stage-4 KPI breakpoints (≤1099 → 4 cols) */
@media (max-width: 1024px) and (min-width: 801px) {
  .filters-form,
  .form-grid,
  .two-col-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 800px) {
  .sidebar {
    position: fixed;
    z-index: 40;
    height: 100vh;
    height: 100dvh;
  }

  .sidebar-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
  }

  .overview-main-grid,
  .overview-lower-grid,
  .panels-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid.kpi-strip {
    /* breakpoints unified in stage-4 KPI section */
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inline-run-form {
    width: 100%;
  }

  .inline-run-form .compact-select,
  .topbar-actions .compact-select {
    max-width: 100%;
    min-width: 0;
    flex: 1 1 140px;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .btn,
  .inline-run-form .btn {
    width: 100%;
  }

  .filters-form,
  .form-grid,
  .two-col-form,
  .field-row {
    grid-template-columns: 1fr;
  }

  .modal,
  .modal-dialog,
  .dialog-panel {
    max-width: calc(100vw - 1.5rem);
    max-height: calc(100dvh - 2rem);
    overflow: auto;
  }
}

/* Mobile */
@media (max-width: 519px) {
  .stats-grid.kpi-strip {
    grid-template-columns: 1fr;
    overflow-x: visible;
  }

  .page-heading {
    font-size: 1.05rem;
  }

  .topbar-actions {
    width: 100%;
    order: 4;
  }

  .user-chip {
    max-width: 46vw;
  }

  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    display: none !important;
  }

  .auth-card {
    width: min(100%, 100vw - 1.5rem);
    margin: 1.25rem auto;
  }

  .btn,
  .btn-block {
    max-width: 100%;
  }
}

/* =========================================================
   Stage 15 — Accessibility
   ========================================================= */

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 100;
  padding: 0.55rem 0.85rem;
  border-radius: var(--qa-radius-sm);
  background: var(--qa-bg-elevated);
  color: var(--qa-text-main);
  border: 1px solid var(--qa-border-strong);
  transform: translateY(-160%);
  transition: transform var(--qa-transition);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  outline: 2px solid var(--qa-cyan);
  outline-offset: 2px;
}

:focus-visible {
  outline: 2px solid rgba(25, 216, 255, 0.85);
  outline-offset: 2px;
}

.btn:focus:not(:focus-visible),
.nav-link:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

.badge {
  font-weight: 600;
}

.core-status-text {
  color: var(--qa-mint);
}

#main-content:focus {
  outline: none;
}

#main-content:focus-visible {
  outline: 2px solid rgba(25, 216, 255, 0.45);
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .skip-link {
    transition: none;
  }

  .sidebar {
    transition: none !important;
  }
}

/* =========================================================
   Global topbar brand + unified controls
   ========================================================= */

:root {
  --qa-topbar-control-h: 42px;
  --qa-topbar-control-radius: 8px;
  --qa-font-brand: "Oxanium", "Segoe UI", system-ui, sans-serif;
  --qa-font-brand-soft: "Exo 2", "Segoe UI", system-ui, sans-serif;
}

.topbar {
  align-items: center;
}

.topbar-product-brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  min-width: 230px;
  line-height: 1;
}

.topbar-product-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  gap: 0.28rem;
}

.topbar-product-name {
  font-family: var(--qa-font-brand);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #eef5ff;
  text-shadow: 0 0 16px rgba(25, 216, 255, 0.16);
  white-space: nowrap;
  line-height: 1.05;
}

.topbar-product-tagline,
.topbar-product-tag {
  margin-top: 0;
  font-family: var(--qa-font-brand-soft);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.62;
  color: var(--qa-text-soft);
  white-space: nowrap;
  line-height: 1.1;
}

.topbar .brand-mark {
  margin: 0;
}

/* Unified control rhythm for the whole top row */
.topbar-control,
.topbar-actions > .btn,
.topbar-actions .btn,
.overview-run-form > .btn,
.topbar-project-zone.topbar-control {
  box-sizing: border-box;
  height: var(--qa-topbar-control-h);
  min-height: var(--qa-topbar-control-h);
  max-height: var(--qa-topbar-control-h);
  border-radius: var(--qa-topbar-control-radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.95rem;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  vertical-align: middle;
}

.logout-form {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

.topbar-user .user-chip.topbar-control {
  justify-content: flex-start;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid rgba(104, 171, 229, 0.28);
  background:
    linear-gradient(180deg, rgba(13, 32, 51, 0.88), rgba(8, 22, 37, 0.94));
  color: var(--qa-text-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  cursor: default;
}

.topbar-user .topbar-logout.topbar-control {
  border: 1px solid rgba(104, 171, 229, 0.28);
  background:
    linear-gradient(180deg, rgba(13, 32, 51, 0.72), rgba(8, 22, 37, 0.86));
  color: var(--qa-text-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  text-transform: none;
  letter-spacing: 0.02em;
}

.topbar-user .topbar-logout.topbar-control:hover {
  color: #eaf2ff;
  border-color: rgba(25, 216, 255, 0.4);
  text-decoration: none;
}

.topbar-project-zone.topbar-control {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  padding: 0 0.55rem 0 0.75rem;
  border: 1px solid rgba(104, 171, 229, 0.35);
  background:
    linear-gradient(180deg, rgba(13, 32, 51, 0.96), rgba(8, 22, 37, 0.98));
  box-shadow: inset 0 0 0 1px rgba(25, 216, 255, 0.04), 0 0 14px rgba(39, 140, 255, 0.08);
}

.topbar-project-label {
  flex: 0 0 auto;
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--qa-text-muted);
  margin: 0;
  padding: 0 0.55rem 0 0;
  border-right: 1px solid rgba(132, 167, 199, 0.22);
  line-height: 1;
  white-space: nowrap;
}

.topbar-project-select,
.overview-run-form .topbar-project-select {
  appearance: none;
  -webkit-appearance: none;
  flex: 1 1 auto;
  height: 100%;
  min-width: 140px;
  max-width: 220px;
  margin: 0;
  padding: 0 1.7rem 0 0.15rem;
  border: 0;
  border-radius: 0;
  background:
    transparent
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236f879e' d='M1 1l5 5 5-5'/%3E%3C/svg%3E")
      right 0.35rem center / 10px no-repeat;
  color: #e8f1ff;
  font-family: var(--qa-font);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: none;
  cursor: pointer;
  outline: none;
}

.topbar-project-zone.topbar-control:focus-within {
  border-color: rgba(25, 216, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(143, 77, 255, 0.16);
}

.topbar-project-select:focus,
.topbar-project-select:focus-visible {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

.overview-run-form {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.overview-run-form .btn-primary.topbar-control {
  align-self: center;
  height: var(--qa-topbar-control-h);
  min-height: var(--qa-topbar-control-h);
  max-height: var(--qa-topbar-control-h);
  padding: 0 1rem;
  border-radius: var(--qa-topbar-control-radius);
}

@media (max-width: 800px) {
  .topbar-product-brand {
    min-width: 0;
    gap: 0.55rem;
  }

  .topbar-product-name {
    font-size: 0.95rem;
    letter-spacing: 0.1em;
  }

  .topbar-product-tagline,
  .topbar-product-tag {
    display: none;
  }

  .topbar .brand-mark {
    width: 32px;
    height: 32px;
  }

  .page-heading,
  .page-title {
    font-size: 1.15rem;
  }

  .topbar-project-zone.topbar-control {
    width: 100%;
    max-width: 100%;
  }

  .topbar-project-select,
  .overview-run-form .topbar-project-select {
    min-width: 0;
    max-width: none;
    width: 100%;
    font-size: 11px;
  }

  .overview-run-form {
    width: 100%;
    align-items: stretch;
  }

  .overview-run-form .btn-primary {
    width: 100%;
  }
}

/* =========================================================
   Overview compact workspace (viewport-fit panels)
   ========================================================= */

:root {
  --qa-topbar-h: 64px;
  --qa-overview-row: 36px;
  --qa-overview-main-max: calc(var(--qa-overview-row) * 8 + 34px);
  --qa-overview-lower-max: 168px;
}

.overview-page {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.overview-workspace {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
}

.overview-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.overview-panel > .panel-header {
  flex: 0 0 auto;
  margin-bottom: 0.55rem;
}

.overview-panel > .panel-header h2 {
  font-size: 0.9rem;
}

.overview-panel > .panel-header h2::before {
  height: 12px;
}

.overview-ellipsis,
.overview-ellipsis a {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-compact-table th {
  height: 28px;
  padding: 0.2rem 0.45rem;
  font-size: 10px;
  line-height: 1.2;
}

.overview-compact-table td {
  height: var(--qa-overview-row);
  padding: 0.2rem 0.45rem;
  line-height: 1.2;
  white-space: nowrap;
  vertical-align: middle;
}

.overview-compact-table .badge {
  height: 20px;
  padding: 0 0.4rem;
  font-size: 10px;
}

.table-scroll,
.panel-scroll {
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.table-scroll {
  overflow: auto;
}

.panel-scroll {
  overflow: auto;
}

@media (min-width: 1100px) {
  body:has(.overview-page) {
    overflow: hidden;
  }

  body:has(.overview-page) .app-shell {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
  }

  body:has(.overview-page) .shell-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  body:has(.overview-page) .main-wrap {
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  body:has(.overview-page) .content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow: hidden;
    padding-top: 1rem;
    padding-bottom: 0.85rem;
  }

  body:has(.overview-page) .overview-hero {
    flex: 0 0 auto;
    margin-bottom: 0.7rem;
  }

  body:has(.overview-page) .overview-sub {
    margin-top: 0.2rem;
  }

  .overview-page {
    flex: 1 1 auto;
    min-height: 0;
  }

  .overview-page > .kpi-strip {
    flex: 0 0 auto;
    margin-bottom: 0.75rem;
  }

  .overview-workspace {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1.4fr) minmax(0, 0.7fr);
    gap: 0.75rem;
    margin-bottom: 0.65rem;
  }

  .overview-main-grid,
  .overview-lower-grid {
    margin-bottom: 0;
    min-height: 0;
    height: 100%;
    gap: 0.75rem;
  }

  .overview-main-grid > .overview-panel,
  .overview-lower-grid > .overview-panel {
    height: 100%;
    max-height: 100%;
    padding: 0.7rem 0.85rem;
  }

  .overview-main-grid .table-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-height: var(--qa-overview-main-max);
  }

  .overview-lower-grid .panel-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-height: var(--qa-overview-lower-max);
  }

  .overview-compact-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(8, 22, 37, 0.96);
    backdrop-filter: blur(4px);
  }

  .overview-lower-grid .unstable-list,
  .overview-lower-grid .rank-list {
    gap: 0.28rem;
  }

  .overview-lower-grid .unstable-item,
  .overview-lower-grid .rank-item {
    padding: 0.2rem 0;
    gap: 0.3rem 0.65rem;
  }

  .overview-lower-grid .unstable-name,
  .overview-lower-grid .rank-name {
    font-size: 12px;
  }

  .overview-lower-grid .unstable-item > .muted {
    font-size: 11px;
  }

  .overview-lower-grid .spark-bar {
    height: 12px;
  }

  .overview-lower-grid .rank-track {
    height: 5px;
  }

  .overview-page > .overview-status-bar {
    flex: 0 0 auto;
    margin-top: 0;
    padding: 0.55rem 0.85rem;
  }

  .overview-page .status-metric .label {
    margin-bottom: 0.1rem;
  }

  .overview-page .status-metric .value {
    font-size: 12px;
  }
}

/* 1440 / 1366 laptop: keep fit, slightly tighter rows */
@media (min-width: 1100px) and (max-height: 900px) {
  :root {
    --qa-overview-row: 34px;
    --qa-overview-main-max: calc(var(--qa-overview-row) * 7 + 30px);
    --qa-overview-lower-max: 140px;
  }

  body:has(.overview-page) .content {
    padding-top: 0.75rem;
    padding-bottom: 0.65rem;
  }

  body:has(.overview-page) .overview-hero {
    margin-bottom: 0.5rem;
  }

  .overview-page > .kpi-strip {
    margin-bottom: 0.55rem;
  }

  .overview-workspace {
    gap: 0.55rem;
    margin-bottom: 0.5rem;
  }

  .overview-main-grid,
  .overview-lower-grid {
    gap: 0.55rem;
  }

  .overview-main-grid > .overview-panel,
  .overview-lower-grid > .overview-panel {
    padding: 0.55rem 0.7rem;
  }
}

@media (min-width: 1100px) and (max-height: 768px) {
  :root {
    --qa-overview-row: 34px;
    --qa-overview-main-max: calc(var(--qa-overview-row) * 6 + 28px);
    --qa-overview-lower-max: 120px;
    --qa-topbar-h: 60px;
  }

  .overview-page > .kpi-strip .stat-card {
    min-height: 48px;
    padding: 6px 10px;
  }

  .overview-page > .kpi-strip .stat-value {
    font-size: 18px;
  }

  .overview-page > .overview-status-bar {
    padding: 0.4rem 0.7rem;
  }
}

/* Tablet / mobile: normal flow, soft internal scroll only */
@media (max-width: 1099px) {
  body:has(.overview-page) {
    overflow: auto;
  }

  body:has(.overview-page) .app-shell,
  body:has(.overview-page) .shell-body,
  body:has(.overview-page) .main-wrap {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  body:has(.overview-page) .content {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .overview-workspace {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
  }

  .overview-main-grid,
  .overview-lower-grid {
    height: auto;
  }

  .overview-main-grid > .overview-panel,
  .overview-lower-grid > .overview-panel {
    height: auto;
    max-height: none;
  }

  .overview-main-grid .table-scroll {
    max-height: min(320px, 45vh);
  }

  .overview-lower-grid .panel-scroll {
    max-height: min(220px, 35vh);
  }
}

/* =========================================================
   Global page spacing scale + pagination
   ========================================================= */

:root {
  --qa-space-xs: 8px;
  --qa-space-sm: 12px;
  --qa-space-md: 16px;
  --qa-space-lg: 20px;
  --qa-space-xl: 24px;
}

.content {
  display: flex;
  flex-direction: column;
  gap: var(--qa-space-lg);
}

.content > .page-header,
.content > .overview-hero,
.content > .alert,
.content > .stats-grid,
.content > .kpi-strip,
.content > .compact-stats,
.content > .panel,
.content > .filters-panel,
.content > .filters-bar,
.content > .overview-page,
.content > .overview-main-grid,
.content > .overview-lower-grid,
.content > .overview-status-bar {
  margin-top: 0;
  margin-bottom: 0;
}

.page-header,
.overview-hero {
  margin-bottom: 0;
}

.stats-grid,
.stats-grid.kpi-strip,
.kpi-strip,
.compact-stats,
.panels-grid,
.overview-main-grid,
.overview-lower-grid {
  gap: var(--qa-space-md);
}

.stats-grid.kpi-strip,
.kpi-strip,
.compact-stats {
  gap: var(--qa-space-sm);
  margin-bottom: 0;
}

.panels-grid,
.overview-main-grid,
.overview-lower-grid {
  gap: var(--qa-space-lg);
  margin-bottom: 0;
}

.filters-panel,
.filters-bar,
.panel.filters-panel,
.panel.filters-bar {
  margin-bottom: 0;
}

.filters-row,
.filters-form {
  gap: var(--qa-space-sm);
}

.table-section .table-wrap {
  margin-bottom: 0;
}

.table-section .pagination-bar {
  margin-top: var(--qa-space-md);
}

.panel + .panel,
.filters-panel + .panel,
.filters-bar + .panel,
.stats-grid + .panel,
.compact-stats + .panel,
.compact-stats + .filters-panel {
  /* spacing handled by .content flex gap */
}

.detail-stack,
.page-stack,
.section-stack {
  display: flex;
  flex-direction: column;
  gap: var(--qa-space-lg);
}

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--qa-space-sm);
  padding-top: var(--qa-space-sm);
  border-top: 1px solid var(--qa-divider);
}

.pagination-meta {
  font-size: 12px;
}

.pagination-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.pagination-controls .btn[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
}

.pagination-current {
  pointer-events: none;
}

.pagination-ellipsis {
  color: var(--qa-text-muted);
  padding: 0 0.2rem;
  font-size: 12px;
}

/* Overview: keep compact internal rhythm, but separate major blocks */
body:has(.overview-page) .content {
  gap: var(--qa-space-md);
}

body:has(.overview-page) .overview-page > .kpi-strip {
  margin-bottom: var(--qa-space-md);
}

body:has(.overview-page) .overview-workspace {
  gap: var(--qa-space-md);
  margin-bottom: var(--qa-space-md);
}

@media (max-width: 800px) {
  .content {
    gap: var(--qa-space-md);
  }

  .stats-grid,
  .stats-grid.kpi-strip,
  .kpi-strip,
  .compact-stats,
  .panels-grid {
    gap: var(--qa-space-sm);
  }

  .pagination-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination-controls {
    justify-content: flex-start;
  }
}

