@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== Design Tokens — PlanA Palette ===== */
:root {
  /* Brand */
  --clr-primary:       #DB0032;
  --clr-primary-dark:  #a80026;
  --clr-primary-light: #ff4466;
  --clr-secondary:     #1d252c;
  --clr-accent:        #1d252c;
  /* Semantic */
  --clr-success:       #16a34a;
  --clr-danger:        #DB0032;
  --clr-warning:       #d97706;
  /* Text */
  --clr-text:          #1d252c;
  --clr-text-2:        #555555;
  --clr-muted:         #8E8E8E;
  /* Surfaces */
  --clr-surface:       #ffffff;
  --clr-surface-2:     #f6f6f6;
  --clr-border:        #e3e3e3;
  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(29,37,44,.06), 0 1px 2px rgba(29,37,44,.03);
  --shadow-md:  0 4px 16px rgba(219,0,50,.07), 0 2px 6px rgba(29,37,44,.04);
  --shadow-lg:  0 20px 48px rgba(219,0,50,.1), 0 8px 20px rgba(29,37,44,.06);
  --shadow-primary: 0 8px 28px rgba(219,0,50,.28);
  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --ease-spring: cubic-bezier(0.34,1.56,0.64,1);
  /* Page layout — matches .app-header__inner horizontal padding */
  --page-gutter: 80px;
  --page-max: 1280px;
}

/* ===== Page hero (Analyze, Users, …) ===== */
.page-hero {
  border-bottom: 1px solid var(--clr-border);
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 45%, #fff5f7 100%);
}

.page-hero__inner {
  width: 100%;
  padding: 28px var(--page-gutter) 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.page-hero__eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--clr-primary);
  margin-bottom: 8px;
}

.page-hero h1 {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 8px;
  color: var(--clr-text);
}

.page-hero__copy > p:last-child {
  font-size: 0.9rem;
  color: var(--clr-text-2);
  line-height: 1.55;
}

.page-hero__aside {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.page-hero__step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--clr-muted);
  padding: 8px 12px;
  border-radius: var(--radius-full);
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
}

.page-hero__step [data-lucide] {
  width: 14px;
  height: 14px;
}

.page-hero__step.is-active,
.page-hero__step.is-done {
  color: var(--clr-primary);
  border-color: rgba(219, 0, 50, 0.15);
  background: #fff0f3;
}

.page-hero__step-line {
  width: 20px;
  height: 1px;
  background: var(--clr-border);
  flex-shrink: 0;
}

.page-hero__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== Base ===== */
body {
  font-family: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  scroll-behavior: smooth;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 80;
  padding: 0;
  animation: fadeInDown .4s ease;
}

.app-header__inner {
  width: 100%;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px var(--page-gutter);
  border: 1px solid rgba(219,0,50,.12);
  border-radius: 0;
  background: rgba(255,255,255,.88);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  box-shadow: 0 20px 48px rgba(29,37,44,.08), 0 8px 20px rgba(219,0,50,.08);
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: max-content;
}

.app-brand__mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-secondary));
}

.app-brand__copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-brand__title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--clr-text);
}

.app-brand__tag {
  font-size: .72rem;
  font-weight: 500;
  color: var(--clr-text-2);
}

.app-nav-toggle {
  display: none;
  margin-left: auto;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--clr-text);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .18s, color .18s;
}

.app-nav-toggle:hover {
  color: var(--clr-primary);
  transform: translateY(-1px);
}

.app-header__panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

@media (min-width: 961px) {
  .app-header__inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
  }

  .app-header__panel {
    display: contents;
  }

  .app-nav {
    justify-self: center;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .app-nav__link {
    white-space: nowrap;
    padding: 9px 14px;
  }

  .app-user-email {
    max-width: 140px;
  }

  .app-header__actions {
    justify-self: end;
    margin-left: 0;
  }
}

.app-nav__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 999px;
  color: var(--clr-text-2);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .01em;
  border: 1px solid transparent;
  transition: color .18s, background .18s, border-color .18s, transform .18s;
}

.app-nav__link:hover,
.app-nav__link:focus-visible,
.app-nav__link.active {
  color: var(--clr-primary);
  background: rgba(219,0,50,.08);
  border-color: rgba(219,0,50,.14);
  transform: translateY(-1px);
  outline: none;
}

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

.app-user-menu {
  position: relative;
}

.app-user-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  border: 1px solid rgba(29,37,44,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(248,250,252,.95));
  color: var(--clr-text);
  cursor: pointer;
  font-family: inherit;
  transition: border-color .18s, box-shadow .18s, transform .18s;
}

.app-user-button:hover,
.app-user-menu.open .app-user-button {
  border-color: rgba(219,0,50,.22);
  box-shadow: 0 12px 24px rgba(219,0,50,.12);
  transform: translateY(-1px);
}

.app-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .04em;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-secondary));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2);
}

.app-user-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.app-user-name {
  font-size: .82rem;
  font-weight: 700;
}

.app-user-email {
  font-size: .68rem;
  color: var(--clr-text-2);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-user-chevron {
  color: var(--clr-text-2);
  opacity: .75;
  transition: transform .18s ease;
}

.app-user-chevron svg {
  width: 20px;
  height: 20px;
}

.app-user-menu.open .app-user-chevron {
  transform: rotate(180deg);
}

.app-user-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: min(260px, calc(100vw - 32px));
  padding: 8px;
  border-radius: 18px;
  border: 1px solid rgba(29,37,44,.08);
  background: rgba(255,255,255,.98);
  box-shadow: 0 20px 48px rgba(29,37,44,.14), 0 8px 18px rgba(219,0,50,.08);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(.98);
  transition: opacity .18s, transform .18s, visibility .18s;
}

.app-user-menu.open .app-user-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.app-user-dropdown__meta {
  padding: 10px 12px 12px;
  border-bottom: 1px solid rgba(29,37,44,.08);
  margin-bottom: 6px;
}

.app-user-dropdown__meta strong {
  display: block;
  font-size: .9rem;
  margin-bottom: 4px;
}

.app-user-dropdown__meta span {
  display: block;
  font-size: .76rem;
  color: var(--clr-text-2);
  word-break: break-word;
}

.app-user-dropdown__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--clr-text);
  text-decoration: none;
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .18s, color .18s;
}

.app-user-dropdown__item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.app-user-dropdown__item:hover {
  background: rgba(219,0,50,.08);
  color: var(--clr-primary);
}

.app-user-dropdown__item.danger {
  color: var(--clr-danger);
}

.app-user-dropdown__item.danger:hover {
  background: rgba(219,0,50,.08);
}

.app-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15,23,42,.42);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 120;
}

.app-overlay.show {
  display: flex;
}

.app-modal {
  width: min(460px, 100%);
  min-width: 0;
  max-height: min(90vh, 720px);
  overflow: auto;
  background: #fff;
  border: 1px solid rgba(29,37,44,.08);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(15,23,42,.18), 0 8px 20px rgba(219,0,50,.08);
  padding: 28px;
}

.app-modal h3,
.app-modal p {
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

.app-modal h3 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--clr-text);
}

.app-modal p {
  margin-top: 8px;
  color: var(--clr-text-2);
  font-size: .88rem;
  line-height: 1.6;
}

.app-modal-form {
  margin-top: 18px;
}

.app-modal-field + .app-modal-field {
  margin-top: 14px;
}

.app-modal-field label {
  display: block;
  margin-bottom: 6px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--clr-text-2);
}

.app-password-field {
  position: relative;
}

.app-modal-field input {
  width: 100%;
  border: 1.5px solid var(--clr-border);
  border-radius: 12px;
  padding: 11px 14px;
  font: inherit;
  color: var(--clr-text);
  background: #f8fafc;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}

.app-password-field input {
  padding-right: 46px;
}

.app-password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--clr-text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.app-password-toggle svg {
  width: 18px;
  height: 18px;
}

.app-password-toggle .icon-hide {
  display: none;
}

.app-password-toggle.is-visible .icon-show {
  display: none;
}

.app-password-toggle.is-visible .icon-hide {
  display: block;
}

.app-modal-field input:focus {
  border-color: var(--clr-primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(219,0,50,.1);
}

.app-form-alert {
  display: none;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: .8rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

.app-form-alert.error {
  display: block;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.app-form-alert.success {
  display: block;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.app-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.app-btn-secondary,
.app-btn-primary,
.app-btn-danger {
  flex: 1;
  border-radius: var(--radius-full);
  padding: 11px 14px;
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
  transition: opacity .18s, background .18s;
}

.app-btn-secondary {
  border: 1.5px solid var(--clr-border);
  background: #fff;
  color: var(--clr-text-2);
}

.app-btn-primary,
.app-btn-danger {
  border: 0;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-secondary));
  color: #fff;
}

.app-btn-primary:disabled,
.app-btn-danger:disabled {
  opacity: .65;
  cursor: not-allowed;
}

.app-section-anchor {
  scroll-margin-top: 120px;
}

/* ===== Markdown report tables (Analyze + My Projects detail) ===== */
.markdown-body > table {
  width: 100%;
  table-layout: fixed;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  border-collapse: collapse;
  border-spacing: 0;
  margin: 12px 0;
  font-size: 0.82rem;
  border: 1px solid var(--clr-border);
}

.markdown-body > table:first-of-type th:first-child,
.markdown-body > table:first-of-type td:first-child {
  width: 26%;
  min-width: 96px;
  max-width: 140px;
  background: var(--clr-surface-2);
  font-weight: 700;
  color: var(--clr-text);
  text-align: left;
}

.markdown-body > table:not(:first-of-type) th:first-child:nth-last-child(2),
.markdown-body > table:not(:first-of-type) td:first-child:nth-last-child(2) {
  width: 2.2rem;
  min-width: 2.2rem;
  max-width: 2.2rem;
  text-align: left;
  padding-left: 8px;
  padding-right: 4px;
  background: var(--clr-surface-2);
  font-weight: 700;
}

.markdown-body table th:nth-child(1):nth-last-child(4),
.markdown-body table td:nth-child(1):nth-last-child(4) {
  width: 12%;
  min-width: 52px;
}

.markdown-body table th:nth-child(2):nth-last-child(3),
.markdown-body table td:nth-child(2):nth-last-child(3) {
  width: 8%;
  min-width: 36px;
  text-align: center;
}

.markdown-body table th:nth-child(3):nth-last-child(2),
.markdown-body table td:nth-child(3):nth-last-child(2) {
  width: 18%;
  min-width: 88px;
}

.markdown-body > table:last-child {
  margin-bottom: 0;
}

.markdown-body > table th,
.markdown-body > table td {
  border: 1px solid var(--clr-border);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}

.markdown-body > table th {
  background: var(--clr-surface-2);
  font-weight: 600;
}

.markdown-body td:has(> table),
.markdown-body th:has(> table) {
  padding: 10px 12px;
  vertical-align: top;
}

.markdown-body td > table,
.markdown-body th > table {
  width: 100%;
  margin: 0;
  border: none;
  border-collapse: collapse;
}

.markdown-body td > table th,
.markdown-body td > table td,
.markdown-body th > table th,
.markdown-body th > table td {
  border: 1px solid var(--clr-border);
  padding: 6px 8px;
}

.uc-detail .markdown-body hr {
  display: none;
}

.uc-detail .markdown-body > table:last-child {
  border-bottom: none;
}

/* ===== Export menu (Analyze + My Projects) ===== */
.export-menu {
  position: relative;
  flex-shrink: 0;
}

.export-menu__trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-full);
  background: #fff;
  color: var(--clr-text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(29, 37, 44, 0.05);
}

.export-menu__trigger [data-lucide] {
  width: 15px;
  height: 15px;
}

.export-menu__trigger .export-menu__chev {
  width: 14px;
  height: 14px;
  opacity: 0.55;
}

.export-menu__trigger:hover,
.export-menu__trigger[aria-expanded='true'] {
  border-color: var(--clr-primary);
  background: #fff0f3;
  color: var(--clr-primary);
}

.export-menu__panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: max-content;
  padding: 4px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: 0 12px 32px rgba(29, 37, 44, 0.12);
}

.export-menu__panel[hidden] {
  display: none !important;
}

.export-menu__panel button {
  width: auto;
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  white-space: nowrap;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--clr-text);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}

.export-format-icon {
  display: inline-flex;
  flex-shrink: 0;
  line-height: 0;
}

.export-format-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.export-menu__panel button:hover {
  background: #fff0f3;
  color: var(--clr-primary);
}

.app-system-footer {
  margin-top: 28px;
  text-align: center;
  padding: 18px 16px;
  font-size: .80rem;
  color: var(--clr-muted);
  border-top: 1px solid var(--clr-border);
  background: rgba(255,255,255,.66);
}

@media (max-width: 960px) {
  :root {
    --page-gutter: 14px;
  }

  .page-hero__inner {
    padding-top: 22px;
    padding-bottom: 20px;
  }

  .app-header {
    padding: 0;
  }

  .app-header__inner {
    position: relative;
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    border-radius: 0;
    padding: 12px 14px;
  }

  .app-brand {
    min-width: 0;
    max-width: calc(100% - 56px);
  }

  .app-brand__copy {
    min-width: 0;
  }

  .app-brand__title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .app-nav-toggle {
    display: inline-flex;
    flex-shrink: 0;
  }

  .app-header__panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 14px;
    right: 14px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
    border: 1px solid rgba(219,0,50,.14);
    border-radius: 18px;
    background: rgba(255,255,255,.98);
    box-shadow: 0 18px 38px rgba(29,37,44,.12), 0 8px 16px rgba(219,0,50,.08);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px) scale(.98);
    transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
  }

  .app-header.is-open .app-header__panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }

  .app-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .app-nav__link {
    width: 100%;
    justify-content: flex-start;
    padding: 12px 16px;
    border-color: rgba(29,37,44,.08);
    background: #fff;
  }

  .app-header__actions {
    margin-left: 0;
    width: 100%;
  }

  .app-user-menu,
  .app-user-button,
  .app-user-dropdown {
    width: 100%;
  }

  .app-user-button {
    justify-content: flex-start;
    padding: 8px 12px 8px 8px;
  }

  .app-user-copy {
    min-width: 0;
    flex: 1;
  }

  .app-user-email {
    max-width: 100%;
  }

  .app-user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 100%;
    margin-top: 0;
    display: none;
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  .app-user-menu.open .app-user-dropdown {
    display: block;
  }
}

@media (max-width: 640px) {
  :root {
    --page-gutter: 12px;
  }

  .app-header__inner {
    padding: 12px;
  }

  .app-header__panel {
    left: 12px;
    right: 12px;
  }

  .app-brand__tag,
  .app-user-email {
    display: none;
  }

  .app-user-button {
    justify-content: space-between;
  }

  .app-modal {
    padding: 22px;
  }

  .app-modal-actions {
    flex-direction: column;
  }

  .app-system-footer {
    margin-top: 22px;
    font-size: .72rem;
  }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar            { width: 6px; height: 6px; }
::-webkit-scrollbar-track      { background: transparent; }
::-webkit-scrollbar-thumb      { background: rgba(219,0,50,.25); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover{ background: rgba(219,0,50,.45); }

/* ===== Selection ===== */
::selection { background: rgba(219,0,50,.12); color: #a80026; }

/* ===== Animations ===== */
@keyframes spin         { to { transform: rotate(360deg); } }
@keyframes fadeInUp     { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInDown   { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInLeft  { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes scaleIn      { from { opacity: 0; transform: scale(.9) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes pulse        { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes floatBlob {
  0%,100% { transform: translate(0,0) scale(1); }
  33%     { transform: translate(30px,-50px) scale(1.05); }
  66%     { transform: translate(-20px,20px) scale(.95); }
}
@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}
@keyframes popIn {
  0%   { opacity: 0; transform: scale(0.8) translateY(8px); }
  60%  { opacity: 1; transform: scale(1.04) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes drawerIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== System skeletons (pages + inline actions) ===== */
:root {
  --skel-gap-xs: 6px;
  --skel-gap-sm: 10px;
  --skel-gap-md: 14px;
  --skel-gap-lg: 20px;
  --skel-gap-xl: 24px;
}

.sys-skel {
  position: relative;
  width: 100%;
}

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

.sys-skel-stack {
  display: flex;
  flex-direction: column;
  gap: var(--skel-gap-md);
}

.sys-skel-row {
  display: flex;
  align-items: center;
  gap: var(--skel-gap-md);
}

.sys-skel-col {
  display: flex;
  flex-direction: column;
  gap: var(--skel-gap-sm);
  min-width: 0;
}

.sys-skel-col--grow {
  flex: 1;
}

.sys-skel-bone {
  display: block;
  flex-shrink: 0;
  background: linear-gradient(90deg, #e8eaed 0%, #f4f5f7 42%, #e8eaed 84%);
  background-size: 200% 100%;
  animation: shimmer 1.35s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.sys-skel-bone--avatar {
  width: 44px;
  height: 44px;
  border-radius: 13px;
}

.sys-skel-bone--icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.sys-skel-bone--line {
  height: 14px;
  width: 100%;
}

.sys-skel-bone--line.sys-skel-bone--sm {
  height: 12px;
}

.sys-skel-bone--line.sys-skel-bone--xs {
  height: 11px;
}

.sys-skel-bone--line.sys-skel-bone--lg {
  height: 18px;
}

.sys-skel-bone--line.sys-skel-bone--title {
  height: 16px;
  max-width: 48%;
}

.sys-skel-bone--line.sys-skel-bone--heading {
  height: 22px;
  max-width: min(360px, 60%);
}

.sys-skel-bone--line.sys-skel-bone--eyebrow {
  height: 11px;
  max-width: 120px;
}

.sys-skel-bone--w-100 { width: 100%; }
.sys-skel-bone--w-94 { width: 94%; }
.sys-skel-bone--w-92 { width: 92%; }
.sys-skel-bone--w-96 { width: 96%; }
.sys-skel-bone--w-90 { width: 90%; }
.sys-skel-bone--w-88 { width: 88%; }
.sys-skel-bone--w-78 { width: 78%; }
.sys-skel-bone--w-72 { width: 72%; }
.sys-skel-bone--w-70 { width: 70%; }
.sys-skel-bone--w-64 { width: 64%; }
.sys-skel-bone--w-58 { width: 58%; }
.sys-skel-bone--w-50 { width: 50%; }
.sys-skel-bone--w-42 { width: 42%; }

.sys-skel-bone--pill {
  width: 76px;
  height: 24px;
  border-radius: var(--radius-full);
}

.sys-skel-bone--pill-sm {
  width: 72px;
  height: 22px;
  border-radius: var(--radius-full);
}

.sys-skel-bone--chip {
  width: 108px;
  height: 28px;
  border-radius: var(--radius-full);
}

.sys-skel-bone--tab {
  width: 120px;
  height: 36px;
  border-radius: var(--radius-full);
}

.sys-skel-bone--tab-wide {
  width: 140px;
  height: 36px;
  border-radius: var(--radius-full);
}

.sys-skel-bone--btn {
  width: 88px;
  height: 36px;
  border-radius: 10px;
}

.sys-skel-bone--action {
  height: 40px;
  width: 100%;
  border-radius: 12px;
}

.sys-skel-bone--block {
  height: 80px;
  width: 100%;
  border-radius: 10px;
}

.sys-skel--projects {
  grid-column: 1 / -1;
}

.sys-skel--processing,
.sys-skel--detail,
.sys-skel--results {
  display: flex;
  flex-direction: column;
  gap: var(--skel-gap-lg);
}

.sys-skel-status-msg {
  margin: 0;
  padding: 14px 20px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--clr-text-2);
  text-align: center;
}

.sys-skel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 2px;
}

.sys-skel-desc-lines {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
}

.sys-skel-results {
  display: flex;
  flex-direction: column;
}

.sys-skel-features-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 22px 26px;
}

.sys-skel-detail__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--skel-gap-md);
  margin-bottom: 4px;
}

.sys-skel-detail__head-main {
  display: flex;
  flex-direction: column;
  gap: var(--skel-gap-xs);
  flex: 1;
  min-width: 0;
}

.sys-skel-detail__summary {
  padding: 20px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  background: var(--clr-surface);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--skel-gap-md);
}

.sys-skel-results__summary {
  padding: 26px 28px 24px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  background: var(--clr-surface);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--skel-gap-lg);
}

.sys-skel-detail__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--skel-gap-sm);
}

.user-card--skeleton,
.project-card--skeleton,
.feature-tile--skeleton {
  pointer-events: none;
  animation: none !important;
}

.user-card--skeleton {
  gap: 28px;
}

.project-card--skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--skel-gap-md);
  padding: 20px 20px 16px;
}

.project-card--skeleton .project-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--skel-gap-md);
}

.project-card--skeleton .project-card__body-lines {
  display: flex;
  flex-direction: column;
  gap: var(--skel-gap-sm);
}

.project-card--skeleton .project-card__foot {
  display: flex;
  gap: var(--skel-gap-sm);
  margin-top: 4px;
  padding-top: 4px;
}

.feature-tile--skeleton {
  padding: 18px 20px;
  margin: 0;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  background: var(--clr-surface);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--skel-gap-md);
}

.feature-tile--skeleton .feature-tile__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--skel-gap-md);
  margin-bottom: 0;
}

.analyze-page .feature-tile--skeleton {
  padding: 20px 22px;
  border-radius: 14px;
  border-color: var(--pf-border, var(--clr-border));
  background: var(--pf-surface, var(--clr-surface));
  box-shadow: none;
}

.feature-tile--skeleton .uc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 0;
}

@media (max-width: 640px) {
  .feature-tile--skeleton .uc-grid {
    grid-template-columns: 1fr;
  }
}

.uc-tile--skeleton {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: #fff;
}

.analyze-page .uc-tile--skeleton {
  border-color: var(--pf-border, var(--clr-border));
}

.sys-skel-uc-detail {
  padding: 18px 20px 24px;
}

.sys-skel-uc-lines {
  display: flex;
  flex-direction: column;
  gap: var(--skel-gap-sm);
}

/* Action buttons while async work runs */
.is-action-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.is-action-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.app-btn-secondary.is-action-loading::after {
  border-color: rgba(29, 37, 44, 0.15);
  border-top-color: var(--clr-primary);
}

.btn-refresh.is-action-loading,
.projects-page .btn-refresh.is-action-loading {
  color: transparent !important;
}

.btn-refresh.is-action-loading::after {
  border-color: rgba(219, 0, 50, 0.15);
  border-top-color: var(--clr-primary);
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .sys-skel-bone { animation: none; background: #ececf0; }
}
