:root {
  color-scheme: dark;
  --bg: #080b0e;
  --surface: #151a20;
  --panel: #20262e;
  --panel-soft: #29313a;
  --line: #39424d;
  --text: #f6f8fb;
  --muted: #a7b0bd;
  --faint: #717b88;
  --green: #19c58b;
  --green-2: #86ecc5;
  --blue: #49a7ff;
  --pink: #f278a6;
  --orange: #ffb15e;
  --red: #ef4762;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
  font-family: "Segoe UI", "Malgun Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 36px;
  align-items: center;
  width: min(1080px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
}

.brand-panel h1 {
  margin: 8px 0 14px;
  font-size: clamp(2.4rem, 5vw, 5rem);
  line-height: 1.04;
}

.eyebrow {
  margin: 0;
  color: var(--green-2);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lead,
.advisor-copy {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.75;
}

.login-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-head {
  display: grid;
  gap: 6px;
  margin-bottom: 4px;
}

.login-card h2 {
  margin: 0;
}

.auth-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.default-credential {
  display: grid;
  gap: 4px;
  border: 1px solid rgba(134, 236, 197, 0.28);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(25, 197, 139, 0.1);
}

.default-credential span {
  color: var(--green-2);
  font-size: 0.82rem;
  font-weight: 900;
}

.default-credential strong {
  font-size: 1rem;
  line-height: 1.35;
}

label {
  color: var(--muted);
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: #101318;
  color: var(--text);
}

input:focus {
  border-color: var(--green);
  outline: 3px solid rgba(25, 197, 139, 0.18);
}

.masked-secret {
  -webkit-text-security: disc;
  text-security: disc;
}

.login-card button,
.force-update-button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--green);
  color: #06130e;
  font-weight: 950;
}

.login-card .text-button {
  min-height: auto;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: transparent;
  color: var(--green-2);
}

.login-card .text-button:hover,
.login-card .text-button:focus-visible {
  border-color: rgba(134, 236, 197, 0.52);
  background: rgba(25, 197, 139, 0.1);
}

.error-message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 800;
}

.dashboard-shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 30px 20px 44px;
}

.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.report-header h1 {
  margin: 6px 0 0;
  font-size: clamp(2.2rem, 5vw, 4.2rem);
  line-height: 1.03;
}

.update-text,
.force-update-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.force-update-status[data-state="success"] {
  color: var(--green-2);
}

.force-update-status[data-state="error"] {
  color: var(--red);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.force-update-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.force-update-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.force-update-button[data-state="loading"] .force-update-icon {
  animation: spin 0.9s linear infinite;
}

.icon-button {
  position: relative;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--panel);
}

.icon-button::before {
  content: "";
  position: absolute;
  inset: 14px 10px;
  border-width: 3px 0;
  border-style: solid;
  border-color: var(--muted);
}

.tab-bar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: rgba(10, 13, 16, 0.92);
  backdrop-filter: blur(16px);
}

.tab-button {
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 950;
}

.tab-button.is-active {
  background: var(--text);
  color: #101318;
}

.tab-panel {
  display: none;
  padding-top: 22px;
}

.tab-panel.is-active {
  display: block;
}

.advisor-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 20px;
  min-height: 320px;
  border-radius: 8px;
  padding: clamp(28px, 5vw, 54px);
  background: linear-gradient(135deg, #20262e 0%, #141a20 58%, #11251d 100%);
  box-shadow: var(--shadow);
}

.retirement-controls {
  display: grid;
  gap: 12px;
}

.retirement-controls input {
  min-height: 48px;
}

.retirement-hero .net-worth-card strong {
  font-size: clamp(1.8rem, 4vw, 3.25rem);
}

.report-hero .net-worth-card strong {
  font-size: clamp(1.7rem, 3.2vw, 2.8rem);
}

.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.report-section {
  overflow: hidden;
}

.report-prose {
  display: grid;
  gap: 14px;
}

.report-prose p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

.report-check-list,
.report-action-list {
  display: grid;
  gap: 10px;
}

.report-bullet {
  display: grid;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.035);
}

.report-bullet strong {
  color: var(--text);
}

.report-bullet p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.report-bullet.good {
  border-color: rgba(25, 197, 139, 0.25);
}

.report-bullet.warn {
  border-color: rgba(255, 177, 94, 0.32);
}

.report-bullet.bad {
  border-color: rgba(242, 120, 166, 0.32);
}

.report-data-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.report-data-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.55fr) minmax(180px, 0.9fr) minmax(180px, 1fr);
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.025);
}

.report-data-row + .report-data-row {
  border-top: 1px solid var(--line);
}

.report-data-row span,
.report-data-row small {
  color: var(--muted);
  font-weight: 850;
  line-height: 1.5;
}

.report-data-row strong {
  overflow-wrap: anywhere;
}

.report-prompt {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #101318;
  color: var(--text);
  font-family: "Consolas", "D2Coding", monospace;
  font-size: 0.92rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.gpt-report-output {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
  border: 1px solid rgba(134, 236, 197, 0.24);
  border-radius: 8px;
  padding: 18px;
  background: rgba(25, 197, 139, 0.08);
}

.gpt-report-output p {
  margin: 0;
  color: var(--text);
  line-height: 1.75;
}

.gpt-report-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--green-2);
  font-size: 0.84rem;
  font-weight: 900;
}

.gpt-chat-form {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.gpt-chat-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.gpt-chat-controls button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--blue);
  color: #06101c;
  font-weight: 950;
}

.gpt-chat-controls button:disabled,
.gpt-chat-controls input:disabled {
  cursor: wait;
  opacity: 0.7;
}

.gpt-chat-log {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  margin-bottom: 16px;
  padding-right: 4px;
}

.gpt-chat-message {
  display: grid;
  gap: 7px;
  max-width: min(760px, 92%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.04);
}

.gpt-chat-message.user {
  justify-self: end;
  border-color: rgba(73, 167, 255, 0.28);
  background: rgba(73, 167, 255, 0.1);
}

.gpt-chat-message.assistant {
  justify-self: start;
  border-color: rgba(134, 236, 197, 0.24);
  background: rgba(25, 197, 139, 0.08);
}

.gpt-chat-message strong {
  color: var(--green-2);
}

.gpt-chat-message.user strong {
  color: #b9dcff;
}

.gpt-chat-message p,
.gpt-chat-empty {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.hero-copy h2 {
  max-width: 800px;
  margin: 10px 0 18px;
  font-size: clamp(2rem, 4vw, 4.6rem);
  line-height: 1.04;
}

.net-worth-card {
  display: grid;
  align-content: center;
  gap: 10px;
  border: 1px solid rgba(134, 236, 197, 0.34);
  border-radius: 8px;
  padding: 26px;
  background: rgba(8, 11, 14, 0.45);
}

.net-worth-card span,
.metric-card span,
.section-title span {
  color: var(--muted);
  font-weight: 850;
}

.net-worth-card strong {
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 1;
}

.net-worth-card small {
  color: var(--green-2);
  font-weight: 900;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.metric-card,
.panel-card,
.note-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18);
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 138px;
  padding: 22px;
}

.metric-card strong {
  font-size: clamp(1.55rem, 3vw, 2.5rem);
  line-height: 1;
}

.metric-card small {
  color: var(--faint);
  font-weight: 850;
  line-height: 1.5;
}

.metric-card.good strong {
  color: var(--green);
}

.metric-card.warn strong {
  color: var(--orange);
}

.metric-card.bad strong {
  color: var(--pink);
}

.advisor-notes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.note-card {
  padding: 22px;
}

.note-card h3 {
  margin: 0 0 10px;
}

.note-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.panel-card {
  padding: 22px;
  margin-bottom: 18px;
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-title h2 {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.7rem);
}

.section-badge {
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(73, 167, 255, 0.13);
  color: #b9dcff;
  font-size: 0.86rem;
  font-weight: 900;
}

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

.chart-area {
  min-height: 270px;
}

.chart-area.tall {
  min-height: 340px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 2px 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 900;
}

.flow-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.flow-summary-card {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(126, 231, 189, 0.16);
  border-radius: 8px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.035);
}

.flow-summary-card span,
.flow-summary-card small {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.flow-summary-card strong {
  font-size: clamp(1.15rem, 2vw, 1.7rem);
  line-height: 1;
}

.investment-chart-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.investment-chart-meta article {
  display: grid;
  gap: 5px;
  border: 1px solid rgba(73, 167, 255, 0.15);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.035);
}

.investment-chart-meta span,
.investment-chart-meta small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.investment-chart-meta strong {
  font-size: clamp(1rem, 1.8vw, 1.35rem);
  line-height: 1.1;
}

.investment-chart-svg {
  min-height: 350px;
}

.delta-positive,
.value-label.positive {
  color: var(--green);
  fill: var(--green);
}

.delta-negative,
.value-label.negative {
  color: var(--pink);
  fill: var(--pink);
}

.flow-change-svg {
  min-height: 330px;
}

.zero-line {
  stroke-dasharray: 8 7;
}

.value-label {
  font-size: 12px;
  font-weight: 950;
}

.investment-value-label {
  paint-order: stroke;
  stroke: #11161c;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.chart-svg {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
}

.axis-label {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.y-axis-label {
  fill: var(--faint);
  font-size: 12px;
}

.rank-list,
.compact-list,
.detail-list {
  display: grid;
  gap: 10px;
}

.rank-row,
.detail-row,
.transaction-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-radius: 8px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.035);
}

.category-drill-button {
  width: 100%;
  border: 1px solid transparent;
  color: var(--text);
  text-align: left;
}

.category-drill-button:hover,
.category-drill-button.is-selected {
  border-color: rgba(134, 236, 197, 0.42);
  background: rgba(25, 197, 139, 0.12);
}

.category-detail-panel {
  margin-top: 16px;
}

.category-detail-card {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(134, 236, 197, 0.18);
  border-radius: 8px;
  padding: 16px;
  background: rgba(8, 11, 14, 0.22);
}

.category-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.category-detail-head span {
  color: var(--green-2);
  font-size: 0.82rem;
  font-weight: 900;
}

.category-detail-head h3 {
  margin: 4px 0 0;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
}

.category-detail-head > strong {
  white-space: nowrap;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
}

.category-month-list,
.category-detail-list {
  display: grid;
  gap: 8px;
}

.category-month-list {
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}

.category-month-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 850;
}

.category-month-track {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: #39404a;
}

.category-month-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--pink);
}

.category-detail-list {
  max-height: 420px;
  overflow: auto;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  padding-right: 4px;
}

.asset-group-picker {
  display: grid;
  gap: 10px;
}

.asset-group-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.asset-group-button:hover,
.asset-group-button.is-selected {
  border-color: rgba(126, 231, 189, 0.42);
  background: rgba(25, 197, 139, 0.12);
}

.asset-group-rank {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-weight: 950;
}

.asset-group-button.is-selected .asset-group-rank {
  background: var(--green);
  color: #06130e;
}

.asset-group-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.asset-group-main strong,
.asset-group-amount,
.asset-subitem-row strong {
  font-size: 1rem;
}

.asset-group-main small,
.asset-subitem-row small,
.asset-group-detail-summary {
  color: var(--muted);
  font-weight: 800;
}

.asset-group-amount {
  white-space: nowrap;
  font-weight: 950;
}

.asset-group-detail-panel {
  margin-top: 18px;
  border: 1px solid rgba(126, 231, 189, 0.18);
  border-radius: 8px;
  padding: 16px;
  background: rgba(8, 11, 14, 0.22);
}

.asset-group-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.asset-group-detail-head span {
  color: var(--green-2);
  font-size: 0.82rem;
  font-weight: 900;
}

.asset-group-detail-head h3 {
  margin: 4px 0 0;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
}

.asset-group-detail-head > strong {
  white-space: nowrap;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
}

.asset-group-detail-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 0.86rem;
}

.asset-subitem-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.asset-subitem-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.035);
}

.rank-row strong,
.detail-row strong,
.transaction-row strong {
  font-size: 1rem;
}

.rank-row small,
.detail-row small,
.transaction-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 750;
}

.amount-positive {
  color: var(--green-2);
}

.amount-negative {
  color: var(--pink);
}

.donut-panel {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}

.donut {
  width: min(320px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--panel-soft);
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 23%;
  border-radius: 50%;
  background: var(--panel);
}

.legend-list {
  display: grid;
  gap: 10px;
}

.legend-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 850;
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.is-hidden {
  display: none !important;
}

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

@media (max-width: 920px) {
  .login-layout,
  .advisor-hero,
  .two-column,
  .report-grid,
  .donut-panel {
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .advisor-notes,
  .flow-summary-grid,
  .investment-chart-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tab-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .dashboard-shell {
    padding: 18px 12px 28px;
  }

  .report-header {
    display: grid;
  }

  .metric-grid,
  .advisor-notes,
  .flow-summary-grid,
  .investment-chart-meta {
    grid-template-columns: 1fr;
  }

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

  .tab-button {
    min-height: 42px;
    font-size: 0.88rem;
  }

  .force-update-button {
    width: 100%;
  }

  .report-data-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .gpt-chat-controls {
    grid-template-columns: 1fr;
  }

  .asset-group-button,
  .asset-subitem-row,
  .category-month-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .asset-group-rank {
    display: none;
  }

  .asset-group-amount,
  .asset-group-detail-head > strong,
  .category-detail-head > strong {
    white-space: normal;
  }

  .asset-group-detail-head,
  .category-detail-head {
    display: grid;
  }
}
