/* Shares the accent color generated reports already use (research_workflows.
   _CORE_REPORT_CSS's own #44c8ff) so the app shell and the report iframes it
   embeds still read as one product - kept deliberately unchanged by the
   ui-ux-pro-max redesign below even though its own generated palette suggested
   a green accent, since switching just this file would have visually split the
   shell from every report page's own extensively-tuned dark theme. Everything
   ELSE (background layering, borders, muted text, typography) follows the
   generated "equity research / financial terminal" design system: a proper
   navy/slate depth scale (was flat near-identical grays before) and the
   Exo/Roboto Mono heading+body pairing. Motion in this file follows one rule
   throughout: eased, not linear (cubic-bezier(0.16,1,0.3,1) - fast start, soft
   landing) - and every animation/transition is neutralized under
   prefers-reduced-motion at the bottom of this file. */

@import url('https://fonts.googleapis.com/css2?family=Exo:wght@300;400;500;600;700&family=Roboto+Mono:wght@300;400;500;700&display=swap');

:root {
  --bg: #020617;
  --bg-raised: #0f172a;
  --bg-panel: #1e293b;
  --bg-input: #0b1220;
  --bg-hover: #24334a;
  --border: #334155;
  --border-hover: #475569;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --accent: #44c8ff;
  --accent-2: #2b7fff;
  --text-on-accent: #051018;
  --danger: #ff5c6c;
  --danger-soft: #ffb3ba;
  --font-heading: 'Exo', 'Segoe UI', Arial, sans-serif;
  --font-body: 'Roboto Mono', 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  height: 100%;
}

h1, h2, h3, h4, h5, h6, .brand-name {
  font-family: var(--font-heading);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.shell {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar / tabs --- */

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 22px 10px;
  background: transparent;
  border: none;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
  color: inherit;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-on-accent);
}

.brand-name {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: .01em;
}

.nav-group-label {
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 16px 10px 6px 10px;
}

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.92rem;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.1s ease;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item:active {
  transform: scale(0.98);
}

.nav-item.active {
  background: rgba(68, 200, 255, 0.14);
  color: var(--accent);
  font-weight: 600;
}

a.nav-link {
  text-decoration: none;
  font-size: 0.85rem;
}

a.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: 0.72rem;
  font-weight: 700;
}

.nav-group-toggle:hover {
  color: var(--text);
}

.toggle-caret {
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-group-toggle.expanded .toggle-caret {
  transform: rotate(180deg);
}

/* Real accordion, not an instant display:none toggle - grid-template-rows animates
   between 0fr and 1fr (the modern CSS-only height-auto trick), and each revealed item
   gets its own transition-delay so they cascade in one after another instead of
   popping in as a block - the "small delay" effect requested directly. */

.nav-more {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-more.expanded {
  grid-template-rows: 1fr;
}

.nav-more-inner {
  overflow: hidden;
  min-height: 0;
}

.nav-more .nav-item {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.25s ease, transform 0.25s ease, background-color 0.18s ease, color 0.18s ease;
}

.nav-more.expanded .nav-item {
  opacity: 1;
  transform: translateY(0);
}

.nav-more.expanded .nav-item:nth-child(1) { transition-delay: 0.05s; }
.nav-more.expanded .nav-item:nth-child(2) { transition-delay: 0.10s; }
.nav-more.expanded .nav-item:nth-child(3) { transition-delay: 0.15s; }
.nav-more.expanded .nav-item:nth-child(4) { transition-delay: 0.20s; }

/* --- Main content --- */

.content {
  flex: 1;
  padding: 40px 44px 80px 44px;
  /* Widened from 1440px - real user report: the report iframe sat in a narrow
     column with unused space on both sides on a wide monitor ("page needs to
     expand the entire screen"). Matches the report's own .wrap width bump
     (research_workflows._CORE_REPORT_CSS, 1320px -> 1800px) so the iframe
     actually has the room to use it. */
  max-width: 1900px;
}

.tab.hidden {
  display: none;
}

/* Browsers restart a CSS animation whenever an element goes from display:none to
   displayed, so switching tabs (toggling .hidden) replays this every time - no JS
   force-reflow needed. */
@keyframes tabEnter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.tab:not(.hidden) {
  animation: tabEnter 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-header h1 {
  font-size: 1.7rem;
  margin: 0 0 4px 0;
}

.tab-header p {
  color: var(--text-muted);
  margin: 0 0 26px 0;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 22px 24px;
  margin-bottom: 24px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.panel:hover {
  border-color: var(--border-hover);
}

.field-row {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.field-row.wide label {
  flex: 1;
}

.field-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  flex: 1;
  min-width: 140px;
}

.field-row input,
.field-row select,
.field-row textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 11px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.field-row textarea {
  resize: vertical;
}

.field-row input:focus,
.field-row select:focus,
.field-row textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
}

.client-compute-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  align-self: center;
}

.run-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--text-on-accent);
  border: none;
  border-radius: 8px;
  padding: 11px 22px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, filter 0.15s ease;
}

.run-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px -6px rgba(68, 200, 255, 0.45);
}

.run-btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 8px -2px rgba(68, 200, 255, 0.35);
}

.run-btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.run-btn.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}

.run-btn.secondary:hover {
  border-color: var(--accent);
  filter: none;
  box-shadow: 0 8px 24px -8px rgba(68, 200, 255, 0.3);
}

/* --- Manual mode (Ask a Question) --- */

.manual-mode {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 14px;
  margin-bottom: 16px;
}

.manual-mode summary {
  cursor: pointer;
  padding: 10px 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
}

.manual-mode[open] summary {
  color: var(--accent);
}

.manual-mode-note {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 14px 0;
}

/* --- Help page --- */

.help-panel h3 {
  margin: 0 0 8px 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.help-panel p {
  color: var(--text);
  margin: 0 0 8px 0;
  line-height: 1.5;
}

.help-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--accent);
  background: rgba(68, 200, 255, 0.14);
  border-radius: 999px;
  padding: 3px 10px;
}

.help-use-case {
  color: var(--text-muted) !important;
  font-size: 0.88rem;
}

/* Reveal-on-scroll, driven by app.js adding .in-view via IntersectionObserver as each
   panel enters the viewport - a JS no-op (no IntersectionObserver support, or reduced
   motion) leaves .in-view permanently applied, so this degrades to always-visible. */
.help-panel {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.help-panel.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* --- Intro / landing page --- */

.intro-hero {
  max-width: 640px;
  padding: 60px 0;
  position: relative;
}

/* One deliberate spot of atmosphere - a soft glow behind the mark, nowhere else on
   the page competes with it. */
.intro-hero::before {
  content: "";
  position: absolute;
  top: -100px;
  left: -140px;
  width: 460px;
  height: 460px;
  background: radial-gradient(circle, rgba(68, 200, 255, 0.14), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.intro-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--text-on-accent);
  font-weight: 700;
  font-size: 1.3rem;
  margin-bottom: 20px;
  box-shadow: 0 12px 32px -10px rgba(68, 200, 255, 0.55);
}

.intro-hero h1 {
  font-size: 2.4rem;
  margin: 0 0 8px 0;
  text-wrap: balance;
}

.intro-tagline {
  font-size: 1.15rem;
  color: var(--accent);
  margin: 0 0 18px 0;
  font-weight: 600;
}

.intro-sub {
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 32px 0;
}

.intro-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.intro-credit {
  color: var(--text-faint);
  font-size: 0.85rem;
}

/* Staggered entrance on first paint - each element fades/rises in slightly after the
   last, the same cascade feel as the nav dropdown above. */
@keyframes introEnter {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.intro-mark, .intro-hero h1, .intro-tagline, .intro-sub, .intro-actions, .intro-credit {
  opacity: 0;
  animation: introEnter 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.intro-mark { animation-delay: 0.05s; }
.intro-hero h1 { animation-delay: 0.12s; }
.intro-tagline { animation-delay: 0.19s; }
.intro-sub { animation-delay: 0.26s; }
.intro-actions { animation-delay: 0.33s; }
.intro-credit { animation-delay: 0.40s; }

/* --- Results --- */

.result-area:empty {
  display: none;
}

.status-card {
  background: var(--bg-panel);
  border-radius: 10px;
  padding: 18px 22px;
  margin-bottom: 18px;
  font-size: 0.92rem;
  animation: cardEnter 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardEnter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.status-card.loading {
  color: var(--text-muted);
}

.status-card.error {
  border-left: 3px solid var(--danger);
  color: var(--danger-soft);
}

.status-card.success {
  border-left: 3px solid var(--accent);
  color: var(--text);
}

.status-card .summary-line {
  margin: 3px 0;
}

.status-card a {
  color: var(--accent);
}

/* Filing-source buttons on the results screen (Core Research) - a clearly-labeled
   row, distinct from the generic GitHub Pages link list, so a real 10-K/10-Q is
   always one click away regardless of whether GitHub publish succeeded. */
.filing-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.filing-links-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-right: 2px;
}

.filing-link-btn {
  display: inline-block;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.82rem;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filing-link-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px -6px rgba(68, 200, 255, 0.4);
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Loading progress bar (app.js's startLoadingUI) --- */

.loading-head {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.loading-text {
  transition: opacity 0.2s ease;
}

.progress-track {
  height: 4px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  width: 4%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer 1.6s linear infinite;
}

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

.loading-hint {
  color: var(--text-faint);
  font-size: 0.8rem;
}

.report-frame {
  width: 100%;
  height: 78vh;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.55);
  animation: cardEnter 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.08s backwards;
}

/* --- Responsive --- */

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px;
    gap: 6px;
  }
  .brand, .nav-group-label:not(.nav-group-toggle) { display: none; }
  .nav-item { white-space: nowrap; width: auto; }
  .nav-more.expanded { grid-template-rows: 1fr; }
  .nav-more-inner { display: flex; }
  .content { padding: 24px 18px 60px 18px; }
  .field-row { flex-direction: column; }
  .report-frame { height: 65vh; }
}

/* --- Reduced motion --- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
