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

:root {
  --primary: #5B21B6;
  --primary-light: #7C3AED;
  --primary-soft: #8B5CF6;
  --primary-bg: rgba(91, 33, 182, 0.08);
  --primary-glow: rgba(91, 33, 182, 0.15);
  --secondary: #C4B5FD;
  --accent: #D4A843;
  --accent-soft: rgba(212, 168, 67, 0.12);
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --warning: #F59E0B;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger: #EF4444;
  --danger-bg: rgba(239, 68, 68, 0.08);

  --ink: #1A1A2E;
  --ink-soft: #6B7280;
  --ink-muted: #9CA3AF;
  --paper: #F8F6F3;
  --paper-warm: #F5F3F0;
  --panel: rgba(255, 255, 255, 0.85);
  --panel-solid: #FFFFFF;
  --line: rgba(0, 0, 0, 0.06);
  --line-strong: rgba(0, 0, 0, 0.1);

  --panel-blend: rgba(255, 255, 255, 0.95);
  --surface-soft: rgba(255, 255, 255, 0.5);
  --surface-strong: rgba(255, 255, 255, 0.8);
  --surface-faint: rgba(255, 255, 255, 0.4);
  --field-bg: rgba(255, 255, 255, 0.9);
  --chip-bg: rgba(255, 255, 255, 0.7);
  --tint-fade: rgba(255, 255, 255, 0.5);
  --metric-track: rgba(0, 0, 0, 0.04);
  --row-hover: rgba(91, 33, 182, 0.02);
  --scrim-bg: rgba(0, 0, 0, 0.3);
  --primary-text: var(--primary);
  --gold-ink: #A0812E;
  --amber-ink: #B45309;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;
}

/* ─── Dark theme ─── */
[data-theme="dark"] {
  color-scheme: dark;

  --primary-bg: rgba(139, 92, 246, 0.18);
  --primary-glow: rgba(139, 92, 246, 0.28);
  --accent-soft: rgba(212, 168, 67, 0.16);
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning-bg: rgba(245, 158, 11, 0.16);
  --danger-bg: rgba(239, 68, 68, 0.14);

  --ink: #F1EFFA;
  --ink-soft: #B7B0CB;
  --ink-muted: #8279A0;
  --paper: #131120;
  --paper-warm: #1A172B;
  --panel: rgba(26, 23, 43, 0.85);
  --panel-solid: #1D1930;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);

  --panel-blend: rgba(29, 25, 48, 0.92);
  --surface-soft: rgba(36, 31, 58, 0.6);
  --surface-strong: rgba(38, 33, 62, 0.92);
  --surface-faint: rgba(36, 31, 58, 0.45);
  --field-bg: rgba(38, 33, 62, 0.9);
  --chip-bg: rgba(38, 33, 62, 0.75);
  --tint-fade: rgba(26, 23, 43, 0.6);
  --metric-track: rgba(255, 255, 255, 0.1);
  --row-hover: rgba(139, 92, 246, 0.09);
  --scrim-bg: rgba(0, 0, 0, 0.55);

  --primary-text: #A78BFA;
  --gold-ink: #E5C76A;
  --amber-ink: #FBBF24;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.45), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
}

.hidden { display: none !important; }

.eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent);
}

.muted, .helper-text { color: var(--ink-soft); }
.kicker { color: var(--ink-muted); font-size: 0.82rem; }

/* ─── Auth Screen ─── */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 45fr 55fr;
  align-items: stretch;
  width: 100%;
  max-width: 1780px;
  margin: 0 auto;
}

.auth-copy {
  background: #14102A;
  color: #fff;
  padding: 2.5rem 3rem;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.mk-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex: 1;
  min-height: 0;
}

/* ─── Marketing background layers ─── */
.mk-background {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.mk-bg-gradients {
  position: absolute;
  inset: -22%;
  background:
    radial-gradient(38% 44% at 18% 16%, rgba(91, 33, 182, 0.55), transparent 70%),
    radial-gradient(42% 46% at 82% 22%, rgba(76, 29, 149, 0.45), transparent 70%),
    radial-gradient(52% 56% at 50% 112%, rgba(30, 27, 75, 0.9), transparent 72%);
  will-change: transform;
  animation: mk-drift 20s ease-in-out infinite alternate;
}

.mk-bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  will-change: transform;
}
.mk-blob-1 {
  width: 42vw; height: 42vw;
  left: -12vw; top: -14vw;
  background: radial-gradient(circle at 30% 30%, rgba(124, 58, 237, 0.5), transparent 65%);
  animation: mk-blob-a 18s ease-in-out infinite alternate;
}
.mk-blob-2 {
  width: 36vw; height: 36vw;
  right: -10vw; bottom: -12vw;
  background: radial-gradient(circle at 60% 60%, rgba(212, 168, 67, 0.2), transparent 65%);
  animation: mk-blob-b 20s ease-in-out infinite alternate;
}
.mk-blob-3 {
  width: 30vw; height: 30vw;
  right: 24vw; top: 10vh;
  background: radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.16), transparent 65%);
  animation: mk-blob-c 16s ease-in-out infinite alternate;
}

.mk-bg-particles { position: absolute; inset: 0; }
.mk-particle {
  position: absolute;
  bottom: -14px;
  left: var(--x, 10%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  opacity: 0;
  will-change: transform, opacity;
  animation: mk-rise var(--dur, 16s) linear infinite;
  animation-delay: var(--delay, 0s);
}

.mk-bg-glass {
  position: absolute;
  inset: 0;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 34%, rgba(255, 255, 255, 0.04) 68%, rgba(255, 255, 255, 0) 100%);
}
.mk-bg-glass::after {
  content: '';
  position: absolute;
  top: -30%;
  bottom: -30%;
  left: -20%;
  width: 55%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  transform: translateX(-160%);
  animation: mk-sheen 9s ease-in-out infinite;
}

.mk-bg-skyline {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 30%;
  will-change: transform;
  animation: mk-parallax 20s ease-in-out infinite alternate;
}
.mk-bg-skyline svg {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0.12;
}

/* ─── Marketing brand ─── */
.mk-brand { display: flex; align-items: center; gap: 0.9rem; }
.mk-brand .brand-mark { width: 3rem; min-width: 3rem; }
.mk-brand-name { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; color: #fff; }
.mk-brand-tag { margin: 0.1rem 0 0; font-size: 0.72rem; color: rgba(255, 255, 255, 0.6); }

/* ─── Marketing hero ─── */
.mk-hero { animation: mk-fade-up 900ms ease both; }
.mk-headline {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 1.85rem);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: #fff;
  max-width: 24ch;
}
.mk-headline em { font-style: normal; color: #E9D5FF; }
.mk-subline {
  margin: 0.9rem 0 0;
  max-width: 46ch;
  font-size: 0.9rem;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.68);
}

/* ─── Product preview ─── */
.mk-stage { position: relative; margin: 0.35rem 0 0.6rem; animation: mk-fade-up 900ms ease 120ms both; }

.mk-preview {
  position: relative;
  width: min(30rem, 88%);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(14px);
  box-shadow: 0 24px 60px -18px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  will-change: transform;
  animation: mk-float-hero 12s ease-in-out infinite;
}
.mk-preview-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.mk-preview-dot { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: rgba(255, 255, 255, 0.28); }
.mk-preview-dot:first-child { background: rgba(244, 114, 182, 0.85); }
.mk-preview-dot:nth-child(2) { background: rgba(251, 191, 36, 0.85); }
.mk-preview-dot:nth-child(3) { background: rgba(52, 211, 153, 0.85); }
.mk-preview-url { margin-left: 0.4rem; font-size: 0.58rem; color: rgba(255, 255, 255, 0.55); letter-spacing: 0.02em; }
.mk-preview-body { padding: 0.7rem; display: grid; gap: 0.6rem; }
.mk-preview-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4rem; }
.mk-preview-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.56rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
}
.mk-preview-kpi b { font-size: 0.95rem; font-weight: 700; letter-spacing: 0; color: #fff; }
.mk-preview-chart { display: flex; align-items: flex-end; gap: 0.35rem; height: 64px; padding: 0 0.2rem; }
.mk-preview-chart i {
  flex: 1;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, rgba(196, 181, 253, 0.95), rgba(124, 58, 237, 0.6));
  transform-origin: bottom;
  animation: mk-grow 1.2s cubic-bezier(0.2, 0.7, 0.3, 1) both;
  animation-delay: var(--d, 0s);
}

/* ─── Capability chips ─── */
.mk-modules {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  animation: mk-fade-up 900ms ease 160ms both;
}
.mk-module {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.65rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
}
.mk-module-check {
  width: 1rem; height: 1rem;
  border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(16, 185, 129, 0.25);
  color: #6EE7B7;
  flex-shrink: 0;
}

/* ─── AEGIS signature ─── */
.mk-aegis-block {
  display: grid;
  gap: 0.22rem;
  padding: 0.9rem 1.15rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.14), rgba(124, 58, 237, 0.04));
  border: 1px solid rgba(167, 139, 250, 0.2);
  box-shadow: 0 0 30px -14px rgba(124, 58, 237, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: mk-fade-up 900ms ease 300ms both;
}
.mk-aegis-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
}
.mk-aegis-icon {
  width: 1.5rem; height: 1.5rem;
  border-radius: 0.5rem;
  display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.5), rgba(124, 58, 237, 0.22));
  color: #D8CCFB;
  animation: mk-ai-glow 5s ease-in-out infinite;
}
.mk-aegis-dot { color: rgba(196, 181, 253, 0.6); }
.mk-aegis-word {
  color: #C4B5FD;
  letter-spacing: 0.22em;
  font-weight: 700;
  text-shadow: 0 0 16px rgba(167, 139, 250, 0.55);
}
.mk-aegis-tagline { margin: 0.35rem 0 0; font-size: 0.72rem; color: rgba(255, 255, 255, 0.62); }
.mk-aegis-note { margin: 0; font-size: 0.68rem; font-style: italic; color: rgba(255, 255, 255, 0.45); }
.mk-aegis-house { margin: 0.3rem 0 0; font-size: 0.72rem; color: rgba(255, 255, 255, 0.5); }
@keyframes mk-ai-glow {
  0%, 100% { box-shadow: 0 0 18px -8px rgba(124, 58, 237, 0.6); }
  50% { box-shadow: 0 0 26px -6px rgba(139, 92, 246, 0.85); }
}

/* ─── Marketing footer ─── */
.mk-footer {
  margin-top: auto;
  padding-top: 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: flex-end;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.55);
  animation: mk-fade-up 900ms ease 540ms both;
}
.mk-footer-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.mk-footer a {
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  padding: 0.3rem 0;
}
.mk-footer a:hover { color: #fff; text-decoration: underline; }

/* ─── Auth Panel ─── */
.auth-panel {
  background: var(--paper);
  padding: 3rem 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
}

.auth-panel-head { margin-bottom: 0.5rem; }
.auth-panel-head .eyebrow { color: var(--primary-text); }
.auth-panel-head h2 { margin: 0; font-size: 1.5rem; font-weight: 700; line-height: 1.3; color: var(--ink); }
.auth-panel-head p { margin: 0.5rem 0 0; font-size: 0.88rem; color: var(--ink-soft); line-height: 1.6; }

.auth-form-meta { display: flex; justify-content: flex-end; margin-top: -0.35rem; }
.forgot-password {
  background: none;
  border: 0;
  padding: 0.3rem 0.25rem;
  color: var(--primary-text);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  min-height: 2rem;
}
.forgot-password:hover { color: var(--primary-light); }

/* ─── Auth Panel Internals ─── */
.auth-panel .stack { gap: 1rem; }
.auth-panel .primary-button { width: 100%; min-height: 2.8rem; font-size: 0.9rem; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.5rem 0;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.auth-divider span {
  font-size: 0.75rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

.auth-registration-toggle {
  width: 100%;
  background: none;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color 200ms ease, background 200ms ease;
}
.auth-registration-toggle:hover {
  border-color: var(--primary-text);
  background: var(--primary-bg);
}
.auth-registration-toggle .toggle-label {
  text-align: left;
}
.auth-registration-toggle .toggle-label strong {
  display: block;
  font-size: 0.85rem;
  color: var(--ink);
  margin-bottom: 0.1rem;
}
.auth-registration-toggle .toggle-label span {
  font-size: 0.75rem;
  color: var(--ink-muted);
}
.auth-registration-toggle .toggle-chevron {
  font-size: 0.7rem;
  color: var(--ink-muted);
  transition: transform 200ms ease;
}
.auth-registration-toggle[aria-expanded="true"] .toggle-chevron {
  transform: rotate(180deg);
}

.auth-registration-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 350ms ease, opacity 250ms ease;
  opacity: 0;
}
.auth-registration-body.open {
  max-height: 2000px;
  opacity: 1;
}
.auth-registration-body .auth-registration-inner {
  padding-top: 0.5rem;
}

.auth-registration-inner .form-grid {
  grid-template-columns: 1fr;
}

/* ─── Brand lockup ─── */
.brand-lockup, .sidebar-brand { display: flex; gap: 1rem; align-items: flex-start; }
.brand-mark { width: 4.75rem; min-width: 4.75rem; color: var(--primary-text); }
.brand-mark.mini { width: 3rem; min-width: 3rem; }
.auth-copy .brand-mark { width: 3rem; min-width: 3rem; }
.brand-mark svg { display: block; width: 100%; height: auto; }
.brand-mark img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--panel-solid); }

.lead { max-width: 56rem; font-size: 0.95rem; line-height: 1.7; color: var(--ink-soft); }

.credential-strip { display: block; }
.credential-card { border-radius: var(--radius-lg); padding: 1.25rem; background: var(--surface-soft); border: 1px solid var(--line); }
.credential-card p, .credential-card h3 { margin: 0; }
.credential-card .role-tag { color: var(--primary-text); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }

.auth-secondary-panel { border-top: 1px solid var(--line); padding-top: 1.25rem; display: grid; gap: 1rem; }
.auth-join-highlight { display: flex; gap: 0.85rem; align-items: center; padding: 1rem 1.15rem; border-radius: var(--radius-md); background: var(--surface-soft); border: 1px solid var(--line); }
.auth-join-highlight strong, .auth-join-highlight p { margin: 0; }

/* ─── Forms ─── */
.stack, .form-grid { display: grid; gap: 1rem; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 0.35rem; }
label > span { font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); }

input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--field-bg);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.password-input-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem; align-items: center; }
.field-note { margin-top: 0.2rem; font-size: 0.75rem; line-height: 1.5; color: var(--ink-muted); }
.form-note { padding: 0.9rem 1rem; border-radius: var(--radius-sm); background: var(--surface-soft); border: 1px solid var(--line); color: var(--ink-soft); line-height: 1.55; }
.full-span { grid-column: 1 / -1; }
textarea { min-height: 100px; resize: vertical; }
button { font: inherit; cursor: pointer; }

/* ─── Buttons ─── */
.primary-button, .secondary-button, .ghost-button, .nav-button, .tiny-button {
  border: 0;
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 200ms ease, background 200ms ease, color 200ms ease;
}
.primary-button:hover, .secondary-button:hover, .ghost-button:hover, .nav-button:hover, .tiny-button:hover {
  transform: translateY(-1px);
}
.primary-button:active, .secondary-button:active, .tiny-button:active {
  transform: translateY(0) scale(0.98);
}

.primary-button {
  min-height: 2.6rem;
  padding: 0 1.5rem;
  border-radius: var(--radius-full);
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  box-shadow: 0 4px 14px var(--primary-glow);
  font-weight: 600;
  font-size: 0.85rem;
}
.primary-button:hover {
  box-shadow: 0 6px 20px var(--primary-glow);
  transform: translateY(-1px);
}

.secondary-button, .ghost-button {
  min-height: 2.6rem;
  padding: 0 1.25rem;
  border-radius: var(--radius-full);
  background: var(--surface-strong);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 500;
}
.secondary-button:hover { background: var(--panel-solid); border-color: var(--line-strong); }

.ghost-button { background: transparent; border-color: transparent; }
.ghost-button:hover { background: var(--primary-bg); color: var(--primary-text); }

.tiny-button {
  min-height: 2rem;
  padding: 0 0.75rem;
  border-radius: var(--radius-full);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.tiny-button.warn { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.tiny-button:hover { background: var(--panel-solid); }

/* ─── App Shell ─── */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1.5rem;
  width: min(1600px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 1.5rem;
}

/* ─── Sidebar ─── */
.sidebar {
  padding: 1.25rem;
  display: grid;
  gap: 0.25rem;
  align-self: start;
  position: sticky;
  top: 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.sidebar-brand { margin-bottom: 0.5rem; }
.sidebar-brand h2 { margin: 0; font-size: 1.1rem; font-weight: 600; line-height: 1.3; }
.sidebar-brand p { margin: 0; font-size: 0.75rem; color: var(--ink-muted); }

.sidebar-section { margin-bottom: 1rem; }
.sidebar-section:last-child { margin-bottom: 0; }
.sidebar-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
}

/* ─── Session Panel ─── */
.sidebar-block {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}
.sidebar-block h3 { margin: 0; font-size: 0.85rem; font-weight: 600; }
.sidebar-block p { margin: 0.15rem 0 0; font-size: 0.75rem; color: var(--ink-muted); }
.sidebar-block .record-meta { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* ─── Navigation ─── */
.nav-menu { display: grid; gap: 0.25rem; }
.nav-group { margin-bottom: 0.25rem; }
.nav-group-label {
  padding: 0.4rem 0.75rem;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

.nav-button {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.85rem;
  font-weight: 500;
  width: 100%;
  position: relative;
  transition: all 200ms ease;
}
.nav-button:hover {
  background: var(--primary-bg);
  color: var(--primary-text);
}
.nav-button.active {
  background: linear-gradient(135deg, var(--primary-bg), rgba(139, 92, 246, 0.12));
  color: var(--primary-text);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary-light);
}
.nav-button .nav-icon {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  color: currentColor;
}
.nav-button.active .nav-icon { color: var(--primary-light); }
.nav-button span:not(.nav-icon) { font-size: 0.72rem; color: var(--ink-muted); display: block; margin-top: 0.1rem; }

.sidebar-scrim { display: none; }

/* ─── Plan Panel ─── */
#planPanel {
  background: linear-gradient(135deg, rgba(91, 33, 182, 0.04), rgba(196, 181, 253, 0.06));
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-top: 0.5rem;
}
#planPanel h3 { margin: 0; font-size: 0.85rem; font-weight: 600; }
#planPanel p { margin: 0.15rem 0 0; font-size: 0.75rem; color: var(--ink-muted); }

/* ─── Main Shell ─── */
.main-shell { display: grid; gap: 1.25rem; min-width: 0; }

/* ─── Topbar ─── */
.topbar {
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-xl);
  animation: rise-in 420ms ease both;
  position: relative;
  z-index: 20;
}
.topbar-main { display: flex; align-items: flex-start; gap: 0.85rem; min-width: 0; }
.topbar-main p { margin: 0; }
.topbar h1 { margin: 0; font-size: clamp(1.1rem, 1.6vw, 1.4rem); font-weight: 600; line-height: 1.3; }
.topbar-main .muted { font-size: 0.8rem; margin-top: 0.15rem; }
.topbar-actions { display: flex; align-items: center; gap: 0.65rem; flex-shrink: 0; }

/* ─── Hero / Overview Panel ─── */
.hero-panel {
  background: linear-gradient(135deg, var(--panel), var(--panel-blend));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  animation: rise-in 420ms ease both;
}
.hero-content { display: flex; align-items: flex-start; justify-content: space-between; gap: 2rem; }
.hero-text { flex: 1; }
.hero-text h1 { margin: 0; font-size: 1.5rem; font-weight: 700; color: var(--ink); }
.hero-text .greeting { font-size: 0.88rem; color: var(--ink-soft); margin-top: 0.25rem; line-height: 1.5; }
.hero-stats { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }

.hero-actions { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.hero-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  background: var(--primary-bg);
  color: var(--primary-text);
  font-size: 0.72rem;
  font-weight: 600;
}

/* ─── Dashboard ─── */
.view-root { display: grid; gap: 1.25rem; min-width: 0; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

/* ─── KPI Cards ─── */
.kpi-card {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: transform 200ms ease, box-shadow 200ms ease;
  display: grid;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06), 0 12px 24px rgba(0,0,0,0.06);
}
.kpi-card .kpi-header { display: flex; align-items: center; justify-content: space-between; }
.kpi-card .kpi-icon {
  width: 2rem; height: 2rem;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem;
}
.kpi-card .kpi-trend {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.kpi-card .kpi-trend.up { color: var(--success); background: var(--success-bg); }
.kpi-card .kpi-trend.down { color: var(--danger); background: var(--danger-bg); }
.kpi-card h3 { margin: 0; font-size: 1.75rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.kpi-card .kpi-label { margin: 0; font-size: 0.82rem; color: var(--ink-soft); font-weight: 500; }

.kpi-purple::before { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.kpi-purple .kpi-icon { background: var(--primary-bg); color: var(--primary-text); }
.kpi-gold::before { background: linear-gradient(90deg, var(--accent), #E5C76A); }
.kpi-gold .kpi-icon { background: var(--accent-soft); color: var(--gold-ink); }
.kpi-emerald::before { background: linear-gradient(90deg, var(--success), #34D399); }
.kpi-emerald .kpi-icon { background: var(--success-bg); color: var(--success); }
.kpi-amber::before { background: linear-gradient(90deg, var(--warning), #FBBF24); }
.kpi-amber .kpi-icon { background: var(--warning-bg); color: var(--amber-ink); }

/* ─── Dashboard Widgets ─── */
.dashboard-widgets {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
}

.widget {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}
.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.widget-header h3 { margin: 0; font-size: 0.9rem; font-weight: 600; }
.widget-header p { margin: 0.15rem 0 0; font-size: 0.75rem; color: var(--ink-muted); }
.widget-header .widget-action {
  font-size: 0.75rem;
  color: var(--primary-text);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}
.widget-header .widget-action:hover { color: var(--primary-light); }

/* ─── Data Table ─── */
.data-table-wrap { overflow: auto; border-radius: var(--radius-md); max-width: 100%; max-height: 600px; overflow-y: auto; }
.data-table-toolbar { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: center; margin-bottom: 0.85rem; }
.data-table-toolbar input,
.data-table-toolbar select,
.data-table-toolbar button { font-size: 0.8rem; }
table { width: 100%; border-collapse: collapse; min-width: 0; }
th, td { padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 0.82rem; }
th { font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-muted); background: var(--surface-strong); font-weight: 600; position: sticky; top: 0; z-index: 1; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--row-hover); }

/* ─── Collapsible Sections ─── */
.collapse-toggle { cursor: pointer; user-select: none; background: none; border: 0; padding: 0; font: inherit; color: inherit; display: flex; align-items: center; gap: 0.5rem; width: 100%; text-align: left; }
.collapse-toggle .collapse-chevron { transition: transform 200ms ease; font-size: 0.7rem; color: var(--ink-muted); }
.collapse-toggle[aria-expanded="false"] .collapse-chevron { transform: rotate(-90deg); }
.collapse-body { overflow: hidden; transition: max-height 300ms ease; }
.collapse-body.collapsed { max-height: 0 !important; }

/* ─── Records ─── */
.record-list { display: grid; gap: 0.65rem; }
.record-list article {
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.record-list article:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.record-list article h4 { margin: 0; font-size: 0.85rem; font-weight: 600; }
.record-list article p { margin: 0.15rem 0 0; font-size: 0.8rem; color: var(--ink-soft); line-height: 1.5; }
.record-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.6rem; }

/* ─── Chips ─── */
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.6rem;
  padding: 0 0.6rem;
  border-radius: var(--radius-full);
  background: var(--chip-bg);
  border: 1px solid var(--line);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ink-soft);
  gap: 0.25rem;
}
.chip.success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.chip.warn { background: var(--warning-bg); color: var(--amber-ink); border-color: transparent; }
.chip.premium { background: var(--primary-bg); color: var(--primary-text); border-color: transparent; }
.chip.soft { background: rgba(107, 114, 128, 0.08); color: var(--ink-soft); border-color: transparent; }

/* ─── Pill ─── */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.75rem;
  padding: 0.1rem 0.7rem;
  border-radius: var(--radius-full);
  background: var(--primary-bg);
  color: var(--primary-text);
  font-weight: 600;
  font-size: 0.72rem;
  white-space: nowrap;
}

/* ─── Composite Layouts ─── */
.split-layout { display: grid; grid-template-columns: 1fr; gap: 3rem; min-width: 0; }
.triple-layout { display: grid; grid-template-columns: 1fr; gap: 3rem; min-width: 0; }

/* ─── Surface ─── */
.surface {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}
.surface-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 0.85rem; }
.surface-head h3, .surface-head h2 { margin: 0; font-size: 0.9rem; font-weight: 600; }
.surface-head p { margin: 0.15rem 0 0; color: var(--ink-muted); font-size: 0.78rem; line-height: 1.5; }
.surface-head .kicker { font-size: 0.78rem; }
.surface h3 + p { margin: 0.2rem 0 0; color: var(--ink-soft); font-size: 0.8rem; line-height: 1.5; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.85rem; }
.stat-card { border-radius: var(--radius-md); padding: 1rem; }
.stat-card p, .stat-card h3 { margin: 0; }
.stat-card p { color: var(--ink-soft); font-size: 0.78rem; }
.stat-card h3 { margin-top: 0.25rem; font-size: clamp(1.2rem, 1.8vw, 1.6rem); font-weight: 700; }

.tint-olive { background: linear-gradient(180deg, var(--primary-bg), var(--tint-fade)); }
.tint-gold { background: linear-gradient(180deg, var(--accent-soft), var(--tint-fade)); }
.tint-wine { background: linear-gradient(180deg, rgba(239,68,68,0.06), var(--tint-fade)); }
.tint-ocean { background: linear-gradient(180deg, rgba(16,185,129,0.06), var(--tint-fade)); }

/* ─── Profile ─── */
.profile-identity { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.profile-photo-preview, .profile-photo-placeholder {
  width: 100px; height: 100px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.9);
  box-shadow: var(--shadow-sm);
}
.profile-photo-preview { display: block; object-fit: contain; object-position: center; padding: 0.25rem; }
.profile-photo-placeholder { display: inline-flex; align-items: center; justify-content: center; font-size: 1.75rem; font-weight: 700; color: var(--ink); }

/* ─── Misc ─── */
.media-preview { display: block; width: 100%; max-height: 220px; object-fit: contain; border-radius: var(--radius-md); margin-top: 0.75rem; border: 1px solid var(--line); background: rgba(255,255,255,0.9); }
.media-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0.65rem; margin-top: 0.75rem; }
.media-gallery-item { display: block; text-decoration: none; color: inherit; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--line); background: rgba(255,255,255,0.9); }
.media-gallery-item img { display: block; width: 100%; height: 120px; object-fit: contain; background: rgba(255,255,255,0.96); }
.media-gallery-item span { display: block; padding: 0.45rem 0.6rem; font-size: 0.75rem; font-weight: 500; }

.qr-preview { width: 200px; max-width: 100%; border-radius: var(--radius-md); border: 1px solid var(--line); background: rgba(255,255,255,0.86); padding: 0.6rem; }
.metric-bar { width: 100%; height: 0.5rem; border-radius: var(--radius-full); background: var(--metric-track); overflow: hidden; }
.metric-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.comparison-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.comparison-grid article { border-radius: var(--radius-md); padding: 1rem; background: var(--surface-soft); border: 1px solid var(--line); }
.comparison-grid h4, .comparison-grid p { margin: 0; }
.comparison-grid p { color: var(--ink-soft); margin-top: 0.2rem; font-size: 0.8rem; }

.two-col-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.two-col-list div { padding: 0.7rem 0.85rem; border-radius: var(--radius-sm); background: var(--surface-soft); border: 1px solid var(--line); }
.two-col-list strong, .two-col-list span { display: block; }
.two-col-list span { font-size: 0.7rem; color: var(--ink-muted); margin-bottom: 0.15rem; }

.inline-actions, .form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.empty-state {
  border-radius: var(--radius-md);
  padding: 1.25rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
  background: var(--surface-faint);
  border: 1px dashed var(--line);
}

.locked-view { min-height: 380px; display: grid; place-items: center; }
.locked-panel { width: min(600px, 100%); text-align: center; padding: 2rem; border-radius: var(--radius-xl); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-xl); }
.locked-panel h2, .locked-panel p { margin: 0; }
.locked-panel p { margin-top: 0.6rem; color: var(--ink-soft); line-height: 1.6; font-size: 0.88rem; }

/* ─── Status Banner ─── */
.status-banner {
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  background: var(--primary-bg);
  border: 1px solid rgba(91, 33, 182, 0.12);
  color: var(--primary-text);
  font-weight: 600;
  font-size: 0.82rem;
  animation: rise-in 300ms ease both;
}

/* ─── Animations ─── */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ─── Marketing motion ─── */
@keyframes mk-drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to { transform: translate3d(2%, 2%, 0) scale(1.06); }
}
@keyframes mk-blob-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(7vw, 5vh, 0) scale(1.12); }
}
@keyframes mk-blob-b {
  from { transform: translate3d(0, 0, 0) scale(1.08); }
  to { transform: translate3d(-6vw, -5vh, 0) scale(0.96); }
}
@keyframes mk-blob-c {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-4vw, 7vh, 0) scale(1.15); }
}
@keyframes mk-rise {
  0% { transform: translate3d(0, 0, 0); opacity: 0; }
  8% { opacity: var(--peak, 0.75); }
  92% { opacity: var(--peak, 0.75); }
  100% { transform: translate3d(var(--sway, 24px), -92vh, 0); opacity: 0; }
}
@keyframes mk-sheen {
  0%, 100% { transform: translateX(-160%); }
  50% { transform: translateX(320%); }
}
@keyframes mk-parallax {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-2.5%, -2%, 0); }
}
@keyframes mk-float-hero {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(0, -7px, 0); }
}
@keyframes mk-fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes mk-grow {
  from { transform: scaleY(0.06); }
  to { transform: scaleY(1); }
}
@keyframes mk-glow {
  0%, 100% { box-shadow: 0 4px 14px var(--primary-glow); }
  50% { box-shadow: 0 4px 24px rgba(124, 58, 237, 0.35); }
}

.auth-panel { animation: fade-in 500ms ease 150ms both; }
.auth-panel .primary-button { animation: mk-glow 5s ease-in-out infinite; }

.rise-in { animation: rise-in 400ms ease both; }
.fade-in { animation: fade-in 250ms ease both; }

/* ─── User Menu (authenticated shell) ─── */
.user-menu { position: relative; }
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: transparent;
  border: 0;
  border-radius: var(--radius-full);
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  min-height: 2.75rem;
  cursor: pointer;
  transition: background 200ms ease;
}
.user-menu-trigger:hover { background: var(--primary-bg); }
.user-menu-trigger .hero-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  flex-shrink: 0;
}
.user-menu-name { font-size: 0.82rem; font-weight: 600; color: var(--ink); white-space: nowrap; }
.user-menu-chevron { transition: transform 200ms ease; color: var(--ink-muted); flex-shrink: 0; }
.user-menu.open .user-menu-chevron { transform: rotate(180deg); }
.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  min-width: 240px;
  padding: 0.4rem;
  border-radius: var(--radius-md);
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-xl);
  z-index: 40;
}
.user-menu-head {
  padding: 0.55rem 0.7rem 0.65rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.35rem;
}
.user-menu-head strong { display: block; font-size: 0.85rem; color: var(--ink); }
.user-menu-head small { display: block; margin-top: 0.1rem; color: var(--ink-muted); font-size: 0.72rem; }
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0 0.7rem;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink);
  min-height: 2.75rem;
  text-align: left;
  transition: background 160ms ease, color 160ms ease;
}
.user-menu-item:hover { background: var(--primary-bg); color: var(--primary-text); }
.user-menu-item .user-menu-item-icon { color: var(--ink-muted); transition: color 160ms ease; }
.user-menu-item:hover .user-menu-item-icon { color: var(--primary-text); }
.user-menu-divider { height: 1px; background: var(--line); margin: 0.3rem 0; }
.user-menu-item.danger, .user-menu-item.danger .user-menu-item-icon { color: var(--danger); }
.user-menu-item.danger:hover { background: var(--danger-bg); }

/* ─── Focus indicators ─── */
.auth-shell button:focus-visible,
.auth-shell a:focus-visible,
.user-menu button:focus-visible,
.user-menu-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  .mk-background *,
  .mk-preview,
  .mk-modules,
  .mk-aegis-block,
  .mk-hero,
  .mk-footer,
  .auth-panel,
  .auth-panel .primary-button {
    animation: none !important;
    transition: none !important;
  }
}

/* ─── Mobile Nav Toggle ─── */
.mobile-nav-toggle {
  display: none;
}

/* ─── Responsive ─── */
@media (max-width: 1280px) {
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-shell { grid-template-columns: 45fr 55fr; }
  .auth-copy { padding: 2.25rem 2.25rem; }
  .mk-preview { width: 100%; }
}
@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; position: relative; }
  .sidebar {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    bottom: 0.75rem;
    width: min(272px, calc(100vw - 4.5rem));
    max-height: calc(100vh - 1.5rem);
    overflow-y: auto;
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    box-shadow: var(--shadow-xl);
  }
  .app-shell.sidebar-open .sidebar {
    display: grid;
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
  }
  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 15;
    border: 0;
    background: var(--scrim-bg);
    backdrop-filter: blur(4px);
  }
  .mobile-nav-toggle {
    display: inline-flex;
    position: fixed;
    top: 0.9rem;
    left: 0.9rem;
    z-index: 32;
    width: 2.5rem;
    min-height: 2.5rem;
    padding: 0;
    border-radius: var(--radius-sm);
    justify-content: center;
    align-items: center;
    background: var(--panel-solid);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    touch-action: manipulation;
  }
  .mobile-nav-toggle svg { width: 1.25rem; height: 1.25rem; color: var(--ink); }
  .topbar { padding-left: 3.8rem; }
  .stat-grid, .comparison-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .mk-stage { display: none; }
  .mk-content { gap: 1.6rem; }
  .mk-headline { font-size: clamp(1.35rem, 3.4vw, 1.6rem); }
}
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; min-height: auto; }
  .auth-panel { order: -1; }
  .auth-copy { padding: 2rem 1.5rem; min-height: auto; }
  .auth-panel { padding: 2rem 1.5rem; }
  .form-grid, .two-col-list, .stat-grid, .comparison-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; padding-left: 3.8rem; }
  .topbar-actions { width: 100%; justify-content: flex-start; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .hero-content { flex-direction: column; }
  .hero-actions { width: 100%; justify-content: flex-start; }
}
@media (max-width: 620px) {
  .app-shell { width: calc(100% - 0.75rem); padding: 0.75rem 0; }
  .auth-shell { width: 100%; }
  .auth-copy { padding: 1.5rem 1.25rem; }
  .auth-panel { padding: 1.5rem 1.25rem; }
.mk-content { gap: 1.25rem; }
  .sidebar { width: min(248px, calc(100vw - 3.5rem)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .topbar-actions { flex-wrap: wrap; }
  .auth-copy, .auth-panel, .sidebar, .topbar, .surface { border-radius: var(--radius-lg); padding-inline: 1rem; }
  .user-menu-name { display: none; }
  .password-input-wrap { grid-template-columns: 1fr; }
  .password-toggle { width: 100%; }
  table { min-width: 0; }
}

/* ─── AEGIS ─────────────────────────────────────────────────────────── */

.aegis-fab {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 900;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  box-shadow: 0 10px 24px -6px rgba(91, 33, 182, 0.55);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.aegis-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 28px -6px rgba(91, 33, 182, 0.6); }
.aegis-fab:active { transform: translateY(0); }

.aegis-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 5.25rem;
  z-index: 950;
  width: min(390px, calc(100vw - 2rem));
  height: min(600px, calc(100vh - 7rem));
  display: flex;
  flex-direction: column;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.aegis-panel.aegis-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.aegis-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, var(--primary-bg), transparent);
}
.aegis-title { display: flex; align-items: center; gap: 0.6rem; }
.aegis-title strong { display: block; font-size: 0.95rem; letter-spacing: 0.02em; }
.aegis-sub { display: block; font-size: 0.72rem; color: var(--ink-soft); }
.aegis-logo {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
}
.aegis-logo-large { width: 44px; height: 44px; }
.aegis-panel-actions { display: flex; gap: 0.25rem; }
.aegis-panel-actions button {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  cursor: pointer;
}
.aegis-panel-actions button:hover { background: var(--primary-bg); color: var(--primary-text); }

.aegis-context {
  margin: 0.6rem 1rem 0;
  padding: 0.4rem 0.6rem;
  font-size: 0.72rem;
  color: var(--ink-soft);
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.aegis-toolbar {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem 1rem 0;
}
.aegis-toolbar-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-full);
  cursor: pointer;
}
.aegis-toolbar-button:hover { border-color: var(--primary-text); color: var(--primary-text); }

.aegis-conversation-list {
  margin: 0.5rem 1rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-warm);
  max-height: 180px;
  overflow-y: auto;
}
.aegis-history-note { padding: 0.6rem 0.8rem; font-size: 0.75rem; color: var(--ink-soft); }
.aegis-history-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.4rem 0.35rem 0.8rem;
  border-bottom: 1px solid var(--line);
}
.aegis-history-row:last-child { border-bottom: none; }
.aegis-history-open {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
.aegis-history-title { font-size: 0.78rem; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.aegis-history-meta { font-size: 0.68rem; color: var(--ink-muted); }
.aegis-history-delete {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  cursor: pointer;
  flex: none;
}
.aegis-history-delete:hover { color: var(--danger); background: var(--danger-bg); }

.aegis-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.aegis-bubble {
  display: flex;
  gap: 0.5rem;
  max-width: 88%;
}
.aegis-bubble.aegis-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.aegis-bubble-mark {
  flex: none;
  width: 22px; height: 22px;
  border-radius: var(--radius-full);
  display: grid; place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
}
.aegis-bubble-content {
  padding: 0.55rem 0.8rem;
  font-size: 0.83rem;
  line-height: 1.5;
  border-radius: var(--radius-md);
  overflow-wrap: break-word;
}
.aegis-bubble.aegis-assistant .aegis-bubble-content {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  color: var(--ink);
  border-top-left-radius: var(--radius-sm);
}
.aegis-bubble.aegis-user .aegis-bubble-content {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #ffffff;
  border-top-right-radius: var(--radius-sm);
}
.aegis-typing { display: inline-flex; gap: 4px; align-items: center; }
.aegis-typing i {
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  animation: aegisPulse 1.2s infinite ease-in-out;
}
.aegis-typing i:nth-child(2) { animation-delay: 0.2s; }
.aegis-typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes aegisPulse {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.aegis-composer {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--panel-solid);
}
.aegis-composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.83rem;
  color: var(--ink);
  background: var(--paper-warm);
  min-height: 40px;
  max-height: 120px;
}
.aegis-composer textarea:focus { outline: none; border-color: var(--primary-text); }
.aegis-send { flex: none; min-height: 40px; }

.aegis-footer {
  padding: 0.45rem 1rem;
  font-size: 0.66rem;
  color: var(--ink-muted);
  border-top: 1px solid var(--line);
  background: var(--paper-warm);
}

/* ─── AEGIS full page ─── */

.aegis-page { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
.aegis-page-hero {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1.1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.aegis-page-hero h2 { margin: 0.1rem 0 0.2rem; }
.aegis-page-panel {
  display: flex;
  flex-direction: column;
  height: min(520px, 62vh);
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.aegis-page-messages { min-height: 0; }

/* ─── AEGIS Analytics ─── */

.aegis-analytics { display: flex; flex-direction: column; gap: 1rem; }
.aegis-analytics-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.aegis-analytics-head h2 { margin: 0.1rem 0 0.2rem; }
.aegis-analytics-meta {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--ink-muted);
}
.aegis-analytics-loading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 2rem;
  justify-content: center;
  color: var(--ink-soft);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  animation: aegisPulse 1.6s infinite ease-in-out;
}
.aegis-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.aegis-section-card {
  padding: 1rem 1.1rem;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.aegis-section-card h3 { margin: 0 0 0.7rem; font-size: 0.9rem; }
.aegis-section-fields { display: flex; flex-direction: column; gap: 0.45rem; }
.aegis-section-field {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.aegis-section-field strong { color: var(--ink); font-size: 0.82rem; }
.aegis-rec-section {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.aegis-rec-heading h3 { margin: 0 0 0.15rem; }
.aegis-rec-heading p { margin: 0; }
.aegis-rec-list { display: flex; flex-direction: column; gap: 0.8rem; }
.aegis-rec-card {
  padding: 1rem 1.1rem;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.aegis-rec-card.priority-high { border-left-color: var(--danger); }
.aegis-rec-card.priority-medium { border-left-color: var(--warning); }
.aegis-rec-card.priority-low { border-left-color: var(--success); }
.aegis-rec-head { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.4rem; }
.aegis-rec-priority {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}
.priority-high .aegis-rec-priority { color: var(--danger); background: var(--danger-bg); }
.priority-medium .aegis-rec-priority { color: var(--warning); background: var(--warning-bg); }
.priority-low .aegis-rec-priority { color: var(--success); background: var(--success-bg); }
.aegis-rec-category { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em; color: var(--ink-muted); }
.aegis-rec-card h4 { margin: 0 0 0.35rem; font-size: 0.92rem; }
.aegis-rec-why { margin: 0 0 0.35rem; font-size: 0.8rem; color: var(--ink-soft); }
.aegis-rec-evidence, .aegis-rec-impact { margin: 0 0 0.2rem; font-size: 0.76rem; color: var(--ink-soft); }

@media (max-width: 640px) {
  .aegis-panel {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 5rem;
    width: auto;
    height: min(560px, calc(100vh - 6.5rem));
  }
  .aegis-fab { right: 0.9rem; bottom: 0.9rem; }
  .aegis-section-grid { grid-template-columns: 1fr; }
}

/* ─── Login busy state ─── */

.login-spinner {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-right: 0.4rem;
  animation: loginSpin 1.1s linear infinite;
}
@keyframes loginSpin {
  to { transform: rotate(360deg); }
}
.primary-button:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

/* AEGIS Integrations */
.notice-block {
  display: grid;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--primary-border, #3b5b92);
  border-radius: var(--radius-md);
  background: var(--primary-bg, rgba(79, 106, 156, 0.1));
}
.notice-block code {
  font-size: 0.82rem;
  word-break: break-all;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--panel-solid, #f6f7f9);
}
.ig-scope-grid {
  grid-column: 1 / -1;
  border: 1px solid var(--line, #e3e5e9);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin: 0;
}
.ig-scope-grid legend {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0 0.4rem;
}
.ig-scope-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 1rem;
  padding: 0.5rem 0;
  border-top: 1px dashed var(--line, #e3e5e9);
}
.ig-scope-group strong {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.ig-scope-group label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
}
.ig-secret {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.8rem;
  word-break: break-all;
}
