:root {
  color-scheme: light;
  --page: #f4f1ea;
  --surface: #fffdf8;
  --surface-muted: #ebe6dc;
  --ink: #17191f;
  --muted: #6c6d73;
  --faint: #9a958c;
  --line: #d9d1c4;
  --line-strong: #bdb3a4;
  --green: #0f7a4f;
  --green-soft: #d9f0e5;
  --red: #b53f3f;
  --red-soft: #f4dddd;
  --blue: #315c8c;
  --blue-soft: #dbe8f5;
  --gold: #a97015;
  --gold-soft: #f6e9d2;
  --sell: #9a5b1f;
  --sell-strong: #7f4a17;
  --shadow: 0 18px 42px rgba(23, 25, 31, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(
    180deg,
    rgba(255, 253, 248, 0.74),
    rgba(244, 241, 234, 0.96)
  ),
    repeating-linear-gradient(
    90deg,
    rgba(23, 25, 31, 0.035) 0 1px,
    transparent 1px 96px
  );
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: var(--line-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

select {
  padding-right: 8px;
}

input:focus,
select:focus {
  outline: 3px solid var(--blue-soft);
  border-color: var(--blue);
}

input[type="range"] {
  min-height: 0;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--ink);
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]:disabled {
  opacity: 0.4;
}

svg {
  display: block;
}

.muted {
  color: var(--muted);
}

.app-shell {
  width: min(1360px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 12px 0;
  background: rgba(244, 241, 234, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand-block,
.watch-card-head,
.panel-heading,
.form-actions,
.input-action,
.search-form,
.settings-actions,
.topbar-actions,
.card-actions,
.button-row,
.chip-row {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
}

.brand-logo {
  display: block;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 1px 2px rgba(23, 25, 31, 0.18);
}

router-link.brand-link {
  display: inline-flex;
  justify-self: start;
  min-height: 0;
  padding: 0;
  border-radius: 10px;
  color: var(--ink);
  font-size: inherit;
  text-align: left;
  white-space: normal;
}

.brand-text {
  display: grid;
  gap: 1px;
}

.brand-title,
.brand-subtitle {
  display: block;
}

router-link.brand-link:hover {
  background: transparent;
}

router-link.brand-link:hover .brand-title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.brand-title,
.brand-subtitle,
.panel-heading h1,
.panel-heading h2,
.panel-heading p {
  margin: 0;
}

.brand-title {
  font-weight: 800;
  font-size: 1.1rem;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.78rem;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.7);
}

router-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 13px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  white-space: nowrap;
}

router-link:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

router-link.panel-link {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.84rem;
}

router-link.row-link {
  justify-content: flex-start;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font-size: inherit;
  text-align: left;
  white-space: normal;
}

router-link.row-link:hover {
  background: transparent;
}

router-link.row-link:hover strong {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.topbar-actions {
  justify-self: end;
  gap: 10px;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.7);
}

.segment {
  min-height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.segment:hover {
  color: var(--ink);
  background: var(--surface-muted);
}

.segment.active {
  background: var(--ink);
  color: var(--surface);
}

.refresh-button {
  min-width: 112px;
}

.workspace {
  padding-top: 22px;
}

.status-banner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid;
}

.status-banner.error {
  background: var(--red-soft);
  border-color: rgba(181, 63, 63, 0.28);
  color: var(--red);
}

.status-banner.notice {
  background: var(--green-soft);
  border-color: rgba(15, 122, 79, 0.25);
  color: var(--green);
}

.dashboard-grid,
.research-grid,
.settings-grid,
.holdings-grid,
.page-stack {
  display: grid;
  gap: 18px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
}

.summary-band {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1.4fr repeat(4, 1fr);
  gap: 12px;
}

.metric,
.panel,
.loading-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  gap: 7px;
  padding: 18px;
  min-height: 124px;
  align-content: start;
}

.primary-metric {
  background: var(--ink);
  color: var(--surface);
}

.metric-label,
.cell-label,
.watch-stats small,
.fact small,
.sell-preview small {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.primary-metric .metric-label {
  color: #c8c2b8;
}

.primary-metric .metric-delta.positive {
  color: #7fd3a8;
}

.primary-metric .metric-delta.negative {
  color: #f0a3a3;
}

.metric strong {
  font-size: 1.65rem;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.metric-delta {
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.panel,
.loading-panel {
  padding: 18px;
}

.holdings-panel {
  grid-column: 1 / -1;
  padding: 14px;
}

.panel-heading {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.panel-heading h1,
.panel-heading h2 {
  font-size: 1.18rem;
  line-height: 1.2;
}

.panel-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.ticker-field {
  position: relative;
}

.ticker-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  max-height: 294px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 18px 34px rgba(23, 25, 31, 0.16);
}

.ticker-option {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 3px 10px;
  min-height: 58px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
  background: #fff;
}

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

.ticker-option:hover,
.ticker-option:focus {
  outline: none;
  background: var(--blue-soft);
}

.ticker-option strong {
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--ink);
}

.ticker-option span,
.ticker-option small,
.ticker-menu-status {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticker-option small {
  font-size: 0.74rem;
}

.ticker-menu-status {
  padding: 13px 12px;
}

.wide-field,
.form-actions {
  grid-column: 1 / -1;
}

.input-action {
  gap: 6px;
}

.input-action input {
  min-width: 0;
  flex: 1 1 auto;
}

.input-action .currency-select {
  flex: 0 0 auto;
  width: auto;
  min-width: 78px;
  padding-left: 10px;
}

.input-action button {
  flex: 0 0 76px;
}

.form-actions {
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
}

.form-actions p,
.inline-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.inline-message.negative {
  color: var(--red);
}

.primary-button {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--surface);
  padding: 0 16px;
}

.sell-button {
  border-color: var(--sell);
  background: var(--sell);
  color: #fff;
  padding: 0 16px;
  font-weight: 600;
}

.panel-heading .sell-button,
.detail-head .sell-button {
  white-space: nowrap;
}

.sell-button:hover {
  border-color: var(--sell-strong);
  background: var(--sell-strong);
}

.danger-button {
  border-color: rgba(181, 63, 63, 0.28);
  color: var(--red);
}

.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.86rem;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--muted);
}

.chip-row {
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
}

.chip.active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--surface);
}

.chip:disabled {
  opacity: 0.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge.buy {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge.sell {
  background: var(--gold-soft);
  color: var(--sell);
}

.position-list,
.lot-list,
.transaction-list,
.timing-list,
.search-results,
.watch-grid,
.allocation-list,
.storage-stats,
.realized-list,
.holding-list {
  display: grid;
  gap: 10px;
}

.position-list,
.transaction-list,
.timing-list,
.realized-list,
.holding-list {
  gap: 6px;
}

.position-row,
.lot-row,
.transaction-row,
.timing-row {
  display: grid;
  align-items: center;
  gap: 14px;
  min-height: 86px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.position-row {
  gap: 10px;
  grid-template-columns:
    minmax(190px, 1.4fr) minmax(120px, 0.7fr) repeat(4, minmax(96px, 0.55fr))
    auto;
  min-height: 58px;
  padding: 8px 10px;
}

.position-row > div {
  display: grid;
  gap: 2px;
}

.lot-row {
  grid-template-columns:
    minmax(160px, 1.4fr) repeat(4, minmax(92px, 0.8fr)) auto;
}

.transaction-row {
  gap: 12px;
  grid-template-columns:
    minmax(200px, 1.5fr) repeat(3, minmax(96px, 0.7fr)) minmax(110px, 0.8fr)
    minmax(130px, 0.9fr) auto;
  min-height: 70px;
  padding: 10px 12px;
}

.transaction-row > div,
.timing-row > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.transaction-row strong,
.timing-row strong,
.fact strong,
.sell-preview strong,
.holding-item b {
  font-variant-numeric: tabular-nums;
}

.transaction-row small,
.timing-row small,
.position-row small {
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-identity {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.tx-identity > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.identity-cell,
.lot-row > div,
.watch-card-head > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.position-row .identity-cell {
  gap: 2px;
}

.position-row strong {
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.position-row .identity-cell span {
  font-size: 0.78rem;
}

.identity-cell span,
.lot-row span,
.tx-identity span:not(.badge),
.watch-card-head span,
.search-result span,
.search-result small,
.timing-row > div > span:not(.cell-label),
.holding-item span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

.neutral {
  color: var(--muted);
}

.sparkline,
.watch-chart {
  width: 100%;
  height: auto;
  overflow: visible;
}

.position-row .sparkline {
  height: 34px;
}

.sparkline-grid {
  fill: none;
  stroke: var(--line);
  stroke-dasharray: 4 6;
}

.sparkline-path {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline-path.positive {
  stroke: var(--green);
}

.sparkline-path.negative {
  stroke: var(--red);
}

.allocation-row {
  display: grid;
  grid-template-columns: minmax(78px, 0.7fr) 1fr 56px;
  align-items: center;
  gap: 12px;
}

.allocation-row > div:first-child {
  display: grid;
  gap: 2px;
}

.allocation-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.allocation-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.allocation-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

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

.mover-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.mover-card span {
  color: var(--muted);
  font-size: 0.78rem;
}

.mover-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.2rem;
}

.mover-card p {
  margin: 6px 0 0;
}

.realized-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.realized-row > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.realized-row span {
  color: var(--muted);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.realized-value {
  text-align: right;
}

.realized-value strong {
  font-variant-numeric: tabular-nums;
}

.realized-value small {
  font-size: 0.76rem;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 142px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

.research-grid {
  grid-template-columns: minmax(320px, 0.7fr) minmax(0, 1.3fr);
}

.search-form {
  gap: 10px;
}

.search-form input {
  flex: 1;
}

.search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.search-result > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.watch-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.watch-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.watch-card-head {
  justify-content: space-between;
  gap: 12px;
}

.card-actions {
  gap: 8px;
  flex: 0 0 auto;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.78rem;
  white-space: nowrap;
}

.pill.closed {
  background: var(--surface-muted);
  color: var(--muted);
}

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

.watch-stats span {
  display: grid;
  gap: 4px;
}

.watch-stats em {
  font-style: normal;
  font-size: 0.78rem;
}

.settings-grid {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.55fr);
}

.currency-panel {
  grid-column: 1 / -1;
}

.settings-actions {
  flex-wrap: wrap;
  gap: 10px;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.file-button input {
  display: none;
}

.storage-stats span {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.rates-list {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 14px;
}

.rates-list span span {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}

/* ---------- facts (small stat tiles) ---------- */

.fact {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.fact strong {
  font-size: 1.05rem;
  line-height: 1.15;
}

.fact span {
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fact span.positive {
  color: var(--green);
}

.fact span.negative {
  color: var(--red);
}

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

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.filter-bar select,
.filter-input {
  min-height: 38px;
}

.filter-bar select {
  width: auto;
  min-width: 170px;
}

/* ---------- sell dialog ---------- */

.sell-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(92vh, 900px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 32px 80px rgba(23, 25, 31, 0.32);
  overflow: auto;
}

.sell-dialog::backdrop {
  background: rgba(23, 25, 31, 0.45);
  backdrop-filter: blur(6px);
}

.sell-dialog[open] {
  animation: dialog-in 0.18s ease-out;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.sell-form {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.sell-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.sell-head h2 {
  margin: 0;
  font-size: 1.3rem;
}

.sell-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.sell-facts,
.detail-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

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

.quantity-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.field-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.field-heading span:last-child {
  font-variant-numeric: tabular-nums;
}

.quantity-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.quantity-controls input {
  font-size: 1.1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sell-preview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.sell-preview.positive {
  background: var(--green-soft);
  border-color: rgba(15, 122, 79, 0.25);
}

.sell-preview.negative {
  background: var(--red-soft);
  border-color: rgba(181, 63, 63, 0.28);
}

.sell-preview > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.sell-preview strong {
  font-size: 1.05rem;
}

.sell-preview span {
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sell-preview span.positive {
  color: var(--green);
}

.sell-preview span.negative {
  color: var(--red);
}

.sell-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.button-row {
  gap: 8px;
  flex: 0 0 auto;
}

/* ---------- holdings page ---------- */

.holdings-grid {
  grid-template-columns: minmax(280px, 0.75fr) minmax(0, 2fr);
  align-items: start;
}

.holdings-list-panel {
  position: sticky;
  top: 92px;
}

.filter-input {
  margin-bottom: 10px;
}

.scope-chips {
  margin-bottom: 12px;
}

.holding-list {
  max-height: calc(100vh - 330px);
  overflow-y: auto;
  padding-right: 2px;
}

.holding-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  min-height: 0;
  padding: 10px 12px;
  text-align: left;
  border-radius: var(--radius);
  background: #fff;
}

.holding-item:hover {
  background: var(--surface);
}

.holding-item.active {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.holding-item strong {
  font-size: 0.95rem;
}

.holding-item b {
  font-weight: 600;
  font-size: 0.9rem;
  text-align: right;
}

.holding-item span,
.holding-item small {
  font-size: 0.78rem;
}

.holding-item small {
  text-align: right;
  white-space: nowrap;
}

.holding-detail {
  display: grid;
  gap: 16px;
}

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

.detail-head h2 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

.detail-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 0.8rem;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
}

.legend-buy {
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--blue);
}

.legend-sell {
  background: var(--sell);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--sell);
  transform: rotate(45deg) scale(0.85);
}

.legend-avg {
  height: 0;
  border-top: 2px dashed var(--gold);
}

.legend-line {
  height: 0;
  border-top: 3px solid var(--ink);
  border-radius: 2px;
}

.price-chart {
  width: 100%;
  height: auto;
  padding: 8px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--blue);
  font-family: inherit;
}

.price-chart.positive {
  color: var(--green);
}

.price-chart.negative {
  color: var(--red);
}

.price-chart text {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-grid line {
  stroke: var(--line);
  stroke-dasharray: 3 5;
}

.chart-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-average line {
  stroke: var(--gold);
  stroke-width: 1.6;
  stroke-dasharray: 6 5;
}

.chart-average text {
  fill: var(--gold);
  font-weight: 600;
}

.chart-markers .marker circle,
.chart-markers .marker path {
  stroke: #fff;
  stroke-width: 2;
  cursor: help;
}

.chart-markers .marker.buy circle {
  fill: var(--blue);
}

.chart-markers .marker.sell path {
  fill: var(--sell);
}

.chart-hover line {
  stroke: var(--ink);
  stroke-width: 1;
  stroke-dasharray: 2 4;
  pointer-events: none;
}

.chart-hover circle {
  fill: #fff;
  stroke: currentColor;
  stroke-width: 2.5;
  pointer-events: none;
}

.chart-hover rect {
  fill: var(--ink);
  opacity: 0.94;
  pointer-events: none;
}

.chart-hover text {
  fill: var(--surface);
  pointer-events: none;
}

.chart-hover .tooltip-date {
  fill: #c8c2b8;
}

.chart-hover .tooltip-price {
  font-size: 13px;
  font-weight: 700;
}

.chart-hover .tooltip-trade.buy {
  fill: #a8c4e6;
}

.chart-hover .tooltip-trade.sell {
  fill: #f0cf97;
}

.price-chart {
  cursor: crosshair;
}

.price-chart svg {
  overflow: visible;
}

.chart-caption {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.detail-section-heading {
  margin-top: 6px;
}

.detail-section-heading h3 {
  margin: 0;
  font-size: 1.05rem;
}

.detail-section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.timing-row {
  grid-template-columns:
    auto minmax(150px, 1.2fr) minmax(100px, 0.8fr) minmax(150px, 1.2fr)
    minmax(120px, 1fr);
  gap: 12px;
  min-height: 64px;
  padding: 10px 12px;
}

/* ---------- responsive ---------- */

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

@media (max-width: 1050px) {
  .topbar,
  .dashboard-grid,
  .research-grid,
  .settings-grid,
  .holdings-grid {
    grid-template-columns: 1fr;
  }

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

  .primary-metric {
    grid-column: 1 / -1;
  }

  .topbar-actions {
    justify-self: stretch;
    justify-content: space-between;
  }

  .refresh-button {
    flex: 1;
  }

  .nav-tabs {
    overflow-x: auto;
  }

  .position-row,
  .lot-row,
  .transaction-row,
  .timing-row {
    grid-template-columns: 1fr 1fr;
  }

  .tx-identity,
  .position-row .identity-cell {
    grid-column: 1 / -1;
  }

  .sparkline {
    grid-column: 1 / -1;
  }

  .timing-row .badge {
    justify-self: start;
  }

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

  .holdings-list-panel {
    position: static;
  }

  .holding-list {
    max-height: 320px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 20px, 1360px);
  }

  .lot-form,
  .position-row,
  .lot-row,
  .transaction-row,
  .timing-row,
  .mover-grid,
  .watch-stats,
  .allocation-row,
  .summary-band,
  .sell-grid,
  .sell-preview,
  .tx-summary,
  .quantity-controls {
    grid-template-columns: 1fr;
  }

  .sell-facts,
  .detail-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fact span {
    white-space: normal;
  }

  .topbar {
    position: static;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  router-link {
    flex: 1;
  }

  .sell-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }

  .sell-form {
    padding: 16px;
  }

  .sell-actions,
  .detail-head {
    flex-direction: column;
    align-items: stretch;
  }

  .button-row {
    justify-content: flex-end;
  }

  .input-action {
    flex-wrap: wrap;
  }

  .input-action input {
    flex-basis: 100%;
  }

  .input-action .currency-select {
    flex: 1;
  }

  .price-chart text {
    font-size: 15px;
  }
}

.ticker-options {
  display: grid;
}
