:root {
  --bg: #eef3fb;
  --card: #ffffff;
  --fg: #131b2e;
  --muted: #5f7396;
  --line: #d8e3f5;
  --series-1: #2a78d6; /* dart_filing / primary line */
  --series-2: #eb6834; /* naver_news */
  --series-3: #1baf7a;
  --series-4: #8b5cf6; /* google_news_rss */
  /* status palette -- fixed, never themed (same steps in light/dark) */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --disabled: #8a8f98;
  /* enabled but never yet exercised -- distinct from --disabled (off on purpose) */
  --pending: #6366f1;
  --topo-text: #1e3a8a; /* navy blue -- topology card heading + legend, was too low-contrast as --muted */
}
/* Dark palette applies automatically by OS preference, or explicitly via the theme button
   (data-theme on <html>, remembered in localStorage). ":not([data-theme=light])" stops the OS
   media query from overriding an explicit "light" choice back to dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1428;
    --card: #12203d;
    --fg: #e7ecf7;
    --muted: #93a5c9;
    --line: #24345a;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #a78bfa;
    --topo-text: #8ab4f8; /* navy reads as near-black on a dark background, so lighten it here */
  }
}
:root[data-theme="dark"] {
  --bg: #0a1428;
  --card: #12203d;
  --fg: #e7ecf7;
  --muted: #93a5c9;
  --line: #24345a;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #a78bfa;
  --topo-text: #8ab4f8;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 system-ui, -apple-system, "Malgun Gothic", sans-serif;
}
header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}
header h1 { font-size: 17px; margin: 0; display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.theme-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font-size: 15px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.theme-btn:hover { border-color: var(--muted); }
main { max-width: 1160px; margin: 0 auto; padding: 16px 20px 40px; }
h2 { font-size: 13px; color: var(--muted); margin: 0 0 10px; font-weight: 600; letter-spacing: .02em; }
.muted { color: var(--muted); font-size: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.badge {
  font-size: 11px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted);
}
.badge.ok { color: var(--good); border-color: var(--good); }
.badge.bad { color: var(--critical); border-color: var(--critical); }

/* process / node status cards */
.proc-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
.proc-card .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.proc-card .label { font-weight: 600; font-size: 13px; word-break: keep-all; }
.proc-card .detail { color: var(--muted); font-size: 12px; margin-top: 4px; font-variant-numeric: tabular-nums; word-break: keep-all; line-height: 1.45; }
.proc-card .detail .paren-clause { display: inline-block; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.dot.healthy { background: var(--good); }
.dot.stale { background: var(--warning); }
.dot.error { background: var(--critical); }
.dot.disabled { background: var(--disabled); }
.dot.unknown { background: var(--pending); }

/* 3D topology */
.topology-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.topology-head h2 { margin: 0; }
.topology-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.topology-reset { flex: none; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--muted); padding: 6px 11px; font: inherit; font-size: 12px; cursor: pointer; }
.topology-reset:hover { color: var(--series-1); border-color: var(--series-1); }
.topology-reset:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
#graph3d { position: relative; width: 100%; height: 420px; border-radius: 10px; overflow: hidden; background: var(--bg); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--topo-text); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* 3D topology HTML speech bubbles overlay */
.topo-bubble-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.node-bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  margin-top: -14px; /* places speech bubble above the 3D node */
  pointer-events: none;
  user-select: none;
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Pretendard", sans-serif;
  z-index: 20;
}

/* When the node is hovered, the speech bubble disappears, showing only the detailed tooltip */
.node-bubble.is-hidden {
  opacity: 0;
  transform: translate(-50%, -100%) scale(0.85);
  pointer-events: none;
}

.node-bubble-body {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  border: 1.5px solid var(--bubble-color, #10b981);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 3px 9px;
  white-space: nowrap;
}

[data-theme="light"] .node-bubble-body {
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.node-bubble-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--bubble-color, #10b981);
  box-shadow: 0 0 6px var(--bubble-color, #10b981);
  flex-shrink: 0;
}

.node-bubble-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Speech bubble bottom pointer arrow */
.node-bubble-arrow {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--bubble-color, #10b981);
}

/* 3d-force-graph injects its own <style>{.scene-tooltip{color:lavender}} at runtime, after this
   stylesheet -- same selector specificity means it wins the cascade on DOM order alone, so this
   needs !important to actually override the hover/click node-description tooltip's text color. */
.scene-tooltip {
  color: var(--fg) !important;
  background: var(--card) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 12px 14px !important;
  border-radius: 12px !important;
  border: 1px solid var(--line) !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35) !important;
  white-space: normal !important;
  pointer-events: none;
  z-index: 1000;
  max-width: 320px;
}
/* The graph clears tooltip text on node exit but keeps the element in the DOM.
   Hide its padding/border too; also hide immediately when the pointer leaves the graph. */
#graph3d .scene-tooltip:empty,
#graph3d:not(:hover) .scene-tooltip { display: none; }

/* 3D topology hover tooltip card */
.topo-tooltip-card {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
}
.topo-tooltip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.topo-tooltip-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.topo-tooltip-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
  flex: 1;
}
.topo-tooltip-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.topo-tooltip-sub {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.topo-tooltip-sep {
  opacity: 0.5;
}
.topo-tooltip-desc {
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
[data-theme="dark"] .topo-tooltip-desc {
  background: rgba(255, 255, 255, 0.04);
}
.topo-tooltip-desc-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.topo-tooltip-desc-body {
  color: var(--fg);
  font-size: 12px;
  word-break: keep-all;
  white-space: pre-wrap;
}

/* stat tiles */
.stat-tile { text-align: center; }
.stat-tile .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-tile .caption { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Chart.js canvases only -- a bare `canvas` selector here would also clamp the 3D topology's
   WebGL canvas (three.js renders into a <canvas> too), squashing it into a tiny corner. */
.analytics-card { min-width: 0; padding: 24px; border-radius: 18px; box-shadow: 0 6px 24px rgb(15 30 60 / 4%); }
.analytics-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.analytics-eyebrow { margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .16em; }
.analytics-card h2 { color: var(--fg); font-size: 15px; letter-spacing: -.02em; margin: 0; }
.analytics-export { flex: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; color: var(--muted); background: var(--card); font: inherit; font-size: 10px; cursor: pointer; }
.analytics-export:hover, .analytics-export:focus-visible { border-color: var(--series-1); color: var(--series-1); }
.analytics-metric { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin: 18px 0 4px; }
.analytics-value { font-size: 32px; line-height: 1.2; font-weight: 700; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.analytics-unit, .analytics-period { color: var(--muted); font-size: 11px; }
.analytics-period { margin-left: auto; }
.analytics-summary { min-height: 18px; color: var(--muted); font-size: 11px; margin-bottom: 20px; }
.analytics-plot { position: relative; height: 224px; min-width: 0; }
.analytics-plot canvas { display: block; width: 100% !important; height: 100% !important; }
.analytics-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; gap: 6px; }
.analytics-empty strong { font-size: 13px; color: var(--fg); font-weight: 600; }
.analytics-empty span { font-size: 11px; color: var(--muted); }
.analytics-empty[hidden] { display: none; }
.analytics-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; min-height: 37px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.analytics-key { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.analytics-key i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.analytics-key b { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }
.analytics-key small { font-size: 10px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: stretch; }
@media (max-width: 600px) {
  .analytics-card { padding: 18px; }
  .analytics-plot { height: 210px; }
  .analytics-value { font-size: 28px; }
}
#graph3d canvas { display: block; width: 100% !important; height: 100% !important; }

/* ---- layout: dashboard on the left, Q&A chat panel on the right ---- */
.layout { display: flex; align-items: flex-start; min-height: 100vh; }
.content { flex: 1; min-width: 0; }
.chat {
  width: 400px; flex: none; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--card); border-left: 1px solid var(--line);
}
.chat[hidden] { display: none; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-head strong { font-size: 14px; }
.chat-head .spacer { flex: 1; }
.chat-icon-btn {
  width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg);
  color: var(--fg); cursor: pointer; font-size: 13px; line-height: 1; padding: 0;
}
.chat-icon-btn:hover { border-color: var(--muted); }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--series-1); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.note { align-self: center; max-width: 100%; color: var(--muted); font-size: 12px; text-align: center; padding: 2px 6px; }
.msg.error { color: var(--critical); }
.msg code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: rgba(127, 127, 127, .18); padding: 1px 5px; border-radius: 4px; }
.msg a { color: inherit; text-decoration: underline; word-break: break-all; }
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: qa-bounce 1.1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes qa-bounce { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.chip-btn { border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 99px; padding: 4px 10px; font-size: 12px; cursor: pointer; text-align: left; }
.chip-btn:hover { border-color: var(--series-1); }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px 12px; border-top: 1px solid var(--line); }
.chat-form textarea {
  flex: 1; resize: none; min-height: 76px; max-height: 240px; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; background: var(--bg); color: var(--fg); font: inherit; font-size: 13px; line-height: 1.4;
}
.chat-form textarea:focus { outline: 2px solid var(--series-1); outline-offset: -1px; }
.chat-send { height: 38px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--series-1); color: #fff; font-weight: 600; cursor: pointer; }
.chat-send:disabled, .chat-form textarea:disabled { opacity: .5; cursor: not-allowed; }
.chat-foot { padding: 0 14px 10px; font-size: 11px; }
.proposal { align-self: stretch; border: 1px solid var(--series-1); border-radius: 12px; padding: 10px 12px; background: var(--card); font-size: 12.5px; }
.proposal h4 { margin: 0 0 6px; font-size: 12.5px; }
.proposal table { width: 100%; border-collapse: collapse; margin: 2px 0 6px; }
.proposal td { padding: 3px 0; vertical-align: top; }
.proposal td.label { color: var(--muted); padding-right: 8px; width: 38%; }
.proposal .new { font-weight: 700; color: var(--series-3); }
.proposal .arrow { color: var(--muted); padding: 0 4px; }
.proposal .warn { color: var(--serious); margin: 4px 0; }
.proposal .trade-line { margin: 4px 0; }
.proposal .effect { color: var(--muted); font-size: 11.5px; margin: 6px 0; }
.proposal .actions { display: flex; gap: 8px; }
.proposal .actions button { flex: 1; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font-weight: 600; cursor: pointer; }
.proposal .actions .apply { background: var(--good); border-color: var(--good); color: #fff; }
.proposal .actions button:disabled { opacity: .5; cursor: not-allowed; }
.proposal .result { font-weight: 600; }
.chat-open {
  position: fixed; right: 16px; bottom: 16px; z-index: 20; padding: 10px 16px; border: 0; border-radius: 99px;
  background: var(--series-1); color: #fff; font-weight: 600; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.chat-open[hidden] { display: none; }
@media (max-width: 980px) {
  .layout { flex-direction: column; }
  .content { width: 100%; }
  .chat { position: static; width: 100%; height: 75vh; border-left: 0; border-top: 1px solid var(--line); }
}

/* ---- login page ---- */
.auth-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; box-sizing: border-box; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px 24px 22px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
}
.auth-logo { text-align: center; margin-bottom: 6px; }
.auth-logo img { border-radius: 14px; }
.auth-card h1 { margin: 0; text-align: center; font-size: 22px; }
.auth-sub { text-align: center; margin: 6px 0 18px; font-size: 13px; }
.auth-card label { display: block; margin: 12px 0 5px; font-size: 13px; font-weight: 600; }
.auth-card input[type="text"], .auth-card input[type="password"] {
  width: 100%; height: 46px; box-sizing: border-box; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px;
  background: var(--bg); color: var(--fg); font: inherit; font-size: 16px; /* 16px: iOS does not zoom on focus */
}
.auth-card input:focus { outline: 2px solid var(--series-1); outline-offset: -1px; }
.pw-row { display: flex; gap: 8px; }
.pw-toggle { flex: none; width: 64px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--fg); cursor: pointer; font-size: 13px; }
.auth-card .remember { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-top: 14px; }
.auth-card .remember input { width: 18px; height: 18px; }
.auth-submit { width: 100%; height: 48px; margin-top: 18px; border: 0; border-radius: 10px; background: var(--series-1); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; }
.auth-submit:disabled { opacity: .6; cursor: progress; }
.auth-error { background: rgba(208, 59, 59, .12); border: 1px solid var(--critical); color: var(--critical); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 4px; }
.auth-warn { margin: 16px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(250, 178, 25, .12); border: 1px solid var(--warning); font-size: 12px; line-height: 1.5; }
.auth-warn code { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; }

/* ---- header links / logout ---- */
.header-link {
  display: inline-flex; align-items: center; height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--fg); font-size: 12.5px; text-decoration: none; cursor: pointer; font-family: inherit;
  transition: all 0.15s ease;
}
.header-link:hover { border-color: var(--muted); }
.header-link.graph-link {
  background: linear-gradient(135deg, rgba(57, 135, 229, 0.12), rgba(167, 139, 250, 0.12));
  border-color: rgba(57, 135, 229, 0.4);
  color: var(--series-1);
  font-weight: 600;
}
.header-link.graph-link:hover {
  background: linear-gradient(135deg, rgba(57, 135, 229, 0.22), rgba(167, 139, 250, 0.22));
  border-color: var(--series-1);
  transform: translateY(-1px);
}
.logout-form { margin: 0; display: inline-flex; }

/* ---- full-screen chat page (phones) ---- */
body.chat-page { margin: 0; height: 100vh; height: 100dvh; overflow: hidden; }
.chat-page-wrap { height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); box-sizing: border-box; }
.chat.chat-full { position: static; width: 100%; height: 100%; border: 0; min-height: 0; }
.chat-nav { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.chat-page .chat-head { padding: 10px 12px; }
.chat-page .chat-icon-btn { width: 34px; height: 34px; font-size: 16px; }
.chat-page .chat-form { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.chat-page .chat-form textarea { font-size: 16px; }
.chat-page .msg { font-size: 15px; max-width: 94%; }
.chat-page .chip-btn { font-size: 13px; padding: 7px 12px; }
.chat-page .proposal .actions button { height: 42px; font-size: 15px; }

/* phones: the embedded chat panel is replaced by the dedicated /chat page */
@media (max-width: 720px) {
  .layout #chatPanel, #chatOpen { display: none !important; }
}

/* buttons / link buttons never wrap their label */
button, .header-link, .chat-nav, .chip-btn, .chat-send, .pw-toggle, .badge { white-space: nowrap; }
.chat-head { flex-wrap: nowrap; min-width: 0; }
.chat-head strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chat-head .chat-icon-btn, .chat-send, .chat-head .header-link, .chat-head .badge { flex: none; }
.chat-suggest { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
.chat-suggest::-webkit-scrollbar { display: none; }
.chat-suggest .chip-btn { flex: none; }

/* phones: compact monitoring screen -- single-line rows, no text wrapping */
@media (max-width: 720px) {
  body { font-size: 13px; }
  header { padding: 10px 12px; flex-direction: column; align-items: stretch; gap: 6px; flex-wrap: nowrap; }
  header h1 { font-size: 15px; white-space: nowrap; }
  .header-right { flex-wrap: nowrap; gap: 6px; }
  .header-right .muted { flex: 1; min-width: 0; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .header-link { height: 28px; padding: 0 8px; font-size: 12px; white-space: nowrap; flex: none; }
  .theme-btn { width: 28px; height: 28px; flex: none; }
  main { padding: 10px 10px 28px; }
  .card { padding: 10px 12px; margin-bottom: 10px; border-radius: 10px; }
  h2 { font-size: 12px; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .badge { white-space: nowrap; }

  /* status / stat cards: 2 columns, one line per item */
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .grid.two { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .proc-card { padding: 8px 10px; min-width: 0; }
  .proc-card .label, .proc-card .detail, .proc-card .caption {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .proc-card .label { font-size: 12px; }
  .proc-card .detail { font-size: 11px; margin-top: 2px; }
  .stat-tile .value { font-size: 18px; white-space: nowrap; }

  /* topology */
  .topology-head { flex-wrap: nowrap; gap: 6px; }
  .topology-head h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .topology-actions { flex-wrap: nowrap; flex: none; gap: 4px; }
  .topology-actions .muted { display: none; }
  .topology-reset { padding: 5px 8px; font-size: 11px; white-space: nowrap; }
  #graph3d { height: 300px; }
  .legend { flex-wrap: nowrap; overflow-x: auto; gap: 10px; font-size: 11px; white-space: nowrap; scrollbar-width: none; }
  .legend::-webkit-scrollbar { display: none; }
  .legend span { flex: none; white-space: nowrap; }

  /* analytics charts */
  .analytics-card { padding: 12px; border-radius: 12px; }
  .analytics-head { gap: 8px; }
  .analytics-head > div { min-width: 0; }
  .analytics-card h2 { font-size: 13px; }
  .analytics-eyebrow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .analytics-export { white-space: nowrap; padding: 4px 7px; }
  .analytics-metric { flex-wrap: nowrap; margin: 10px 0 2px; white-space: nowrap; }
  .analytics-value { font-size: 24px; }
  .analytics-period { overflow: hidden; text-overflow: ellipsis; }
  .analytics-summary { min-height: 16px; margin-bottom: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .analytics-plot { height: 170px; }
  .analytics-empty strong, .analytics-empty span { white-space: nowrap; }
  .analytics-legend { flex-wrap: nowrap; overflow-x: auto; gap: 12px; min-height: 0; margin-top: 10px; padding-top: 10px; scrollbar-width: none; }
  .analytics-legend::-webkit-scrollbar { display: none; }
  .analytics-key { flex: none; white-space: nowrap; }
}

/* proposals / holdings tables */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.data-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td.pos { color: var(--critical); }   /* Korean convention: up = red */
.data-table td.neg { color: var(--series-1, #2563eb); }
.data-table td.warn { color: var(--warning); font-weight: 600; }
#picksEmpty, #holdingsEmpty { padding: 6px 2px; }

/* LLM Usage section */
.card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head-row h2 { margin: 0; }
.period-toggle {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.toggle-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.toggle-btn:hover {
  color: var(--fg);
}
.toggle-btn.active {
  background: var(--card);
  color: var(--fg);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.grid.four {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}
.stat-tile .value {
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.stat-tile .caption {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.llm-chart-wrap {
  position: relative;
  height: 220px;
  margin-top: 14px;
  width: 100%;
}

