:root {
  --bg-1: #07181f;
  --bg-2: #0f2b38;
  --bg-3: #144558;
  --panel: rgba(248, 253, 255, 0.94);
  --panel-strong: #ffffff;
  --ink: #09202a;
  --ink-muted: #45626f;
  --line: rgba(16, 63, 82, 0.16);
  --shadow-lg: 0 24px 58px rgba(4, 21, 29, 0.26);
  --shadow-md: 0 10px 24px rgba(6, 28, 39, 0.12);
  --accent-1: #e76f51;
  --accent-2: #2db6aa;
  --accent-3: #f0b06d;
  --ok: #0f8b62;
  --warn: #b9472d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: #f5fcff;
  background:
    radial-gradient(880px 420px at 0% -4%, #2db6aa42 0%, transparent 62%),
    radial-gradient(960px 500px at 102% 0%, #e76f513a 0%, transparent 54%),
    linear-gradient(132deg, var(--bg-1), var(--bg-2) 58%, var(--bg-3));
}

.page {
  width: min(1220px, 94vw);
  margin: 0 auto;
  padding: 2.1rem 0 3.4rem;
}

.hero h1,
.panel h2,
.broker-section h3,
.tax-summary-card h3,
.tax-modal-panel h3 {
  font-family: "Space Grotesk", sans-serif;
}

.hero {
  display: grid;
  gap: 0.78rem;
}

.eyebrow {
  margin: 0;
  color: #8ce6dd;
  text-transform: uppercase;
  letter-spacing: 0.095em;
  font-size: 0.74rem;
  font-weight: 600;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 3rem);
  line-height: 1.05;
  max-width: 16ch;
}

.hero-band {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 0.9rem;
  align-items: stretch;
}

.subtitle {
  margin: 0;
  max-width: 68ch;
  line-height: 1.42;
  color: #d3ebf1;
  font-size: 0.98rem;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.hero-metric {
  border: 1px solid rgba(195, 231, 243, 0.34);
  border-radius: 13px;
  background: rgba(7, 31, 40, 0.48);
  backdrop-filter: blur(2px);
  padding: 0.56rem 0.62rem;
  display: grid;
  gap: 0.12rem;
}

.hero-metric span {
  color: #97c5d5;
  font-size: 0.7rem;
  letter-spacing: 0.01em;
}

.hero-metric strong {
  color: #f0fbff;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
}

.layout {
  margin-top: 1.35rem;
  display: grid;
  grid-template-columns: minmax(370px, 1.05fr) minmax(330px, 0.95fr);
  gap: 1rem;
  align-items: start;
}

.panel {
  background: var(--panel);
  color: var(--ink);
  border-radius: 18px;
  border: 1px solid rgba(197, 226, 235, 0.64);
  box-shadow: var(--shadow-lg);
  padding: 1rem;
}

.form-panel {
  display: grid;
  gap: 0.88rem;
}

.section-head {
  display: grid;
  gap: 0.26rem;
}

.section-head h2,
.result-panel h2 {
  margin: 0;
  font-size: 1.17rem;
}

.section-head p,
.panel-subtitle {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.84rem;
  line-height: 1.36;
}

label {
  display: grid;
  gap: 0.36rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.api-config {
  padding: 0.62rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(180deg, #ffffff, #f4fbfe);
}

.input-hint {
  font-size: 0.74rem;
  color: #4a6672;
  font-weight: 500;
}

input,
select,
button {
  font: inherit;
}

input:not([type="checkbox"]),
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.62rem 0.72rem;
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

input:not([type="checkbox"]):focus,
select:focus {
  outline: 3px solid rgba(45, 182, 170, 0.25);
  border-color: rgba(45, 182, 170, 0.7);
}

.trade-date-option {
  padding: 0.58rem 0.62rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f5fbfe);
  display: grid;
  gap: 0.35rem;
}

.toggle-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #1f4250;
  line-height: 1.32;
}

.toggle-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: auto;
  margin: 0.08rem 0 0;
  accent-color: #2db6aa;
  box-shadow: none;
}

.grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.broker-section {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.76rem;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbfd 100%);
  display: grid;
  gap: 0.65rem;
}

.collapsible-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.55rem;
}

.broker-schwab {
  box-shadow: inset 0 4px 0 rgba(45, 182, 170, 0.22);
}

.broker-local {
  box-shadow: inset 0 4px 0 rgba(231, 111, 81, 0.2);
}

.broker-section h3 {
  margin: 0;
  font-size: 1rem;
}

button.collapsible-toggle {
  display: none;
  border: 1px solid #c7dce4;
  border-radius: 999px;
  min-height: 32px;
  padding: 0.28rem 0.62rem;
  background: #fff;
  color: #1a4050;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
}

button.collapsible-toggle::after {
  content: "▾";
  margin-left: 0.34rem;
  font-size: 0.66rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

[data-collapsible][data-expanded="false"] button.collapsible-toggle::after {
  transform: rotate(-90deg);
}

.collapsible-body[hidden] {
  display: none !important;
}

.broker-caption {
  margin: 0;
  font-size: 0.76rem;
  color: #4d6875;
}

.tax-mode-row {
  margin-top: 0.15rem;
}

.tax-config-group {
  border: 1px dashed rgba(16, 63, 82, 0.2);
  border-radius: 12px;
  padding: 0.66rem;
  background: #fbfeff;
}

.tax-hint {
  margin: 0.5rem 0 0;
  font-size: 0.77rem;
  color: #4a6672;
  line-height: 1.34;
}

.form-footer {
  margin-top: 0.2rem;
  padding-top: 0.62rem;
  border-top: 1px dashed rgba(16, 63, 82, 0.24);
  display: grid;
  gap: 0.48rem;
}

button {
  border: 0;
  border-radius: 12px;
  min-height: 46px;
  padding: 0.72rem 0.95rem;
  background: linear-gradient(100deg, var(--accent-1), #f59d74);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
  box-shadow: var(--shadow-md);
}

button:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.primary-action {
  background: linear-gradient(96deg, var(--accent-1), var(--accent-3));
  letter-spacing: 0.01em;
}

.hint {
  margin: 0;
  font-size: 0.77rem;
  color: #486473;
  line-height: 1.35;
}

.result-panel {
  display: grid;
  align-content: start;
  gap: 0.76rem;
  position: sticky;
  top: 0.9rem;
}

.result-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.62rem;
  background: #f9fdff;
  display: grid;
  gap: 0.58rem;
}

.result-section-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
}

.status {
  margin: 0;
  padding: 0.76rem;
  border: 1px dashed rgba(16, 63, 82, 0.26);
  border-radius: 12px;
  background: #fcffff;
  font-size: 0.86rem;
}

.headline {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  padding: 0.72rem 0.82rem;
  border-radius: 11px;
  background: #f1faf7;
  border: 1px solid #cdece4;
}

.headline.positive {
  color: var(--ok);
}

.headline.negative {
  color: var(--warn);
  background: #fff6f3;
  border-color: #ffd8cb;
}

.price-info {
  font-size: 0.84rem;
  color: #355563;
  line-height: 1.35;
}

.price-note {
  margin: 0.5rem 0 0;
  padding: 0.45rem 0.52rem;
  border-radius: 8px;
  border: 1px solid #cfe8e3;
  background: #f2fbf8;
  color: #1f5f50;
  font-size: 0.78rem;
  line-height: 1.34;
  font-weight: 600;
}

.chart {
  display: grid;
  gap: 0.54rem;
}

.chart-hint {
  margin: 0;
  font-size: 0.76rem;
  color: #44606d;
  line-height: 1.3;
}

.bar-row {
  display: grid;
  grid-template-columns: 104px 1fr;
  align-items: center;
  gap: 0.7rem;
}

.bar-row strong {
  font-size: 0.8rem;
}

.bar-track {
  position: relative;
  border-radius: 999px;
  background: #e6eff3;
  overflow: hidden;
  min-height: 26px;
}

.bar-fill {
  display: flex;
  min-height: 26px;
}

.seg-net {
  background: linear-gradient(95deg, #2bb2a3, #7cd7cc);
}

.seg-tax {
  background: #d06d53;
}

.seg-fee {
  background: #efbf7b;
}

.seg-gain-positive {
  background: linear-gradient(95deg, #2bb2a3, #7cd7cc);
}

.seg-gain-negative {
  background: linear-gradient(95deg, #d06d53, #e79a84);
}

.bar-track.negative .bar-value {
  color: #9f2a0f;
}

.bar-value {
  position: absolute;
  top: 50%;
  right: 0.52rem;
  transform: translateY(-50%);
  font-size: 0.73rem;
  font-weight: 700;
  color: #0b2430;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(16, 63, 82, 0.2);
  border-radius: 12px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.comparison-table {
  min-width: 560px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.46rem;
  text-align: right;
}

th {
  background: #f6fbfd;
  font-weight: 700;
}

th:first-child,
td:first-child {
  text-align: left;
}

.comparison-cards {
  display: none;
}

.tax-summary {
  margin-top: 0.36rem;
}

.tax-summary-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 0.75rem;
  background: #f7fbfc;
}

.tax-summary-card h3 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
}

.tax-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.56rem;
}

.tax-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.54rem 0.6rem;
  background: var(--panel-strong);
}

.tax-label {
  display: block;
  font-size: 0.74rem;
  color: #46636f;
}

.tax-item strong {
  display: block;
  margin-top: 0.11rem;
  font-size: 0.9rem;
}

.tax-summary-note {
  margin: 0.64rem 0 0;
  font-size: 0.82rem;
  line-height: 1.36;
  border-radius: 9px;
  padding: 0.48rem 0.54rem;
  border: 1px solid #d8e8ed;
  background: #fff;
}

.tax-summary-note.positive {
  color: var(--ok);
  border-color: #bde4d8;
  background: #f1fbf6;
}

.tax-summary-note.negative {
  color: var(--warn);
  border-color: #ffd8cb;
  background: #fff6f3;
}

.tax-summary-note.neutral {
  color: #2d4b57;
}

.tax-context {
  margin: 0.42rem 0 0;
  font-size: 0.75rem;
  color: #3b5a67;
  line-height: 1.34;
}

.tax-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.62rem;
}

.tax-modal-trigger {
  border: 1px solid #c8dce4;
  border-radius: 9px;
  background: #fff;
  color: #183a48;
  min-height: 38px;
  padding: 0.42rem 0.58rem;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.tax-modal-trigger:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.tax-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
}

.tax-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 18, 24, 0.55);
}

.tax-modal-panel {
  position: relative;
  width: min(900px, 92vw);
  max-height: min(84vh, 860px);
  overflow: auto;
  background: #fafdff;
  border: 1px solid #d3e5eb;
  border-radius: 15px;
  padding: 0.9rem;
  box-shadow: 0 24px 60px rgba(6, 18, 24, 0.3);
}

.tax-modal-panel h3 {
  margin: 0 0 0.74rem;
  font-size: 1.04rem;
}

.tax-modal-close {
  position: absolute;
  top: 0.62rem;
  right: 0.62rem;
  border: 1px solid #d1e2e8;
  border-radius: 8px;
  background: #fff;
  color: #173945;
  min-height: 32px;
  padding: 0.24rem 0.54rem;
  font-size: 0.73rem;
  font-weight: 700;
}

.tax-modal-content {
  display: grid;
  gap: 0.75rem;
}

.tax-modal-section {
  border: 1px solid #d9e8ed;
  border-radius: 10px;
  padding: 0.62rem;
  background: #fff;
}

.tax-modal-section h4 {
  margin: 0 0 0.44rem;
  font-size: 0.9rem;
}

.tax-modal-meta {
  margin: 0.22rem 0 0.5rem;
  font-size: 0.77rem;
  color: #395863;
  line-height: 1.34;
}

.tax-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
  min-width: 620px;
}

.tax-breakdown-table th,
.tax-breakdown-table td {
  border-bottom: 1px solid #e4eef2;
  padding: 0.37rem;
  text-align: right;
}

.tax-breakdown-table th:first-child,
.tax-breakdown-table td:first-child {
  text-align: left;
}

.hidden {
  display: none;
}

@media (max-width: 1080px) {
  .hero-band {
    grid-template-columns: 1fr;
  }

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

  .result-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .page {
    width: min(100%, 100vw);
    padding: 0.9rem 0.68rem 1.6rem;
  }

  .hero {
    gap: 0.52rem;
  }

  .hero h1 {
    max-width: none;
    font-size: clamp(1.55rem, 7vw, 2.1rem);
    line-height: 1.08;
  }

  .subtitle {
    font-size: 0.9rem;
  }

  .hero-metrics {
    grid-template-columns: 1fr;
    gap: 0.42rem;
  }

  .panel {
    padding: 0.8rem;
    border-radius: 14px;
  }

  .form-panel {
    gap: 0.72rem;
  }

  .grid.two {
    grid-template-columns: 1fr;
    gap: 0.56rem;
  }

  .section-head {
    gap: 0.2rem;
  }

  .section-head p {
    font-size: 0.8rem;
  }

  label {
    font-size: 0.86rem;
    gap: 0.3rem;
  }

  input:not([type="checkbox"]),
  select {
    min-height: 44px;
    font-size: 16px;
    padding: 0.58rem 0.66rem;
  }

  .api-config {
    padding: 0.56rem;
  }

  .input-hint {
    line-height: 1.28;
  }

  .trade-date-option {
    padding: 0.52rem 0.56rem;
  }

  .broker-section {
    padding: 0.66rem;
    gap: 0.54rem;
  }

  button.collapsible-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .collapsible-head {
    align-items: flex-start;
  }

  .broker-caption {
    font-size: 0.74rem;
    line-height: 1.32;
  }

  .tax-config-group {
    padding: 0.56rem;
  }

  .tax-hint {
    margin-top: 0.42rem;
    font-size: 0.75rem;
    line-height: 1.32;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .tax-summary-grid {
    grid-template-columns: 1fr;
  }

  .result-section {
    padding: 0.56rem;
    gap: 0.48rem;
  }

  .table-wrap {
    overflow-x: visible;
    border: 0;
    background: transparent;
  }

  .comparison-table {
    display: none;
  }

  .comparison-cards {
    display: grid;
    gap: 0.48rem;
  }

  .metric-card {
    border: 1px solid rgba(16, 63, 82, 0.2);
    border-radius: 10px;
    background: #fff;
    padding: 0.56rem;
    display: grid;
    gap: 0.42rem;
  }

  .metric-card h4 {
    margin: 0;
    font-size: 0.84rem;
    color: #1a3f4d;
  }

  .metric-values {
    display: grid;
    gap: 0.3rem;
  }

  .metric-pair {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.6rem;
  }

  .metric-pair span {
    font-size: 0.73rem;
    color: #4b6773;
  }

  .metric-pair strong {
    font-size: 0.83rem;
    color: #102f3a;
    white-space: nowrap;
  }

  .form-footer {
    position: static;
    margin-top: 0.1rem;
    padding-top: 0.54rem;
    border-top: 1px dashed rgba(16, 63, 82, 0.22);
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    z-index: auto;
  }

  .primary-action {
    min-height: 48px;
  }

  .tax-modal-panel {
    width: min(96vw, 96vw);
    max-height: min(88vh, 88vh);
    padding: 0.74rem;
  }
}

@media (max-width: 430px) {
  .page {
    padding-left: 0.56rem;
    padding-right: 0.56rem;
  }

  .panel {
    padding: 0.68rem;
  }

  .hero-metric {
    border-radius: 11px;
    padding: 0.48rem 0.54rem;
  }

  .form-footer .hint {
    font-size: 0.73rem;
    line-height: 1.3;
  }

  .status,
  .price-info {
    font-size: 0.8rem;
  }
}
