:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(29, 29, 31, 0.12);
  --panel: rgba(255, 255, 255, 0.74);
  --panel-solid: #ffffff;
  --panel-soft: #fbfbfd;
  --accent: #0071e3;
  --green: #0a8f55;
  --red: #d93025;
  --amber: #b06b00;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0%, rgba(0, 113, 227, 0.14), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 34%);
  color: var(--text);
}

body.dark {
  color-scheme: dark;
  --bg: #0b0b0d;
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --line: rgba(255, 255, 255, 0.14);
  --panel: rgba(28, 28, 30, 0.72);
  --panel-solid: #1c1c1e;
  --panel-soft: #151517;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
  background:
    radial-gradient(circle at 22% 0%, rgba(0, 113, 227, 0.24), transparent 28%),
    linear-gradient(180deg, #121216 0%, var(--bg) 44%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 14px;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: min(1160px, calc(100% - 32px));
  height: 54px;
  margin: 14px auto 0;
  padding: 0 10px 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  backdrop-filter: saturate(180%) blur(24px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 750;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    linear-gradient(135deg, transparent 47%, rgba(255, 255, 255, 0.82) 49% 56%, transparent 58%),
    linear-gradient(135deg, #111827, #0071e3 48%, #34c759);
}

.nav {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.13);
}

.nav a {
  min-width: 54px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.nav a:hover {
  background: var(--panel-solid);
  color: var(--text);
}

.icon-button {
  justify-self: end;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(128, 128, 128, 0.16);
  color: var(--text);
}

.moon-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: inset -5px -3px 0 currentColor;
}

main {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(360px, 1.14fr);
  gap: 28px;
  align-items: end;
  min-height: calc(100vh - 82px);
  padding: 78px 0 34px;
}

.hero-copy {
  padding-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 660px;
  margin-bottom: 22px;
  font-size: clamp(46px, 7.5vw, 92px);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  max-width: 590px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.65;
}

.glass {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: saturate(180%) blur(28px);
}

.summary-panel {
  overflow: hidden;
  border-radius: 8px;
  padding: 26px;
}

.panel-head,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.panel-head span,
.market-note,
.metrics span {
  color: var(--muted);
  font-size: 14px;
}

.panel-head strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(38px, 6vw, 66px);
  line-height: 1;
  letter-spacing: 0;
}

.return-badge {
  display: inline-flex;
  margin: 18px 0 22px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(10, 143, 85, 0.12);
  color: var(--green);
  font-weight: 760;
}

.return-badge.loss {
  background: rgba(217, 48, 37, 0.12);
  color: var(--red);
}

.sparkline-wrap {
  min-height: 260px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(0, 113, 227, 0.08), rgba(128, 128, 128, 0.04));
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  margin: 8px 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.metrics article {
  min-height: 128px;
  padding: 24px;
  background: var(--panel-solid);
}

.metrics strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.05;
}

.auth-card {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  gap: 18px;
  align-items: center;
  margin-top: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
}

.auth-card h2 {
  margin-bottom: 10px;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.05;
}

.auth-card p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.auth-form input {
  min-height: 44px;
}

.auth-form button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 760;
}

.auth-form button:nth-of-type(2),
.auth-form button:nth-of-type(4) {
  background: rgba(128, 128, 128, 0.14);
  color: var(--text);
}

.auth-form button[hidden] {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  padding-top: 64px;
}

.entry-card,
.analysis-card,
.records-panel,
.market {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
}

.entry-card,
.analysis-card {
  padding: 24px;
}

.section-title h2,
.market h2 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
}

.record-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

label.full {
  grid-column: 1 / -1;
}

.suggest-field {
  position: relative;
}

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

input:focus,
select:focus {
  border-color: rgba(0, 113, 227, 0.72);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

.assist-text {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.suggest-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  z-index: 10;
  display: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.dark .suggest-menu {
  background: #ffffff;
  color: #1d1d1f;
}

.suggest-menu.open {
  display: block;
}

.suggest-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  border: 0;
  border-bottom: 1px solid rgba(29, 29, 31, 0.1);
  background: #ffffff;
  color: #1d1d1f;
  padding: 10px 12px;
  text-align: left;
}

.record-form .suggest-option {
  min-height: 58px;
  border-radius: 0;
  background: #ffffff;
  color: #1d1d1f;
  font-weight: 500;
}

.suggest-option:last-child {
  border-bottom: 0;
}

.suggest-option:hover,
.suggest-option:focus {
  background: #f5f5f7;
}

.suggest-option span,
.suggest-option strong,
.suggest-option small {
  min-width: 0;
}

.suggest-option span {
  display: grid;
  gap: 3px;
}

.suggest-option strong {
  overflow: hidden;
  color: #1d1d1f;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggest-option small,
.suggest-option em,
.suggest-empty {
  color: #6e6e73;
  font-size: 12px;
  font-style: normal;
  font-weight: 650;
}

.suggest-empty {
  padding: 14px;
}

.record-form button,
.tools button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 760;
}

.record-form button {
  grid-column: 1 / -1;
}

.donut-layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 20px;
  align-items: center;
  margin-top: 30px;
}

.legend {
  display: grid;
  gap: 12px;
}

.legend-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

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

.legend-item strong {
  color: var(--text);
}

.records-panel,
.market {
  margin-top: 18px;
  padding: 24px;
}

.tools {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.tools button:last-child {
  background: rgba(128, 128, 128, 0.14);
  color: var(--text);
}

.table-wrap {
  overflow-x: auto;
  margin-top: 22px;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  padding: 15px 12px;
  border-top: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

td {
  font-size: 14px;
}

.fund-name {
  display: grid;
  gap: 4px;
}

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

.pill {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(0, 113, 227, 0.12);
  color: var(--accent);
  font-weight: 760;
}

.pill.sell {
  background: rgba(176, 107, 0, 0.12);
  color: var(--amber);
}

.pill.dividend {
  background: rgba(10, 143, 85, 0.12);
  color: var(--green);
}

.profit {
  color: var(--green);
  font-weight: 760;
}

.profit.loss {
  color: var(--red);
}

.delete-btn {
  border: 0;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.14);
  color: var(--muted);
  padding: 7px 10px;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.market {
  margin-bottom: 72px;
}

.market-grid,
.topic-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 22px;
}

.market-card,
.topic-card {
  min-height: 142px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 20px;
}

.market-card span,
.topic-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.market-card strong {
  display: block;
  margin: 16px 0 8px;
  font-size: 30px;
}

.market-card em {
  font-style: normal;
  font-weight: 760;
}

.up {
  color: var(--green);
}

.down {
  color: var(--red);
}

.topic-card h3 {
  margin: 14px 0 10px;
  font-size: 20px;
  line-height: 1.25;
}

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

@media (max-width: 980px) {
  .hero,
  .auth-card,
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-top: 64px;
  }

  .hero-copy {
    padding-bottom: 0;
  }

  .metrics,
  .market-grid,
  .topic-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 680px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    width: calc(100% - 20px);
    padding-left: 14px;
  }

  .brand {
    font-size: 0;
  }

  .nav {
    justify-self: center;
  }

  .nav a {
    min-width: 44px;
    padding-inline: 8px;
  }

  main {
    width: calc(100% - 20px);
  }

  h1 {
    font-size: clamp(42px, 14vw, 64px);
  }

  .summary-panel,
  .entry-card,
  .analysis-card,
  .records-panel,
  .market {
    padding: 18px;
  }

  .metrics,
  .auth-form,
  .record-form,
  .market-grid,
  .topic-grid,
  .donut-layout {
    grid-template-columns: 1fr;
  }

  .donut-layout canvas {
    max-width: 240px;
    margin: 0 auto;
  }

  .panel-head,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .tools {
    width: 100%;
    justify-content: stretch;
  }

  .tools button {
    flex: 1;
  }
}
