:root { color-scheme: light; }
body { font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
       margin: 0; padding: 24px; background: #fafafa; color: #1f2937; }
.container { max-width: 1200px; margin: 0 auto; background: #fff; border-radius: 12px; padding: 24px;
             box-shadow: 0 1px 3px rgba(0,0,0,.08); }
h1 { font-size: 1.6rem; margin: 0 0 4px; }
.header-row { display: flex; justify-content: space-between; align-items: center; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.tabs { display: flex; gap: 8px; border-bottom: 1px solid #e5e7eb; margin: 12px 0 16px; }
.tab-btn { padding: 8px 16px; font-size: .95rem; font-weight: 500; color: #6b7280; background: transparent;
           border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.tab-btn:hover { color: #1f2937; }
.tab-btn.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }
.tab-btn:focus-visible, .icon-btn:focus-visible, .dialog-close:focus-visible, #refresh-btn:focus-visible, .primary-btn:focus-visible {
  outline: 3px solid #bfdbfe; outline-offset: 2px;
}
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
            padding: 0; color: #2563eb; background: #fff; border: 1px solid #dbeafe;
            border-radius: 50%; cursor: pointer; }
.icon-btn:hover { background: #eff6ff; }
.info-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.refresh-ring { position: relative; width: 40px; height: 40px; margin-bottom: 4px; }
.refresh-ring svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #e5e7eb; stroke-width: 4; }
.ring-fg { fill: none; stroke: #2563eb; stroke-width: 4; stroke-linecap: round;
           stroke-dasharray: 106.8; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear; }
#ring-text { position: absolute; inset: 0; display: flex; align-items: center;
             justify-content: center; font-size: .7rem; color: #2563eb; font-weight: 600; }
.caption { color: #6b7280; font-size: .9rem; margin: 0 0 16px; }
.refresh-progress { color: #1d4ed8; background: #eff6ff; border: 1px solid #bfdbfe;
                   border-radius: 6px; padding: 8px 12px; font-size: .9rem; margin: -4px 0 16px; }
.loader { text-align: center; padding: 40px 0; }
.spinner { border: 4px solid #e5e7eb; border-top-color: #2563eb; border-radius: 50%;
           width: 40px; height: 40px; margin: 0 auto; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { color: #6b7280; font-size: .9rem; margin-top: 12px; }
.stale { color: #92400e; background: #fef3c7; border: 1px solid #fcd34d; border-radius: 6px;
         padding: 8px 12px; font-size: .9rem; margin: 0 0 12px; }
.error { color: #b91c1c; background: #fee2e2; border: 1px solid #fca5a5; border-radius: 6px;
         padding: 8px 12px; font-size: .9rem; margin: 0 0 12px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 8px 12px; border-bottom: 1px solid #e5e7eb; text-align: left; white-space: nowrap; }
th { background: #f3f4f6; font-weight: 600; }
.sort-button { display: inline-flex; align-items: center; gap: 6px; padding: 0; color: inherit;
               font: inherit; background: transparent; border: 0; cursor: pointer; }
.sort-button:hover { color: #2563eb; }
.sort-button:focus-visible { outline: 3px solid #bfdbfe; outline-offset: 2px; border-radius: 3px; }
.sort-indicator { color: #6b7280; font-size: .75rem; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: #f9fafb; }
tbody tr.selected td { background: #eff6ff; }
.up { color: #2ca02c; font-weight: bold; }
.down { color: #d62728; font-weight: bold; }
.val-high { color: #d62728; font-weight: bold; }
.val-low { color: #2ca02c; font-weight: bold; }
.muted { color: #9ca3af; font-size: .85rem; }
.loss-badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: .78rem;
              color: #b91c1c; background: #fee2e2; font-weight: 600; }
.etf-badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: .75rem;
             color: #4b5563; background: #f3f4f6; }
.pct-cell { display: inline-flex; align-items: center; gap: 8px; min-width: 148px; }
.pct-bar { position: relative; width: 84px; height: 8px; border-radius: 999px; background: #e5e7eb; overflow: hidden; }
.pct-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; }
.pct-low .pct-fill { background: #16a34a; }
.pct-mid .pct-fill { background: #2563eb; }
.pct-high .pct-fill { background: #dc2626; }
.pct-low .pct-text { color: #15803d; font-weight: 600; }
.pct-mid .pct-text { color: #1d4ed8; font-weight: 600; }
.pct-high .pct-text { color: #b91c1c; font-weight: 600; }
.detail-wrap { margin-top: 16px; }
.detail { border: 1px solid #e5e7eb; border-radius: 8px; padding: 14px 16px; background: #f9fafb; }
.detail h3 { margin: 0 0 10px; font-size: 1.05rem; }
.metrics { display: flex; flex-wrap: wrap; gap: 24px; margin-bottom: 10px; }
.metric-label { color: #6b7280; font-size: .75rem; }
.metric-value { font-size: 1.1rem; font-weight: 600; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
               gap: 6px 16px; font-size: .85rem; color: #374151; margin-top: 8px; }
.detail-item { padding: 2px 0; border-bottom: 1px dashed #e5e7eb; }
.pe-chart-wrap { margin-top: 12px; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; }
.pe-chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .78rem; color: #4b5563; margin-bottom: 8px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.pe-chart-svg { width: 100%; height: auto; display: block; }
.info-dialog { width: min(580px, calc(100% - 32px)); box-sizing: border-box; padding: 0;
               color: #1f2937; background: #fff; border: 1px solid #dbeafe; border-radius: 12px;
               box-shadow: 0 20px 50px rgba(15, 23, 42, .2); }
.info-dialog::backdrop { background: rgba(15, 23, 42, .38); }
.dialog-header { display: flex; align-items: center; justify-content: space-between;
                 padding: 16px 20px; border-bottom: 1px solid #e5e7eb; }
.dialog-header h2 { margin: 0; font-size: 1.15rem; }
.dialog-close { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
                padding: 0; color: #6b7280; background: transparent; border: 0; border-radius: 6px;
                font-size: 1.5rem; line-height: 1; cursor: pointer; }
.dialog-close:hover { color: #1f2937; background: #f3f4f6; }
.info-list { margin: 0; padding: 16px 24px 20px 42px; color: #374151; line-height: 1.65; }
.info-list li + li { margin-top: 10px; }
#actions, .panel-actions { margin-top: 16px; }
#refresh-btn, .primary-btn { background: #2563eb; color: #fff; border: none; border-radius: 6px;
                             padding: 8px 16px; font-size: .9rem; cursor: pointer; }
#refresh-btn:hover, .primary-btn:hover { background: #1d4ed8; }
#refresh-btn:disabled, .primary-btn:disabled { background: #9ca3af; cursor: default; }

@media (max-width: 600px) {
  body { padding: 12px; }
  .container { padding: 16px; }
  h1 { font-size: 1.3rem; }
  .info-dialog { width: calc(100% - 24px); }
  .dialog-header { padding: 14px 16px; }
  .info-list { padding: 14px 18px 18px 36px; font-size: .9rem; }
}
