:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-border: #dbe3ef;
  --ink: #142033;
  --muted: #54647a;
  --brand: #0b5fff;
  --brand-2: #1342b3;
  --danger: #bf183f;
  --good: #0b9a6d;
  --warn: #b87400;
  --bad: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% -20%, #d9e7ff 0%, var(--bg) 45%);
  color: var(--ink);
}

.hidden {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.login-gate {
  min-height: 100svh;
  height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 396px);
  align-items: stretch;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}

.login-hero {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #bfd1f0;
  box-shadow: 0 24px 52px rgba(10, 24, 52, 0.2);
  min-height: 0;
  height: 100%;
}

.login-hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.login-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(5, 14, 32, 0.1) 20%, rgba(5, 14, 32, 0.72) 100%);
}

.login-hero-copy {
  position: absolute;
  z-index: 2;
  left: 18px;
  right: 18px;
  bottom: 16px;
  color: #f5f8ff;
  display: grid;
  gap: 6px;
}

.login-hero-copy h1 {
  font-size: clamp(38px, 8vw, 82px);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.login-hero-copy p {
  font-size: clamp(15px, 2.2vw, 20px);
  line-height: 1.2;
  max-width: 24ch;
}

.login-hero-copy small {
  font-size: 12px;
  color: rgba(230, 239, 255, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.login-card {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px;
  display: grid;
  gap: 12px;
  align-self: stretch;
  align-content: center;
  max-height: 100%;
  box-shadow: 0 20px 44px rgba(12, 24, 56, 0.12);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-avatar {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid #d5deed;
  background: #f2f6ff;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  background: #fff;
  color: var(--ink);
  border: 1px solid #c6d3e6;
  border-radius: 10px;
  padding: 10px 12px;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

button {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

.btn {
  background: linear-gradient(145deg, var(--brand), var(--brand-2));
  color: #fff;
}

.btn.secondary {
  background: #e8eef9;
  color: #1f3760;
}

.btn.danger {
  background: linear-gradient(145deg, #cc224f, var(--danger));
  color: #fff;
}

.status-line {
  font-size: 13px;
  color: var(--muted);
}

.app {
  min-height: 100vh;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.stonky-hero {
  background: linear-gradient(140deg, #0f1f3c 0%, #1f3f7a 58%, #245f8a 100%);
  border: 1px solid #21477f;
  border-radius: 14px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(170px, 250px) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  color: #f2f6ff;
}

.stonky-hero-art {
  width: 100%;
  min-height: 140px;
  max-height: 200px;
  object-fit: cover;
  object-position: center;
  border-radius: 12px;
  border: 1px solid rgba(207, 226, 255, 0.35);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.35);
}

.stonky-hero-copy {
  display: grid;
  gap: 6px;
  align-content: start;
}

.hero-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.hero-brand {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.hero-brand .kicker {
  color: #9fbceb;
  margin-bottom: 2px;
}

.hero-brand h1 {
  font-size: clamp(34px, 4.1vw, 52px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: #f3f7ff;
}

.stonky-hero-copy h2 {
  font-size: clamp(20px, 2.7vw, 31px);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stonky-hero-copy p {
  font-size: clamp(13px, 1.25vw, 16px);
  line-height: 1.35;
  max-width: 66ch;
  color: #e5efff;
}

.stonky-hero-copy small {
  color: #b8ceef;
  font-size: 12px;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.badge {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #f3f7ff;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

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

.chip {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px 10px;
  display: grid;
  gap: 4px;
}

.chip span {
  color: var(--muted);
  font-size: 12px;
}

.banner {
  background: #fff6d8;
  border: 1px solid #efcf72;
  color: #6b4a00;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 10px;
  min-height: 0;
}

.nav {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.nav-btn {
  background: #f4f7fd;
  color: #253955;
  border: 1px solid #d6e1f0;
  text-align: left;
  font-weight: 700;
}

.nav-btn.active {
  background: linear-gradient(145deg, #153a88, #0f2860);
  color: #fff;
  border-color: #0f2860;
}

.content {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px;
  min-height: 0;
  overflow: auto;
}

.tab {
  display: none;
  gap: 10px;
}

.tab.active {
  display: grid;
}

.panel {
  background: #fbfdff;
  border: 1px solid #d8e2f0;
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.status-box {
  background: #f3f7fe;
  border: 1px solid #ccdaef;
  color: #2a3f63;
  border-radius: 10px;
  padding: 10px 12px;
  white-space: pre-wrap;
}

.status-box.markdown {
  white-space: pre-wrap;
}

.status-box.compact {
  font-size: 12px;
  line-height: 1.45;
  padding: 8px 10px;
}

.panel-note {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.radar-panel {
  gap: 12px;
}

.macro-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.macro-card {
  background: linear-gradient(165deg, #f9fbff 0%, #eef4ff 100%);
  border: 1px solid #d4e0f2;
  border-radius: 10px;
  padding: 8px 9px;
  display: grid;
  gap: 3px;
}

.macro-card span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.macro-card strong {
  font-size: 19px;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.macro-card small {
  font-size: 11px;
  color: #60738f;
}

.viz-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1.85fr) minmax(320px, 1fr);
  align-items: start;
}

.viz-main,
.viz-rail {
  display: grid;
  gap: 10px;
}

.timeline-block {
  min-height: 360px;
}

.viz-block {
  border: 1px solid #d4e0f2;
  border-radius: 10px;
  background: #f8fbff;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.timeline-wrap {
  border: 1px solid #d9e4f3;
  border-radius: 10px;
  overflow: hidden;
  background: #f4f8ff;
}

.timeline-svg {
  width: 100%;
  height: 280px;
  display: block;
}

.timeline-bg {
  fill: #f7faff;
}

.timeline-grid {
  stroke: #dbe5f4;
  stroke-width: 1;
}

.timeline-area {
  fill: url(#timelineFill);
}

.timeline-line {
  fill: none;
  stroke: #2470ff;
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.timeline-dot {
  fill: #ffffff;
  stroke: #2a7fff;
  stroke-width: 1.4;
  cursor: pointer;
}

.timeline-dot.active {
  fill: #2a7fff;
  stroke: #ffffff;
  stroke-width: 1.8;
}

.timeline-label {
  display: grid;
  gap: 4px;
  color: #4e6385;
  font-size: 12px;
  font-weight: 600;
}

.timeline-controls {
  display: grid;
  gap: 8px;
}

.timeline-jumps {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.timeline-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.timeline-point-select {
  width: 100%;
}

.timeline-label-text {
  fill: #687fa2;
  font-size: 11px;
  font-weight: 600;
}

.timeline-label-text-right {
  text-anchor: end;
}

.allocation-bars {
  display: grid;
  gap: 8px;
}

.allocation-row {
  width: 100%;
  text-align: left;
  border: 1px solid #d0ddf0;
  border-radius: 10px;
  background: #ffffff;
  padding: 8px 10px;
  display: grid;
  gap: 6px;
}

.allocation-row.active {
  border-color: #2a7fff;
  box-shadow: 0 0 0 2px rgba(42, 127, 255, 0.15) inset;
}

.allocation-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #253a5b;
  font-size: 12px;
  font-weight: 700;
}

.allocation-track {
  height: 7px;
  border-radius: 999px;
  background: #e3ebf8;
  overflow: hidden;
}

.allocation-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2a7fff, #114fcb);
}

.allocation-meta {
  color: #526a8d;
  font-size: 11px;
}

.allocation-empty {
  color: #5c7190;
  font-size: 12px;
  padding: 6px 0;
}

.spark-grid {
  display: grid;
  gap: 8px;
}

.spark-row {
  border: 1px solid #d1def0;
  border-radius: 10px;
  background: #fff;
  padding: 7px 8px;
  display: grid;
  gap: 5px;
}

.spark-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #2a3e5f;
}

.spark-trend {
  font-weight: 800;
}

.spark-trend.up {
  color: var(--good);
}

.spark-trend.down {
  color: var(--bad);
}

.spark-trend.flat {
  color: #60738f;
}

.spark-svg-wrap {
  border: 1px solid #dde7f5;
  border-radius: 8px;
  background: #f8fbff;
  overflow: hidden;
  min-height: 44px;
}

.spark-svg {
  display: block;
  width: 100%;
  height: 44px;
}

.spark-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spark-line.up {
  stroke: #148d63;
}

.spark-line.down {
  stroke: #c3314f;
}

.spark-line.flat {
  stroke: #4a6f98;
}

.spark-area {
  opacity: 0.25;
}

.spark-area.up {
  fill: #67caa8;
}

.spark-area.down {
  fill: #ef98ac;
}

.spark-area.flat {
  fill: #b9cae0;
}

.spark-ref {
  stroke: #324d6d;
  stroke-width: 1;
  stroke-dasharray: 3 2;
  opacity: 0.7;
}

.spark-meta {
  color: #536a8a;
  font-size: 11px;
}

.spark-empty,
.spark-missing {
  color: #597195;
  font-size: 12px;
  padding: 8px;
}

.brief-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.chat-thread {
  border: 1px solid #d3dff1;
  border-radius: 10px;
  background: #f9fbff;
  max-height: 300px;
  min-height: 180px;
  overflow: auto;
  padding: 8px;
  display: grid;
  gap: 8px;
}

.chat-bubble {
  border-radius: 10px;
  padding: 8px 9px;
  display: grid;
  gap: 4px;
}

.chat-bubble.user {
  background: #edf4ff;
  border: 1px solid #cfdff9;
}

.chat-bubble.assistant {
  background: #fff6e8;
  border: 1px solid #f0d8a8;
}

.chat-role {
  font-size: 10px;
  letter-spacing: 0.06em;
  font-weight: 800;
  color: #486187;
}

.chat-text {
  color: #233854;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.35;
}

.chat-empty {
  color: #597195;
  font-size: 12px;
  padding: 6px;
}

.chat-input-wrap {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: #4f6383;
  font-weight: 700;
}

.chat-input {
  min-height: 72px;
}

.chat-actions {
  display: flex;
  gap: 8px;
}

.list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  color: #30486d;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #d7e1ef;
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid #e0e8f3;
  padding: 8px 9px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #eff4fc;
  color: #334b72;
  position: sticky;
  top: 0;
}

pre {
  margin: 0;
  background: #0f1a30;
  color: #e3ecff;
  border-radius: 10px;
  padding: 10px;
  overflow: auto;
}

.grid-3 {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-2 {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 1600px) {
  .macro-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1080px) {
  .login-gate {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    height: 100svh;
    min-height: 100svh;
    padding: 10px;
  }

  .login-hero {
    display: none;
  }

  .login-card {
    width: min(100%, 460px);
    margin: auto;
    max-height: none;
    align-content: stretch;
  }

  .login-hero-copy h1 {
    font-size: clamp(34px, 16vw, 76px);
  }

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

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

  .nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-btn {
    text-align: center;
    font-size: 12px;
    padding: 8px;
  }

  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

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

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

  .timeline-svg {
    height: 230px;
  }

  .panel-note {
    margin-left: 0;
  }

  .stonky-hero {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .stonky-hero-art {
    max-height: 360px;
  }

  .hero-title-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .top-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .hero-brand h1 {
    font-size: clamp(28px, 6.2vw, 44px);
  }
}

@media (max-width: 720px) {
  .login-hero {
    min-height: 340px;
  }

  .login-hero-copy {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
}
