    :root {
      color-scheme: light;
      --bg: #f5f5f7;
      --panel: #ffffff;
      --panel-2: #fbfbfd;
      --panel-glass: rgba(255, 255, 255, .78);
      --line: rgba(60, 60, 67, .14);
      --text: #1d1d1f;
      --muted: #6e6e73;
      --soft: #3a3a3c;
      --green: #248a3d;
      --red: #d70015;
      --amber: #b26a00;
      --blue: #007aff;
      --teal: #0071a4;
      --violet: #8e44ad;
      --focus: #007aff;
      --shadow: 0 10px 30px rgba(0, 0, 0, .05);
      --details-toggle-collapsed-label: "Expand";
      --details-toggle-open-label: "Collapse";
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      /* Tabular figures keep money/percent columns aligned everywhere. */
      font-variant-numeric: tabular-nums;
    }

    :root[data-theme="dark"] {
      color-scheme: dark;
      --bg: #101113;
      --panel: #1c1c1e;
      --panel-2: #242427;
      --panel-glass: rgba(28, 28, 30, .82);
      --line: rgba(255, 255, 255, .10);
      --text: #f5f5f7;
      --muted: #9b9ba1;
      --soft: #d1d1d6;
      --green: #30d158;
      --red: #ff453a;
      --amber: #ffd60a;
      --blue: #0a84ff;
      --teal: #64d2ff;
      --violet: #bf5af2;
      --focus: #007aff;
      --shadow: 0 18px 48px rgba(0, 0, 0, .22);
    }

    @media (prefers-color-scheme: dark) {
      :root[data-theme="auto"] {
        color-scheme: dark;
        --bg: #101113;
        --panel: #1c1c1e;
        --panel-2: #242427;
        --panel-glass: rgba(28, 28, 30, .82);
        --line: rgba(255, 255, 255, .10);
        --text: #f5f5f7;
        --muted: #9b9ba1;
        --soft: #d1d1d6;
        --green: #30d158;
        --red: #ff453a;
        --amber: #ffd60a;
        --blue: #0a84ff;
        --teal: #64d2ff;
        --violet: #bf5af2;
        --focus: #007aff;
        --shadow: 0 18px 48px rgba(0, 0, 0, .22);
      }
    }

    * { box-sizing: border-box; }

    [hidden] {
      display: none !important;
    }

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

    body.modal-scroll-lock {
      position: fixed;
      width: 100%;
      overflow: hidden;
      touch-action: none;
    }

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

    button {
      border: 0;
      cursor: pointer;
    }

    .app {
      width: min(1440px, calc(100vw - 36px));
      margin: 0 auto;
      padding: 20px 0 34px;
    }

    .topbar {
      min-height: 64px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 18px;
      border-bottom: 1px solid var(--line);
      margin-bottom: 16px;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 12px;
      min-width: 220px;
    }

    .brand-mark {
      width: 42px;
      height: 42px;
      display: grid;
      place-items: center;
      border-radius: 8px;
      background: var(--panel);
      color: var(--focus);
      border: 1px solid var(--line);
      box-shadow: var(--shadow);
    }

    .brand h1 {
      font-size: 18px;
      line-height: 1.1;
      margin: 0;
      font-weight: 760;
    }

    .brand p {
      margin: 4px 0 0;
      color: var(--muted);
      font-size: 12px;
    }

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

    .demo-auth-btn {
      font-weight: 700;
    }

    .demo-banner {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      margin: 0 0 16px;
      padding: 12px 14px;
      border: 1px solid color-mix(in srgb, var(--blue), transparent 68%);
      border-radius: 12px;
      background: color-mix(in srgb, var(--blue), var(--panel) 88%);
      color: var(--text);
      box-shadow: var(--shadow);
    }

    .demo-banner span {
      font-size: 14px;
      line-height: 1.35;
    }

    .fx-warning-banner {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      margin: 0 0 14px;
      padding: 12px 14px;
      border: 1px solid color-mix(in srgb, #d97706, transparent 48%);
      border-radius: 10px;
      background: color-mix(in srgb, #f59e0b, var(--panel) 88%);
      color: var(--text);
      box-shadow: var(--shadow);
      font-size: 13px;
      line-height: 1.4;
    }

    .fx-warning-banner[hidden] {
      display: none;
    }

    .view-demo-btn {
      width: 100%;
      justify-content: center;
      border-style: dashed;
    }

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

    .account-section {
      padding: 18px;
    }

    .account-section h2 {
      margin: 0 0 14px;
      font-size: 16px;
    }

    .account-email {
      padding: 12px;
      border: 1px solid rgba(255, 255, 255, .08);
      border-radius: 8px;
      background: rgba(255, 255, 255, .035);
      color: var(--soft);
      word-break: break-word;
    }

    .preference-fields {
      display: grid;
      gap: 14px;
    }

    .preference-note {
      margin: 6px 0 0;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.45;
    }

    .account-actions {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      margin-top: 16px;
    }

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

    .cash-actions .ghost-btn {
      flex: 0 1 auto;
      min-width: max-content;
      min-height: 34px;
      padding: 0 12px;
      justify-content: center;
      white-space: nowrap;
    }

    .cash-metrics {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 10px;
      padding: 14px 16px 0;
    }

    .cash-metrics > div {
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: rgba(255, 255, 255, .035);
    }

    .cash-metrics span, .cash-metrics strong {
      display: block;
    }

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

    .cash-metrics strong {
      margin-top: 7px;
      font-size: 17px;
    }

    .dividend-entry-panel {
      width: min(560px, calc(100vw - 28px));
      gap: 14px;
    }

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

    .dividend-entry-panel .field-grid label,
    .dividend-entry-panel .field-grid input {
      min-width: 0;
      width: 100%;
    }

    .cash-hint {
      color: var(--muted);
      font-size: 12px;
      white-space: nowrap;
    }

    .cash-total-inline {
      display: block;
      margin-top: 3px;
      color: var(--text);
      font-size: 13px;
      font-weight: 680;
      line-height: 1.25;
    }

    .icon-btn, .primary-btn, .ghost-btn {
      min-height: 40px;
      border-radius: 8px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      transition: transform .16s ease, background .16s ease, border-color .16s ease;
      color: var(--text);
    }

    .icon-btn {
      width: 40px;
      background: var(--panel-2);
      border: 1px solid var(--line);
    }

    .primary-btn {
      padding: 0 14px;
      background: var(--focus);
      color: #ffffff;
      font-weight: 720;
    }

    .ghost-btn {
      padding: 0 12px;
      background: var(--panel-2);
      border: 1px solid var(--line);
      color: var(--soft);
      font-size: 13px;
      line-height: 1;
      cursor: pointer;
      user-select: none;
    }

    .icon-btn:hover, .ghost-btn:hover, .primary-btn:hover {
      transform: translateY(-1px);
    }

    .layout {
      display: grid;
      grid-template-columns: 1fr;
      gap: 18px;
      align-items: start;
    }

    .layout > section {
      display: grid;
    }

    .market-settings {
      display: grid;
      grid-template-columns: 1.1fr 1.45fr .9fr auto;
      gap: 12px;
      align-items: end;
      margin-bottom: 12px;
      padding: 10px;
      border: 1px solid var(--line);
      background: var(--panel-glass);
      box-shadow: none;
      border-radius: 8px;
      backdrop-filter: blur(18px);
    }

    .market-settings.compact-toolbar {
      grid-template-columns: minmax(160px, .9fr) minmax(240px, 1.25fr) minmax(150px, .8fr) auto;
      align-items: center;
    }

    /* A utility action should not be the loudest element on the page: the
       refresh button sizes to its content instead of filling the column. */
    #refreshPricesBtn {
      justify-self: start;
      padding: 0 18px;
    }

    #portfolioBenchmark {
      max-width: 230px;
    }

    .portfolio-panel {
      margin-bottom: 14px;
      padding: 12px;
      border: 1px solid var(--line);
      background: var(--panel-glass);
      box-shadow: none;
      border-radius: 8px;
      display: grid;
      gap: 12px;
      backdrop-filter: blur(18px);
    }

    .portfolio-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 12px;
    }

    .portfolio-row {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
    }

    /* Segmented chips: selection reads through fill + ink instead of a boxed
       checkbox; the real input stays for keyboard/AT access. */
    .portfolio-check {
      position: relative;
      min-height: 34px;
      padding: 7px 14px;
      border: 1px solid transparent;
      border-radius: 999px;
      background: transparent;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
      transition: background .15s ease, color .15s ease;
    }

    .portfolio-check:hover {
      background: var(--panel-2);
    }

    .portfolio-check:has(input:checked) {
      background: color-mix(in srgb, var(--focus) 12%, transparent);
      color: var(--focus);
    }

    .portfolio-check:has(input:focus-visible) {
      outline: 2px solid var(--focus);
      outline-offset: 2px;
    }

    .portfolio-check input {
      position: absolute;
      width: 1px;
      height: 1px;
      min-height: auto;
      padding: 0;
      opacity: 0;
      pointer-events: none;
    }

    .portfolio-manage-list {
      display: grid;
      gap: 10px;
      margin-bottom: 12px;
    }

    .portfolio-manage-row {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px;
      align-items: center;
    }

    .portfolio-manage-add {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px;
    }

    .settings-status {
      color: var(--muted);
      font-size: 12px;
      line-height: 1.35;
      align-self: center;
      min-width: 150px;
    }

    .provider-badge {
      min-height: 42px;
      display: flex;
      align-items: center;
      gap: 10px;
      color: var(--soft);
      font-size: 13px;
      font-weight: 720;
    }

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

    .metric {
      border: 1px solid var(--line);
      background: var(--panel);
      box-shadow: var(--shadow);
      border-radius: 8px;
      padding: 18px;
      min-height: 118px;
      display: grid;
      grid-template-rows: auto 1fr;
      gap: 14px;
    }

    .metric-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      color: var(--muted);
      font-size: 12px;
      font-weight: 680;
    }

    .metric-icon {
      width: 34px;
      height: 34px;
      border-radius: 8px;
      display: grid;
      place-items: center;
      background: var(--panel-2);
      color: var(--muted);
    }

    .metric strong {
      display: block;
      font-size: clamp(24px, 2.1vw, 34px);
      line-height: 1;
      letter-spacing: -0.02em;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .metric-body {
      display: grid;
      align-content: start;
      grid-template-rows: 36px 20px 20px 20px;
      gap: 7px;
    }

    .metric small {
      color: var(--muted);
      display: block;
      line-height: 1.35;
    }

    .panel {
      border: 1px solid var(--line);
      background: var(--panel);
      box-shadow: var(--shadow);
      border-radius: 8px;
      overflow: hidden;
      min-width: 0;
    }

    .panel-head {
      min-height: 58px;
      padding: 14px 16px;
      border-bottom: 1px solid var(--line);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .panel-title {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
    }

    .panel-title h2 {
      font-size: 15px;
      margin: 0;
      font-weight: 760;
    }

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

    .grid-2 {
      margin-bottom: 14px;
    }

    .chart-wrap {
      padding: 18px;
      min-height: 308px;
    }

    .echart {
      width: 100%;
      min-height: 292px;
    }

    .echart.asset-echart {
      min-height: 224px;
    }

    .chart-controls {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }

    .benchmark-search {
      position: relative;
      min-width: 176px;
    }

    .benchmark-search input {
      min-height: 34px;
      border-radius: 999px;
      padding: 6px 12px;
      font-size: 13px;
    }

    .benchmark-search .suggestions {
      top: calc(100% + 8px);
      z-index: 90;
      border-radius: 12px;
    }

    .chart-controls select {
      min-width: 104px;
      min-height: 34px;
      border-radius: 999px;
      padding: 6px 12px;
      background: var(--panel-2);
    }

    .chart-button-group {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 3px;
      border: 1px solid var(--line);
      border-radius: 999px;
      background: var(--panel-2);
      max-width: 100%;
      overflow-x: auto;
      scrollbar-width: none;
    }

    .chart-button-group::-webkit-scrollbar {
      display: none;
    }

    .chart-range-group {
      flex-wrap: nowrap;
    }

    .chart-toggle-btn {
      min-height: 30px;
      padding: 0 12px;
      border-radius: 999px;
      background: transparent;
      color: var(--muted);
      font-size: 12px;
      font-weight: 720;
      white-space: nowrap;
      transition: background .16s ease, color .16s ease, box-shadow .16s ease;
    }

    .chart-toggle-btn:hover {
      color: var(--text);
    }

    .chart-toggle-btn.active {
      background: var(--blue);
      color: #fff;
      box-shadow: 0 6px 16px color-mix(in srgb, var(--blue) 24%, transparent);
    }

    .chart-period-summary {
      display: flex;
      align-items: baseline;
      gap: 8px;
      flex-wrap: wrap;
      margin: 0 0 10px;
      color: var(--muted);
      font-size: 13px;
    }

    #portfolioChartSummary {
      cursor: pointer;
    }

    .sync-status.sync-error {
      color: var(--red);
      font-weight: 640;
    }

    #portfolioChartSummary:hover strong {
      text-decoration: underline;
      text-underline-offset: 3px;
    }

    .chart-period-summary strong {
      color: var(--text);
      font-size: 18px;
      font-weight: 780;
    }

    .chart-period-summary strong.positive,
    .chart-period-summary span.positive {
      color: var(--green);
    }

    .chart-period-summary strong.negative,
    .chart-period-summary span.negative {
      color: var(--red);
    }

    .panel.feature-chart .chart-wrap {
      min-height: 360px;
    }

    .panel.feature-chart .echart {
      /* ~3:1 width-to-height at typical desktop widths — the common ratio on
         financial platforms. Flatter (4:1+) visually deadens the swings. */
      min-height: clamp(360px, 31vw, 460px);
    }

    .donut-area {
      min-height: 420px;
      display: grid;
      grid-template-columns: minmax(300px, 430px) minmax(260px, 1fr);
      align-items: center;
      gap: 24px;
      overflow: visible;
    }

    .allocation-chart-type {
      min-width: 104px;
    }

    .allocation-treemap {
      display: none;
      min-height: 420px;
      position: relative;
      overflow: hidden;
      border-radius: 8px;
    }

    .allocation-treemap.show { display: block; }

    .treemap-tile {
      position: absolute;
      min-width: 0;
      min-height: 0;
      border: 1px solid color-mix(in srgb, var(--panel) 82%, transparent);
      border-radius: 8px;
      padding: clamp(5px, 1.15vw, 12px);
      background: var(--tile-bg);
      color: #111114;
      display: grid;
      place-content: center;
      justify-items: center;
      gap: 4px;
      text-align: center;
      overflow: hidden;
      inset: var(--tile-y) auto auto var(--tile-x);
      width: var(--tile-w);
      height: var(--tile-h);
      box-shadow: inset 0 0 0 1px rgba(255,255,255,.24);
    }

    .treemap-tile strong,
    .treemap-tile span {
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      text-shadow: 0 1px 0 rgba(255,255,255,.36);
    }

    .treemap-tile strong {
      font-size: clamp(11px, 1.2vw, 15px);
      font-weight: 800;
      line-height: 1.1;
    }

    .treemap-tile span {
      color: rgba(17, 17, 20, .72);
      font-size: clamp(10px, 1vw, 13px);
      line-height: 1.15;
    }

    .treemap-tile.is-small span,
    .treemap-tile.is-tiny span {
      display: none;
    }

    .treemap-tile.is-tiny strong {
      font-size: 10px;
    }

    .donut {
      width: min(430px, 100%);
      aspect-ratio: 1;
      border-radius: 50%;
      background: conic-gradient(var(--green) 0deg, var(--green) 120deg, var(--blue) 120deg, var(--blue) 220deg, var(--amber) 220deg, var(--amber) 290deg, var(--violet) 290deg);
      position: relative;
      box-shadow: inset 0 0 0 1px var(--line);
      overflow: visible;
    }

    .donut::after {
      content: "";
      position: absolute;
      inset: 32%;
      border-radius: 50%;
      background: var(--panel);
      border: 1px solid var(--line);
    }

    .donut-labels {
      position: absolute;
      inset: 0;
      z-index: 2;
      pointer-events: none;
    }

    .donut-label {
      position: absolute;
      left: var(--x);
      top: var(--y);
      transform: translate(-50%, -50%);
      max-width: 104px;
      text-align: center;
      z-index: 1;
      font-size: 11px;
      line-height: 1.2;
      color: var(--text);
      text-shadow: 0 1px 7px rgba(0, 0, 0, .55);
    }

    .donut-label.outside {
      display: none;
    }

    .donut-label.outside.left {
      text-align: right;
      transform: translate(-100%, -50%);
    }

    .donut-label.outside.right {
      text-align: left;
      transform: translate(0, -50%);
    }

    .donut-leaders {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      z-index: 1;
      overflow: visible;
    }

    .donut-leaders polyline {
      stroke: color-mix(in srgb, var(--muted) 55%, transparent);
      stroke-width: 1;
      fill: none;
    }

    .donut-label strong {
      display: block;
      font-size: 12px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .donut-label span {
      display: block;
      color: rgba(238, 245, 238, .86);
    }

    .legend {
      display: grid;
      gap: 8px;
      min-width: 0;
      width: 100%;
      max-height: 370px;
      overflow: auto;
      padding-right: 4px;
    }

    .legend-row {
      display: grid;
      grid-template-columns: 12px minmax(0, 1fr) auto;
      align-items: center;
      gap: 10px;
      color: var(--soft);
      font-size: 12px;
      padding: 8px 10px;
      border: 1px solid var(--line);
      background: var(--panel-2);
      border-radius: 8px;
    }

    .legend-row strong {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-weight: 650;
      min-width: 0;
    }

    .legend-row span:last-child {
      color: var(--muted);
      white-space: nowrap;
    }

    .swatch {
      width: 10px;
      height: 10px;
      border-radius: 2px;
    }

    form {
      padding: 16px;
      display: grid;
      gap: 18px;
    }

    .entry-panel {
      margin-top: 18px;
      order: 30;
    }

    .quick-trade-panel {
      display: flex;
      justify-content: flex-start;
      gap: 10px;
      margin-bottom: 14px;
      order: 10;
    }

    .quick-trade-btn {
      min-height: 40px;
      font-size: 14px;
      padding: 0 28px;
    }

    /* One accent color for actions; green/red stay reserved for P&L numbers.
       Buy is the solid primary action, Sell a quiet outline. */
    .quick-trade-btn.buy-action {
      background: var(--focus);
      border-color: var(--focus);
      color: #ffffff;
    }

    .quick-trade-btn.sell-action {
      background: var(--panel-2);
      border: 1px solid var(--line);
      color: var(--red);
    }

    .transaction-dialog-panel {
      width: min(960px, calc(100vw - 28px));
      max-height: calc(100vh - 28px);
      margin: 0;
      overflow: auto;
      overflow-x: hidden;
    }

    .entry-panel form {
      grid-template-columns: 1.05fr 1fr;
      align-items: start;
    }

    .form-section {
      display: grid;
      gap: 12px;
      padding-top: 2px;
    }

    .mode-switch {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
      padding: 4px;
      border: 1px solid var(--line);
      border-radius: 999px;
      background: var(--panel-2);
    }

    .mode-btn {
      min-height: 40px;
      border-radius: 999px;
      border: 1px solid transparent;
      color: var(--muted);
      background: transparent;
      font-weight: 760;
    }

    .mode-btn.active {
      color: #ffffff;
      background: var(--focus);
      border-color: var(--focus);
    }

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

    .form-section.notes-section {
      grid-column: 1 / -1;
      padding-top: 16px;
      border-top: 1px solid var(--line);
    }

    .section-label {
      display: flex;
      align-items: center;
      gap: 8px;
      color: var(--soft);
      font-size: 12px;
      font-weight: 760;
      text-transform: uppercase;
      letter-spacing: .04em;
    }

    .section-label::before {
      content: "";
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: var(--focus);
    }

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

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

    label {
      display: grid;
      gap: 7px;
      color: var(--muted);
      font-size: 12px;
    }

    .combo-field {
      position: relative;
    }

    .suggestions {
      position: absolute;
      left: 0;
      right: 0;
      top: calc(100% + 6px);
      z-index: 10;
      max-height: 280px;
      overflow: auto;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      box-shadow: var(--shadow);
      display: none;
    }

    .suggestions.show {
      display: grid;
    }

    .suggestion-btn {
      width: 100%;
      min-height: 58px;
      padding: 10px 12px;
      border-bottom: 1px solid var(--line);
      background: transparent;
      color: var(--text);
      text-align: left;
      display: grid;
      gap: 4px;
    }

    .suggestion-btn:hover {
      background: var(--panel-2);
    }

    .suggestion-main {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      font-size: 13px;
      font-weight: 700;
    }

    .suggestion-meta {
      color: var(--muted);
      font-size: 12px;
      line-height: 1.35;
    }

    input, select, textarea {
      width: 100%;
      border: 1px solid var(--line);
      background: var(--panel-2);
      color: var(--text);
      border-radius: 8px;
      min-height: 42px;
      padding: 10px 11px;
      outline: none;
    }

    select option {
      background: var(--panel);
      color: var(--text);
    }

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

    input:focus, select:focus, textarea:focus {
      border-color: var(--focus);
      box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent);
    }

    .checkline {
      min-height: 42px;
      padding: 10px 11px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel-2);
      display: flex;
      align-items: center;
      gap: 9px;
      color: var(--soft);
      font-size: 13px;
    }

    .checkline-label {
      display: flex;
      align-items: center;
      gap: 9px;
      flex: 1 1 auto;
      min-width: 0;
    }

    .checkline input {
      width: auto;
      min-height: auto;
      padding: 0;
    }

    .help-dot {
      width: 22px;
      height: 22px;
      min-height: 0;
      padding: 0;
      border-radius: 50%;
      border: 1px solid var(--line);
      background: var(--panel);
      color: var(--muted);
      display: inline-grid;
      place-items: center;
      font-size: 12px;
      font-weight: 800;
      flex: 0 0 auto;
    }

    .inline-help {
      position: relative;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 22px;
      height: 22px;
      min-width: 22px;
      border: 1px solid var(--line);
      border-radius: 50%;
      background: var(--panel-2);
      color: var(--soft);
      font-size: 12px;
      font-weight: 850;
      line-height: 1;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .025);
    }

    .inline-help .help-dot {
      width: 100%;
      height: 100%;
      border: 0;
      background: transparent;
      color: inherit;
      font: inherit;
      display: grid;
      place-items: center;
    }

    .inline-tooltip {
      position: absolute;
      left: 50%;
      bottom: calc(100% + 8px);
      z-index: 120;
      width: min(280px, calc(100vw - 48px));
      padding: 10px 12px;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: var(--panel);
      color: var(--text);
      box-shadow: var(--shadow);
      font-size: 12px;
      line-height: 1.45;
      font-weight: 560;
      text-transform: none;
      letter-spacing: 0;
      opacity: 0;
      pointer-events: none;
      transform: translate(-50%, 4px);
      transition: opacity .16s ease, transform .16s ease;
    }

    .inline-tooltip::after {
      content: "";
      position: absolute;
      left: 50%;
      top: 100%;
      transform: translateX(-50%);
      border: 7px solid transparent;
      border-top-color: var(--panel);
    }

    .inline-help.align-left .inline-tooltip {
      left: 0;
      transform: translate(0, 4px);
    }

    .inline-help.align-left .inline-tooltip::after {
      left: 11px;
      transform: none;
    }

    .inline-help.align-right .inline-tooltip {
      left: auto;
      right: 0;
      transform: translate(0, 4px);
    }

    .inline-help.align-right .inline-tooltip::after {
      left: auto;
      right: 11px;
      transform: none;
    }

    .inline-help:hover .inline-tooltip,
    .inline-help:focus-within .inline-tooltip {
      opacity: 1;
      pointer-events: auto;
      transform: translate(-50%, 0);
    }

    .inline-help.align-left:hover .inline-tooltip,
    .inline-help.align-left:focus-within .inline-tooltip,
    .inline-help.align-right:hover .inline-tooltip,
    .inline-help.align-right:focus-within .inline-tooltip {
      transform: translate(0, 0);
    }

    .detail-meta-line .inline-help .inline-tooltip {
      left: 0 !important;
      right: auto !important;
      transform: translate(0, 4px) !important;
    }

    .detail-meta-line .inline-help .inline-tooltip::after {
      left: 11px !important;
      right: auto !important;
      transform: none !important;
    }

    .detail-meta-line .inline-help:hover .inline-tooltip,
    .detail-meta-line .inline-help:focus-within .inline-tooltip {
      transform: translate(0, 0) !important;
    }

    @media (max-width: 760px) {
      .detail-meta-line .inline-help .inline-tooltip {
        left: auto !important;
        right: 0 !important;
        width: min(280px, calc(100vw - 48px));
        transform: translate(0, 4px) !important;
      }

      .detail-meta-line .inline-help .inline-tooltip::after {
        left: auto !important;
        right: 11px !important;
        transform: none !important;
      }

      .detail-meta-line .inline-help:hover .inline-tooltip,
      .detail-meta-line .inline-help:focus-within .inline-tooltip {
        transform: translate(0, 0) !important;
      }
    }

    .form-actions {
      display: flex;
      gap: 10px;
      justify-content: flex-end;
      flex-wrap: wrap;
      grid-column: 1 / -1;
    }

    .advanced-fields {
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 10px 12px 12px;
      background: var(--panel-2);
    }

    .advanced-fields summary {
      cursor: pointer;
      color: var(--muted);
      font-size: 12px;
      font-weight: 760;
      list-style-position: inside;
    }

    .advanced-fields .field-grid {
      margin-top: 12px;
    }

    .table-panel {
      margin-top: 14px;
      order: 40;
    }

    .grid-2 {
      order: 20;
    }

    .feature-chart {
      order: 10;
    }

    .quick-trade-panel {
      order: 30;
    }

    .holding-cash-strip {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 12px 16px;
      border-bottom: 1px solid var(--line);
      background: var(--panel-2);
    }

    .holding-cash-main {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
    }

    .holding-cash-main strong {
      display: block;
      font-size: 13px;
      color: var(--text);
    }

    .cash-transaction-wrap {
      border-bottom: 1px solid var(--line);
    }

    .closed-history-panel {
      order: 50;
    }

    .transaction-log-panel {
      order: 60;
    }

    .collapsible-panel .panel-head {
      border-bottom: 1px solid var(--line);
    }

    .collapse-toggle {
      min-width: 86px;
    }

    .collapsible-panel.is-collapsed .collapsible-content {
      display: none;
    }

    .collapsible-panel.is-collapsed .panel-head {
      border-bottom: 0;
    }

    .collapsible-content.is-collapsed {
      display: none;
    }

    .table-wrap {
      overflow: auto;
      max-width: 100%;
      min-width: 0;
    }

    .holdings-table-wrap {
      overflow-x: auto;
    }

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

    .holdings-table {
      min-width: 1180px;
    }

    th, td {
      padding: 12px 14px;
      text-align: left;
      border-bottom: 1px solid var(--line);
      font-size: 13px;
      white-space: nowrap;
    }

    th {
      color: var(--muted);
      font-weight: 650;
      background: var(--panel-2);
      position: sticky;
      top: 0;
      z-index: 1;
    }

    .sort-th {
      border: 0;
      background: transparent;
      color: inherit;
      padding: 0;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font: inherit;
      cursor: pointer;
    }

    .sort-th:hover {
      color: var(--text);
    }

    .sort-th span {
      color: var(--green);
      font-size: 12px;
      min-width: 10px;
    }

    td {
      color: var(--soft);
    }

    td:nth-child(n+4),
    th:nth-child(n+4) {
      text-align: right;
    }

    td:first-child,
    th:first-child,
    td:nth-child(2),
    th:nth-child(2),
    td:nth-child(3),
    th:nth-child(3) {
      text-align: left;
    }

    tr:hover td {
      background: color-mix(in srgb, var(--focus) 7%, transparent);
    }

    .asset-cell {
      display: grid;
      gap: 4px;
      color: var(--text);
      font-weight: 680;
      max-width: 190px;
      overflow: hidden;
    }

    .asset-badge {
      width: 34px;
      height: 34px;
      border-radius: 8px;
      display: grid;
      place-items: center;
      background: rgba(255, 255, 255, .07);
      color: var(--text);
      font-size: 13px;
      flex: 0 0 auto;
    }

    .asset-link {
      border: 0;
      background: transparent;
      padding: 0;
      color: var(--text);
      text-decoration: none;
      display: block;
      align-items: center;
      gap: 6px;
      max-width: 190px;
      overflow: hidden;
      white-space: nowrap;
      text-align: left;
    }

    .asset-link:hover {
      color: var(--green);
    }

    .asset-name-scroll {
      display: inline-block;
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      vertical-align: bottom;
    }

    .asset-symbol-line {
      color: var(--muted);
      font-size: 12px;
      font-weight: 560;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .asset-link:hover .asset-name-scroll {
      overflow: visible;
      text-overflow: clip;
      animation: reveal-name 4.5s linear infinite alternate;
    }

    .mobile-pnl-stack {
      display: none;
    }

    .mobile-holding-quantity {
      display: none;
    }

    .mobile-holdings-sort,
    .holdings-sort-popover {
      display: none;
    }

    @keyframes reveal-name {
      from { transform: translateX(0); }
      to { transform: translateX(min(0px, calc(190px - 100%))); }
    }

    .external-mark {
      color: var(--muted);
      font-size: 12px;
    }

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

    .detail-stat {
      border: 1px solid rgba(255, 255, 255, .08);
      background: rgba(255, 255, 255, .045);
      border-radius: 8px;
      padding: 10px;
      display: grid;
      gap: 5px;
    }

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

    .detail-stat strong {
      color: var(--text);
      font-size: 15px;
    }

    .detail-table {
      width: 100%;
      min-width: 0;
      border-collapse: collapse;
    }

    .detail-table-wrap {
      overflow: auto;
      max-width: 100%;
    }

    .detail-table th, .detail-table td {
      padding: 10px 8px;
      white-space: nowrap;
      font-size: 13px;
    }

    .trade-note-row td {
      padding-top: 0;
      color: var(--muted);
      font-size: 12px;
      border-bottom-color: rgba(255, 255, 255, .1);
    }

    .trade-note {
      display: inline-flex;
      gap: 6px;
      line-height: 1.5;
    }

    .detail-trade-list {
      display: none;
      gap: 10px;
    }

    .detail-trades-section {
      margin-top: 16px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel-2);
      overflow: hidden;
    }

    .detail-trades-section summary {
      min-height: 46px;
      padding: 12px 14px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      cursor: pointer;
      color: var(--text);
      font-weight: 760;
      list-style: none;
    }

    .detail-trades-section summary::-webkit-details-marker {
      display: none;
    }

    .detail-trades-section summary::after {
      content: var(--details-toggle-collapsed-label);
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
    }

    .detail-trades-section[open] summary {
      border-bottom: 1px solid var(--line);
    }

    .detail-trades-section[open] summary::after {
      content: var(--details-toggle-open-label);
    }

    .detail-trades-section .detail-table-wrap,
    .detail-trades-section .detail-trade-list {
      padding: 10px;
      background: var(--panel);
    }

    .detail-trade-card {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel-2);
      padding: 10px;
      display: grid;
      gap: 8px;
    }

    .detail-trade-card-head,
    .detail-trade-card-actions {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      flex-wrap: wrap;
    }

    .detail-trade-card-head strong {
      color: var(--text);
      font-size: 13px;
    }

    .detail-trade-card-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 7px 10px;
      font-size: 12px;
    }

    .detail-trade-card-grid span {
      display: block;
      color: var(--muted);
      margin-bottom: 2px;
    }

    .detail-chart-card {
      margin: 14px 0 16px;
      border: 1px solid rgba(255, 255, 255, .08);
      background: rgba(255, 255, 255, .035);
      border-radius: 8px;
      padding: 12px;
    }

    .dialog-body.html-content .detail-chart-card {
      margin-left: -6px;
      margin-right: -6px;
    }

    .detail-chart-head {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 12px;
      flex-wrap: wrap;
      color: var(--soft);
      font-size: 13px;
      margin-bottom: 8px;
    }

    .detail-chart-controls {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }

    .detail-history-action {
      display: flex;
      justify-content: flex-end;
      margin-top: 10px;
    }

    .detail-chart-controls .chart-range-group {
      flex: 1 1 auto;
      justify-content: flex-start;
    }

.chart-empty-state,
.chart-loading-state {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.chart-loading-state {
  gap: 10px;
  align-content: center;
}

.chart-loading-spinner {
  width: 26px;
  height: 26px;
  border: 2px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: chart-spin .8s linear infinite;
}

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

.detail-chart-card .asset-echart {
  min-height: 224px;
}

    .detail-chart-note {
      color: var(--muted);
      font-size: 12px;
      line-height: 1.4;
      margin-top: 8px;
    }

    @media (max-width: 700px) {
      .dialog-body.html-content {
        overflow-x: hidden;
      }

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

      .detail-stat {
        padding: 9px;
      }

      .detail-stat strong {
        font-size: 14px;
      }

      .detail-table-wrap {
        display: none;
      }

      .detail-trade-list {
        display: grid;
      }

.detail-chart-card .asset-echart {
  min-height: 300px;
}

      .dialog-body.html-content .detail-chart-card {
        margin-left: 0;
        margin-right: 0;
        padding-left: clamp(8px, 2.6vw, 12px);
        padding-right: clamp(8px, 2.6vw, 12px);
      }

      .detail-chart-controls {
        width: 100%;
        min-width: 0;
        gap: 6px;
      }

      .detail-chart-controls .chart-button-group {
        width: 100%;
        min-width: 0;
      }

      #assetHistoryRangeButtons {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
        overflow: visible;
      }
    }

    .pill {
      display: inline-flex;
      align-items: center;
      min-height: 26px;
      padding: 0 9px;
      border-radius: 999px;
      background: rgba(255, 255, 255, .07);
      color: var(--soft);
      font-size: 12px;
      text-decoration: none;
    }

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

    .calc-link {
      border: 0;
      border-bottom: 0;
      background: transparent;
      color: inherit;
      padding: 0;
      font: inherit;
      font-weight: 680;
      cursor: pointer;
      text-decoration: none;
    }

    /* The clickable-number underline appears on hover only; always-on
       underlines under the largest figures read as clutter. */
    .summary-grid .calc-link {
      border-bottom: 1.5px solid transparent;
      padding-bottom: 1px;
    }

    .summary-grid .calc-link:hover {
      border-bottom-color: currentColor;
    }

    .metric-calc {
      font-size: inherit;
      line-height: inherit;
      font-weight: inherit;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 100%;
      display: inline-block;
    }

    .metric-summary-link {
      font-size: inherit;
      line-height: inherit;
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      display: inline-block;
    }

    .metric-inline-calcs {
      display: flex;
      align-items: center;
      gap: 4px;
      min-width: 0;
      flex-wrap: wrap;
    }

    .metric-small-link {
      font-size: inherit;
      line-height: inherit;
      font-weight: inherit;
    }

    .calc-list {
      display: grid;
      gap: 10px;
      margin-top: 8px;
    }

    .calc-line {
      padding: 10px;
      border: 1px solid rgba(255, 255, 255, .08);
      border-radius: 8px;
      background: rgba(255, 255, 255, .04);
      line-height: 1.45;
    }

    .calc-line strong {
      display: block;
      color: var(--text);
      margin-bottom: 3px;
    }

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

    .report-summary-single {
      grid-template-columns: minmax(0, 1fr);
    }

    .report-metric {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel-2);
      padding: 9px 10px;
      display: grid;
      gap: 3px;
    }

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

    .report-metric strong {
      font-size: 16px;
      color: var(--text);
    }

    .report-section {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      margin-top: 8px;
      overflow: hidden;
    }

    .report-section summary {
      cursor: pointer;
      padding: 9px 11px;
      color: var(--text);
      font-weight: 760;
      display: flex;
      justify-content: space-between;
      gap: 12px;
      list-style-position: inside;
    }

    .report-section summary span {
      color: var(--muted);
      font-weight: 650;
    }

    .report-table-wrap {
      overflow: auto;
      border-top: 1px solid var(--line);
    }

    .report-table {
      width: 100%;
      min-width: 680px;
      border-collapse: collapse;
    }

    .report-table th, .report-table td {
      padding: 7px 9px;
      border-bottom: 1px solid var(--line);
      font-size: 12px;
      white-space: nowrap;
    }

    .report-table th {
      color: var(--muted);
      font-weight: 650;
      background: var(--panel-2);
    }

    .report-note {
      padding: 8px 11px;
      color: var(--muted);
      line-height: 1.4;
      font-size: 12px;
    }

    @media (max-width: 760px) {
      .report-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .report-summary-single {
        grid-template-columns: minmax(0, 1fr);
      }
    }

    .auth-backdrop {
      position: fixed;
      inset: 0;
      z-index: 1000;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 20px;
      background: color-mix(in srgb, var(--bg) 82%, rgba(0, 0, 0, .72));
    }

    .auth-backdrop.show {
      display: flex;
    }

    .auth-panel {
      width: min(420px, 100%);
      padding: 22px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      box-shadow: var(--shadow);
    }

    .auth-panel h2 {
      margin: 0 0 6px;
      font-size: 20px;
    }

    .history-progress-panel {
      width: min(460px, 100%);
      gap: 14px;
    }

    .history-progress-bar {
      height: 10px;
      overflow: hidden;
      border-radius: 999px;
      background: var(--panel-2);
      border: 1px solid var(--line);
    }

    .history-progress-bar span {
      display: block;
      height: 100%;
      width: var(--progress, 0%);
      border-radius: inherit;
      background: var(--green);
      transition: width .2s ease;
    }

    .history-progress-meta {
      display: grid;
      gap: 4px;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.45;
    }

    .auth-panel p {
      margin: 0 0 18px;
      color: var(--muted);
      font-size: 13px;
    }

    .auth-panel label {
      display: grid;
      gap: 6px;
      margin-top: 12px;
      color: var(--muted);
      font-size: 12px;
    }

    .auth-panel input {
      width: 100%;
    }

    .auth-panel [hidden] {
      display: none !important;
    }

    .password-field {
      position: relative;
      display: block;
    }

    .password-field input {
      width: 100%;
      padding-right: 42px;
    }

    .password-toggle {
      position: absolute;
      top: 50%;
      right: 6px;
      width: 32px;
      height: 32px;
      transform: translateY(-50%);
      display: grid;
      place-items: center;
      border-radius: 6px;
      background: transparent;
      color: var(--muted);
    }

    .password-toggle:hover {
      background: rgba(255, 255, 255, .07);
      color: var(--text);
    }

    .password-toggle .eye {
      display: none;
    }

    .password-toggle.password-visible .eye {
      display: block;
    }

    .password-toggle.password-visible .eye-off {
      display: none;
    }

    .auth-actions {
      display: flex;
      gap: 8px;
      margin-top: 18px;
    }

    .auth-secondary {
      display: flex;
      justify-content: flex-end;
      margin-top: 8px;
    }

    .auth-link {
      padding: 0;
      background: transparent;
      color: var(--blue);
      font-size: 12px;
      text-decoration: underline;
      text-underline-offset: 3px;
    }

    .auth-link:hover {
      color: var(--text);
    }

    .auth-signup-prompt {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 12px;
      margin-top: 12px;
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel-2);
      color: var(--muted);
      font-size: 13px;
    }

    .auth-create-account-btn {
      min-height: 36px;
      padding: 0 14px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      color: var(--blue);
      font-size: 13px;
      font-weight: 720;
      white-space: nowrap;
    }

    .auth-create-account-btn:hover {
      border-color: color-mix(in srgb, var(--blue) 44%, var(--line));
      color: var(--text);
    }

    .auth-status {
      min-height: 18px;
      margin-top: 12px;
      color: var(--amber);
      font-size: 12px;
      white-space: pre-wrap;
    }

    .account-backdrop {
      position: fixed;
      inset: 0;
      z-index: 900;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 20px;
      background: color-mix(in srgb, var(--bg) 78%, rgba(0, 0, 0, .62));
    }

    .account-backdrop.show {
      display: flex;
    }

    .account-dialog {
      width: min(760px, 100%);
      max-height: calc(100vh - 40px);
      overflow: auto;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      box-shadow: var(--shadow);
    }

    .account-dialog-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 16px 18px;
      border-bottom: 1px solid var(--line);
    }

    .account-dialog-head h2 {
      margin: 0;
      font-size: 18px;
    }

    .account-dialog-body {
      display: grid;
      gap: 18px;
      padding: 18px;
    }

    .row-actions {
      display: flex;
      gap: 7px;
    }

    .mini-btn {
      width: 32px;
      height: 32px;
      border-radius: 8px;
      display: grid;
      place-items: center;
      background: rgba(255, 255, 255, .06);
      color: var(--soft);
      border: 1px solid rgba(255, 255, 255, .08);
    }

    .mini-btn:hover {
      background: rgba(255, 255, 255, .1);
    }

    .detail-meta-block {
      display: grid;
      gap: 4px;
      margin-top: 14px;
    }

    .detail-meta-line {
      display: flex;
      align-items: center;
      gap: 8px;
      min-height: 28px;
    }

    .detail-tag-edit-btn {
      width: 24px;
      height: 24px;
      border-radius: 6px;
      flex: 0 0 auto;
    }

    .detail-inline-editor {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 8px;
      align-items: center;
      max-width: 460px;
      margin-top: 2px;
    }

    .detail-inline-editor[hidden] {
      display: none;
    }

    .empty {
      padding: 44px 18px;
      text-align: center;
      color: var(--muted);
    }

    .importer {
      display: none;
    }

    .excel-drop-zone {
      min-height: 156px;
      border: 1px dashed var(--line);
      border-radius: 8px;
      background: var(--panel-2);
      color: var(--muted);
      display: grid;
      place-items: center;
      text-align: center;
      padding: 18px;
      transition: border-color .16s ease, color .16s ease, background .16s ease;
    }

    .excel-drop-zone strong {
      display: block;
      color: var(--soft);
      margin-bottom: 6px;
    }

    .excel-drop-zone.dragging,
    .excel-drop-zone:hover,
    .excel-drop-zone:focus-visible {
      border-color: var(--focus);
      color: var(--text);
      outline: none;
    }

    .portfolio-chart-legend {
      display: flex;
      align-items: center;
      gap: 14px;
      flex-wrap: wrap;
      margin-top: 10px;
      color: var(--muted);
      font-size: 12px;
    }

    .asset-chart-legend {
      margin-top: 8px;
    }

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

    .chart-key::before {
      content: "";
      width: 18px;
      height: 3px;
      border-radius: 999px;
      background: var(--green);
    }

    .chart-key.price::before {
      background: var(--green);
    }

    .chart-key.cost::before {
      background: var(--blue);
    }

    .chart-key.gain::before {
      background: var(--blue);
    }

    .chart-key.return::before {
      background: var(--violet);
    }

    .chart-key.buy::before {
      width: 9px;
      height: 9px;
      background: var(--blue);
    }

    .chart-key.sell::before {
      width: 0;
      height: 0;
      border-radius: 0;
      background: transparent;
      border-left: 5px solid transparent;
      border-right: 5px solid transparent;
      border-bottom: 9px solid var(--red);
    }

    .chart-tooltip {
      position: fixed;
      display: none;
      z-index: 45;
      min-width: 178px;
      max-width: 260px;
      padding: 10px 11px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      color: var(--soft);
      box-shadow: var(--shadow);
      pointer-events: none;
      font-size: 12px;
      line-height: 1.45;
    }

    .chart-tooltip strong {
      color: var(--text);
      display: block;
      font-size: 13px;
      margin-bottom: 4px;
    }

    .import-review-backdrop {
      position: fixed;
      inset: 0;
      z-index: 60;
      display: grid;
      place-items: center;
      padding: 18px;
      background: rgba(0, 0, 0, .38);
    }

    .import-review {
      width: min(980px, calc(100vw - 28px));
      max-height: calc(100vh - 28px);
      overflow: auto;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      color: var(--text);
      box-shadow: var(--shadow);
    }

    .import-review-head {
      padding: 14px 16px;
      border-bottom: 1px solid var(--line);
      display: flex;
      justify-content: space-between;
      gap: 12px;
      align-items: center;
    }

    .import-review-head h3 {
      margin: 0;
      font-size: 15px;
    }

    .import-review-body {
      padding: 16px;
      display: grid;
      grid-template-columns: minmax(260px, .85fr) minmax(320px, 1.15fr);
      gap: 16px;
    }

    .import-review-panel {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel-2);
      padding: 12px;
      min-width: 0;
    }

    .import-review-panel h4 {
      margin: 0 0 10px;
      font-size: 13px;
      color: var(--muted);
    }

    .import-trade-list {
      display: grid;
      gap: 7px;
      max-height: 340px;
      overflow: auto;
    }

    .import-trade-row, .import-candidate {
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 9px 10px;
      background: var(--panel);
    }

    .import-trade-row strong, .import-candidate strong {
      display: block;
      color: var(--text);
      font-size: 13px;
      margin-bottom: 4px;
    }

    .import-trade-row span, .import-candidate span {
      display: block;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.45;
    }

    .import-candidates {
      display: grid;
      gap: 8px;
      max-height: 430px;
      overflow: auto;
    }

    .import-candidate {
      width: 100%;
      text-align: left;
      color: var(--soft);
      cursor: pointer;
    }

    .import-candidate:hover {
      border-color: rgba(87, 214, 141, .45);
      background: rgba(87, 214, 141, .08);
    }

    .import-review-actions {
      padding: 12px 16px;
      border-top: 1px solid rgba(255, 255, 255, .09);
      display: flex;
      justify-content: flex-end;
      gap: 10px;
    }

    @media (max-width: 760px) {
      .import-review-body {
        grid-template-columns: 1fr;
      }
    }

    .toast {
      position: fixed;
      left: 50%;
      bottom: 22px;
      transform: translateX(-50%) translateY(20px);
      background: #eef5ee;
      color: #0f1411;
      border-radius: 8px;
      padding: 10px 13px;
      font-size: 13px;
      opacity: 0;
      pointer-events: none;
      transition: opacity .18s ease, transform .18s ease;
      box-shadow: var(--shadow);
      z-index: 1000;
    }

    .toast.show {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }

    .reconciliation-toast {
      background: rgba(238, 245, 238, .94);
      backdrop-filter: blur(14px);
      -webkit-backdrop-filter: blur(14px);
    }

    .modal-backdrop {
      position: fixed;
      inset: 0;
      display: none;
      place-items: center;
      padding: 18px;
      background: rgba(4, 8, 6, .62);
      z-index: 30;
      overscroll-behavior: contain;
    }

    .modal-backdrop.show {
      display: grid;
    }

    .dialog {
      --dialog-scale: 1;
      width: min(880px, calc(100vw - 36px));
      height: auto;
      min-width: min(420px, calc(100vw - 36px));
      min-height: min(320px, calc(100vh - 36px));
      max-width: calc(100vw - 36px);
      max-height: calc(100vh - 36px);
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      box-shadow: var(--shadow);
      overflow: hidden;
      overscroll-behavior: contain;
      resize: both;
      display: grid;
      grid-template-rows: auto minmax(0, 1fr) auto;
      touch-action: pan-y;
    }

    .dialog-head {
      min-height: 56px;
      padding: 14px 16px;
      border-bottom: 1px solid var(--line);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .dialog-title {
      margin: 0;
      font-size: calc(15px * var(--dialog-scale));
    }

    .dialog-body {
      padding: 16px;
      color: var(--soft);
      font-size: calc(13px * var(--dialog-scale));
      line-height: 1.55;
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      overflow: auto;
      min-height: 0;
      max-height: calc(100vh - 148px);
      overscroll-behavior: contain;
      -webkit-overflow-scrolling: touch;
      touch-action: pan-y;
    }

    .dialog-body.html-content {
      white-space: normal;
    }

    .dialog-actions {
      padding: 0 16px 16px;
      display: flex;
      justify-content: flex-end;
    }

    svg.icon {
      width: 18px;
      height: 18px;
      stroke: currentColor;
      stroke-width: 2;
      fill: none;
      stroke-linecap: round;
      stroke-linejoin: round;
      flex: 0 0 auto;
    }

    @media (max-width: 1180px) {
      .layout, .grid-2, .market-settings {
        grid-template-columns: 1fr;
      }

      .entry-panel form {
        grid-template-columns: 1fr;
      }

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

    @media (min-width: 1500px) {
      .app {
        width: min(1760px, calc(100vw - 48px));
      }

      .holdings-table-wrap {
        overflow-x: visible;
      }
    }

    @media (max-width: 700px) {
      .app {
        width: min(100vw - 22px, 1480px);
        padding-top: 12px;
      }

      .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding-bottom: 14px;
      }

      .actions {
        width: 100%;
        justify-content: flex-start;
      }

      .summary-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: clamp(8px, 2.6vw, 12px);
      }

      .metric {
        min-height: clamp(112px, 29vw, 142px);
        padding: clamp(12px, 3.8vw, 18px);
      }

      .metric-body {
        grid-template-rows: auto minmax(17px, auto) minmax(17px, auto) minmax(17px, auto);
        gap: clamp(5px, 1.7vw, 8px);
      }

      .metric strong {
        font-size: clamp(17px, 5.2vw, 24px);
        overflow: visible;
        text-overflow: clip;
      }

      .metric-calc {
        max-width: none;
        overflow: visible;
        text-overflow: clip;
      }

      .metric small {
        font-size: clamp(10px, 2.9vw, 12px);
      }

      .quick-trade-panel {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      /* Icon-only header actions on small screens keep the toolbar on one row. */
      .actions .btn-label {
        display: none;
      }

      .actions .ghost-btn {
        padding: 0 10px;
      }

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

      .market-settings.compact-toolbar {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
        padding: 8px;
      }

      .market-settings.compact-toolbar .provider-badge {
        min-height: 34px;
        font-size: 12px;
        gap: 7px;
        white-space: nowrap;
        overflow: hidden;
      }

      .market-settings.compact-toolbar .provider-badge .icon {
        width: 15px;
        height: 15px;
      }

      #refreshPricesBtn {
        min-height: 34px;
        padding: 0 10px;
        font-size: 12px;
        flex: 0 0 auto;
      }

      #refreshPricesBtn .icon {
        width: 15px;
        height: 15px;
      }

      .market-settings.compact-toolbar .settings-status {
        display: none;
      }

      #managePortfolioBtn {
        min-height: 34px;
        padding: 0 10px;
        font-size: 12px;
        flex: 0 0 auto;
      }

      .portfolio-head {
        flex-wrap: nowrap;
      }

      .portfolio-head .section-label {
        min-width: 0;
      }

      .portfolio-manage-add {
        grid-template-columns: 1fr;
      }

      .full-span {
        grid-column: auto;
      }

      .donut-area {
        grid-template-columns: 1fr;
        justify-items: center;
      }

      .allocation-treemap {
        min-height: 360px;
      }

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

      .panel-head .chart-controls {
        width: 100%;
        min-width: 0;
        align-items: stretch;
        justify-content: flex-start;
        gap: 7px;
      }

      .panel-head .chart-controls > * {
        max-width: 100%;
        min-width: 0;
      }

      #portfolioChartViewButtons {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      #portfolioChartRangeButtons {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
        overflow: visible;
      }

      .chart-toggle-btn {
        width: 100%;
        min-width: 0;
        padding: 0 clamp(6px, 2.4vw, 10px);
        font-size: clamp(10px, 3vw, 12px);
      }

      #portfolioBenchmark,
      .benchmark-search {
        width: 100%;
      }

      .holdings-head {
        position: relative;
        align-items: center;
        flex-direction: row;
        justify-content: space-between;
        gap: 10px;
      }

      .holdings-head .panel-title {
        min-width: 0;
      }

      .mobile-holdings-sort {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        flex: 0 0 auto;
        min-height: 34px;
        padding: 0 10px;
        font-size: clamp(11px, 3.2vw, 13px);
        white-space: nowrap;
      }

      .mobile-holdings-sort .icon {
        width: 15px;
        height: 15px;
      }

      .holdings-sort-popover {
        position: absolute;
        top: calc(100% + 8px);
        right: 0;
        z-index: 20;
        width: min(260px, calc(100vw - 44px));
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: 16px;
        background: color-mix(in srgb, var(--panel) 88%, transparent);
        box-shadow: var(--shadow);
        backdrop-filter: blur(22px);
      }

      .holdings-sort-popover.show {
        display: grid;
        gap: 12px;
      }

      .sort-popover-section {
        display: grid;
        gap: 4px;
      }

      .sort-popover-section + .sort-popover-section {
        padding-top: 10px;
        border-top: 1px solid var(--line);
      }

      .sort-popover-label {
        color: var(--muted);
        font-size: 12px;
        font-weight: 750;
        padding: 0 8px 4px;
      }

      .sort-popover-section button {
        border: 0;
        background: transparent;
        color: var(--text);
        min-height: 38px;
        padding: 0 8px;
        display: grid;
        grid-template-columns: 18px 1fr;
        gap: 8px;
        align-items: center;
        text-align: left;
        font-size: 15px;
      }

      .sort-popover-section button span {
        color: var(--green);
        font-weight: 800;
      }

      .holding-cash-strip {
        align-items: flex-start;
        flex-direction: column;
      }

      .cash-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: clamp(4px, 1.5vw, 6px);
      }

      .cash-actions .ghost-btn {
        width: 100%;
        flex: 0 1 auto;
        min-width: 0;
        padding: 0 2px;
        font-size: clamp(9px, 2.55vw, 11px);
      }

      .dialog {
        width: calc(100vw - 20px);
        height: calc(100vh - 20px);
        min-width: 0;
        min-height: 0;
        resize: none;
      }

      .primary-btn, .ghost-btn {
        flex: 1 1 auto;
      }

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

      .cash-metrics {
        grid-template-columns: 1fr;
      }

      .transaction-dialog-panel {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
      }

      .transaction-dialog-panel > .panel-head {
        align-items: center;
        flex-direction: row;
        justify-content: space-between;
      }

      .transaction-dialog-panel form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px 10px;
        min-width: 0;
      }

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

      .transaction-dialog-panel .full-span,
      .transaction-dialog-panel .combo-field,
      .transaction-dialog-panel .sell-only,
      .transaction-dialog-panel .date-field,
      .transaction-dialog-panel .notes-section,
      .transaction-dialog-panel .form-actions {
        grid-column: 1 / -1;
      }

      .transaction-dialog-panel .buy-only .current-price-field,
      .transaction-dialog-panel .buy-only .currency-field,
      .transaction-dialog-panel .buy-only .tags-field,
      .transaction-dialog-panel .fee-field {
        grid-column: 1 / -1;
      }

      .transaction-dialog-panel form.sell-mode .transaction-info-section {
        grid-column: 1 / -1;
      }

      .transaction-dialog-panel form.sell-mode .transaction-info-section .field-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-items: stretch;
        align-items: start;
        width: 100%;
      }

      .transaction-dialog-panel form.sell-mode .date-field {
        grid-column: 1 / 2;
      }

      .transaction-dialog-panel form.sell-mode .quantity-field {
        grid-column: 2 / 3;
      }

      .transaction-dialog-panel form.sell-mode .trade-price-field {
        grid-column: 1 / 2;
      }

      .transaction-dialog-panel form.sell-mode .fee-field {
        grid-column: 2 / 3;
      }

      .transaction-dialog-panel label,
      .transaction-dialog-panel .section-label {
        font-size: 11px;
      }

      .transaction-dialog-panel input,
      .transaction-dialog-panel select,
      .transaction-dialog-panel textarea {
        min-height: 38px;
        padding: 8px 9px;
      }

      .transaction-dialog-panel .checkline {
        height: 38px;
        min-height: 38px;
        padding: 8px 9px;
        font-size: 11px;
      }

      .transaction-dialog-panel .inline-tooltip {
        left: 0;
        right: auto;
        width: min(260px, calc(100vw - 44px));
        transform: translate(0, 4px);
      }

      .transaction-dialog-panel .inline-tooltip::after {
        left: 11px;
        right: auto;
        transform: none;
      }

      .transaction-dialog-panel .inline-help:hover .inline-tooltip,
      .transaction-dialog-panel .inline-help:focus-within .inline-tooltip {
        transform: translate(0, 0);
      }

      .transaction-dialog-panel textarea {
        min-height: 58px;
      }

      input, select, textarea {
        font-size: 16px !important;
      }

      .holdings-table-wrap,
      .cash-transaction-wrap,
      .closed-table-wrap,
      .transaction-log-table-wrap {
        overflow: visible;
      }

      .holdings-table,
      .cash-transaction-wrap table,
      .closed-table,
      .transaction-log-table {
        min-width: 0;
        display: block;
      }

      .holdings-table thead,
      .cash-transaction-wrap thead,
      .closed-table thead,
      .transaction-log-table thead {
        display: none;
      }

      .holdings-table tbody,
      .cash-transaction-wrap tbody,
      .closed-table tbody,
      .transaction-log-table tbody {
        display: grid;
        gap: 10px;
      }

      .holdings-table tr,
      .cash-transaction-wrap tr,
      .closed-table tr,
      .transaction-log-table tr {
        display: grid;
        gap: 8px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--panel-2);
      }

      .holdings-table tr:hover td,
      .cash-transaction-wrap tr:hover td,
      .closed-table tr:hover td,
      .transaction-log-table tr:hover td {
        background: transparent;
      }

      .holdings-table td,
      .cash-transaction-wrap td,
      .closed-table td,
      .transaction-log-table td {
        border-bottom: 0;
        padding: 0;
        white-space: normal;
        min-width: 0;
      }

      .holdings-table td::before,
      .cash-transaction-wrap td::before,
      .closed-table td::before,
      .transaction-log-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        font-weight: 650;
      }

      .holdings-table td,
      .cash-transaction-wrap td,
      .closed-table td,
      .transaction-log-table td {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 10px;
        text-align: right;
        font-size: 12px;
      }

      .holdings-table td[data-label-key="asset"],
      .cash-transaction-wrap td[data-label-key="notes"],
      .closed-table td[data-label-key="asset"],
      .transaction-log-table td[data-label-key="asset"],
      .transaction-log-table td[data-label-key="notes"] {
        display: grid;
        gap: 5px;
        text-align: left;
      }

      .holdings-table td[data-label-key="asset"]::before,
      .closed-table td[data-label-key="asset"]::before,
      .transaction-log-table td[data-label-key="asset"]::before {
        display: none;
      }

      .holdings-table tr {
        grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
        align-items: start;
      }

      .holdings-table td[data-label-key="asset"] {
        grid-column: 1 / 2;
        grid-row: 1;
      }

      .holdings-table .asset-cell,
      .holdings-table .asset-link {
        max-width: 100%;
      }

      .mobile-holding-quantity {
        display: block;
        color: var(--muted);
        font-size: 11px;
        font-weight: 650;
      }

      .mobile-holding-quantity .calc-link {
        color: var(--soft);
        font-size: 11px;
      }

      .holdings-table td[data-label-key="averageCost"],
      .holdings-table td[data-label-key="currentPrice"],
      .holdings-table td[data-label-key="value"],
      .holdings-table td[data-label-key="cost"] {
        display: grid;
        grid-template-columns: auto minmax(72px, 1fr);
        align-items: baseline;
        column-gap: 4px;
        justify-content: stretch;
        text-align: left;
        font-size: 11px;
      }

      .holdings-table td[data-label-key="averageCost"] .calc-link,
      .holdings-table td[data-label-key="currentPrice"] .calc-link,
      .holdings-table td[data-label-key="value"] .calc-link,
      .holdings-table td[data-label-key="cost"] .calc-link {
        justify-self: end;
        text-align: right;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: clamp(9px, 2.65vw, 11px);
      }

      .holdings-table td[data-label-key="quantity"],
      .holdings-table td[data-label-key="unrealizedGain"],
      .holdings-table td[data-label-key="realizedGain"],
      .holdings-table td[data-label-key="returnRate"] {
        display: none;
      }

      .holdings-table .desktop-value {
        display: none;
      }

      .holdings-table .mobile-pnl-cell {
        grid-column: 2 / 3;
        grid-row: 1;
        display: block;
        text-align: left;
        min-width: 0;
      }

      .holdings-table .mobile-pnl-cell::before {
        display: none;
      }

      .mobile-pnl-stack {
        display: grid;
        justify-items: start;
        gap: 3px;
        min-width: 0;
      }

      .mobile-pnl-head {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 7px;
        flex-wrap: wrap;
        width: 100%;
        max-width: 100%;
      }

      .mobile-pnl-total {
        font-size: clamp(13px, 4.2vw, 18px);
        font-weight: 800;
        white-space: nowrap;
      }

      .mobile-pnl-rate {
        font-size: 11px;
        font-weight: 750;
      }

      .mobile-pnl-line {
        font-size: clamp(9px, 2.7vw, 11px);
        font-weight: 650;
        text-align: left;
        white-space: nowrap;
      }

      .cash-transaction-wrap tr {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .cash-transaction-wrap td[data-label-key="notes"] {
        grid-column: 1 / -1;
      }

      .holdings-table td[data-label-key="value"] {
        grid-column: 1 / 2;
        grid-row: 2;
      }

      .holdings-table td[data-label-key="cost"] {
        grid-column: 2 / 3;
        grid-row: 2;
      }

      .holdings-table td[data-label-key="currentPrice"] {
        grid-column: 1 / 2;
        grid-row: 3;
      }

      .holdings-table td[data-label-key="averageCost"] {
        grid-column: 2 / 3;
        grid-row: 3;
      }

      .closed-table tr,
      .transaction-log-table tr {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .closed-table td[data-label-key="asset"],
      .transaction-log-table td[data-label-key="asset"],
      .transaction-log-table td[data-label-key="notes"] {
        grid-column: 1 / -1;
      }

      .transaction-log-table .row-actions {
        justify-content: flex-start;
      }
    }

    @media (max-width: 390px) {
      .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
      }

      .metric {
        min-height: 96px;
        padding: 10px;
      }

      .metric strong {
        font-size: clamp(14px, 4.7vw, 19px);
      }

      .metric small {
        font-size: 10px;
      }

      #portfolioChartRangeButtons,
      #assetHistoryRangeButtons {
        grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
      }

      #assetHistoryRangeButtons .chart-toggle-btn[data-asset-history-range="holding"] {
        grid-column: span 2;
      }

      .chart-toggle-btn {
        min-height: 28px;
        font-size: 10px;
      }
    }
