:root {
  color-scheme: light dark;
  font-family: Inter, "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --canvas: light-dark(#f5f7fb, #111925);
  --panel: light-dark(#fff, #182333);
  --panel-soft: light-dark(#f8fafd, #1c2a3b);
  --ink: light-dark(#15233a, #ecf2fb);
  --muted: light-dark(#5e6d85, #aab8cc);
  --line: light-dark(#e1e8f2, #304158);
  --strong-line: light-dark(#cbd6e6, #4b5e77);
  --accent: light-dark(#275cc9, #9fc1ff);
  --blue: #275ed4;
  --hover-blue: #1c4eb7;
  --tint: light-dark(#eaf1ff, #223858);
  --green: light-dark(#147254, #80d1af);
  --green-bg: light-dark(#e8f6ef, #214139);
  --violet: light-dark(#6852b8, #c6afff);
  --violet-bg: light-dark(#f0edff, #373054);
  --amber: light-dark(#875414, #f5c980);
  --amber-bg: light-dark(#fff4dd, #463821);
  --red: light-dark(#b02536, #ffa5ad);
  --red-bg: light-dark(#fff0f1, #492a38);
  --down: light-dark(#285caf, #a1c4ff);
  --bar: light-dark(#a6bceb, #526f9f);
  --bar-selected: light-dark(#376de0, #76a0ff);
  --bar-fallback: light-dark(#b2bfce, #798b9d);
  --radius: 13px;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-size: 14px; line-height: 1.5; }
h1, h2, p, ul, ol { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; }
.icon-fill { fill: var(--panel); }

.skip-link { position: fixed; z-index: 5; top: 10px; left: 10px; padding: 11px 16px; background: var(--panel); transform: translateY(-160%); border-radius: 8px; }
.skip-link:focus { transform: none; }
.workspace {
  display: grid;
  grid-template: auto 1fr / 224px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}
.sidebar {
  grid-area: 1 / 1 / span 2;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 35px;
  overflow: auto;
  padding: 24px 16px 19px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.brand {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 23px;
  line-height: 1.07;
  font-weight: 760;
  letter-spacing: -.055em;
}
.sidebar .brand { margin-left: 9px; }
.brand-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--blue);
  color: #fff;
}
.brand-mark .icon { width: 23px; height: 23px; transform: translate(1px, -1px); stroke-width: 1.85; }
.brand-owner { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .035em; }
.side-nav { display: grid; gap: 20px; }
.side-nav ul { list-style: none; padding: 0; }
.side-nav a, .nav-label { display: flex; align-items: center; gap: 10px; }
.side-nav a {
  min-height: 42px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
}
.side-nav a:hover { color: var(--ink); background: var(--panel-soft); }
.nav-label { padding: 0 10px 5px; color: var(--ink); font-weight: 720; font-size: 13px; }
.nav-label .icon { width: 16px; height: 16px; color: var(--muted); }
.side-nav li a { padding-left: 23px; }
.side-nav a[aria-current="page"] { background: var(--tint); color: var(--accent); font-weight: 725; }
.nav-current { margin-left: auto; width: 14px; height: 14px; }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 15px 9px 3px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.topbar {
  grid-area: 1 / 2;
  min-height: 65px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 30px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.breadcrumbs { min-width: 0; }
.breadcrumbs ol { display: flex; list-style: none; padding: 0; flex-wrap: wrap; align-items: center; gap: 4px 9px; color: var(--muted); font-size: 13px; }
.breadcrumbs li { display: flex; align-items: center; gap: 9px; }
.breadcrumbs .icon { width: 13px; height: 13px; }
.breadcrumbs strong { color: var(--ink); font-weight: 720; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.button, .icon-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  gap: 7px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: var(--panel);
  font-weight: 700;
}
.button { padding: 6px 13px; }
.icon-button { min-width: 40px; padding: 0; }
.button:hover, .icon-button:hover { background: var(--panel-soft); border-color: var(--accent); }
.button .icon { width: 16px; height: 16px; }
.primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.primary:hover { background: var(--hover-blue); border-color: var(--hover-blue); }
.theme-toggle, .reveal-password, .menu-trigger, .menu-close { color: var(--muted); }
.show-in-dark { display: none; }
:root[data-theme="dark"] .show-in-dark { display: inline; }
:root[data-theme="dark"] .show-in-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .show-in-dark { display: inline; }
  :root[data-theme="system"] .show-in-light { display: none; }
}
.menu-trigger, .mobile-menu { display: none; }

.main { grid-area: 2 / 2; min-width: 0; padding: 28px 30px 35px; }
.main-inner { max-width: 1360px; margin-inline: auto; }
.page-heading {
  margin-bottom: 23px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
}
.page-heading h1 { font-size: clamp(27px, 3vw, 34px); line-height: 1.2; letter-spacing: -.055em; font-weight: 780; }
.page-heading p { margin-top: 7px; color: var(--muted); word-break: keep-all; }
.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 750; white-space: nowrap; }
.sample { margin-top: 5px; color: var(--amber); background: var(--amber-bg); }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 22px;
  padding: 13px 16px;
  margin-bottom: 17px;
}
.filter-market, .filter-date, .date-controls { display: flex; align-items: center; gap: 10px; min-width: 0; }
.control-label { flex: 0 0 auto; font-size: 13px; font-weight: 730; }
.date-controls select { min-height: 40px; padding: 5px 9px; border: 1px solid var(--strong-line); border-radius: 8px; background: var(--panel); color: var(--ink); font-weight: 630; }
.segmented {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  width: max-content;
  max-width: 100%;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
}
.segmented a { display: flex; align-items: center; justify-content: center; min-width: 46px; min-height: 32px; padding: 4px 10px; border-radius: 6px; white-space: nowrap; color: var(--muted); font-size: 12px; font-weight: 680; }
.segmented a:hover { color: var(--accent); }
.segmented a[aria-current="true"] { background: var(--tint); color: var(--accent); font-weight: 780; }
.fallback-note { display: flex; align-items: center; gap: 8px; margin: -4px 0 16px; padding: 10px 13px; border-radius: 8px; color: var(--amber); background: var(--amber-bg); }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin-bottom: 17px; }
.metric { display: flex; align-items: flex-start; gap: 13px; padding: 16px; }
.metric-icon, .feature-icon, .data-icon { display: grid; place-items: center; flex: 0 0 auto; width: 39px; height: 39px; border-radius: 10px; color: var(--accent); background: var(--tint); }
.metric-icon.pulse { background: var(--green-bg); color: var(--green); }
.metric-icon.chart { background: var(--violet-bg); color: var(--violet); }
.metric h2 { font-size: 13px; color: var(--muted); font-weight: 730; }
.metric-value { margin-block: 2px 1px; color: var(--ink); font-size: 25px; font-weight: 760; letter-spacing: -.032em; font-variant-numeric: tabular-nums; }
.metric-value span { margin-left: 4px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: normal; white-space: nowrap; }
.metric-note { color: var(--muted); font-size: 12px; }

.data-layout { display: grid; grid-template-columns: minmax(0, 2.05fr) minmax(260px, 1fr); gap: 17px; align-items: start; }
.section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; column-gap: 10px; row-gap: 8px; padding: 16px 17px 13px; }
.section-heading h2, .settings-panel h2 { font-size: 17px; line-height: 1.35; font-weight: 750; letter-spacing: -.034em; }
.section-heading p, .settings-panel p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.section-heading > .icon { color: var(--accent); }
.table-scroll { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
.table-scroll:focus-visible { outline-offset: -3px; }
table { border-collapse: collapse; width: 100%; min-width: 470px; font-variant-numeric: tabular-nums; }
thead { background: var(--panel-soft); color: var(--muted); }
th, td { padding: 8px 9px; text-align: left; white-space: nowrap; }
thead th { font-size: 12px; font-weight: 720; border-top: 1px solid var(--line); }
tbody tr { border-top: 1px solid var(--line); }
tbody tr:hover { background: var(--panel-soft); }
tbody th { font-weight: 650; }
.rank { width: 53px; padding-left: 15px; color: var(--muted); text-align: center; }
.company { display: block; color: var(--ink); font-size: 13px; }
.company-detail { display: block; margin-top: 1px; color: var(--muted); font-weight: 520; font-size: 11px; }
.company-detail span { padding-inline: 2px; }
.numeric { text-align: right; }
.amount { font-weight: 730; }
.positive { color: var(--red); font-weight: 690; }
.negative { color: var(--down); font-weight: 690; }
.candle { text-align: right; padding-right: 17px; }
.candle-label { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px; font-weight: 710; }
.rising { background: var(--red-bg); color: var(--red); }
.falling { background: var(--tint); color: var(--down); }
.empty-row { color: var(--muted); text-align: center; padding: 30px 10px; }

.trend-chart { display: block; width: calc(100% - 22px); margin: 7px 12px 1px 10px; overflow: visible; }
.trend-chart text { fill: var(--muted); font-size: 11px; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-bar { fill: var(--bar); }
.chart-bar.selected { fill: var(--bar-selected); }
.chart-bar.fallback { fill: var(--bar-fallback); }
.chart-bar.fallback.selected { stroke: var(--bar-selected); stroke-width: 2; }
.trend-chart .chart-selected { fill: var(--accent); font-weight: 760; }
.chart-legend { display: flex; gap: 7px 14px; flex-wrap: wrap; padding: 0 17px 14px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: flex; gap: 5px; align-items: center; }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; background: var(--bar-selected); }
.chart-legend .legend-fallback { background: var(--bar-fallback); }
.trend-footer { display: flex; align-items: center; gap: 10px; padding: 13px 17px; border-top: 1px solid var(--line); }
.data-icon { width: 32px; height: 32px; border-radius: 8px; }
.data-icon .icon { width: 16px; height: 16px; }
.trend-footer strong { font-size: 12px; }
.trend-footer p { color: var(--muted); font-size: 12px; }

.empty-state { display: grid; justify-items: center; gap: 14px; min-height: 260px; padding: 44px 20px; text-align: center; }
.empty-state h2 { font-size: 20px; }
.feature-icon { width: 48px; height: 48px; border-radius: 12px; }
.feature-icon .icon { width: 23px; height: 23px; }
.settings-panel { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; padding: 20px; }
.theme-options { display: flex; flex-wrap: wrap; gap: 7px; border: 0; padding: 0; margin: 0; }
.theme-options label { display: flex; gap: 6px; align-items: center; min-height: 40px; padding: 4px 10px; cursor: pointer; border: 1px solid var(--line); border-radius: 8px; }
.theme-options label:has(:checked) { background: var(--tint); color: var(--accent); }
.theme-options input { accent-color: var(--accent); margin: 0; }

.login-header { display: flex; align-items: center; justify-content: space-between; margin: 0 auto; max-width: 1360px; padding: 20px 26px; }
.login-main { display: grid; justify-items: center; align-items: start; padding: min(10vh, 80px) 18px 34px; }
.login-card { width: min(100%, 410px); padding: 28px; box-shadow: 0 12px 30px light-dark(#182f5710, #080e1660); }
.login-card h1 { margin-top: 16px; font-size: 27px; line-height: 1.25; letter-spacing: -.045em; }
.login-card p { color: var(--muted); margin-top: 8px; }
.login-card form { display: grid; gap: 8px; margin-top: 22px; }
.login-card label { font-weight: 720; }
.password-field { display: flex; align-items: center; border: 1px solid var(--strong-line); border-radius: 8px; }
.password-field:focus-within { border-color: var(--accent); }
.password-field input { min-width: 0; flex: 1; min-height: 44px; border: 0; padding: 8px 11px; background: transparent; border-radius: 8px; }
.reveal-password { border: 0; margin-right: 2px; }
.login-card .login-error { margin-top: 2px; color: var(--red); font-weight: 660; }
.login-submit { margin-top: 9px; min-height: 44px; }

@media (max-width: 1140px) {
  .workspace { grid-template-columns: 204px minmax(0, 1fr); }
  .topbar { padding-inline: 22px; }
  .main { padding-inline: 22px; }
  .data-layout { grid-template-columns: minmax(0, 1fr); }
  .trend-chart { max-width: 440px; }
}

@media (max-width: 800px) {
  .workspace { display: block; }
  .sidebar, .breadcrumb-root { display: none !important; }
  .topbar { min-height: 60px; padding: 7px 12px; }
  .topbar-actions { gap: 6px; }
  .breadcrumbs ol, .breadcrumbs li { gap: 4px; }
  .breadcrumbs li:nth-child(2) .icon { display: none; }
  .menu-trigger { display: inline-flex; }
  .icon-button, .logout { min-width: 44px; min-height: 44px; }
  .mobile-menu[open] { display: block; }
  .mobile-menu {
    inset: 0 auto 0 0;
    margin: 0;
    width: min(305px, calc(100% - 42px));
    height: 100dvh;
    max-width: none;
    max-height: none;
    padding: 14px 15px 24px;
    border: 0;
    border-right: 1px solid var(--line);
    color: var(--ink);
    background: var(--panel);
  }
  .mobile-menu::backdrop { background: #0b16277f; }
  body:has(.mobile-menu[open]) { overflow: hidden; }
  .mobile-menu-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
  .mobile-menu a { min-height: 44px; }
  .main { padding: 21px 15px 27px; }
}

@media (max-width: 520px) {
  .page-heading { gap: 7px; margin-bottom: 16px; }
  .page-heading p { font-size: 13px; }
  .topbar .logout span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .filter-market, .filter-date { flex-wrap: wrap; }
  .filters { padding: 11px; margin-bottom: 12px; }
  .segmented a { min-height: 38px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
  .metric:first-child { grid-column: 1 / -1; }
  .metric { gap: 8px; padding: 10px; }
  .metric-icon { width: 29px; height: 29px; border-radius: 7px; }
  .metric-icon .icon { width: 15px; height: 15px; }
  .metric h2, .metric-note { font-size: 11px; }
  .metric-value { font-size: 22px; }
  .data-layout { gap: 12px; }
  .section-heading { padding-inline: 12px; }
  table { min-width: 340px; }
  th, td { padding-inline: 6px; }
  .rank { width: 32px; padding-left: 7px; }
  .candle { padding-right: 9px; }
  .login-card { padding: 22px; }
}
