:root {
  --ink: #241437;
  --ink-soft: #6f6287;
  --paper: #f7f1fb;
  --panel: rgba(255, 255, 255, 0.86);
  --line: rgba(86, 58, 124, 0.14);
  --gold: #c9a03e;
  --gold-soft: #f7e6bc;
  --mint: #5d2d90;
  --mint-soft: #f0e6fb;
  --rose: #9f3f63;
  --rose-soft: #fde7ef;
  --sky: #7c56bf;
  --sky-soft: #efe6ff;
  --amber-soft: #fff5d9;
  --shadow: 0 22px 65px rgba(41, 22, 68, 0.16);
  --shadow-sm: 0 2px 8px rgba(41, 22, 68, 0.06);
  --shadow-md: 0 8px 30px rgba(41, 22, 68, 0.08);
  --radius: 0.85rem;
  --radius-sm: 0.6rem;
  --radius-lg: 1.15rem;
  --space-xs: 0.35rem;
  --space-sm: 0.5rem;
  --space: 0.85rem;
  --space-md: 1.15rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --transition: 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(circle at 4% 8%, rgba(201, 160, 62, 0.12), transparent 28%),
    radial-gradient(circle at 96% 12%, rgba(93, 45, 144, 0.10), transparent 24%),
    radial-gradient(circle at 85% 86%, rgba(124, 86, 191, 0.08), transparent 28%),
    linear-gradient(180deg, #fcf8ff 0%, #f5effb 50%, #fefbf0 100%);
  background-attachment: fixed;
}

.scene {
  position: fixed;
  width: 24rem;
  height: 24rem;
  border-radius: 50%;
  filter: blur(16px);
  opacity: 0.32;
  pointer-events: none;
}

.scene-a {
  top: -6rem;
  left: -6rem;
  background: linear-gradient(135deg, #f7deb0, #fff8ea);
}

.scene-b {
  right: -7rem;
  bottom: -6rem;
  background: linear-gradient(135deg, #d8c3fb, #f5efff);
}

.hidden {
  display: none !important;
}

body.document-overlay-open,
body.ai-overlay-open {
  overflow: hidden;
}

.eyebrow {
  margin: 0 0 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
  font-size: 0.76rem;
  color: var(--gold);
}

.muted {
  color: var(--ink-soft);
}

.auth-screen {
  width: min(1240px, calc(100% - 1.25rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.auth-panel {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
  align-items: stretch;
}

.consent-panel {
  grid-template-columns: minmax(0, 720px);
  justify-content: center;
}

.consent-screen .auth-intro h1 {
  max-width: none;
}

.auth-intro,
.auth-card,
.panel,
.sidebar-card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}

.auth-intro {
  padding: 2rem;
}

.hero-brand,
.brand-logo-row {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
}

.hero-brand {
  margin-bottom: 1.25rem;
}

.hero-brand-copy .eyebrow,
.hero-brand-copy .muted {
  margin-bottom: 0.2rem;
}

.hero-brand-copy .muted {
  margin-top: 0;
  font-size: 0.92rem;
}

.hero-logo,
.brand-logo {
  display: block;
  width: 4rem;
  height: 4rem;
  flex: 0 0 auto;
}

.auth-intro h1 {
  margin: 0;
  max-width: 12ch;
  font-family: "Georgia", "Palatino Linotype", serif;
  font-size: clamp(2.25rem, 4vw, 3.5rem);
  font-weight: 700;
  line-height: 1.0;
}

.auth-copy {
  max-width: 46rem;
  margin-top: 0.85rem;
  font-size: 0.96rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.credential-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 1.4rem;
}

.credential-card {
  padding: 1rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.credential-card h3 {
  margin: 0.15rem 0 0.35rem;
}

.credential-card p {
  margin: 0;
  color: var(--ink-soft);
}

.credential-role {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
  color: var(--gold);
}

.auth-card {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ========================================
   PREMIUM LANDING PAGE — AEGIS & Dashboard
   ======================================== */

.aegis-tagline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--gold);
}

.aegis-sparkle,
.aegis-sparkle-sm {
  width: 1rem;
  height: 1rem;
  stroke: var(--gold);
  flex-shrink: 0;
}

.aegis-sparkle-sm {
  width: 0.75rem;
  height: 0.75rem;
}

/* Dashboard Preview */
.dashboard-preview {
  margin: 1.25rem 0 1rem;
  padding: 1.1rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, rgba(255,255,255,0.92), rgba(247,241,251,0.88));
  border: 1px solid rgba(86,58,124,0.08);
  box-shadow:
    0 24px 60px rgba(41,22,68,0.10),
    0 2px 8px rgba(41,22,68,0.04),
    inset 0 1px 0 rgba(255,255,255,0.9);
  animation: dash-float 6s ease-in-out infinite;
  position: relative;
  overflow: hidden;
}

.dashboard-preview::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(201,160,62,0.04), transparent 60%);
  pointer-events: none;
}

@keyframes dash-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.dash-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid rgba(86,58,124,0.07);
}

.dash-preview-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dash-preview-logo {
  width: 1.6rem;
  height: 1.6rem;
}

.dash-preview-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
}

.dash-preview-sub {
  margin: 0;
  font-size: 0.6rem;
  color: var(--ink-soft);
  opacity: 0.7;
}

.dash-preview-aegis {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--gold);
  background: rgba(201,160,62,0.08);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
}

.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin-bottom: 0.65rem;
}

.dash-kpi {
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(86,58,124,0.06);
}

.dash-kpi-label {
  margin: 0 0 0.2rem;
  font-size: 0.56rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.dash-kpi-value {
  margin: 0 0 0.3rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}

.kpi-count {
  font-variant-numeric: tabular-nums;
}

.dash-kpi-bar {
  height: 3px;
  border-radius: 2px;
  background: rgba(86,58,124,0.08);
  overflow: hidden;
}

.dash-kpi-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #5d2d90, #7c56bf);
  transition: width 1.2s cubic-bezier(0.22,1,0.36,1);
}

.dash-kpi-fill.kpi-gold { background: linear-gradient(90deg, #c9a03e, #dfc06a); }
.dash-kpi-fill.kpi-rose { background: linear-gradient(90deg, #9f3f63, #c4608a); }
.dash-kpi-fill.kpi-sky  { background: linear-gradient(90deg, #7c56bf, #a07ee0); }
.dash-kpi-fill.kpi-mint { background: linear-gradient(90deg, #5d2d90, #8b5cc0); }

.dash-aegis-card {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(46,18,77,0.05), rgba(201,160,62,0.05));
  border: 1px solid rgba(201,160,62,0.12);
}

.dash-aegis-icon {
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dash-aegis-icon svg {
  width: 1rem;
  height: 1rem;
  stroke: var(--gold);
}

.dash-aegis-title {
  margin: 0;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ink);
}

.dash-aegis-text {
  margin: 0.15rem 0 0;
  font-size: 0.56rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

/* Trust Badges */
.trust-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.trust-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: rgba(86,58,124,0.04);
  border: 1px solid rgba(86,58,124,0.08);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.trust-badge:hover {
  background: rgba(86,58,124,0.07);
  border-color: rgba(86,58,124,0.14);
}

.trust-badge svg {
  width: 0.7rem;
  height: 0.7rem;
  stroke: var(--ink-soft);
  opacity: 0.6;
}

/* Auth Info Section */
.auth-info-section {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(86,58,124,0.08);
}

.auth-info-secure {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0 0 1rem;
  font-size: 0.76rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

.auth-info-secure svg {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  stroke: var(--gold);
  margin-top: 0.1rem;
}

.auth-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.auth-info-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.68rem;
  color: var(--ink-soft);
  font-weight: 500;
  transition: color 0.2s ease;
}

.auth-info-item:hover {
  color: var(--ink);
}

.auth-info-item svg {
  width: 0.8rem;
  height: 0.8rem;
  stroke: var(--ink-soft);
  opacity: 0.5;
  flex-shrink: 0;
  transition: opacity 0.2s ease;
}

.auth-info-item:hover svg {
  opacity: 0.8;
}

/* Login Button Enhancement */
.login-button {
  min-height: 3rem;
  font-size: 0.9rem;
  background: linear-gradient(135deg, #58288b, #7d56bf, #c9a03e);
  background-size: 200% 200%;
  animation: login-gradient 4s ease infinite;
}

@keyframes login-gradient {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.login-button:hover {
  box-shadow: 0 12px 28px rgba(88,40,139,0.25);
}

/* Enhanced Input Styles */
.auth-card label > span {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.auth-card input {
  background: rgba(247,241,251,0.6);
  border: 1px solid rgba(86,58,124,0.1);
  min-height: 2.9rem;
  transition: all var(--transition);
}

.auth-card input:hover {
  border-color: rgba(86,58,124,0.18);
  background: rgba(255,255,255,0.8);
}

.auth-card input:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(124,86,191,0.12);
  background: rgba(255,255,255,0.95);
}

/* Switch Enhancement */
.auth-switch {
  margin-bottom: 1.25rem;
}

.toggle {
  min-height: 2.8rem;
}

.auth-switch .toggle.active {
  box-shadow: 0 8px 20px rgba(78,35,123,0.2);
}

.auth-switch .toggle:not(.active):hover {
  background: rgba(226,233,247,0.95);
}

.auth-switch .toggle:not(.active):focus-visible {
  outline: 2px solid var(--sky);
  outline-offset: 2px;
}

/* Background Animation Enhancement */
.scene {
  animation: scene-drift 20s ease-in-out infinite alternate;
}

.scene-b {
  animation-delay: -10s;
  animation-direction: alternate-reverse;
}

@keyframes scene-drift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(12px, 8px) scale(1.04); }
}

/* Focus ring animation */
input:focus,
select:focus,
textarea:focus {
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Card hover elevation */
.auth-intro,
.auth-card {
  transition: transform 0.4s cubic-bezier(0.22,1,0.36,1), box-shadow 0.4s ease;
}

.auth-card:hover {
  box-shadow: 0 12px 40px rgba(41,22,68,0.12);
}

/* Form stack spacing */
.auth-card .stack {
  gap: 0.85rem;
}

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.toggle,
.primary-button,
.secondary-button,
.ghost-button,
.action-button,
.sidebar-button,
.tiny-button,
.nav-link,
.child-card {
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.toggle:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.action-button:hover,
.sidebar-button:hover,
.tiny-button:hover,
.nav-link:hover,
.child-card:hover {
  transform: translateY(-1px);
}

.toggle:disabled,
.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled,
.action-button:disabled,
.sidebar-button:disabled,
.tiny-button:disabled,
.nav-link:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
  box-shadow: none;
}

.toggle {
  min-height: 3rem;
  border-radius: 999px;
  background: rgba(226, 233, 247, 0.86);
  color: var(--ink-soft);
  font-weight: 700;
}

.toggle.active {
  background: linear-gradient(135deg, #4e237b, #7d56bf);
  color: white;
  box-shadow: 0 12px 25px rgba(78, 35, 123, 0.24);
}

.stack {
  display: grid;
  gap: var(--space);
  min-width: 0;
}

label {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

label > span,
.inline-select > span {
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 2.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(86, 58, 124, 0.12);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(124, 86, 191, 0.1);
  background: rgba(255, 255, 255, 0.96);
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

.primary-button,
.secondary-button,
.ghost-button,
.action-button,
.sidebar-button {
  min-height: 2.75rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  text-wrap: pretty;
}

.primary-button,
.action-button {
  color: white;
  background: linear-gradient(135deg, #58288b, #c9a03e);
  box-shadow: 0 8px 20px rgba(88, 40, 139, 0.18);
  font-weight: 600;
}

.primary-button.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
}

.login-hourglass {
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-bottom-color: transparent;
  clip-path: polygon(0 0, 100% 0, 50% 50%, 100% 100%, 0 100%, 50% 50%);
  animation: haes-hourglass-spin 900ms linear infinite;
}

@keyframes haes-hourglass-spin {
  to {
    transform: rotate(360deg);
  }
}

.secondary-button,
.sidebar-button-alt,
.action-button-soft {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(86, 58, 124, 0.1);
}

.secondary-button:hover,
.sidebar-button-alt:hover,
.action-button-soft:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(86, 58, 124, 0.18);
}

.ghost-button {
  color: var(--sky);
  background: rgba(239, 230, 255, 0.86);
}

.helper-text {
  margin: 0;
  min-height: 1.2rem;
  color: var(--ink-soft);
}

.is-busy {
  opacity: 0.98;
}

.reset-panel,
.notes-card,
.focus-card {
  padding: 1rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
}

.focus-label,
.sidebar-label {
  margin: 0 0 0.25rem;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0.6;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 1.25rem;
  width: min(1520px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1rem 0 2rem;
  position: relative;
}

.sidebar {
  position: sticky;
  top: 1rem;
  align-self: start;
  display: grid;
  gap: 0.75rem;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(38, 18, 64, 0.46);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 59;
}

.brand-block,
.sidebar-card {
  padding: 0.9rem 1rem;
}

.brand-block {
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(46, 18, 77, 0.98), rgba(95, 45, 144, 0.94));
  color: white;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.brand-block h2 {
  margin: 0;
  font-family: "Inter", -apple-system, sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-wrap: balance;
  overflow-wrap: break-word;
  word-break: normal;
  max-width: 100%;
}

.brand-title-school {
  font-size: 1.05rem;
}

.brand-block .eyebrow {
  margin: 0 0 0.1rem;
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.55);
}

.brand-block .muted {
  margin: 0.15rem 0 0;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.45);
}

.nav-menu {
  display: grid;
  gap: 0.2rem;
}

.nav-section {
  display: grid;
  gap: 0.15rem;
  padding: 0.6rem 0 0.2rem;
}

.nav-section + .nav-section {
  border-top: 1px solid var(--border-subtle, rgba(0,0,0,0.06));
  margin-top: 0.6rem;
  padding-top: 0.8rem;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-faint, #8a8fa8);
  padding: 0 0.75rem 0.3rem;
  text-transform: uppercase;
  line-height: 1;
}

.nav-section-active .nav-section-label {
  color: var(--sky);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.82rem;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  text-wrap: pretty;
  transition: background var(--transition), color var(--transition);
}

.nav-link:hover {
  background: rgba(124, 86, 191, 0.06);
  color: var(--ink);
}

.nav-link-active {
  background: rgba(124, 86, 191, 0.1);
  color: var(--sky);
  font-weight: 600;
}

.nav-link-active:hover {
  background: rgba(124, 86, 191, 0.14);
}

.nav-icon {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  opacity: 0.65;
  transition: opacity var(--transition);
}

.nav-link:hover .nav-icon,
.nav-link-active .nav-icon {
  opacity: 1;
}

.nav-link-locked {
  opacity: 0.5;
  cursor: pointer;
  position: relative;
}

.nav-link-locked:hover {
  opacity: 0.7;
  background: rgba(124, 86, 191, 0.04);
}

.nav-lock-icon {
  flex: 0 0 auto;
  width: 0.85rem;
  height: 0.85rem;
  opacity: 0.7;
  margin-left: auto;
}

.upgrade-modal {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
}

.upgrade-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(38, 18, 64, 0.6);
  backdrop-filter: blur(4px);
}

.upgrade-modal-panel {
  position: relative;
  z-index: 1;
  width: min(96vw, 420px);
  padding: 1.5rem;
  border-radius: 1.35rem;
  background: rgba(251, 248, 255, 0.98);
  border: 1px solid rgba(189, 170, 222, 0.85);
  box-shadow: 0 28px 80px rgba(41, 22, 68, 0.3);
  text-align: center;
}

.upgrade-modal-panel h2 {
  margin: 0.5rem 0 0.5rem;
  font-family: "Georgia", "Palatino Linotype", serif;
  font-size: 1.5rem;
}

.upgrade-modal-panel p {
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0.5rem 0 1rem;
}

.ai-report-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(86, 58, 124, 0.08);
}

.ai-report-actions .tiny-button {
  font-size: 0.72rem;
  min-height: 2rem;
  padding: 0.3rem 0.6rem;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

/* PDF export report styling */
.pdf-report {
  max-width: 794px;
  margin: 0 auto;
  padding: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: #241437;
  line-height: 1.5;
}

.pdf-header {
  background: linear-gradient(135deg, #1a0a2e, #4a1a7a);
  color: #fff;
  padding: 16px 24px;
  border-radius: 0;
  margin: 0;
}

.pdf-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
}

.pdf-header-haes {
  letter-spacing: 2px;
}

.pdf-header-sep {
  opacity: 0.3;
}

.pdf-header-aegis {
  opacity: 0.8;
  font-weight: 400;
}

.pdf-body {
  padding: 0 24px 24px;
}

.pdf-title-block {
  padding: 24px 0 8px;
}

.pdf-title {
  font-family: "Georgia", "Palatino Linotype", serif;
  font-size: 28px;
  margin: 0 0 16px;
  color: #1a0a2e;
}

.pdf-meta-table {
  width: 100%;
  border-collapse: collapse;
}

.pdf-meta-table td {
  padding: 3px 0;
  font-size: 13px;
  border: none;
  vertical-align: top;
}

.pdf-meta-label {
  color: #6f6287;
  font-weight: 600;
  width: 100px;
  padding-right: 12px;
}

.pdf-meta-value {
  color: #241437;
}

.pdf-footer {
  text-align: center;
  font-size: 7px;
  color: #82789a;
  padding: 8px 24px;
  border-top: 1px solid rgba(86, 58, 124, 0.08);
}

.upgrade-modal-panel .upgrade-tier-badge {
  display: inline-block;
  margin: 0.5rem 0;
  padding: 0.25rem 1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.upgrade-tier-gold {
  background: rgba(201, 160, 62, 0.15);
  color: #9b7421;
}

.upgrade-tier-platinum {
  background: rgba(124, 86, 191, 0.12);
  color: var(--sky);
}

.sidebar-button {
  width: 100%;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  min-height: 2.4rem;
  padding: 0.5rem 0.75rem;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  text-wrap: pretty;
}

.sidebar-link {
  display: block;
  margin-top: 0.45rem;
  color: var(--sky);
  text-decoration: none;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: break-word;
  word-break: normal;
  text-wrap: pretty;
}

.main-shell {
  min-width: 0;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: flex-start;
  padding: 0 0 0.75rem;
}

.topbar-main {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  min-width: 0;
}

.topbar-main > div:last-child {
  min-width: 0;
  flex: 1 1 auto;
}

.topbar > div:first-child {
  min-width: 0;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.28rem;
  width: 3rem;
  min-width: 3rem;
  height: 3rem;
  border: 1px solid rgba(86, 58, 124, 0.14);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.menu-toggle span {
  display: block;
  width: 1.1rem;
  height: 2px;
  border-radius: 999px;
  background: #552885;
  transition: transform 180ms ease, opacity 180ms ease;
}

.menu-toggle-active span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.menu-toggle-active span:nth-child(2) {
  opacity: 0;
}

.menu-toggle-active span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  text-wrap: balance;
  overflow-wrap: break-word;
  word-break: normal;
  color: var(--ink);
}

.topbar-actions {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-self: start;
  max-width: 100%;
}

.topbar .muted {
  max-width: 72ch;
  overflow-wrap: break-word;
  word-break: normal;
  text-wrap: pretty;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0.2rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  font-weight: 700;
}

.pill-online {
  color: var(--mint);
  background: var(--mint-soft);
}

.pill-offline {
  color: var(--rose);
  background: var(--rose-soft);
}

.pill-muted {
  color: var(--ink-soft);
}

.banner,
.toast {
  margin-bottom: 1rem;
  padding: 0.95rem 1rem;
  border-radius: 1rem;
  border: 1px solid transparent;
  box-shadow: var(--shadow);
}

.banner-success {
  background: var(--mint-soft);
  border-color: rgba(93, 45, 144, 0.18);
}

.banner-warning {
  background: var(--amber-soft);
  border-color: rgba(201, 160, 62, 0.22);
}

.banner-danger,
.toast-error {
  background: var(--rose-soft);
  border-color: rgba(159, 63, 99, 0.22);
}

.toast {
  position: sticky;
  top: 0.75rem;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
}

.document-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
}

.document-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(38, 18, 64, 0.54);
  backdrop-filter: blur(3px);
}

.document-overlay-panel {
  position: relative;
  z-index: 1;
  width: min(96vw, 70rem);
  max-height: min(94vh, 58rem);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 1.35rem;
  background: rgba(251, 248, 255, 0.98);
  border: 1px solid rgba(189, 170, 222, 0.85);
  box-shadow: 0 28px 80px rgba(41, 22, 68, 0.3);
}

.document-overlay-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.document-overlay-head h2 {
  margin: 0.15rem 0 0;
  font-family: "Georgia", "Palatino Linotype", serif;
  font-size: clamp(1.3rem, 2.2vw, 1.9rem);
}

.document-overlay-hint {
  margin: 0;
  padding: 0.8rem 0.95rem;
  border-radius: 0.95rem;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(212, 196, 236, 0.88);
  color: #5d5172;
  font-size: 0.96rem;
}

.document-overlay-frame {
  width: 100%;
  min-height: 0;
  height: min(72vh, 46rem);
  border: 1px solid rgba(189, 170, 222, 0.9);
  border-radius: 1rem;
  background: #ffffff;
}

.view {
  display: none;
}

.view-active {
  display: block;
}

.content-stack {
  display: grid;
  gap: var(--space);
  min-width: 0;
}

.layout-two {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space);
}

.panel {
  padding: 1.25rem 1.35rem;
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.panel-head > * {
  min-width: 0;
}

.panel-head h3 {
  margin: 0;
  line-height: 1.15;
  text-wrap: balance;
  overflow-wrap: break-word;
  word-break: normal;
}

.panel-head p {
  margin: 0;
  color: var(--ink-soft);
  max-width: 72ch;
  line-height: 1.55;
  overflow-wrap: break-word;
  word-break: normal;
  text-wrap: pretty;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: 0.85rem;
}

.metric-card {
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: rgba(255, 255, 255, 0.8);
  transition: box-shadow var(--transition);
}

.metric-card:hover {
  box-shadow: var(--shadow-md);
}

.metric-card h3,
.metric-card p,
.metric-card small {
  margin: 0;
  overflow-wrap: break-word;
  word-break: normal;
}

.metric-card p {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-soft);
  text-wrap: pretty;
  letter-spacing: 0.02em;
}

.metric-card h3 {
  margin-top: 0.3rem;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.metric-card-sun {
  background: linear-gradient(145deg, #fff3d8, #ffffff);
}

.metric-card-rose {
  background: linear-gradient(145deg, #ffecee, #ffffff);
}

.metric-card-mint {
  background: linear-gradient(145deg, #f2e9ff, #ffffff);
}

.metric-card-sky {
  background: linear-gradient(145deg, #f4ecff, #ffffff);
}

.dashboard-chart-panel {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(247, 241, 251, 0.9)),
    radial-gradient(circle at 92% 10%, rgba(201, 160, 62, 0.18), transparent 28%);
}

.chart-filter-row {
  margin-bottom: 1rem;
}

.bar-chart {
  display: grid;
  gap: 0.85rem;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(7.5rem, 0.75fr) minmax(0, 2fr) minmax(6.5rem, auto);
  gap: 0.8rem;
  align-items: center;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.72);
}

.bar-label strong,
.bar-label span,
.bar-value {
  display: block;
}

.bar-label span {
  margin-top: 0.25rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.bar-track-stack {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
}

.bar-track {
  position: relative;
  min-height: 1.65rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(86, 58, 124, 0.08);
  border: 1px solid rgba(86, 58, 124, 0.08);
}

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
}

.bar-fill-expected {
  background: linear-gradient(90deg, rgba(93, 45, 144, 0.82), rgba(124, 86, 191, 0.62));
}

.bar-fill-collected {
  background: linear-gradient(90deg, #c9a03e, #f1d28a);
}

.bar-track small {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  min-height: 1.65rem;
  padding-left: 0.75rem;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.bar-value {
  justify-self: end;
  color: var(--rose);
  font-weight: 800;
  white-space: nowrap;
}

.bar-value.positive {
  color: var(--mint);
}

.donut-card {
  display: grid;
  grid-template-columns: minmax(10rem, 13rem) 1fr;
  gap: 1rem;
  align-items: center;
}

.donut-ring {
  width: min(13rem, 100%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin: 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--gold) 0 var(--income-deg), var(--rose) var(--income-deg) 360deg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7), 0 18px 40px rgba(41, 22, 68, 0.12);
}

.donut-ring > div {
  width: 68%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 1rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  text-align: center;
}

.donut-ring strong {
  font-size: clamp(1rem, 2vw, 1.35rem);
  line-height: 1.1;
}

.donut-ring span {
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.chart-legend {
  display: grid;
  gap: 0.7rem;
}

.chart-legend div {
  min-width: 0;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.95rem;
  background: rgba(255, 255, 255, 0.72);
}

.chart-legend strong,
.chart-legend small {
  display: block;
}

.chart-legend small {
  margin-top: 0.25rem;
  color: var(--ink-soft);
}

.legend-dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.4rem;
  border-radius: 999px;
}

.legend-income {
  background: var(--gold);
}

.legend-expense {
  background: var(--rose);
}

.line-chart-wrap {
  display: grid;
  gap: 1rem;
}

.line-chart {
  width: 100%;
  min-height: 16rem;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background:
    linear-gradient(rgba(86, 58, 124, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(86, 58, 124, 0.05) 1px, transparent 1px),
    rgba(255, 255, 255, 0.72);
  background-size: 100% 25%, 12.5% 100%, auto;
}

.chart-axis {
  stroke: rgba(86, 58, 124, 0.22);
  stroke-width: 1;
}

.line-chart-area {
  fill: rgba(201, 160, 62, 0.16);
}

.line-chart-line {
  fill: none;
  stroke: var(--gold);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-chart-point {
  fill: #fff9e8;
  stroke: var(--gold);
  stroke-width: 3;
}

.line-chart-value {
  fill: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.line-chart-label {
  fill: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
}

.chart-legend.compact {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
}

.action-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 0.85rem;
}

.form-grid-span-2 {
  grid-column: 1 / -1;
}

.toolbar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: end;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.focus-card h3 {
  margin: 0.25rem 0 0.6rem;
  line-height: 1.12;
  text-wrap: balance;
  overflow-wrap: break-word;
  word-break: normal;
}

.identity-preview {
  display: grid;
  gap: 1rem;
}

.identity-header {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.identity-header h3 {
  margin: 0;
  font-family: "Georgia", "Palatino Linotype", serif;
  font-size: 1.7rem;
}

.school-logo-preview {
  width: 5.25rem;
  height: 5.25rem;
  object-fit: cover;
  border-radius: 1.1rem;
  border: 1px solid var(--line);
  background: white;
  box-shadow: var(--shadow);
}

.school-logo-preview-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #58288b, #c9a03e);
  color: white;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.form-photo-field {
  display: grid;
  gap: 0.55rem;
}

.student-passport-thumb {
  display: block;
  width: 5.1rem;
  height: 5.1rem;
  object-fit: cover;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.student-profile-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.student-profile-head h3 {
  margin: 0;
}

.student-profile-head .muted {
  margin: 0.3rem 0 0;
}

.student-search-preview {
  margin: 0 0 1rem;
}

.student-passport-thumb-profile {
  flex: 0 0 auto;
}

.student-passport-thumb-table {
  width: 3rem;
  height: 3rem;
  border-radius: 0.85rem;
  box-shadow: none;
}

.focus-grid,
.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
  gap: 0.7rem;
}

.focus-grid div {
  padding: 0.85rem;
  border-radius: 0.95rem;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
}

.focus-grid span {
  display: block;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.focus-grid strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.05rem;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  max-height: min(68vh, 36rem);
  border: 1px solid rgba(86, 58, 124, 0.06);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.6);
}

table {
  width: max(100%, 760px);
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid rgba(86, 58, 124, 0.06);
  text-align: left;
  vertical-align: top;
  font-size: 0.85rem;
}

tbody tr:last-child td {
  border-bottom: none;
}

th {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(250, 247, 255, 0.96);
  backdrop-filter: blur(8px);
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: rgba(124, 86, 191, 0.03);
}

td input,
td select,
td textarea {
  min-width: 11rem;
}

.row-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.tiny-button {
  min-height: 2.2rem;
  padding: 0.4rem 0.7rem;
  border-radius: 0.85rem;
  background: rgba(239, 230, 255, 0.82);
  color: var(--sky);
  font-weight: 700;
}

.tiny-button-danger {
  background: rgba(253, 233, 233, 0.88);
  color: var(--rose);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.9rem;
  padding: 0 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pill-success {
  background: var(--mint-soft);
  color: var(--mint);
}

.status-pill-warn {
  background: var(--amber-soft);
  color: #9b7421;
}

.status-pill-danger {
  background: var(--rose-soft);
  color: var(--rose);
}

.status-pill-sky {
  background: var(--sky-soft);
  color: var(--sky);
}

.empty-state {
  padding: 1.15rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed rgba(86, 58, 124, 0.2);
  color: var(--ink-soft);
}

.mini-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--ink);
  line-height: 1.7;
}

.child-card {
  display: grid;
  gap: 0.2rem;
  padding: 1rem;
  border-radius: 1.1rem;
  text-align: left;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  overflow-wrap: break-word;
  word-break: normal;
  text-wrap: pretty;
}

.child-card-active {
  background: linear-gradient(135deg, #532683, #7c56bf);
  color: white;
}

.card-rack,
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
}

.feature-card {
  padding: 1.15rem;
  border-radius: 1.2rem;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.feature-card h3 {
  margin-top: 0;
  line-height: 1.15;
  text-wrap: balance;
  overflow-wrap: break-word;
  word-break: normal;
}

.feature-card p {
  overflow-wrap: break-word;
  word-break: normal;
  text-wrap: pretty;
}

.marketplace-ad-image {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 1rem;
  margin-bottom: 0.9rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.marketplace-ad-image-preview {
  max-width: 320px;
}

.homework-attachment-preview {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 1rem;
  margin-bottom: 0.9rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.doc-link {
  display: block;
  padding: 1rem;
  border-radius: 1rem;
  text-decoration: none;
  color: var(--sky);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: break-word;
  word-break: normal;
  text-wrap: pretty;
}

.panel-hero {
  text-align: center;
  padding: 2rem;
}

.panel-hero h2 {
  margin: 0 0 0.8rem;
  font-family: "Georgia", "Palatino Linotype", serif;
  font-size: 2.6rem;
}

.inline-select {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.3rem 0.3rem 0.3rem 0.9rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
}

.inline-select select {
  min-width: 180px;
}

.grid-input {
  min-height: 2.6rem;
}

code {
  font-family: "Consolas", "Courier New", monospace;
}

.ai-floating-button {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1.1rem 0.7rem 0.9rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #1a0a2e, #4a1a7a);
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 12px 35px rgba(26, 10, 46, 0.4);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.ai-floating-button:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 18px 45px rgba(26, 10, 46, 0.5);
}

.ai-floating-icon {
  width: 1.4rem;
  height: 1.4rem;
  flex-shrink: 0;
}

.ai-floating-label {
  letter-spacing: 0.08em;
}

.ai-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
}

.ai-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(38, 18, 64, 0.54);
  backdrop-filter: blur(3px);
}

.ai-overlay-panel {
  position: relative;
  z-index: 1;
  width: min(96vw, 42rem);
  max-height: min(94vh, 44rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 1.35rem;
  background: rgba(251, 248, 255, 0.98);
  border: 1px solid rgba(189, 170, 222, 0.85);
  box-shadow: 0 28px 80px rgba(41, 22, 68, 0.3);
}

.ai-overlay-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.ai-overlay-head h2 {
  margin: 0.15rem 0 0;
  font-family: "Georgia", "Palatino Linotype", serif;
  font-size: clamp(1.3rem, 2.2vw, 1.9rem);
}

.ai-overlay-body {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0.75rem;
  min-height: 0;
  overflow: hidden;
}

.ai-message-list {
  display: grid;
  gap: 0.65rem;
  padding: 0.5rem;
  overflow-y: auto;
  border: 1px solid rgba(86, 58, 124, 0.1);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.72);
}

.ai-message {
  padding: 0.85rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(86, 58, 124, 0.08);
}

.ai-message strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.82rem;
  color: var(--sky);
}

.ai-message p {
  margin: 0;
  line-height: 1.55;
}

.ai-message small {
  display: block;
  margin-top: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.ai-message-user strong {
  color: var(--mint);
}

.ai-message-assistant strong {
  color: var(--sky);
}

.form-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-row .form-actions {
  flex: 0 0 auto;
  margin-left: auto;
}

.file-upload-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  cursor: pointer;
}

.file-upload-label input[type="file"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.file-upload-button {
  display: inline-flex;
  align-items: center;
  min-height: 2.6rem;
  padding: 0.5rem 1rem;
  border-radius: 0.85rem;
  background: rgba(239, 230, 255, 0.86);
  color: var(--sky);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 160ms ease;
  white-space: nowrap;
}

.file-upload-button:hover {
  background: rgba(226, 210, 250, 0.9);
}

.file-upload-name {
  font-size: 0.82rem;
  color: var(--ink-soft);
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .form-row .form-actions {
    margin-left: 0;
  }

  .file-upload-name {
    max-width: 100%;
  }
}

.ai-assistant-meta {
  font-size: 0.82rem;
  overflow-wrap: break-word;
  word-break: normal;
  text-wrap: pretty;
}

/* ========================================
   AI Report Rendering
   ======================================== */

/* Executive Summary Card */
/* ============================================
   AEGIS DASHBOARD — Premium AI Report
   Modular, adaptive executive dashboard
   ============================================ */

/* --- Dashboard Root Grid --- */
.ai-dashboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  align-content: start;
}

/* --- Hero Section (full width) --- */
.ai-dash-hero {
  background: linear-gradient(145deg, #140624, #2a1060);
  border-radius: 1.35rem;
  padding: 1.5rem 1.75rem;
  color: #fff;
  box-shadow: 0 20px 50px rgba(20,6,36,0.35);
  display: grid;
  gap: 1rem;
}
.ai-dash-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.ai-dash-hero-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.4);
}
.ai-dash-hero-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.ai-dash-hero-btn {
  padding: 0.3rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: default;
  transition: background 140ms ease;
}
.ai-dash-hero-btn:hover { background: rgba(255,255,255,0.12); }

.ai-dash-hero-body {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
  align-items: center;
}
.ai-dash-score {
  text-align: center;
  padding: 0.5rem 1.5rem;
}
.ai-dash-score-num {
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}
.ai-dash-score-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.45);
  margin-top: 0.2rem;
}
.ai-dash-badge {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ai-dash-badge.safe { background: rgba(46,139,87,0.25); color: #5dbf7a; }
.ai-dash-badge.warning { background: rgba(201,160,62,0.25); color: #e8c96a; }
.ai-dash-badge.critical { background: rgba(192,57,43,0.25); color: #f05a5a; }

.ai-dash-hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.5rem), 1fr));
  gap: 0.55rem;
}
.ai-dash-hero-cell {
  padding: 0.55rem 0.65rem;
  border-radius: 0.8rem;
  background: rgba(255,255,255,0.07);
  text-align: center;
}
.ai-dash-hero-cell-val {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
}
.ai-dash-hero-cell-lbl {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.1rem;
}
.ai-dash-dot {
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  margin-right: 0.25rem;
}
.ai-dash-dot.green { background: #3cb371; }
.ai-dash-dot.amber { background: #e8c96a; }
.ai-dash-dot.red { background: #f05a5a; }

/* --- Dashboard 2-col split layout --- */
.ai-dash-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.ai-dash-split-col {
  display: grid;
  gap: 1rem;
  align-content: start;
}

/* --- Dashboard Cards (shared) --- */
.ai-dash-card {
  background: #fff;
  border-radius: 1.2rem;
  padding: 1.15rem 1.25rem;
  box-shadow: 0 4px 16px rgba(41,22,68,0.05);
  border: 1px solid rgba(255,255,255,0.7);
  transition: box-shadow 200ms ease;
}
.ai-dash-card:hover { box-shadow: 0 8px 28px rgba(41,22,68,0.09); }
.ai-dash-card-head {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(86,58,124,0.04);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* --- KPI Grid --- */
.ai-dash-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
  gap: 0.85rem;
}
.ai-kpi-card {
  background: #fff;
  border-radius: 1.2rem;
  padding: 1rem 1.15rem;
  box-shadow: 0 4px 16px rgba(41,22,68,0.05);
  border: 1px solid rgba(255,255,255,0.7);
  transition: box-shadow 200ms ease, transform 200ms ease;
}
.ai-kpi-card:hover { box-shadow: 0 8px 28px rgba(41,22,68,0.09); transform: translateY(-1px); }
.ai-kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}
.ai-kpi-ico {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}
.ai-kpi-ico.purple { background: rgba(124,86,191,0.1); color: var(--sky); }
.ai-kpi-ico.gold { background: rgba(201,160,62,0.12); color: var(--gold); }
.ai-kpi-ico.rose { background: rgba(159,63,99,0.1); color: var(--rose); }
.ai-kpi-ico.mint { background: rgba(93,45,144,0.1); color: var(--mint); }
.ai-kpi-tr {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
}
.ai-kpi-tr.up { background: rgba(46,139,87,0.1); color: #2e8b57; }
.ai-kpi-tr.down { background: rgba(192,57,43,0.1); color: #c0392b; }
.ai-kpi-tr.neutral { background: rgba(86,58,124,0.05); color: var(--ink-soft); }
.ai-kpi-label { font-size: 0.68rem; color: var(--ink-soft); font-weight: 500; margin-bottom: 0.1rem; }
.ai-kpi-val {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--ink);
}
.ai-kpi-sub { font-size: 0.68rem; color: var(--ink-soft); margin-top: 0.15rem; }
.ai-kpi-comp {
  font-size: 0.65rem;
  color: var(--ink-soft);
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  border-top: 1px solid rgba(86,58,124,0.04);
}

/* --- Insights --- */
.ai-insights { }
.ai-insights-list { display: grid; gap: 0.6rem; }
.ai-insight-item {
  padding: 0.8rem 1rem;
  border-radius: 0.9rem;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(86,58,124,0.05);
  display: grid;
  gap: 0.2rem;
  font-size: 0.84rem;
  line-height: 1.5;
  transition: box-shadow 140ms ease;
}
.ai-insight-item:hover { box-shadow: 0 2px 10px rgba(41,22,68,0.05); }
.ai-insight-item[data-severity="critical"] { border-left: 3px solid #e74c3c; background: rgba(253,237,239,0.4); }
.ai-insight-item[data-severity="warning"] { border-left: 3px solid #e8c96a; background: rgba(255,245,217,0.35); }
.ai-insight-item[data-severity="info"] { border-left: 3px solid var(--sky); }
.ai-insight-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
}
.ai-insight-text { display: block; font-size: 0.8rem; line-height: 1.5; color: var(--ink-soft); }
.ai-insight-badge {
  display: inline-block;
  padding: 0.06rem 0.4rem;
  border-radius: 999px;
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: auto;
}
.ai-insight-badge.critical { background: rgba(192,57,43,0.1); color: #c0392b; }
.ai-insight-badge.high { background: rgba(201,160,62,0.12); color: #b8942e; }
.ai-insight-badge.medium { background: rgba(124,86,191,0.08); color: var(--sky); }
.ai-insight-badge.low { background: rgba(86,58,124,0.05); color: var(--ink-soft); }
.ai-insight-impact { font-size: 0.7rem; color: var(--ink-soft); padding-top: 0.2rem; }

/* --- Recommendations --- */
.ai-recommendations { }
.ai-recommendations-list { display: grid; gap: 0.5rem; }
.ai-rec-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  border-radius: 0.85rem;
  background: rgba(255,255,255,0.65);
  border: 1px solid rgba(86,58,124,0.04);
  transition: background 140ms ease, box-shadow 140ms ease;
  font-size: 0.84rem;
  line-height: 1.5;
}
.ai-rec-item:hover { background: rgba(255,255,255,0.85); box-shadow: 0 2px 8px rgba(41,22,68,0.05); }
.ai-rec-item input[type="checkbox"] { margin-top: 0.12rem; flex: 0 0 auto; accent-color: var(--mint); }
.ai-rec-label { flex: 1; }
.ai-rec-priority {
  display: inline-block;
  padding: 0.06rem 0.4rem;
  border-radius: 999px;
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 0.4rem;
  flex: 0 0 auto;
}
.ai-rec-priority.critical { background: rgba(192,57,43,0.1); color: #c0392b; }
.ai-rec-priority.high { background: rgba(201,160,62,0.12); color: #b8942e; }
.ai-rec-priority.medium { background: rgba(124,86,191,0.08); color: var(--sky); }
.ai-rec-priority.low { background: rgba(86,58,124,0.05); color: var(--ink-soft); }
.ai-rec-outcome { font-size: 0.72rem; color: var(--ink-soft); margin-top: 0.15rem; }

/* --- Progress Bar --- */
.ai-pbar {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 4rem;
}
.ai-pbar-track {
  flex: 1;
  height: 0.35rem;
  border-radius: 999px;
  background: rgba(86,58,124,0.08);
  overflow: hidden;
  min-width: 2rem;
}
.ai-pbar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width 320ms ease;
}
.ai-pbar-high { background: linear-gradient(90deg, #2e8b57, #3cb371); }
.ai-pbar-mid { background: linear-gradient(90deg, #c9a03e, #e8c96a); }
.ai-pbar-low { background: linear-gradient(90deg, #c0392b, #e74c3c); }
.ai-pbar-label {
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  min-width: 3ch;
  text-align: right;
}

/* --- Risk Grid --- */
.ai-risk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr));
  gap: 0.85rem;
}
.ai-risk-card {
  background: #fff;
  border-radius: 1.2rem;
  padding: 1rem 1.15rem;
  box-shadow: 0 4px 16px rgba(41,22,68,0.05);
  border: 1px solid rgba(255,255,255,0.7);
  display: grid;
  gap: 0.25rem;
  transition: box-shadow 200ms ease;
}
.ai-risk-card:hover { box-shadow: 0 8px 28px rgba(41,22,68,0.09); }
.ai-risk-score {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}
.ai-risk-score.critical { color: #e74c3c; }
.ai-risk-score.high { color: #e8c96a; }
.ai-risk-score.medium { color: var(--sky); }
.ai-risk-score.low { color: #3cb371; }
.ai-risk-dept { font-size: 0.72rem; color: var(--ink-soft); font-weight: 500; }
.ai-risk-desc { font-size: 0.8rem; color: var(--ink); line-height: 1.4; }
.ai-risk-impact { font-size: 0.7rem; color: var(--rose); font-weight: 600; }

/* --- Smart Callout --- */
.ai-callout {
  padding: 0.9rem 1.1rem;
  border-radius: 1rem;
  display: grid;
  gap: 0.2rem;
  border-left: 4px solid;
  font-size: 0.82rem;
  line-height: 1.5;
}
.ai-callout-critical { background: rgba(253,237,239,0.5); border-color: #e74c3c; }
.ai-callout-warning { background: rgba(255,245,217,0.5); border-color: #e8c96a; }
.ai-callout-info { background: rgba(239,230,255,0.45); border-color: var(--sky); }
.ai-callout-success { background: rgba(240,255,240,0.45); border-color: #3cb371; }
.ai-callout-title { font-weight: 700; font-size: 0.85rem; color: var(--ink); }
.ai-callout-text { color: var(--ink-soft); }

/* --- Confidence Badge --- */
.ai-confidence {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.6rem;
  border-radius: 0.5rem;
  background: rgba(255,255,255,0.5);
  font-size: 0.7rem;
  color: var(--ink-soft);
}
.ai-confidence-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  flex: 0 0 auto;
}
.ai-confidence-dot.high { background: #3cb371; }
.ai-confidence-dot.medium { background: #e8c96a; }
.ai-confidence-dot.low { background: #e74c3c; }

/* --- Status Pills --- */
.ai-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.06rem 0.45rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ai-pill-safe { background: rgba(46,139,87,0.1); color: #2e8b57; }
.ai-pill-warning { background: rgba(201,160,62,0.12); color: #b8942e; }
.ai-pill-danger { background: rgba(192,57,43,0.1); color: #c0392b; }
.ai-pill-info { background: rgba(124,86,191,0.08); color: var(--sky); }
.ai-pill-neutral { background: rgba(86,58,124,0.05); color: var(--ink-soft); }

/* --- Premium Table --- */
.ai-report-table {
  margin: 0;
  overflow-x: auto;
  border: 1px solid rgba(86,58,124,0.04);
  border-radius: 1.1rem;
  background: #fff;
  box-shadow: 0 2px 10px rgba(41,22,68,0.04);
}
.ai-report-table table {
  width: 100%;
  min-width: 460px;
  border-collapse: collapse;
}
.ai-report-table th,
.ai-report-table td {
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid rgba(86,58,124,0.04);
  text-align: left;
  font-size: 0.82rem;
  color: var(--ink);
}
.ai-report-table th {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  background: rgba(250,247,255,0.92);
  position: sticky;
  top: 0;
  z-index: 1;
  backdrop-filter: blur(6px);
}
.ai-report-table tbody tr { transition: background 140ms ease; }
.ai-report-table tbody tr:hover { background: rgba(124,86,191,0.03); }
.ai-report-table tbody tr:last-child td { border-bottom: none; }
.ai-col-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.ai-col-percent { text-align: right; min-width: 6.5rem; }
.ai-rank-top { font-weight: 700; }
.ai-rank-1 td:first-child::before { content: "🥇 "; }
.ai-rank-2 td:first-child::before { content: "🥈 "; }
.ai-rank-3 td:first-child::before { content: "🥉 "; }
.ai-rank-1 { background: linear-gradient(90deg, rgba(255,215,0,0.05), transparent) !important; }
.ai-rank-2 { background: linear-gradient(90deg, rgba(192,192,192,0.05), transparent) !important; }
.ai-rank-3 { background: linear-gradient(90deg, rgba(205,127,50,0.04), transparent) !important; }

/* --- Key-Value Grid --- */
.ai-kv-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.65rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border-radius: 1rem;
  border: 1px solid rgba(86,58,124,0.03);
  box-shadow: 0 2px 10px rgba(41,22,68,0.03);
}
.ai-kv-row { display: contents; }
.ai-kv-label { font-size: 0.7rem; font-weight: 600; color: var(--ink-soft); text-align: right; white-space: nowrap; padding: 0.1rem 0; }
.ai-kv-value { font-size: 0.82rem; color: var(--ink); padding: 0.1rem 0; font-weight: 500; }
.ai-kv-value .ai-pbar { display: inline-flex; vertical-align: middle; }

/* --- Reporting Context (metadata footer) --- */
.ai-reporting-context {
  background: rgba(255,255,255,0.55);
  border-radius: 1rem;
  padding: 0.85rem 1rem;
}
.ai-rc-header {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.ai-rc-icon { font-size: 0.75rem; }
.ai-rc-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 0.25rem 0.75rem; }
.ai-rc-item { font-size: 0.75rem; }
.ai-rc-label { font-weight: 600; color: var(--ink-soft); }
.ai-rc-value { color: var(--ink); }

/* --- Missing Info --- */
.ai-missing-info {
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid rgba(86,58,124,0.04);
  background: #fff;
  box-shadow: 0 2px 10px rgba(41,22,68,0.03);
}
.ai-missing-info summary {
  padding: 0.6rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  transition: background 140ms ease;
}
.ai-missing-info summary:hover { background: rgba(86,58,124,0.02); }
.ai-missing-info-body {
  padding: 0.6rem 0.8rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
  line-height: 1.5;
  border-top: 1px solid rgba(86,58,124,0.03);
}

/* --- Code block --- */
.ai-code-block {
  margin: 0.5rem 0;
  padding: 0.8rem;
  border-radius: 0.85rem;
  background: #1a1a2e;
  color: #e0e0e0;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre-wrap;
}

/* --- Section heading (dynamic) --- */
.ai-report-heading {
  margin: 0.4rem 0 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* --- Text content within dashboard --- */
.ai-dash-text { font-size: 0.85rem; line-height: 1.6; color: var(--ink); }
.ai-dash-text p { margin: 0.3rem 0; }

/* --- Fallback for non-analytical messages --- */
.ai-message-content p { margin: 0.3rem 0; line-height: 1.65; }
.ai-message-content p:first-child { margin-top: 0; }

@media (max-width: 860px) {
  .ai-floating-button {
    right: 0.75rem;
    bottom: 0.75rem;
    padding: 0.6rem 0.9rem 0.6rem 0.75rem;
    font-size: 0.85rem;
  }

  .ai-floating-label {
    display: none;
  }

  .ai-overlay-panel {
    width: 100vw;
    height: 100vh;
    max-height: none;
    border-radius: 0;
    padding: 0.75rem;
  }
}

.import-progress-track {
  width: 100%;
  height: 12px;
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
  margin: 0.25rem 0 0.25rem 0;
}

.import-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.import-phase-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.25rem;
}

.import-pct-label {
  font-size: 0.78rem;
  color: #64748b;
  text-align: right;
  margin-top: 0.15rem;
}

.summary-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.summary-num {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2563eb;
}

.summary-label {
  font-size: 0.78rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.text-link {
  color: #2563eb;
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.85rem;
}

.text-link:hover {
  color: #1d4ed8;
}

.import-stage-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.import-stage {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.8rem;
  color: #94a3b8;
}

.import-stage.stage-current {
  color: #1e293b;
  background: #eff6ff;
  font-weight: 600;
}

.import-stage.stage-complete {
  color: #16a34a;
}

.stage-icon {
  font-size: 0.7rem;
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
}

.stage-done { color: #16a34a; }
.stage-active { color: #2563eb; animation: pulse 1.5s infinite; }
.stage-pending { color: #cbd5e1; }

.stage-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.import-warning-summary {
  color: #d97706;
  font-weight: 600;
  cursor: pointer;
}

.import-error-summary {
  color: #dc2626;
  font-weight: 600;
  cursor: pointer;
}

.import-warning-item {
  color: #92400e;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@media (max-width: 1180px) {
  .auth-panel,
  .app-shell,
  .layout-two,
  .card-rack,
  .link-grid {
    grid-template-columns: 1fr;
  }

  .auth-intro {
    order: 1;
  }

  .auth-card {
    order: 2;
  }

  .dashboard-preview {
    max-width: 560px;
  }

  .auth-intro h1 {
    font-size: 3rem;
  }

  .app-shell {
    width: min(100% - 1rem, 70rem);
  }

  .sidebar {
    position: static;
  }

  .metric-grid,
  .toolbar-grid,
  .focus-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .auth-screen,
  .app-shell {
    width: min(100% - 0.75rem, 42rem);
  }

  .auth-screen {
    padding: 1rem 0 2rem;
  }

  .auth-intro h1 {
    font-size: clamp(2rem, 6vw, 2.5rem);
  }

  .dashboard-preview {
    margin: 1.25rem 0 1rem;
  }

  .dash-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .trust-badges {
    gap: 0.4rem;
  }

  .trust-badge {
    font-size: 0.58rem;
    padding: 0.25rem 0.5rem;
  }

  body.mobile-nav-open {
    overflow: hidden;
  }

  .app-shell {
    display: block;
    width: min(100% - 0.5rem, 42rem);
    padding-top: 0.75rem;
  }

  .app-shell.mobile-nav-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 60;
    width: min(84vw, 21rem);
    max-width: 21rem;
    height: 100dvh;
    max-height: 100dvh;
    padding: 0.9rem 0.75rem 1.4rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    align-content: start;
    background: linear-gradient(180deg, rgba(249, 244, 255, 0.98), rgba(244, 235, 252, 0.98));
    box-shadow: 24px 0 46px rgba(41, 22, 68, 0.28);
    transform: translateX(calc(-100% - 1.25rem));
    transition: transform 220ms ease;
  }

  .sidebar .nav-menu {
    min-height: 0;
    padding-bottom: 1rem;
  }

  .app-shell.mobile-nav-open .sidebar {
    transform: translateX(0);
  }

  .main-shell {
    overflow: visible;
  }

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

  .brand-block,
  .sidebar-card,
  .panel {
    border-radius: var(--radius);
  }

  .brand-block,
  .sidebar-card {
    padding: 1rem;
  }

  .topbar {
    gap: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .credential-grid,
  .metric-grid,
  .toolbar-grid,
  .focus-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar-main {
    align-items: center;
  }

  .topbar h1 {
    font-size: clamp(1.55rem, 7vw, 2.2rem);
  }

  .topbar .muted {
    font-size: 0.94rem;
  }

  .topbar-actions {
    justify-content: flex-start;
    width: 100%;
    gap: 0.5rem;
  }

  .bar-row,
  .donut-card {
    grid-template-columns: 1fr;
  }

  .bar-value {
    justify-self: start;
  }

  .line-chart {
    min-height: 13rem;
  }

  .pill,
  .secondary-button {
    min-height: 2.7rem;
  }

  .view-active {
    padding-bottom: 1rem;
  }

  .document-overlay {
    align-items: stretch;
  }

  .document-overlay-panel {
    width: 100vw;
    height: 100vh;
    max-height: none;
    border-radius: 0;
    padding: 0.9rem 0.75rem 0.75rem;
  }

  .document-overlay-head {
    flex-direction: column;
    align-items: stretch;
  }

  .document-overlay-head .row-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .document-overlay-frame {
    height: calc(100vh - 12.5rem);
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .table-wrap {
    max-height: min(62vh, 28rem);
  }

  table {
    width: max(100%, 620px);
    min-width: 620px;
  }

  td input,
  td select,
  td textarea {
    min-width: 8.5rem;
  }
}

/* Analytics dashboard */
.analytics-health-banner { border-left: 6px solid var(--ink); }
.analytics-health-banner.health-healthy { border-left-color: var(--green); }
.analytics-health-banner.health-at-risk { border-left-color: var(--yellow); }
.analytics-health-banner.health-critical { border-left-color: var(--red); }

.analytics-category-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.analytics-category-card .panel-head { padding-bottom: 0.3rem; }
.analytics-score { font-size: 1.1rem; font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 0.4rem; }
.analytics-score.severity-low { background: var(--green-bg, #d4edda); color: var(--green, #155724); }
.analytics-score.severity-medium { background: var(--yellow-bg, #fff3cd); color: var(--yellow, #856404); }
.analytics-score.severity-high { background: var(--red-bg, #f8d7da); color: var(--red, #721c24); }

.analytics-insight-item:last-child { border-bottom: none !important; }

.analytics-overlay-panel { max-width: 720px; }

.badge { display: inline-block; font-size: 0.65rem; font-weight: 700; padding: 0.1rem 0.4rem; border-radius: 0.3rem; background: var(--ink); color: var(--paper); text-transform: uppercase; letter-spacing: 0.03em; vertical-align: middle; margin-left: 0.4rem; }
.error-text { color: var(--red); }
.warning-text { color: var(--yellow); }

.aegis-report {
  margin: 0.5rem 0;
}

.ai-inline-code {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 0.25rem;
  padding: 0.1rem 0.3rem;
  font-family: "SF Mono", "Menlo", "Monaco", "Consolas", monospace;
  font-size: 0.82em;
  color: #1e293b;
}

.ai-report-hr {
  border: none;
  border-top: 2px solid #e2e8f0;
  margin: 1rem 0;
}

.ai-streaming {
  color: #6b7280;
  font-style: italic;
  animation: pulse 1.5s infinite;
}

.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid #cbd5e1;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 0.2rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.tiny-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media print {
  body * { visibility: hidden; }
  .aegis-report, .aegis-report * { visibility: visible; }
  .aegis-report { position: absolute; inset: 0; width: 100%; }
  .ai-report-actions, .report-actions, .no-print { display: none !important; }
  .ai-message strong, .ai-message small { display: none !important; }
}
