* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f1420;
  color: #e6e9f0;
  display: grid;
  /* The panel is fixed; everything else fills the remaining width. */
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1.5rem;
  padding: 0.75rem 1rem 3rem;
}

/* The panel holds the title, the ticker box and sign-out. It sticks so the
   controls stay reachable while the results column scrolls past. */
#sidebar {
  position: sticky;
  top: 0.75rem;
  align-self: start;
  /* Full viewport height minus the body's top padding and a matching gap at
     the bottom, so sign-out has something to be pushed against. */
  height: calc(100vh - 1.5rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #1a2130;
  border: 1px solid #2a3346;
  border-radius: 10px;
  padding: 1.25rem;
}

/* Stack the panel above the results once two columns no longer fit. */
@media (max-width: 780px) {
  body {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
  }
  /* Stacked, the panel is just a card again -- a viewport-tall one would push
     the results off screen. */
  #sidebar { position: static; height: auto; }
}

/* The "Steeple" wordmark is dark navy, which is near-invisible against the
   panel, so the mark sits on a light tile rather than straight on the dark. */
#logo {
  display: block;
  width: 100%;
  height: auto;
  background: #f4f6fb;
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
}

h1 { font-size: 1.35rem; line-height: 1.3; }

/* Centred over the logo above it, which is full panel width. */
#sidebar h1 { text-align: center; }

/* Rainbow rule under the panel title. Drawn as a pseudo-element so the divider
   tracks the heading and needs no markup of its own. */
#sidebar h1::after {
  content: "";
  display: block;
  height: 3px;
  margin-top: 0.7rem;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    #f87171, #fb923c, #fbbf24, #4ade80, #38bdf8, #818cf8, #c084fc
  );
}
h2 { font-size: 1.15rem; margin-bottom: 0.5rem; }

.hidden { display: none !important; }

/* Login gate vs. signed-in app. Both the top-bar controls and the view below it
   hang off one flag on <body>, so a single switch can't leave the ticker row
   hidden while the app view is showing. */
#login-view, #app-view, #ticker-form, #logout-btn, #docs-link, .dashboard-link { display: none; }
body[data-view="login"] #login-view { display: block; }
body[data-view="app"] #app-view { display: block; }
body[data-view="app"] #ticker-form { display: flex; }
body[data-view="app"] #logout-btn { display: block; }
body[data-view="app"] #docs-link { display: block; }
body[data-view="app"] .dashboard-link { display: block; }
.muted { color: #8b94a7; }
.error { color: #ff6b64; margin: 0.75rem 0; }
.warn { color: #e8b339; }

.card {
  background: #1a2130;
  border: 1px solid #2a3346;
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.login-card { max-width: 420px; margin: 3rem auto; }
.login-card p { margin: 0.5rem 0 1rem; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

/* Two selectors side by side in the forecast card's summary. */
.card-pickers {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.card-picker {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #8b94a7;
  white-space: nowrap;
}

.card-picker select {
  padding: 0.35rem 0.5rem;
  border: 1px solid #3a465e;
  border-radius: 6px;
  background: #131a28;
  color: #e6e9f0;
  font-size: 0.85rem;
  cursor: pointer;
}
.card-picker select:focus { outline: 2px solid #5b82f0; border-color: #5b82f0; }

form { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }

/* Stacked rather than side by side: the panel is too narrow for a row. */
#ticker-form { flex-direction: column; margin-bottom: 0; }

#search-picker { margin-bottom: 0.75rem; }
#search-picker-list { display: flex; flex-direction: column; gap: 0.4rem; }
.picker-row {
  display: block;
  width: 100%;
  text-align: left;
  background: #131a28;
  border: 1px solid #3a465e;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  color: #e6e9f0;
  font-family: inherit;
}
.picker-row:hover { border-color: #5b82f0; }
.picker-row .symbol { font-weight: 700; }
.picker-row .name { display: block; font-size: 0.8rem; color: #a8b3c4; margin-top: 0.1rem; }
.picker-row .exchange { color: #6b7484; }

input {
  flex: 1;
  /* Flex items default to min-width:auto, which for a text input is its ~20
     character intrinsic width -- without this it stops shrinking and pushes
     the button out of the row. */
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid #3a465e;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  background: #131a28;
  color: #e6e9f0;
}
input::placeholder { color: #6b7484; }
input:focus { outline: 2px solid #5b82f0; border-color: #5b82f0; }

button {
  flex-shrink: 0;
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 8px;
  background: #3563e9;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}
button:hover { background: #4a73ec; }
button:disabled { background: #33415e; cursor: wait; }

#analyze-btn { background: #16a34a; }
#analyze-btn:hover { background: #22c55e; }

/* Keeps the base button blue; only the size and full-width fit differ. */
#logout-btn {
  /* Soaks up the panel's free space so sign-out sits on the bottom edge. */
  margin-top: auto;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  width: 100%;
}

/* Reference doc and trading dashboards, each opened in their own tab so an
   analysis in progress is not lost. */
#docs-link, .dashboard-link {
  font-size: 0.8rem;
  color: #8b94a7;
  text-align: center;
  text-decoration: none;
}
#docs-link:hover, .dashboard-link:hover { color: #e6e9f0; text-decoration: underline; }
#docs-link:focus-visible, .dashboard-link:focus-visible { outline: 2px solid #5b82f0; border-radius: 6px; }

.summary { margin: 0.5rem 0 1rem; line-height: 1.55; }

.signal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.9rem;
}

.signal-panel {
  border: 1px solid #2a3346;
  border-radius: 10px;
  overflow: hidden;
  background: #1a2130;
}

.signal-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  background: #232b3d;
}
.signal-panel-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: #c7cddb;
}
.signal-value {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #a8b3c4;
}
.signal-panel.BUY .signal-panel-head { background: #14351f; }
.signal-panel.BUY .signal-value { color: #4ade80; }
.signal-panel.SELL .signal-panel-head { background: #3d1a18; }
.signal-panel.SELL .signal-value { color: #f87171; }
.signal-panel.HOLD .signal-panel-head { background: #232b3d; }
.signal-panel.HOLD .signal-value { color: #a8b3c4; }

.signal-panel-body { padding: 0.9rem 1rem 1rem; }
.signal-panel-body .metrics { margin-top: 0; }
.signal-panel-body p:last-child { margin-bottom: 0; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}
.metric {
  background: #232b3d;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}
.metric .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: #8b94a7; }
.metric .value { font-size: 1.05rem; font-weight: 600; margin-top: 0.15rem; }
.metric .value.pos { color: #4ade80; }
.metric .value.neg { color: #f87171; }

table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid #2a3346; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: #8b94a7; }
tr:last-child td { border-bottom: none; }

.small { font-size: 0.85rem; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: #232b3d;
  color: #8b94a7;
}
.badge.bullish { background: #14351f; color: #4ade80; }
.badge.bearish { background: #3d1a18; color: #f87171; }
.badge.neutral { background: #232b3d; color: #a8b3c4; }

.news-list { list-style: none; margin-top: 0.75rem; }
.news-list li { padding: 0.4rem 0; border-bottom: 1px solid #2a3346; line-height: 1.45; }
.news-list li:last-child { border-bottom: none; }
.news-list a { color: #7c9aff; text-decoration: none; }
.news-list a:hover { text-decoration: underline; }

.filing-summary { margin: 0.75rem 0 1rem; }
.filing-summary summary {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  cursor: pointer;
  list-style: revert;
}
.filing-summary summary::marker { color: #8b94a7; }
.filing-summary a { color: #7c9aff; text-decoration: none; }
.filing-summary a:hover { text-decoration: underline; }
.bullets {
  white-space: pre-wrap;
  font-family: inherit;
  background: #232b3d;
  border-radius: 8px;
  padding: 0.75rem;
  line-height: 1.5;
  margin-top: 0.4rem;
}

#filings-table-details > summary {
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin: 0.5rem 0;
  list-style: revert;
}
#filings-table-details > summary::marker { color: #8b94a7; }
#filings-table a { color: #7c9aff; text-decoration: none; }
#filings-table a:hover { text-decoration: underline; }

#forecast-chart { width: 100%; }

/* --- Collapsible cards -------------------------------------------------- */
/* The three data cards are <details>. Only the summary row is styled here;
   the card chrome itself still comes from .card. */
details.card > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before {
  content: "";
  flex-shrink: 0;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid #8b94a7;
  border-bottom: 2px solid #8b94a7;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
details.card[open] > summary::before { transform: rotate(45deg); }
/* h2 keeps its bottom margin everywhere else, but inside a summary that margin
   hangs below the title of a collapsed card. */
details.card > summary h2 { margin-bottom: 0; }
details.card[open] > summary { margin-bottom: 0.6rem; }
details.card > summary .card-head { flex: 1; }
details.card > summary:focus-visible { outline: 2px solid #5b82f0; border-radius: 6px; }

@media (prefers-reduced-motion: reduce) {
  details.card > summary::before { transition: none; }
}

/* --- Decision card ------------------------------------------------------ */
.verdict { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.badge.rate { background: #14351f; color: #4ade80; }
.badge.insufficient { background: #3d2a12; color: #e8b339; }

/* Surviving decision weight against the abstention floor. The floor is drawn
   as a tick rather than a second bar so the comparison is positional. */
.meter {
  position: relative;
  height: 10px;
  background: #232b3d;
  border-radius: 999px;
  margin: 0.75rem 0 0.4rem;
}
.meter-fill { height: 100%; border-radius: 999px; background: #4ade80; }
.meter-fill.short { background: #e8b339; }
.meter-floor {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: #e6e9f0;
  border-radius: 1px;
}

.slots {
  display: grid;
  gap: 1px;
  background: #2a3346;
  border: 1px solid #2a3346;
  border-radius: 8px;
  overflow: hidden;
  margin: 1rem 0;
}
.slot { display: grid; grid-template-columns: 185px 1fr; background: #1a2130; }
.slot-lab { background: #202839; padding: 0.7rem 0.85rem; }
.slot-name { font-weight: 600; font-size: 0.9rem; }
.slot-src { color: #8b94a7; font-size: 0.75rem; margin-top: 0.15rem; }
.slot-src.req { color: #e8b339; }
.slot-text { padding: 0.7rem 0.9rem; line-height: 1.55; font-size: 0.93rem; }

@media (max-width: 640px) {
  .slot { grid-template-columns: 1fr; }
}

#decision-evidence-details > summary {
  cursor: pointer;
  color: #8b94a7;
  font-size: 0.9rem;
  padding: 0.3rem 0;
  list-style: revert;
}
#decision-evidence-details > summary::marker { color: #8b94a7; }
#decision-evidence h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8b94a7;
  margin: 1rem 0 0.15rem;
}
#decision-evidence a { color: #7c9aff; text-decoration: none; }
#decision-evidence a:hover { text-decoration: underline; }

.tier {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}
.tier-A { background: #14351f; color: #4ade80; }
.tier-B { background: #3d2a12; color: #e8b339; }
.tier-C { background: #232b3d; color: #8b94a7; }

.gate-list { list-style: none; margin-top: 0.3rem; }
.gate-list li { padding: 0.3rem 0; border-bottom: 1px solid #2a3346; font-size: 0.9rem; }
.gate-list li:last-child { border-bottom: none; }
.gate-id { color: #f87171; font-weight: 700; margin-right: 0.4rem; }

/* --- Work-in-progress indicator ----------------------------------------- */
/* Paired with a ticking elapsed counter, because the decision panel waits on
   the local LLM and a bare spinner gives no sense of how long that has run. */
#decision-loading { display: flex; align-items: center; gap: 0.5rem; }

.spinner {
  flex-shrink: 0;
  width: 0.95rem;
  height: 0.95rem;
  border: 2px solid #2a3346;
  border-top-color: #5b82f0;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.elapsed { font-variant-numeric: tabular-nums; color: #8b94a7; margin-left: auto; }

@media (prefers-reduced-motion: reduce) {
  /* The counter still conveys that work is under way, so the ring can hold
     still rather than spin at a token slow speed. */
  .spinner { animation: none; }
}

/* Sector/policy evidence: real enough to explain a move, not company-specific
   enough to count toward the verdict, so it reads between A and B. */
.tier-R { background: #16283d; color: #7c9aff; }
