/* =============================================================================
   AI Stock KR·US — 관제 콘솔 디자인 시스템
   =============================================================================
   장시간 응시하는 화면입니다. 대비를 과하게 올리지 않고, 색은 "의미가 있을 때만"
   씁니다. 색 결정은 눈대중이 아니라 검증기(dataviz validate_palette)로 통과시킨
   값입니다 — 아래 주석의 수치가 그 근거입니다.

   ── 색이 하는 일 네 가지 ────────────────────────────────────────────────────
   1) 등락(diverging)  : --up / --down. 빨강↔파랑은 "반대"로 읽히는 한 쌍입니다.
                         한국식(상승=빨강)이 기본, [data-convention="us"] 로 전환.
   2) 상태(status)     : --good/--warn/--serious/--critical. 항상 아이콘+라벨과
                         함께 씁니다. 색만으로 의미를 전달하지 않습니다.
   3) 강조(accent)     : --accent. UI 크롬(포커스·활성 탭·링크) 전용입니다.
                         데이터 마크에는 쓰지 않습니다.
   4) 크기(sequential) : 히트맵. 등락은 방향이 있으므로 단일 색조가 아니라
                         --up/--down 두 팔 + 중립 회색 중간값을 씁니다.

   검증 결과 (validate_palette.js, --pairs all)
     dark  surface #151a21 : #e66767 / #3987e5 / #199e70 → 전 항목 PASS
     light surface #ffffff : #d03b3b / #2a78d6 / #128a5f → 전 항목 PASS
   ============================================================================= */

/* ── 토큰 ─────────────────────────────────────────────────────────────────── */

:root {
  color-scheme: dark;

  /* 표면 */
  --plane: #0b0e13;
  --surface: #151a21;
  --surface-2: #1b212a;
  --surface-3: #222a34;
  --surface-hover: #1e252f;

  /* 선 */
  --line: #262e3a;
  --line-strong: #333d4c;

  /* 잉크 */
  --ink: #eaeef4;
  --ink-2: #9aa6b6;
  --ink-3: #6b7787;

  /* 등락 (한국식 기본: 상승 = 빨강) */
  --up: #e66767;
  --down: #3987e5;
  --flat: #6b7787;
  --up-wash: rgba(230, 103, 103, 0.14);
  --down-wash: rgba(57, 135, 229, 0.14);

  /* 강조 — UI 크롬 전용 */
  --accent: #199e70;
  --accent-ink: #7ee8bd;
  --accent-wash: rgba(25, 158, 112, 0.14);

  /* 상태 — 아이콘/라벨과 항상 동반 */
  --good: #0ca30c;
  --warn: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-wash: rgba(12, 163, 12, 0.14);
  --warn-wash: rgba(250, 178, 25, 0.14);
  --critical-wash: rgba(208, 59, 59, 0.16);

  /* 차트 크롬 */
  --grid: #222a34;
  --axis: #333d4c;

  /* 형태 */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-full: 999px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.28);

  --sans: system-ui, -apple-system, "Segoe UI", "Malgun Gothic",
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --rail-w: 224px;
}

:root[data-theme="light"] {
  color-scheme: light;

  --plane: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef1f6;
  --surface-hover: #f2f5f9;

  --line: #e2e7ee;
  --line-strong: #cbd3de;

  --ink: #0f151d;
  --ink-2: #4d5866;
  --ink-3: #7b8694;

  --up: #d03b3b;
  --down: #2a78d6;
  --flat: #7b8694;
  --up-wash: rgba(208, 59, 59, 0.10);
  --down-wash: rgba(42, 120, 214, 0.10);

  --accent: #128a5f;
  --accent-ink: #0b6444;
  --accent-wash: rgba(18, 138, 95, 0.10);

  --good-wash: rgba(12, 163, 12, 0.12);
  --warn-wash: rgba(250, 178, 25, 0.18);
  --critical-wash: rgba(208, 59, 59, 0.10);

  --grid: #eaeef4;
  --axis: #cbd3de;

  --shadow: 0 1px 2px rgba(15, 21, 29, 0.06), 0 8px 24px rgba(15, 21, 29, 0.06);
}

/* 미국식 관행: 상승 = 초록, 하락 = 빨강.
   초록↔빨강은 색각 이상에서 가장 약한 쌍이므로, 이 앱은 등락을 **항상**
   부호(+/−)와 화살표로도 표시합니다. 색은 보조 채널입니다. */
:root[data-convention="us"] {
  --up: #0ca30c;
  --down: #e66767;
  --up-wash: rgba(12, 163, 12, 0.14);
  --down-wash: rgba(230, 103, 103, 0.14);
}
:root[data-theme="light"][data-convention="us"] {
  --up: #0a8a0a;
  --down: #d03b3b;
  --up-wash: rgba(10, 138, 10, 0.10);
  --down-wash: rgba(208, 59, 59, 0.10);
}

/* ── 기본 ─────────────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

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

a {
  color: var(--accent-ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

[hidden] {
  display: none !important;
}

/* 표에서만 자릿수를 맞춥니다. 큰 단독 숫자에는 쓰지 않습니다 —
   display 크기에서 등폭 숫자는 오히려 성기게 보입니다. */
.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.tnum {
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--ink-2);
}
.dim {
  color: var(--ink-3);
}
.small {
  font-size: 12px;
}
.xsmall {
  font-size: 11px;
}
.spacer {
  flex: 1;
}
.nowrap {
  white-space: nowrap;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.pos {
  color: var(--up);
}
.neg {
  color: var(--down);
}
.flat {
  color: var(--flat);
}

/* =============================================================================
   앱 셸 — 좌측 레일 + 상단 바 + 콘텐츠
   ============================================================================= */

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ── 좌측 레일 ────────────────────────────────────────────────────────────── */

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  /* 메뉴 + 계좌 요약 + 사용자 블록이 짧은 화면(노트북 세로 700px 이하)에서
     화면 밖으로 밀릴 수 있습니다. 잘리면 로그아웃 버튼에 닿을 수 없게 되므로
     레일 안에서 스크롤되게 둡니다. */
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 16px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: linear-gradient(150deg, var(--accent), color-mix(in oklab, var(--accent) 55%, var(--down)));
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.04em;
}
.brand-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}
.brand-sub {
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.2;
}

.nav-group-label {
  padding: 14px 10px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.nav-item[aria-current="page"] {
  background: var(--accent-wash);
  color: var(--accent-ink);
}
.nav-item .ico {
  flex: none;
  width: 18px;
  text-align: center;
  font-size: 14px;
}
/* 섹션별 미확인 건수 — 색이 아니라 숫자로 알립니다. */
.nav-count {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.nav-count[data-tone="critical"] {
  background: var(--critical-wash);
  color: var(--critical);
}

/* ── 레일 계좌 요약 ───────────────────────────────────────────────────────────
   잔고 · 예수금 · 주문가능금액. 어느 화면에 있든 계좌의 돈이 보여야 합니다.

   숫자는 tabular-nums 고정폭입니다. 3초마다 갱신되는 자리라, 자릿수가 바뀔 때
   글자가 좌우로 흔들리면 읽는 사람이 매번 다시 조준해야 합니다. */

.rail-accounts {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.acct-title {
  padding: 0 10px 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.acct {
  padding: 8px 10px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.acct-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-2);
}
.acct-name {
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.acct-tail {
  flex: none;
  font-size: 10px;
  color: var(--ink-3);
}
/* 「주문 대상」 표식 — 조건검색 브리지가 주문을 내보내는 계좌입니다.
   ● 는 전송이 켜진 상태, ○ 는 기록만 하는 상태. 레일에서 계좌를 착각한 채
   「지금 주문」을 누르는 일을 막는 유일한 단서라 항상 붙입니다. */
.acct-badge {
  flex: none;
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--accent, #199e70);
  background: color-mix(in oklab, var(--accent, #199e70) 16%, transparent);
}

.acct-sync {
  margin-left: auto;
  flex: none;
  font-size: 10px;
  color: var(--ink-3);
}
/* 오래된 잔고는 색으로 알립니다. 값 자체는 그대로 보여줍니다 — 지우면
   "얼마였는지" 조차 알 수 없게 되고, 그건 오래된 값보다 나쁩니다. */
.acct-sync.is-stale {
  color: color-mix(in oklab, var(--warn) 72%, var(--ink));
}

.acct-main {
  margin-top: 2px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acct-rows {
  margin: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.acct-rows > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.acct-rows dt {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}
.acct-rows dd {
  margin: 0 0 0 auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acct-empty {
  margin-top: 3px;
  font-size: 11px;
  color: var(--ink-3);
}

/* 축약 표기는 넓은 화면에서는 필요 없습니다(아래 좁은 화면 규칙에서 켭니다). */
.acct-compact {
  display: none;
}

.rail-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rail-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px;
  min-width: 0;
}
.avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
}
.rail-user-name {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-user-sub {
  font-size: 10px;
  color: var(--ink-3);
}

/* ── 상단 바 ──────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

/* 실거래 여부를 착각하는 것이 이 화면에서 가장 위험합니다.
   그래서 모드 띠는 스크롤과 무관하게 항상 최상단에 있습니다. */
.mode-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 22px;
  font-size: 13px;
  font-weight: 650;
  border-bottom: 1px solid var(--line);
}
.mode-strip .mode-icon {
  font-size: 14px;
}
.mode-dry {
  background: var(--good-wash);
  color: color-mix(in oklab, var(--good) 72%, var(--ink));
}
.mode-live {
  background: var(--critical-wash);
  color: color-mix(in oklab, var(--critical) 78%, var(--ink));
}
.mode-killed {
  background: var(--warn-wash);
  color: color-mix(in oklab, var(--warn) 68%, var(--ink));
}
.mode-unknown {
  background: var(--surface-2);
  color: var(--ink-3);
}
/* 실거래 중에는 띠가 천천히 숨 쉽니다 — 눈에 띄되 방해하지 않는 정도로. */
.mode-live .mode-icon {
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
}
.page-title {
  font-size: 17px;
  font-weight: 680;
}
.page-sub {
  font-size: 12px;
  color: var(--ink-3);
}

.clocks {
  display: flex;
  gap: 8px;
}
.clock {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.clock-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.clock-time {
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
/* 장중인 시장의 시계에만 점이 붙습니다. */
.clock[data-open="1"] .clock-label::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: var(--r-full);
  background: var(--good);
  vertical-align: middle;
}

/* ── 콘텐츠 ───────────────────────────────────────────────────────────────── */

.content {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 1560px;
}

/* 폴링 중 화면을 비우지 않습니다. 이전 렌더를 옅게 유지해 레이아웃이 튀지
   않게 합니다(스켈레톤 깜빡임 방지). */
.stale {
  opacity: 0.55;
  transition: opacity 0.2s;
}

/* =============================================================================
   카드 / 패널
   ============================================================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.card-head h2,
.card-head h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.card-head .hint {
  font-size: 11px;
  color: var(--ink-3);
}
.card-body {
  padding: 16px 18px;
}
.card-body.flush {
  padding: 0;
}
.card.danger {
  border-color: color-mix(in oklab, var(--critical) 40%, var(--line));
}

.grid {
  display: grid;
  gap: 16px;
}
.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* =============================================================================
   스탯 타일 — "한 개의 숫자가 곧 차트" 인 자리
   ============================================================================= */

.tile {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.tile-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
/* 큰 단독 숫자는 비례 숫자(기본값)를 씁니다. tabular 는 표에서만. */
.tile-value {
  font-size: 24px;
  font-weight: 660;
  letter-spacing: -0.02em;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-value.sm {
  font-size: 19px;
}
.tile-sub {
  font-size: 11px;
  color: var(--ink-3);
}
/* 부제가 「값이 낡았다」를 말할 때. 회색으로 두면 읽히지 않습니다. */
.tile-sub.warn {
  color: color-mix(in oklab, var(--warn) 70%, var(--ink));
  font-weight: 600;
}
.tile-spark {
  margin-top: 6px;
  height: 30px;
}

/* =============================================================================
   버튼
   ============================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--accent);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.sm {
  padding: 5px 10px;
  font-size: 12px;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}
.btn.danger {
  background: var(--critical);
  border-color: var(--critical);
  color: #fff;
}
.btn.danger:hover:not(:disabled) {
  filter: brightness(1.1);
}
.btn.warn {
  border-color: color-mix(in oklab, var(--warn) 45%, var(--line-strong));
  color: color-mix(in oklab, var(--warn) 78%, var(--ink));
}
.btn.ghost {
  background: none;
  border-color: transparent;
  color: var(--ink-2);
}
.btn.ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--ink);
}
.btn.icon {
  padding: 7px;
  width: 32px;
  height: 32px;
}
.btn-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--ink-2);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.btn-link:hover {
  color: var(--ink);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* 세그먼트 컨트롤 — 필터는 항상 카드 밖 한 줄에 모읍니다. */
/* ── 거래 환경 전환 (모의투자 / 실전투자) ──────────────────────────────────
   .segmented 와 비슷하지만 일부러 더 큽니다. 이 스위치를 잘못 누르면 실제
   자금이 걸리므로, 다른 필터들과 같은 무게로 보이면 안 됩니다.
   선택된 쪽만 색을 갖고, 실전은 위험색(critical)으로 물듭니다. */
.env-switch {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.env-switch button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.env-switch button:hover:not([aria-pressed='true']) {
  color: var(--ink-2);
}
.env-switch .env-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
}
.env-switch button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.env-switch button[aria-pressed='true'] .env-dot {
  opacity: 1;
}
.env-switch button[data-env-switch='mock'][aria-pressed='true'] .env-dot {
  background: var(--good);
}
.env-switch button[data-env-switch='live'][aria-pressed='true'] {
  color: color-mix(in oklab, var(--critical) 82%, var(--ink));
}
.env-switch button[data-env-switch='live'][aria-pressed='true'] .env-dot {
  background: var(--critical);
}
/* 전환 요청이 왕복하는 동안 두 버튼 모두 잠깁니다 — 연타로 두 번 전환되면
   어느 환경에 있는지 사람이 놓칩니다. */
.env-switch button[disabled] {
  opacity: 0.5;
  cursor: progress;
}

/* 실전투자에서는 상단 띠가 항상 위험색입니다(무장 여부와 무관). */
.mode-env-live {
  background: var(--critical-wash);
  color: color-mix(in oklab, var(--critical) 78%, var(--ink));
}

.segmented {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.segmented button {
  padding: 5px 11px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── 입력 ─────────────────────────────────────────────────────────────────── */

.input {
  padding: 8px 12px;
  background: var(--plane);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  color: var(--ink);
  min-width: 0;
}
.input::placeholder {
  color: var(--ink-3);
}
.input:focus-visible {
  border-color: var(--accent);
}
.search {
  flex: 1;
  max-width: 260px;
}

/* ── 토글 ─────────────────────────────────────────────────────────────────── */

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.switch .slider {
  position: absolute;
  inset: 0;
  border-radius: var(--r-full);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  transition: background 0.16s, border-color 0.16s;
  pointer-events: none;
}
.switch .slider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: var(--r-full);
  background: var(--ink-2);
  transition: transform 0.16s, background 0.16s;
}
.switch input:checked + .slider {
  background: var(--accent-wash);
  border-color: var(--accent);
}
.switch input:checked + .slider::before {
  transform: translateX(18px);
  background: var(--accent);
}
.switch input:disabled + .slider {
  opacity: 0.4;
}
.switch input:focus-visible + .slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* =============================================================================
   배지 · 태그 · 상태
   ============================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge-open {
  background: var(--good-wash);
  color: color-mix(in oklab, var(--good) 74%, var(--ink));
}
.badge-closed {
  background: var(--surface-3);
  color: var(--ink-3);
}
.badge-armed {
  background: var(--critical-wash);
  color: color-mix(in oklab, var(--critical) 80%, var(--ink));
}
.badge-neutral {
  background: var(--surface-3);
  color: var(--ink-2);
}

/* 공시 판정 배지 — 호재 / 악재.
   등락 색(--up / --down)을 씁니다. 호재가 «오르는 색» 과 같아야 한 화면 안에서
   방향이 일관되게 읽히고, 등락 관행을 미국식으로 뒤집으면 여기도 따라 뒤집힙니다.
   색만으로 읽히지 않도록 배지 안에는 언제나 「호재 / 악재」 글자가 함께 들어갑니다. */
.badge-bull {
  background: var(--up-wash);
  color: color-mix(in oklab, var(--up) 78%, var(--ink));
}
.badge-bear {
  background: var(--down-wash);
  color: color-mix(in oklab, var(--down) 78%, var(--ink));
}
.badge-warn {
  background: var(--warn-wash);
  color: color-mix(in oklab, var(--warn) 70%, var(--ink));
}

.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 700;
}
.tag-buy {
  background: var(--up-wash);
  color: var(--up);
}
.tag-sell {
  background: var(--down-wash);
  color: var(--down);
}
.tag-dry {
  background: var(--good-wash);
  color: color-mix(in oklab, var(--good) 74%, var(--ink));
}
.tag-live {
  background: var(--critical-wash);
  color: color-mix(in oklab, var(--critical) 80%, var(--ink));
}

/* 상태 점은 반드시 라벨과 함께 씁니다. 점만 있는 UI 는 만들지 않습니다. */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--ink-3);
}
.dot-ok {
  background: var(--good);
}
.dot-warn {
  background: var(--warn);
}
.dot-bad {
  background: var(--critical);
}
.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
}

/* 게이트 진행 표시 — 3중 관문이 각각 열렸는지 한눈에 보이게 합니다. */
.gates {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gate {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: 12px;
}
.gate[data-open="1"] {
  border-color: color-mix(in oklab, var(--good) 35%, var(--line));
}
.gate-num {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
}
.gate[data-open="1"] .gate-num {
  background: var(--good-wash);
  color: color-mix(in oklab, var(--good) 80%, var(--ink));
}
.gate-name {
  font-weight: 650;
}
.gate-why {
  color: var(--ink-3);
  font-size: 11px;
}

/* 차단 사유 상자.
   제목 줄이 있는 이유는 §overview.js blockerBox 에 적어 두었습니다 —
   요약하면, 제목 없는 느낌표 목록은 안전장치가 아니라 고장으로 읽힙니다. */
.blockers {
  margin: 12px 0 0;
  padding: 10px 12px;
  background: var(--warn-wash);
  border-radius: var(--r-md);
}
/* 제목 없이 <ul class="blockers"> 로 쓰는 화면(스크리너·전략·시스템)이 아직
   있습니다. 그쪽은 ul 자신이 상자라 왼쪽 여백을 직접 져야 합니다. */
ul.blockers {
  padding-left: 28px;
  list-style: none;
}
.blockers-head {
  font-size: 11px;
  font-weight: 700;
  color: color-mix(in oklab, var(--warn) 75%, var(--ink));
  margin-bottom: 6px;
}
.blockers-note {
  font-weight: 400;
  color: var(--ink-3);
}
.blockers-list {
  margin: 0;
  padding: 0 0 0 16px;
  list-style: none;
}
.blockers li {
  position: relative;
  font-size: 12px;
  color: color-mix(in oklab, var(--warn) 60%, var(--ink));
  margin-bottom: 6px;
}
.blockers li::before {
  content: "!";
  position: absolute;
  left: -16px;
  font-weight: 800;
}
.blockers li:last-child {
  margin-bottom: 0;
}
.blockers-fix {
  display: block;
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 11px;
}

/* =============================================================================
   시장 카드
   ============================================================================= */

.market-card .card-head {
  gap: 8px;
}
.market-flag {
  font-size: 18px;
}

/* 장 진행률 — 개장에서 마감까지 어디쯤인지. 시간 텍스트와 함께 씁니다. */
.session-bar {
  position: relative;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  overflow: hidden;
}
.session-bar > i {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  background: var(--accent);
  transition: width 0.6s ease;
}
.session-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 11px;
  color: var(--ink-3);
}

.kv {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}
.kv-label {
  font-size: 11px;
  color: var(--ink-3);
}
.kv-value {
  font-size: 17px;
  font-weight: 620;
  letter-spacing: -0.01em;
}
.kv-value.sm {
  font-size: 14px;
  font-weight: 600;
}

/* 현금 / 평가금액 배분 — 2조각 파이 대신 한 줄 막대.
   조각 사이 2px 표면 간격을 둡니다(테두리를 그리지 않습니다). */
.alloc {
  display: flex;
  gap: 2px;
  height: 8px;
  margin-top: 4px;
}
.alloc > i {
  display: block;
  height: 100%;
  border-radius: 2px;
  min-width: 2px;
}
.alloc-legend {
  display: flex;
  gap: 14px;
  margin-top: 7px;
  font-size: 11px;
  color: var(--ink-2);
}
.alloc-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex: none;
}

/* =============================================================================
   표
   ============================================================================= */

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th,
table.data td {
  padding: 9px 12px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.data th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.03em;
  color: var(--ink-3);
}
table.data th.sortable {
  cursor: pointer;
  user-select: none;
}
table.data th.sortable:hover {
  color: var(--ink);
}
table.data th[aria-sort="ascending"]::after {
  content: " ↑";
  color: var(--accent);
}
table.data th[aria-sort="descending"]::after {
  content: " ↓";
  color: var(--accent);
}
table.data th.left,
table.data td.left {
  text-align: left;
}
table.data td.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
table.data tbody tr:hover {
  background: var(--surface-hover);
}
table.data tbody tr:last-child td {
  border-bottom: 0;
}
.sym {
  font-weight: 650;
}
.sym-name {
  color: var(--ink-3);
  font-weight: 400;
  font-size: 11px;
  margin-left: 6px;
}

/* 종목명 / 종목코드를 각각 다른 칸에 그릴 때 씁니다.
   이름은 읽는 값이라 본문색·가변폭, 코드는 대조하는 값이라 고정폭입니다. */
.sym-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 16ch;
  display: inline-block;
  vertical-align: bottom;
}
.sym-code {
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: 0.02em;
}

.empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}
.empty strong {
  display: block;
  color: var(--ink-2);
  font-size: 14px;
  margin-bottom: 4px;
}

/* 값이 바뀌면 셀이 한 번 번쩍입니다 — 폴링 화면에서 "무엇이 변했나" 를
   눈으로 잡아내기 위한 최소한의 신호입니다. */
@keyframes flash-up {
  from {
    background: var(--up-wash);
  }
  to {
    background: transparent;
  }
}
@keyframes flash-down {
  from {
    background: var(--down-wash);
  }
  to {
    background: transparent;
  }
}
.flash-up {
  animation: flash-up 0.7s ease-out;
}
.flash-down {
  animation: flash-down 0.7s ease-out;
}

/* =============================================================================
   차트
   ============================================================================= */

/* 차트 틀
   ─────────────────────────────────────────────────────────────────────────
   SVG 는 가로로 늘려 폭을 채웁니다(preserveAspectRatio="none"). 그러면 같은
   변환이 글자와 원에도 걸려 폰트가 눌리고 점이 타원이 되므로, **축 라벨과
   끝점 마커는 SVG 밖 HTML** 로 얹습니다. 선 굵기는 non-scaling-stroke 가
   지킵니다. x축 글자 띠는 카드 안에서 잘리지 않도록 틀 높이에 포함됩니다. */
.chart-frame {
  --plot-h: 150px;
  --pad-l: 56px;
  --pad-r: 60px;
  width: 100%;
}
.chart-frame .plot {
  position: relative;
  height: var(--plot-h);
  padding-left: var(--pad-l);
  padding-right: var(--pad-r);
}
.chart-frame .plot > svg.chart {
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
.chart-frame .y-labels span {
  position: absolute;
  left: 0;
  width: calc(var(--pad-l) - 10px);
  transform: translateY(-50%);
  text-align: right;
  font-size: 10px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chart-frame .end-dot {
  position: absolute;
  right: calc(var(--pad-r) - 3.5px);
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
  transform: translateY(-50%);
  /* 겹치는 마크 위에는 테두리 대신 2px 표면 링을 둡니다. */
  box-shadow: 0 0 0 2px var(--surface);
}
.chart-frame .end-flag {
  position: absolute;
  right: 2px;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chart-frame .x-labels {
  display: flex;
  justify-content: space-between;
  height: 18px;
  padding-left: var(--pad-l);
  padding-right: var(--pad-r);
  font-size: 10px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.chart {
  display: block;
  overflow: visible;
}
.chart .grid-line {
  stroke: var(--grid);
  stroke-width: 1;
}
.chart .series-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart .series-area {
  stroke: none;
  opacity: 0.16;
}
.chart .zero-line {
  stroke: var(--axis);
  stroke-width: 1;
}
.chart .crosshair {
  stroke: var(--ink-3);
  stroke-width: 1;
  pointer-events: none;
}

.chart-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}
.chart-title {
  font-size: 12px;
  font-weight: 650;
}
.chart-note {
  font-size: 11px;
  color: var(--ink-3);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-2);
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend i {
  width: 10px;
  height: 2px;
  border-radius: 1px;
  flex: none;
}

/* 툴팁은 값을 "더" 보여줄 뿐, 값에 이르는 유일한 길이 아닙니다.
   같은 값은 표 보기에서도 항상 읽을 수 있습니다. */
.tooltip {
  position: fixed;
  z-index: 60;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  font-size: 12px;
  pointer-events: none;
  max-width: 240px;
}
.tooltip .t-title {
  font-weight: 700;
  margin-bottom: 3px;
}
.tooltip .t-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--ink-2);
}
.tooltip .t-row b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* 포지션 손익 막대 — 0을 기준으로 좌우로 자랍니다(diverging).
   막대 끝은 4px 라운드, 기준선에 붙어 있습니다. */
.pnl-bar {
  position: relative;
  height: 16px;
  min-width: 90px;
}
.pnl-bar .mid {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--axis);
}
.pnl-bar i {
  position: absolute;
  top: 3px;
  height: 10px;
  border-radius: 3px;
}

/* 가격 사다리 — 손절 · 평단 · 현재가 · 목표가의 상대 위치. */
.ladder {
  position: relative;
  height: 18px;
  min-width: 130px;
}
.ladder .track {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 1px;
  background: var(--surface-3);
}
.ladder .mark {
  position: absolute;
  top: 3px;
  width: 2px;
  height: 12px;
  border-radius: 1px;
  transform: translateX(-1px);
}
.ladder .now {
  top: 1px;
  width: 8px;
  height: 16px;
  border-radius: var(--r-full);
  border: 2px solid var(--surface);
  transform: translateX(-4px);
}

/* 히트맵 — 등락은 방향이 있으므로 발산 배색 + 중립 회색 중간값.
   각 타일에 숫자를 직접 적어 색만으로 읽지 않아도 되게 합니다. */
.heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 6px;
}
.heat-cell {
  padding: 9px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  min-width: 0;
  cursor: default;
}
.heat-sym {
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 타일에서는 이름이 주인공이고 코드는 확인용이라 한 단계 작고 흐리게 둡니다. */
.heat-code {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.heat-val {
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.heat-scale {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--ink-3);
}
.heat-scale .ramp {
  display: flex;
  height: 8px;
  width: 160px;
  border-radius: 2px;
  overflow: hidden;
}
.heat-scale .ramp i {
  flex: 1;
}

/* =============================================================================
   매매 로직 — 파라미터 위젯
   =============================================================================
   슬라이더와 숫자칸을 **쌍으로** 둡니다. 슬라이더는 감각을, 숫자칸은 정확한
   값을 담당합니다. 둘 다 같은 data-path 를 물고 있어 서로를 즉시 따라갑니다. */

.param {
  margin-bottom: 16px;
}
.param-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}
.param-label {
  font-size: 13px;
  font-weight: 600;
}
.param-value {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.param-num {
  width: 92px;
  padding: 4px 8px;
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.param-help {
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-3);
}

/* 슬라이더 없이 «라벨 + 입력칸 + 설명» 만 있는 설정 묶음(조건검색 → KIS 주문).
   매매 로직의 파라미터와 달리 값의 «감각» 이 필요 없는 것들이라(계좌 · 건수 ·
   금액) 슬라이더를 붙이지 않고 격자로 늘어놓습니다. */
.param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(216px, 1fr));
  gap: 4px 18px;
}
.param-grid .param-label {
  display: block;
  margin-bottom: 5px;
}
.param-grid .input {
  width: 100%;
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  margin: 4px 0;
  border-radius: var(--r-full);
  background: var(--surface-3);
  cursor: pointer;
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: var(--r-full);
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: var(--r-full);
  background: var(--accent);
  border: 2px solid var(--surface);
}
input[type='range']:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.grade-scale {
  margin: 4px 0 16px;
}

/* =============================================================================
   조건검색식
   ============================================================================= */

.rule-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.rule-row select.input {
  padding: 6px 10px;
  font-size: 12px;
}
.rule-row select.input:first-child {
  min-width: 148px;
}
.rule-row input[type='number'] {
  width: 118px;
  padding: 6px 10px;
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.scr-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.scr-item:last-child {
  border-bottom: 0;
}
.scr-main {
  flex: 1;
  min-width: 240px;
}
.scr-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.scr-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  cursor: pointer;
}

.scr-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
.chip {
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
/* 공시 감성의 근거 키워드 칩. 글자색만 등락 색으로 바꾸고 테두리는 그대로 둡니다 —
   칩이 여럿 붙는 자리라 배경까지 물들이면 표가 읽히지 않습니다. */
.chip.pos {
  border-color: color-mix(in oklab, var(--up) 35%, var(--line));
}
.chip.neg {
  border-color: color-mix(in oklab, var(--down) 35%, var(--line));
}

/* =============================================================================
   감시 종목 판정 — 좌: 종목 목록 / 우: 고른 종목의 공시 이력
   =============================================================================
   왼쪽은 «지금 매매가 보는 창»(72시간), 오른쪽은 «사람이 읽는 창»(3개월)입니다.
   서로 다른 시간창을 나란히 두는 배치라, 둘 사이에는 실선을 긋습니다 — 여백만으로
   나누면 한 목록의 연속으로 읽혀서 오른쪽 날짜가 왼쪽 판정 근거로 오해받습니다. */

.dart-split {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  align-items: start;
}
.dart-split-list {
  min-width: 0;
  border-right: 1px solid var(--line);
}
.dart-split-detail {
  min-width: 0;
  padding: 14px 18px 18px;
  /* 3개월이면 수십 건이 됩니다. 카드가 세로로 한없이 길어지면 아래 카드들이
     화면 밖으로 밀리므로, 목록 쪽만 스크롤합니다. */
  max-height: 620px;
  overflow-y: auto;
}
.dart-detail-head {
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

/* 선택 가능한 줄. 열려 있는 줄은 왼쪽 굵은 선으로 표시합니다 — 배경색만으로는
   호버와 구분되지 않습니다. */
.scr-item.pickable {
  cursor: pointer;
}
.scr-item.pickable:hover {
  background: var(--surface-hover);
}
.scr-item.pickable[aria-current='true'] {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent);
}
.scr-item.pickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* 목록 안의 소제목. 「판정 창 밖」 종목을 갈라 놓는 자리입니다. */
.dart-group {
  padding: 10px 18px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

/* 오른쪽 패널의 공시 한 건 */
.dart-docs {
  display: flex;
  flex-direction: column;
}
.dart-doc {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.dart-doc:last-child {
  border-bottom: 0;
}
.dart-doc-title {
  display: block;
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink);
}
.dart-doc-title:hover {
  color: var(--accent-ink);
}

/* 두 창을 나란히 두려면 최소 폭이 필요합니다. 좁아지면 위아래로 쌓고,
   경계선도 세로에서 가로로 옮깁니다. */
@media (max-width: 1180px) {
  .dart-split {
    grid-template-columns: minmax(0, 1fr);
  }
  .dart-split-list {
    border-right: 0;
  }
  .dart-split-detail {
    border-top: 1px solid var(--line);
    max-height: none;
  }
}

/* =============================================================================
   토스트 · 모달
   ============================================================================= */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(400px, calc(100vw - 36px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left-width: 3px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in 0.18s ease-out;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.toast[data-tone="ok"] {
  border-left-color: var(--good);
}
.toast[data-tone="warn"] {
  border-left-color: var(--warn);
}
.toast[data-tone="error"] {
  border-left-color: var(--critical);
}
.toast[data-tone="info"] {
  border-left-color: var(--accent);
}
.toast-body {
  min-width: 0;
  flex: 1;
}
.toast-title {
  font-weight: 650;
  margin-bottom: 2px;
}
.toast-msg {
  color: var(--ink-2);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow: auto;
}

dialog.modal {
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  max-width: min(460px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}
.modal-head {
  padding: 16px 18px 0;
  font-size: 15px;
  font-weight: 700;
}
.modal-body {
  padding: 10px 18px 4px;
  font-size: 13px;
  color: var(--ink-2);
  white-space: pre-wrap;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px 16px;
}

/* 결과 출력(JSON 등) */
.result {
  margin-top: 12px;
  padding: 11px 13px;
  background: var(--plane);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow: auto;
}

/* =============================================================================
   로그인 / 권한 화면
   ============================================================================= */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, var(--accent-wash), transparent 70%),
    radial-gradient(700px 420px at 100% 0%, var(--down-wash), transparent 65%),
    var(--plane);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.auth-card .brand {
  padding: 0 0 18px;
}
.auth-card h1 {
  font-size: 20px;
  margin-bottom: 4px;
}
.auth-lede {
  color: var(--ink-2);
  font-size: 13px;
  margin: 0 0 20px;
}

.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  margin-bottom: 10px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}
.oauth-btn svg {
  flex: none;
}
.oauth-google {
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
}
/* 카카오 디자인 가이드는 배경 #FEE500 과 검정 85% 를 고정값으로 요구합니다.
   테마에 맞춘다고 색을 바꾸면 가이드 위반입니다.
   https://developers.kakao.com/docs/latest/ko/kakaologin/design-guide */
.oauth-kakao {
  background: #fee500;
  color: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.oauth-kakao .kakao-symbol {
  fill: rgba(0, 0, 0, 0.85);
}
.oauth-btn:hover {
  filter: brightness(0.96);
}
.oauth-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(1);
}
.oauth-kakao.disabled {
  filter: none;
  opacity: 0.45;
}
.oauth-wrap {
  position: relative;
}
.oauth-badge {
  position: absolute;
  top: -7px;
  right: 8px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--warn);
  color: #201400;
  font-size: 10px;
  font-weight: 800;
}

.auth-note {
  margin: 16px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
}
.error-text {
  margin: 12px 0 0;
  color: var(--critical);
  font-size: 13px;
  white-space: pre-line;
}

.setup-guide {
  margin-top: 14px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 12px;
  line-height: 1.65;
}
.setup-guide h3 {
  margin: 0 0 8px;
  font-size: 12px;
  color: color-mix(in oklab, var(--warn) 70%, var(--ink));
}
.setup-guide h3:not(:first-child) {
  margin-top: 18px;
}
.setup-guide ol {
  margin: 0;
  padding-left: 18px;
}
.setup-guide li {
  margin-bottom: 7px;
}
.setup-guide code,
code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-3);
  font-family: var(--mono);
  font-size: 11px;
  word-break: break-all;
}

.copy-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 10px;
}
.copy-row input {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  background: var(--plane);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
}
.copy-row button {
  flex: none;
  padding: 7px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 11px;
  cursor: pointer;
}
.copy-row button.copied {
  background: var(--good);
  border-color: var(--good);
  color: #fff;
}

/* =============================================================================
   반응형
   ============================================================================= */

@media (max-width: 1100px) {
  :root {
    --rail-w: 64px;
  }
  .rail {
    padding: 14px 8px;
  }
  .nav-item {
    justify-content: center;
    padding: 10px 0;
  }
  .nav-item .label,
  .nav-count,
  .brand-text,
  .nav-group-label,
  .rail-user-text {
    display: none;
  }
  /* 레일이 아이콘 폭(64px)만 남습니다. 계좌는 축약 금액 한 줄만 남기고
     나머지는 접습니다 — 통째로 숨기면 계좌 잔고를 볼 곳이 사라집니다.
     정확한 값은 툴팁(title)에 그대로 들어 있습니다. */
  .acct-title,
  .acct-head,
  .acct-main,
  .acct-rows,
  .acct-badge {
    display: none;
  }
  .acct {
    padding: 6px 2px;
    text-align: center;
  }
  .acct-compact {
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .acct-empty {
    font-size: 9px;
    text-align: center;
    line-height: 1.15;
  }
  .brand {
    justify-content: center;
    padding: 6px 0 14px;
  }
  .rail-user {
    justify-content: center;
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  /* 좁은 화면에서는 레일이 하단 탭 바가 됩니다. */
  .rail {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: auto;
    flex-direction: row;
    gap: 2px;
    padding: 6px;
    border-right: 0;
    border-top: 1px solid var(--line);
    z-index: 40;
    overflow-x: auto;
  }
  /* 레일이 가로 탭 바가 되어 세로 공간이 없습니다. 계좌 요약은 「개요」 화면
     상단 카드에 같은 값이 있으므로 여기서는 접습니다. */
  .brand,
  .rail-foot,
  .rail-accounts {
    display: none;
  }
  .nav-item {
    flex: 1;
    min-width: 52px;
  }
  .content {
    padding: 14px;
    padding-bottom: 76px;
  }
  .topbar-main {
    padding: 10px 14px;
    flex-wrap: wrap;
  }
  .mode-strip {
    padding: 8px 14px;
    font-size: 12px;
  }
  .clocks {
    width: 100%;
  }
  .clock {
    flex: 1;
  }
  .toasts {
    right: 12px;
    bottom: 76px;
    left: 12px;
  }
}

/* =============================================================================
   접근성 — 움직임 최소화 / 고대비 강제 모드
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (forced-colors: active) {
  .card,
  .tile,
  .btn,
  .badge,
  .heat-cell {
    border: 1px solid CanvasText;
  }
  .session-bar > i,
  .alloc > i,
  .pnl-bar i {
    forced-color-adjust: none;
  }
}

@media print {
  .rail,
  .topbar,
  .toasts,
  .btn,
  .filter-bar {
    display: none !important;
  }
  .shell {
    grid-template-columns: 1fr;
  }
  body {
    background: #fff;
    color: #000;
  }
}
