.legacy-page {
    --legacy-border: var(--hd-line, #dfe3e8);
    --legacy-muted: var(--hd-subtle, #596572);
    --legacy-surface: #fff;
    --legacy-hover: #f2f6fa;
    --legacy-accent: var(--hd-link, #174e84);
    width: min(calc(100% - 40px), var(--hd-max, 1224px));
    margin: 0 auto;
    padding: 26px 0 8px;
    font: 14px/1.45 system-ui, "Malgun Gothic", sans-serif;
}

.legacy-page, .legacy-page * { box-sizing: border-box; }
.legacy-page [hidden] { display: none !important; }
.legacy-page button, .legacy-page input { font: inherit; }
.legacy-page :focus-visible { outline: 2px solid var(--legacy-accent); outline-offset: 2px; }
.legacy-hero { margin-bottom: 22px; }
.legacy-hero h1 { margin: 4px 0 7px; font-size: clamp(25px, 4vw, 34px); line-height: 1.2; letter-spacing: -.035em; }
.legacy-hero p { margin: 0; color: var(--legacy-muted); }
.legacy-page .legacy-kicker { color: var(--legacy-muted); font-size: .78rem; font-weight: 650; }
.legacy-panel { min-width: 0; border: 1px solid var(--legacy-border); border-radius: 5px; background: var(--legacy-surface); }
.legacy-source { margin: 13px 0 0; color: var(--legacy-muted); font-size: .8rem; line-height: 1.6; }
.legacy-page .legacy-field { display: grid; gap: 7px; color: #18222c; font-size: .85rem; font-weight: 650; }
.legacy-field input, .search-box input {
    width: 100%;
    height: 38px;
    padding: 7px 10px;
    color: #15202b;
    background: var(--legacy-surface);
    border: 1px solid #b8c0c8;
    border-radius: 4px;
    font-weight: 400;
}

.trend-layout { display: grid; grid-template-columns: minmax(250px, 305px) minmax(0, 1fr); gap: 16px; align-items: start; }
.stock-panel, .chart-panel { padding: 19px; }
.stock-count { margin: 12px 0 7px; color: var(--legacy-muted); font-size: .77rem; }
.stock-list { max-height: 460px; overflow: auto; }
.stock-item {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 9px 8px;
    border: 0;
    border-bottom: 1px solid var(--legacy-border);
    background: var(--legacy-surface);
    color: inherit;
    text-align: left;
    cursor: pointer;
}
.stock-item:hover, .stock-item.active { background: var(--legacy-hover); }
.stock-item.active { box-shadow: inset 3px 0 var(--legacy-accent); }
.stock-item span { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stock-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; }
.stock-item small { color: var(--legacy-muted); font-size: .72rem; }
.stock-item .stock-price { flex-shrink: 0; align-items: flex-end; font-variant-numeric: tabular-nums; }
.stock-price .up, .change-badge.up { color: var(--hd-up, #b42318); }
.stock-price .down, .change-badge.down { color: var(--hd-down, #174e9a); }
.chart-panel { min-height: 375px; }
.chart-empty { display: grid; min-height: 335px; place-items: center; color: var(--legacy-muted); text-align: center; }
.chart-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.chart-header h2 { margin: 3px 0 0; font-size: 1.6rem; }
.change-badge { padding: 6px 8px; border-radius: 4px; background: #f3f5f7; color: var(--legacy-muted); font-size: .79rem; font-weight: 700; white-space: nowrap; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 17px 0; }
.metrics div { border: 1px solid var(--legacy-border); border-radius: 4px; padding: 10px; background: #f8f9fb; }
.metrics span { display: block; margin-bottom: 4px; color: var(--legacy-muted); font-size: .75rem; }
.metrics strong { font-size: .98rem; font-variant-numeric: tabular-nums; }
.chart-wrap { overflow: hidden; border: 1px solid var(--legacy-border); border-radius: 4px; padding: 6px; }
#price-chart { display: block; width: 100%; height: auto; }
#price-chart .grid line { stroke: #e1e6eb; stroke-width: 1; }
#price-chart text { fill: #4e5d6a; font: 12px ui-monospace, monospace; text-anchor: end; }
#price-chart text.date { text-anchor: middle; }
#price-chart .area { fill: #e9f1f9; }
#price-chart .line { fill: none; stroke: #205d96; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
#price-chart .end { fill: #205d96; stroke: #fff; stroke-width: 2; }
.chart-range { margin-top: 9px; color: var(--legacy-muted); font-size: .76rem; text-align: right; }

.weekly-shell .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.weekly-hero { display: flex; justify-content: space-between; align-items: end; gap: 16px; }
.updated-box, .summary-grid > div { min-width: 0; border: 1px solid var(--legacy-border); border-radius: 4px; background: var(--legacy-surface); padding: 10px 12px; }
.updated-box { min-width: 145px; }
.updated-box span, .summary-grid span { display: block; margin-bottom: 4px; color: var(--legacy-muted); font-size: .75rem; }
.updated-box strong, .summary-grid strong { font-size: .92rem; font-variant-numeric: tabular-nums; }
.summary-grid { display: grid; grid-template-columns: 1fr 1.6fr 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.workbook .tabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--legacy-border); background: #f7f8fa; }
.workbook .tab { flex: 0 0 auto; padding: 12px 17px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #3c4854; font-size: .87rem; font-weight: 650; cursor: pointer; }
.workbook .tab:hover { background: #eef2f6; }
.workbook .tab.active { border-bottom-color: var(--legacy-accent); background: #fff; color: var(--legacy-accent); }
.workbook .toolbar { display: flex; justify-content: space-between; align-items: center; gap: 13px; padding: 12px; border-bottom: 1px solid var(--legacy-border); }
.search-box { width: min(330px, 100%); }
.toolbar-meta { display: flex; gap: 10px; align-items: center; color: var(--legacy-muted); font-size: .77rem; }
#unit-label { border-radius: 4px; background: #edf3f9; color: var(--legacy-accent); padding: 3px 6px; }
#unit-label:empty { display: none; }
.data-notice { margin: 9px 12px; border: 1px solid #ecd69d; border-radius: 4px; background: #fff7df; color: #694f1c; padding: 8px 10px; font-size: .8rem; }
.workbook .loading { display: grid; min-height: 180px; place-items: center; color: var(--legacy-muted); }
.sheet-wrap, .raw-table { overflow: auto; max-height: 650px; }
.data-sheet { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: .81rem; }
.data-sheet th, .data-sheet td { height: 36px; padding: 0 10px; border-right: 1px solid var(--legacy-border); border-bottom: 1px solid var(--legacy-border); white-space: nowrap; }
.data-sheet th { position: sticky; top: 0; z-index: 3; background: #edf1f5; color: #18222c; text-align: center; }
.data-sheet th:first-child, .data-sheet td:first-child { position: sticky; left: 0; z-index: 2; width: 100px; min-width: 100px; max-width: 100px; }
.data-sheet th:nth-child(2), .data-sheet td:nth-child(2) { position: sticky; left: 100px; z-index: 2; min-width: 148px; }
.data-sheet th:first-child, .data-sheet th:nth-child(2) { z-index: 4; }
.data-sheet tbody td { background: #fff; }
.data-sheet tbody tr:nth-child(even) td { background: #f8fafb; }
.data-sheet tbody tr:hover td { background: #eef4fa; }
.data-sheet td.number { text-align: right; font-variant-numeric: tabular-nums; }
.data-sheet .code { font-family: ui-monospace, monospace; color: #4e5d6a; }
.data-sheet .name { font-weight: 650; }
.workbook .pagination { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 10px; }
.workbook .pagination button { min-height: 33px; padding: 4px 10px; border: 1px solid #b8c0c8; border-radius: 4px; background: #fff; color: #243441; cursor: pointer; }
.workbook .pagination button:hover:not(:disabled) { background: var(--legacy-hover); }
.workbook .pagination button:disabled { color: #6f7a85; border-color: var(--legacy-border); cursor: default; }
.workbook .pagination span { min-width: 62px; color: var(--legacy-muted); font-size: .8rem; text-align: center; font-variant-numeric: tabular-nums; }
.raw-shell .card { border-color: var(--legacy-border); border-radius: 4px; }
.raw-shell .raw-table th { background: #edf1f5; }
.raw-shell .raw-table td { font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
    .legacy-page { padding-top: 21px; }
    .trend-layout { grid-template-columns: 1fr; }
    .stock-list { max-height: 230px; }
    .weekly-hero { align-items: start; flex-direction: column; }
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 500px) {
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .workbook .toolbar { align-items: stretch; flex-direction: column; }
    .search-box { width: 100%; }
    .data-sheet th:nth-child(2), .data-sheet td:nth-child(2) { left: auto; }
    .data-sheet td:nth-child(2) { position: static; }
    .data-sheet th:nth-child(2) { z-index: 3; }
}
