/* dxmon 화면 스타일(design-spec (a)(b)(c), spec/ui.md 9.4·9.10·9.18).
   색 변수 10개는 server/app/theme.py COLORS 와 이름·값이 글자 단위로 같다(시험이 대조한다). 색 값은 바꾸지 않고 쓰는 곳만 정한다:
   글자는 --bg·--surface 위에만 놓는다(색을 입힌 바탕을 만들지 않는다). 예외 둘: 주 단추(바탕 --text·글자 --bg), ! 표식
   (바탕 --warn·글자 --surface). 놋쇠(--brass)는 진행 자 채움·지금 탭 표시 줄·초점 테두리에만 쓴다.
   글자 크기 12·14·16·20·24px, 계수기 34px(1024px 이상 36px). 굵기 400·600·700(700 은 계수기만). 고정폭 글꼴은 쓰지 않는다.
   기준 폭: 768px 미만 휴대폰, 768~1023px 태블릿, 1024px 이상 PC(왼쪽 메뉴). 320px 까지 가로 넘침이 없다.
   한 벌의 DOM 을 이 파일이 폭에 따라(개인 화면 탭 칸 안은 칸 폭 container query 로) 다시 놓는다. JS 가 폭을 보는 곳은 개인
   화면의 PC 오른쪽 칸(1280px. 봇·상태 탭을 칸으로 바꾼다) 하나다.
   동적인 위치·크기는 JS 가 CSSOM(style.setProperty)과 SVG 속성으로 넣는다. */

:root {
  --bg: #152030;
  --surface: #1C2A3D;
  --line: #2B3B52;
  --text: #E8EDF3;
  --muted: #8D9AAC;
  --brass: #D4A84B;
  --gain: #FF6B6B;
  --loss: #5DA3FF;
  --ok: #3CC48A;
  --warn: #F28C28;
  color-scheme: dark;
  --font-body: -apple-system, 'Apple SD Gothic Neo', 'Pretendard', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  --card-edge: var(--line);
  --shadow-card: none;
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.36);
  --gutter: 16px;
  --appbar: 52px;
  --tabbar: 56px;
  --tabrow: 49px;
  --sidebar: 200px;
  --gap: 12px;
  --pad: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #F5F7FA;
    --surface: #FFFFFF;
    --line: #DCE2EA;
    --text: #16202C;
    --muted: #5E6B7C;
    --brass: #8A6410;
    --gain: #D7263D;
    --loss: #1F5FD1;
    --ok: #1C7F52;
    --warn: #B45309;
    color-scheme: light;
    --card-edge: transparent;
    --shadow-card: 0 1px 2px rgba(22, 32, 44, 0.06), 0 1px 8px rgba(22, 32, 44, 0.04);
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.18);
  }
}

@media (max-width: 359px) {
  :root { --gutter: 12px; }
}
@media (min-width: 768px) {
  :root { --gutter: 24px; --gap: 16px; --pad: 20px; }
}
@media (min-width: 1024px) {
  :root { --appbar: 64px; }
}
@media (min-width: 1280px) {
  :root { --gutter: 32px; }
}

/* ---------- 바탕 ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
  /* 키보드 초점·scrollIntoView 가 붙어 있는 위 막대(개인 화면은 탭 줄까지)·아래 탭 밑에 가려지지 않게 */
  scroll-padding-top: calc(var(--appbar) + var(--safe-top) + 8px);
}
html:has(> body[data-screen="instance"]) { scroll-padding-top: calc(var(--appbar) + var(--safe-top) + var(--tabrow) + 8px); }
@media (max-width: 1023px) {
  html:has(> body.with-menu) { scroll-padding-bottom: calc(var(--tabbar) + var(--safe-bottom) + 8px); }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  word-break: keep-all;
  -webkit-tap-highlight-color: transparent;
}

main {
  display: block;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 calc(var(--gutter) + var(--safe-right)) calc(32px + var(--safe-bottom)) calc(var(--gutter) + var(--safe-left));
}
body.with-menu main { padding-bottom: calc(var(--tabbar) + var(--safe-bottom) + 24px); }

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
noscript { display: block; padding: 24px; font-size: 14px; }

:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 4px; }

.nowrap { white-space: nowrap; overflow-wrap: normal; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.pre { white-space: pre-wrap; }

.tone-ok { color: var(--ok); }
.tone-warn { color: var(--warn); }
.tone-muted { color: var(--muted); }
.tone-profit { color: var(--gain); }
.tone-loss { color: var(--loss); }
.tone-zero { color: var(--text); }

.ic {
  width: 24px;
  height: 24px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- 위 막대(b-1) ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: calc(var(--appbar) + var(--safe-top));
  margin: 0 calc(-1 * var(--gutter));
  padding: var(--safe-top) var(--gutter) 0;
  background: var(--bg);
}
.top-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-size: 20px;
  font-weight: 600;
  line-height: 28px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.top-tools { display: flex; flex: none; align-items: center; gap: 0; margin-right: -8px; }

.back {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 2px;
  min-width: 44px;
  min-height: 44px;
  margin-left: -10px;
  padding: 0 4px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}
.back-text { display: none; font-size: 14px; color: var(--muted); padding-right: 8px; }

.refresh, .account-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
  cursor: pointer;
}
.refresh .ic { width: 18px; height: 18px; }
.refresh-text { white-space: nowrap; }
.account-btn { justify-content: center; color: var(--text); }
.refresh.tone-warn { color: var(--warn); font-weight: 600; }
/* 메뉴 없는 화면(로그인·첫 비밀번호 변경): 제목을 가운데 폼 카드의 왼쪽 선에 맞춘다 */
@media (min-width: 480px) {
  body:not(.with-menu) .top { max-width: calc(400px + 2 * var(--gutter)); margin-right: auto; margin-left: auto; }
}
.top-user { display: none; max-width: 140px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.account { position: relative; }
.top-actions {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 10;
  width: 200px;
  padding: 4px 0;
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}
.menu-user {
  padding: 8px 16px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-item + .menu-item { border-top: 1px solid var(--line); }

@media (max-width: 359px) {
  .refresh .ic { display: none; }
}
@media (min-width: 768px) {
  .back-text { display: inline; }
  .top-user { display: inline; }
}
@media (min-width: 1024px) {
  .top-title { font-size: 24px; line-height: 32px; }
}

/* 위 막대 아래: 외부 접속 안내·연결 끊김 띠·결과 띠(b-1·b-9) */
.notice { padding: 4px 0; color: var(--muted); font-size: 12px; line-height: 16px; }
.banner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0 8px;
  margin: 4px 0 8px;
  padding: 10px 16px 10px 16px;
  overflow: hidden;
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--text);
  font-size: 14px;
  line-height: 20px;
}
/* 왼쪽 4px 줄은 곧은 막대로 그린다(테두리를 쓰면 둥근 모서리에서 괄호처럼 휜다) */
.banner::before, .alert-card::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
  background: var(--warn);
}
.banner.tone-ok::before { background: var(--ok); }
.banner.tone-ok { color: var(--text); }

/* ---------- 아래 탭(<1024)·왼쪽 메뉴(≥1024)(b-2) ---------- */

.menu {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6;
  display: flex;
  height: calc(var(--tabbar) + var(--safe-bottom));
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.menu-brand { display: none; }
.menu-link {
  position: relative;
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 44px;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  text-decoration: none;
}
.menu-link .ic { width: 22px; height: 22px; }
.menu-label { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.menu-link[aria-current="page"] { color: var(--text); font-weight: 600; }
.menu-link[aria-current="page"]::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  width: 24px;
  height: 2px;
  margin-left: -12px;
  border-radius: 2px;
  background: var(--brass);
}

@media (min-width: 1024px) {
  body.with-menu { padding-left: var(--sidebar); }
  .menu {
    top: 0;
    right: auto;
    flex-direction: column;
    gap: 2px;
    width: var(--sidebar);
    height: auto;
    padding: 0 8px;
    border-top: 0;
    border-right: 1px solid var(--line);
  }
  .menu-brand {
    display: flex;
    align-items: center;
    height: 64px;
    padding: 0 12px;
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
  }
  .menu-link {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 20px;
  }
  .menu-link .ic { width: 20px; height: 20px; }
  .menu-link:hover { background: var(--bg); }
  .menu-link[aria-current="page"] { background: var(--bg); }
  .menu-link[aria-current="page"]::before {
    top: 10px;
    bottom: 10px;
    left: 0;
    width: 3px;
    height: auto;
    margin-left: 0;
  }
}

/* ---------- 화면 칸·카드(b-3) ---------- */

.screen { padding-top: 4px; }
.view { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }

.card {
  display: block;
  min-width: 0;
  padding: var(--pad);
  border: 1px solid var(--card-edge);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
  margin-bottom: 8px;
}
.card-title { min-width: 0; font-size: 14px; font-weight: 600; line-height: 20px; }
.card-sub { margin-left: 6px; color: var(--muted); font-weight: 400; }
.card-meta { flex: none; color: var(--muted); font-size: 12px; line-height: 16px; }
.sub-title { margin: 16px 0 4px; font-size: 14px; font-weight: 600; line-height: 20px; }

.more-link {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 2px;
  min-width: 44px;
  min-height: 44px;
  justify-content: flex-end;
  margin: -10px 0;
  padding: 0 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}
.chev { font-size: 16px; }

/* ---------- 이름—값 행(b-4) ---------- */

.rows { display: block; }
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  min-height: 40px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.rows > .row:first-child { border-top: 0; }
.row-k { flex: 0 1 auto; min-width: 0; color: var(--muted); font-size: 14px; line-height: 20px; }
.row-v { margin: 0 0 0 auto; min-width: 0; font-size: 16px; line-height: 24px; text-align: right; }
.row-sub { display: block; color: var(--muted); font-size: 12px; line-height: 16px; }
/* 문장 값(서버 글자가 길다): 이름 아래 줄에 왼쪽 맞춤 14px. 경고 문장은 글자색을 그대로 두고 앞 ! 표식만 경고색 */
.row-v.long { flex-basis: 100%; margin-left: 0; font-size: 14px; line-height: 20px; text-align: left; }
.row-v.long .tone-warn { color: var(--text); }
.bot-detail { margin: -4px 0 4px; padding-bottom: 8px; font-size: 14px; line-height: 20px; white-space: pre-line; }
.bot-detail + .rows { border-top: 1px solid var(--line); }
.bot-detail .mark { margin-right: 2px; }
.row-tag { margin-left: 6px; color: var(--muted); font-size: 12px; }
.row-pre { color: var(--muted); }

.note { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 16px; }
.note.tone-warn { color: var(--warn); }
.empty { padding: 24px 0; color: var(--muted); font-size: 14px; line-height: 20px; text-align: center; }
.empty.tone-warn { color: var(--warn); }

/* ---------- 상태·배지·표식(b-7) ---------- */

.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--warn);
  color: var(--surface);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  vertical-align: -2px;
}
.state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
}
.state.tone-ok { color: var(--text); }
.sdot { width: 8px; height: 8px; flex: none; border-radius: 999px; background: var(--ok); }
.sdot.hollow { border: 1.5px solid var(--muted); background: transparent; }
.state.pill { min-height: 24px; padding: 2px 10px 2px 8px; border-radius: 999px; background: var(--bg); }
.warned { display: inline; }
.warned > .mark { margin-right: 0; }

.badges { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 8px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 20px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  vertical-align: 1px;
}
.badge.tone-warn { color: var(--warn); }
.badge.tone-ok { color: var(--ok); }

/* ---------- 경고 카드(b-9) ---------- */

.alert-card { position: relative; padding: 12px 16px 12px 20px; overflow: hidden; border-radius: 12px; }
.alert-title {
  display: flex;
  align-items: center;
  gap: 0 6px;
  min-height: 24px;
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
}
.alert-count { margin-left: auto; color: var(--muted); font-size: 14px; font-weight: 400; }
.alert-more { color: var(--muted); font-size: 14px; font-weight: 400; }
.alert-list { margin-top: 2px; }
.alert-item {
  min-height: 28px;
  padding: 4px 0;
  overflow: hidden;
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.alert-item .mark { margin-right: 2px; }
.alert-link { font-weight: 600; text-decoration: none; }
.alert-name { font-weight: 600; }
.alert-text { color: var(--muted); }
.alert-body {
  display: -webkit-box;
  margin-top: 2px;
  padding-left: 22px;
  overflow: hidden;
  font-size: 14px;
  line-height: 20px;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
@media (min-width: 768px) {
  .alert-body { -webkit-line-clamp: 2; }
}
.alert-hint { display: block; color: var(--muted); }
/* 개인 화면의 경고 카드는 카드 전체가 누르는 칸(오른쪽 ›): 봇·상태 탭의 그 봇 카드·수집 상태로 간다 */
.alert-tap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin: -12px -16px -12px -20px;
  padding: 12px 16px 12px 20px;
  border-radius: 12px;
  cursor: pointer;
}
.alert-tap:focus-visible { outline-offset: -2px; }
.alert-main { flex: 1 1 auto; min-width: 0; }
.alert-chev {
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
}
@media (hover: hover) {
  .alert-tap:hover .alert-chev { border-color: var(--text); }
}
.alert-card .fold.inline { margin-top: 0; border-top: 0; }
.alert-card .fold.inline > summary { min-height: 44px; }
.alert-card .pre { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 16px; }

/* ---------- 접힘(b-10) ---------- */

.fold > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  cursor: pointer;
  list-style: none;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  margin: -4px 4px 0 auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
}
.fold[open] > summary::after { margin-top: 4px; transform: rotate(-135deg); }
.card.fold { padding-top: 0; padding-bottom: 0; }
.card.fold[open] { padding-bottom: var(--pad); }
.fold-title { font-size: 14px; font-weight: 600; line-height: 20px; }
.fold.inline { margin-top: 8px; border-top: 1px solid var(--line); }
.fold.inline > summary { min-height: 44px; }
.fold-title-s { color: var(--muted); font-size: 14px; line-height: 20px; }
.fold-body { min-width: 0; }

/* ---------- 1단계 묶음: 큰 숫자 카드 + 숫자 카드(b-5·b-6) ---------- */

.summary { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }

.caption { color: var(--muted); font-size: 14px; line-height: 20px; }
.counter-wrap { display: block; min-width: 0; max-width: 100%; margin-top: 2px; }

/* max-width 를 두지 않는다: 상자 폭 = 글자 폭이어야 넘침을 getBoundingClientRect 로 잴 수 있다(fit·판정 4).
   min-height 44px: 누르면 text↔full 을 오가는 터치 대상이다. 줄인 글자에서도 44px 를 지킨다. */
.counter {
  display: inline-block;
  min-height: 44px;
  font-size: 34px;
  font-weight: 700;
  line-height: 44px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  white-space: pre;
  color: var(--text);
  overflow-wrap: normal;
  word-break: normal;
  cursor: pointer;
}
@media (min-width: 1024px) {
  .counter { font-size: 36px; }
}
.counter-ch { display: inline-block; }
.counter-unit { display: inline-block; margin: 0 1px; font-size: 0.62em; font-weight: 600; }

.counter-roll { position: relative; overflow: hidden; vertical-align: bottom; }
.counter-roll > .counter-in { display: inline-block; position: relative; animation: dx-roll 0.6s ease-out; }
.counter-roll > .counter-in::before { content: attr(data-old); position: absolute; left: 0; top: -100%; }
@keyframes dx-roll {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.hero-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 8px;
  margin-top: 4px;
  font-size: 14px;
  line-height: 20px;
}
.hero-line-k { color: var(--muted); }
.hero-next {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2px 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.hero-next-k { display: flex; flex-direction: column; min-width: 0; }
.hero-next-name { color: var(--muted); font-size: 14px; line-height: 20px; }
.hero-next-sub { color: var(--muted); font-size: 12px; line-height: 16px; }
.hero-next-v { margin-left: auto; font-size: 16px; font-weight: 600; line-height: 24px; }
.hero-sync { margin-top: 8px; }

.kpis {
  display: block;
  min-width: 0;
  padding: 4px 16px;
  border: 1px solid var(--card-edge);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.kpi {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  min-height: 44px;
  border-top: 1px solid var(--line);
}
.kpi:first-child { border-top: 0; }
.kpi-k {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}
.kpi-v { margin-left: auto; font-size: 16px; font-weight: 600; line-height: 24px; text-align: right; }
.kpi-sub { display: none; }

@media (min-width: 768px) {
  .kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--gap);
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
  }
  .kpi {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 4px;
    padding: var(--pad);
    border: 1px solid var(--card-edge);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
  }
  .kpi:first-child { border-top: 1px solid var(--card-edge); }
  .kpi-v { margin-left: 0; font-size: 20px; line-height: 28px; text-align: left; }
  .kpi-sub { display: block; color: var(--muted); font-size: 12px; line-height: 16px; text-wrap: balance; }
}
@media (min-width: 1024px) {
  .kpi-v { font-size: 24px; line-height: 32px; }
}
/* 1280px 이상: 큰 숫자 카드 | 숫자 셋을 한 카드의 이름—값 행(이름·보조 왼쪽, 값 오른쪽)으로 나란히. 행이 카드 높이를 똑같이
   나눠 이름과 값이 행마다 같은 선에 놓인다(1024~1279px 는 768px 처럼 큰 숫자 카드 아래에 숫자 카드 셋) */
@media (min-width: 1280px) {
  .summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
  .summary > .hero { height: 100%; }
  .summary > .kpis {
    display: flex;
    flex-direction: column;
    padding: 4px var(--pad);
    border: 1px solid var(--card-edge);
    background: var(--surface);
    box-shadow: var(--shadow-card);
  }
  .summary .kpi {
    display: grid;
    flex: 1 1 0;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'k v' 's v';
    align-content: center;
    gap: 2px 16px;
    padding: 8px 0;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: none;
    box-shadow: none;
  }
  .summary .kpi:first-child { border-top: 0; }
  .summary .kpi-k { grid-area: k; }
  .summary .kpi-v { grid-area: v; align-self: center; text-align: right; }
  .summary .kpi-sub { grid-area: s; }
}

/* 상태 줄(개인 화면)·모두 정상 줄(전체 현황) */
.status-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  min-height: 28px;
}
.status-row > .status-item:last-child { justify-self: end; }
/* 연결이 끊긴 동안 초록 점을 흐리게(값이 지난 것이다) */
.is-stale .sdot:not(.hollow) { background: var(--muted); }
.status-item { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; font-size: 14px; }
.status-k { color: var(--muted); font-size: 14px; line-height: 20px; }
.status-acc { color: var(--muted); font-size: 12px; }
.status-row .state.pill { background: var(--surface); }
.all-ok { display: flex; align-items: center; min-height: 28px; }
.all-ok .state { font-weight: 400; }

/* ---------- 진행 자(b-8) ---------- */

.ruler-host { display: block; width: 100%; min-width: 0; margin-top: 8px; }
.ruler { display: block; width: 100%; min-width: 0; }
.ruler-svg { display: block; width: 100%; overflow: hidden; }
.ruler-track { fill: var(--line); }
.ruler-fill { fill: var(--brass); }
.ruler-hollow { fill: none; stroke: var(--brass); stroke-width: 1.5; }
.ruler-tick { stroke: var(--muted); stroke-width: 1; }
.ruler-tick-major { stroke: var(--text); stroke-width: 2; }
.ruler-dot { fill: var(--brass); stroke: var(--surface); stroke-width: 2; }
.ruler-ring { fill: var(--surface); stroke: var(--brass); stroke-width: 2; }
.ruler-text { fill: var(--text); font-family: var(--font-body); font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
.ruler-text.ruler-next { font-weight: 600; }
.ruler-text-major { font-weight: 600; }
.ruler-meaning { fill: var(--muted); font-weight: 400; }
.ruler-text.ruler-passed { fill: var(--muted); }
.ruler-over { display: block; margin-top: 8px; padding: 8px 12px; border-radius: 12px; background: var(--bg); font-size: 14px; line-height: 20px; text-align: left; }
.ruler-tail-k { fill: var(--muted); font-weight: 400; }

/* 목표 진행 막대(b-8-1) */
.bar { position: relative; height: 8px; margin: 8px 0; overflow: hidden; border-radius: 4px; background: var(--line); }
.bar-fill { display: block; height: 100%; border-radius: 4px; background: var(--brass); }

/* ---------- 클라이언트 목록(b-11) ---------- */

.list-card { padding-bottom: 8px; }
.clist { min-width: 0; }
.chead { display: none; }
.chunk { border-top: 1px solid var(--line); }
.clist-rows > .chunk:first-child { border-top: 0; }
.crow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 2px 0;
  min-height: 48px;
  padding: 12px 0;
  color: var(--text);
  text-decoration: none;
}
a.crow { cursor: pointer; }
.c-name { grid-row: 1; grid-column: 1; display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 16px; font-weight: 600; line-height: 24px; }
.c-name-t { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.c-state { grid-row: 1; grid-column: 2; justify-self: end; min-width: 0; }
.c-amt { grid-row: 1; grid-column: 3; justify-self: end; font-size: 16px; font-weight: 600; line-height: 24px; text-align: right; }
.c-next { grid-row: 2; grid-column: 1; min-width: 0; color: var(--muted); font-size: 12px; line-height: 16px; }
.c-next-v { color: var(--text); }
.c-seen { grid-row: 2; grid-column: 2; justify-self: end; color: var(--muted); font-size: 12px; line-height: 16px; white-space: nowrap; }
.c-pnl { grid-row: 2; grid-column: 3; justify-self: end; font-size: 14px; line-height: 20px; text-align: right; }
/* 칸 사이는 여백으로 띄운다(빈 칸이면 여백도 없어 오른쪽 끝이 맞는다) */
.c-state, .c-seen, .c-amt, .c-pnl { margin-left: 8px; }
.c-amt:empty, .c-pnl:empty { margin-left: 0; }
.c-name .badge { flex: none; }
.crow .state { font-size: 14px; }
.crow.is-group .c-name { font-size: 14px; }
.crow.is-member .c-name { color: var(--muted); font-size: 14px; font-weight: 400; }
/* 묶음(회원 합산 머리 → 클라이언트 → 회원): 행 사이 점선, 소속은 왼쪽 세로 안내선과 들여쓰기 */
.chunk > .crow + .crow { border-top: 1px dashed var(--line); }
.crow.is-child, .crow.is-member { margin-left: 4px; padding-left: 12px; box-shadow: inset 2px 0 0 var(--line); }
.crow.is-deep { margin-left: 4px; padding-left: 28px; box-shadow: inset 2px 0 0 var(--line), inset 16px 0 0 var(--surface), inset 18px 0 0 var(--line); }

@media (hover: hover) {
  a.crow:hover .c-name-t { text-decoration: underline; }
}

/* 768~1023: 4열(이름+다음 기준 | 상태+마지막 수집 | 거래대금 | 손익). 휴대폰 두 줄 행을 늘리지 않고 가운데를 채운다 */
@media (min-width: 768px) and (max-width: 1023px) {
  .crow { grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); column-gap: 16px; }
  .c-state { grid-row: 1; grid-column: 2; justify-self: start; }
  .c-seen { grid-row: 2; grid-column: 2; justify-self: start; }
  .c-amt { grid-row: 1 / span 2; grid-column: 3; align-self: center; }
  .c-pnl { grid-row: 1 / span 2; grid-column: 4; align-self: center; font-size: 16px; line-height: 24px; }
  .c-state, .c-seen, .c-amt, .c-pnl { margin-left: 0; }
}

@media (min-width: 1024px) {
  .chead, .crow {
    grid-template-columns: minmax(0, 20fr) minmax(0, 18fr) minmax(0, 13fr) minmax(0, 22fr) minmax(0, 13fr) minmax(0, 14fr);
    column-gap: 16px;
  }
  .chead { display: grid; align-items: center; border-bottom: 1px solid var(--line); }
  .c-state, .c-seen, .c-amt, .c-pnl { margin-left: 0; }
  .sort {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
    text-align: left;
    cursor: pointer;
  }
  .sort.c-h2, .sort.c-h3, .sort.c-h4, .sort.c-h5 { justify-content: flex-end; text-align: right; }
  .sort-ic::after { content: '↕'; opacity: 0.5; }
  .sort[aria-sort="ascending"] .sort-ic::after { content: '↑'; opacity: 1; }
  .sort[aria-sort="descending"] .sort-ic::after { content: '↓'; opacity: 1; }
  .crow { align-items: center; min-height: 56px; padding: 8px 0; }
  .chunk > .crow + .crow { min-height: 44px; }
  .c-name, .c-state, .c-amt, .c-next, .c-pnl, .c-seen { grid-row: 1; }
  .c-name { grid-column: 1; }
  .c-state { grid-column: 2; justify-self: start; }
  .c-amt { grid-column: 3; font-size: 14px; line-height: 20px; }
  /* 다음 기준까지: '300억까지 179억 4,813만 남음' 한 줄 오른쪽 맞춤(좁으면 조각 사이에서 줄을 바꾼다) */
  .c-next { grid-column: 4; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-end; column-gap: 6px; justify-self: stretch; text-align: right; }
  /* 표 꼴에서는 칸이 머리 행과 맞아야 하므로 들여쓰기·안내선을 이름 칸에만 둔다 */
  .crow.is-child, .crow.is-member, .crow.is-deep { margin-left: 0; padding-left: 0; box-shadow: none; }
  .crow.is-child .c-name, .crow.is-member .c-name { padding-left: 12px; box-shadow: inset 2px 0 0 var(--line); }
  .crow.is-deep .c-name { padding-left: 28px; box-shadow: inset 2px 0 0 var(--line), inset 16px 0 0 var(--surface), inset 18px 0 0 var(--line); }
  .c-next-v { font-size: 14px; line-height: 20px; }
  .c-pnl { grid-column: 5; }
  .c-seen { grid-column: 6; font-size: 14px; line-height: 20px; }
}

/* 전체 현황 "자세히 보기"의 클라이언트별 상세 */
.dgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.dblock { min-width: 0; padding: 12px 16px 4px; border-radius: 12px; background: var(--bg); }
.dblock-title { font-size: 14px; font-weight: 600; line-height: 20px; }
.dblock .badge { background: var(--surface); }
@media (min-width: 768px) {
  .dgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1280px) {
  .dgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .overview .fold-body > .rows { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 24px; }
  .overview .fold-body > .rows > .row { border-top: 0; }
}

/* 내 클라이언트(주인): 회원마다 작은 1단계 카드 */
.msum-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
@media (min-width: 768px) {
  .msum-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 개인 화면(c-4) ---------- */

/* 회원 고르기(회원이 둘 이상일 때. 증권 앱의 계좌 고르기 꼴): 고른 칸은 카드 바탕 + 테두리(색만으로 알리지 않는다) */
.mseg {
  display: flex;
  gap: 4px;
  min-width: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}
.mseg-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}
.mseg-btn[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.mseg-btn:focus-visible { outline-offset: -2px; }
@media (hover: hover) {
  .mseg-btn:hover { color: var(--text); }
}
@media (min-width: 768px) {
  .mseg { align-self: flex-start; max-width: 100%; }
  .mseg-btn { flex: 0 1 auto; min-width: 112px; }
}

/* 탭(증권·은행 앱 상세 화면 꼴): 1단계 요약 아래 탭 줄, 위 막대 바로 아래에 붙는다(sticky). 탭 줄은 위 막대처럼 화면 끝까지
   바탕(--bg)을 깔아 아래로 지나가는 카드를 가린다. 지금 탭은 글자색 + 놋쇠 밑줄(색만으로 알리지 않는다).
   휴대폰은 탭 셋이 폭을 똑같이 나누고(320px 에서도 한 줄), 768px 이상은 왼쪽부터 글자 폭만큼 놓는다.
   높이는 --tabrow(.tab 48 + 아래 선 1). */
.tabbox { min-width: 0; }
.tabs {
  position: sticky;
  top: calc(var(--appbar) + var(--safe-top));
  z-index: 4;
  display: flex;
  margin: 0 calc(-1 * var(--gutter));
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.tab {
  position: relative;
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: calc(var(--tabrow) - 1px);
  padding: 0 2px;
  border: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
  white-space: nowrap;
  cursor: pointer;
}
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after {
  content: '';
  position: absolute;
  right: 6px;
  bottom: -1px;
  left: 6px;
  height: 2px;
  border-radius: 2px;
  background: var(--brass);
}
.tab:focus-visible { outline-offset: -2px; }
.tab-label { position: relative; display: inline-block; }
/* 칸 안에 경고가 있는 탭: 이름 오른쪽 위의 작은 ! 표식(폭을 차지하지 않는다) */
.tab-mark {
  position: absolute;
  top: -4px;
  right: -14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--warn);
  color: var(--surface);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (hover: hover) {
  .tab:hover { color: var(--text); }
}
/* 탭 칸: 짧은 탭으로 바꿔도 탭 줄이 위에 붙은 채로 있게 한 화면 높이를 채운다(위 막대·탭 줄·아래 탭·아래 여백을 뺀 높이).
   주소창이 보였다 숨는 휴대폰은 작은 화면 높이(svh)를 쓴다(지원하지 않으면 vh) */
.tab-panels {
  min-width: 0;
  min-height: calc(100vh - var(--appbar) - var(--safe-top) - var(--tabrow) - var(--tabbar) - var(--safe-bottom) - 24px);
  min-height: calc(100svh - var(--appbar) - var(--safe-top) - var(--tabrow) - var(--tabbar) - var(--safe-bottom) - 24px);
  padding-top: var(--gap);
}
/* 탭 칸 하나 = 폭을 재는 상자(container). 안의 배치는 칸 폭으로 정한다(화면 폭이 아니다: PC 오른쪽 칸이 생겨도 맞는다).
   칸 안은 덩어리(.pcols. 일별은 소스마다 하나)를 세로로 쌓는다 */
.tab-panel { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; container-type: inline-size; }
.tab-panel:focus-visible { outline-offset: 4px; }
.side-title { display: none; }
/* 좁은 칸: 한 열. 두 칸의 카드를 .ord-n 순서로 섞는다(휴대폰 순서 = 중요한 것 먼저) */
.pcols { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.pcol { display: contents; }
.ord-1 { order: 1; }
.ord-2 { order: 2; }
.ord-3 { order: 3; }
.ord-4 { order: 4; }
/* 넓은 칸(700px 이상): 왼쪽 큰 칸 7 : 오른쪽 작은 칸 5. 칸마다 세로로 쌓아 한쪽 접힘을 열어도 옆 칸에 빈자리가 생기지 않는다.
   일별은 목록에 열이 다섯이라 800px 이상일 때만 두 칸이다(그보다 좁으면 목록 아래에 합계) */
@container (min-width: 700px) {
  .pcols { flex-direction: row; align-items: flex-start; }
  .pcol { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
  .pcol-main { flex: 7 1 0; }
  .pcol-side { flex: 5 1 0; }
  .pcol:empty { display: none; }
}
@container (min-width: 700px) and (max-width: 799.98px) {
  .pcols.is-daily { flex-direction: column; align-items: stretch; }
  .pcols.is-daily > .pcol { display: contents; }
}
@media (min-width: 768px) {
  .tabs { gap: 4px; }
  .tab { flex: none; padding: 0 var(--pad); }
}
/* PC(1024px 이상): 탭 줄은 내용 폭(첫 탭 글자가 카드 글자와 같은 선) */
@media (min-width: 1024px) {
  .tabs { margin: 0; padding: 0; }
}
/* PC(1280px 이상): 봇·상태는 탭이 아니라 오른쪽 칸(360px)에 늘 보인다. 왼쪽은 일별·인센티브 탭.
   오른쪽 칸 머리(봇·상태)는 탭 줄과 같은 높이·선. 이 기준은 instance.js 의 WIDE 와 같다 */
@media (min-width: 1280px) {
  .tabbox {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-rows: auto 1fr;
    column-gap: var(--gap);
    align-items: start;
  }
  .tabs { grid-column: 1; grid-row: 1; }
  .tab-panels { display: contents; }
  /* 짧은 탭으로 바꿔도 탭 줄이 붙은 채로 있게 왼쪽 칸이 한 화면 높이를 채운다 */
  .tab-panel {
    grid-column: 1;
    grid-row: 2;
    min-height: calc(100vh - var(--appbar) - var(--safe-top) - var(--tabrow) - 24px);
    padding-top: var(--gap);
  }
  #panel-status { grid-column: 2; grid-row: 1 / span 2; min-height: 0; padding-top: 0; }
  #tab-status { display: none; }
  .side-title {
    display: flex;
    align-items: center;
    min-height: var(--tabrow);
    border-bottom: 1px solid var(--line);
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
  }
}

.today-none { padding: 4px 0 8px; color: var(--muted); font-size: 14px; }

/* 일별 목록: 열 머리 + 행. 열 폭은 목록 전체가 한 번 정한다(subgrid: 금액이 긴 행이 있어도 숫자 줄이 맞는다).
   좁은 카드는 날짜·거래대금·손익 세 칸과 처음 5행, 560px 이상은 체결·수수료 칸이 더 보이고 처음 7행 */
.daily-card, .month-card { container-type: inline-size; }
.dlist {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto 12px;
  column-gap: 12px;
  min-width: 0;
}
.dhead, .ditem, .drow {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) minmax(5.5em, auto) minmax(4.5em, auto) 12px;
  grid-template-columns: subgrid;
  min-width: 0;
}
@supports not (grid-template-columns: subgrid) {
  .dhead, .drow { column-gap: 12px; }
}
.dhead {
  padding: 0 0 6px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}
.ditem { border-top: 1px solid var(--line); }
.dhead + .ditem { border-top: 0; }
.drow {
  align-items: center;
  min-height: 44px;
  padding: 6px 0;
  font-size: 16px;
  line-height: 24px;
  cursor: pointer;
}
.d-date { min-width: 0; }
.d-date-in { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.d-amt, .d-trades, .d-fee, .d-pnl { text-align: right; }
.d-trades, .d-fee { display: none; }
.ditem.is-total .drow { font-weight: 600; }
.ditem.is-wide-row { display: none; }
.dlist.is-open > .ditem.is-wide-row { display: grid; }
.d-detail { grid-column: 1 / -1; padding: 0 0 8px; }
.d-detail .row { min-height: 32px; padding: 4px 0; }
.d-detail .row-v { font-size: 14px; line-height: 20px; }
.chev-down {
  justify-self: end;
  width: 8px;
  height: 8px;
  margin: -4px 2px 0 0;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
}
[aria-expanded="true"] > .chev-down,
[aria-expanded="true"] .chev-down { margin-top: 4px; transform: rotate(-135deg); }
@media (max-width: 359px) {
  .drow { font-size: 14px; line-height: 20px; }
  .dlist { column-gap: 8px; }
}
@container (min-width: 560px) {
  .dlist { grid-template-columns: minmax(0, 1fr) auto auto auto auto 12px; column-gap: 24px; }
  .d-trades, .d-fee { display: block; }
  .ditem.is-wide-row { display: grid; }
  .more-btn.is-narrow-only { display: none; }
}

/* 이번 달 합계: 좁으면 이름—값 행, 넓은 카드(560px 이상)면 숫자 칸(이름 위·값 아래)을 글자 폭대로 한 줄에(넘치면 다음 줄) */
@container (min-width: 560px) {
  .month-card .rows { display: flex; flex-wrap: wrap; gap: 8px 40px; }
  .month-card .row {
    flex: 0 0 auto;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-start;
    min-height: 0;
    padding: 0;
    border-top: 0;
  }
  .month-card .row-v { margin-left: 0; font-weight: 600; text-align: left; }
}

.btn.more-btn { width: 100%; margin-top: 8px; }

.tmini { min-width: 0; }
.tmini + .tmini { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.tmini-name { font-size: 14px; font-weight: 600; line-height: 20px; }
.tmini-now { font-size: 14px; line-height: 20px; }
.tmini-k { color: var(--muted); }
.tmini-goal { color: var(--muted); }

.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin-top: 12px;
  padding: 8px 16px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.link-text { display: flex; flex-direction: column; min-width: 0; }
.link-main { font-size: 14px; font-weight: 600; line-height: 20px; }
.link-sub { color: var(--muted); font-size: 12px; line-height: 16px; }
.ext-icon { flex: none; color: var(--muted); }

.seg { margin-top: 12px; padding: 8px 12px 0; border-radius: 12px; background: var(--bg); }
.seg-name { font-size: 12px; font-weight: 600; line-height: 16px; }
.seg .row { border-top-color: var(--line); }

.evlist { min-width: 0; }
.ev { display: flex; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; line-height: 20px; }
.evlist > .ev:first-child { border-top: 0; }
.ev-time { flex: none; min-width: 3.4em; color: var(--muted); font-size: 12px; }
.ev-text { flex: 1 1 auto; min-width: 0; }
.ev-acc { margin-right: 6px; color: var(--muted); font-size: 12px; }
.ev-count { color: var(--muted); }

/* ---------- 목표(c-5) ---------- */

.tgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); align-items: start; }
@media (min-width: 768px) {
  .tgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1280px) {
  .tgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.t-name { font-size: 16px; line-height: 24px; }
.t-now { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 4px; }
.t-now-v { font-size: 20px; font-weight: 600; line-height: 28px; }
.t-goal { color: var(--muted); font-size: 14px; }
.t-top .rows .row:first-child { border-top: 0; }
.tcard > .rows { border-top: 1px solid var(--line); }
.th-title { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.th-list { margin-top: 0; }
.tcard .fold.inline { margin-top: 4px; }
.tcard .fold.inline + .th-title { margin-top: 0; }
.th-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.th-list > .th-row:first-child { border-top: 0; }
.th-k { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; min-width: 0; }
.th-amt { font-size: 16px; font-weight: 600; line-height: 24px; }
.th-label { color: var(--muted); font-size: 14px; line-height: 20px; }
.th-v { margin-left: auto; font-size: 14px; line-height: 20px; text-align: right; }
.th-row.is-done { color: var(--muted); }

/* ---------- 알림(c-6) ---------- */

@media (min-width: 1024px) {
  .view.alerts { max-width: 800px; }
}
.alist { min-width: 0; }
.aitem { border-top: 1px solid var(--line); }
.alist > .aitem:first-child { border-top: 0; }
.arow { display: block; min-height: 64px; padding: 10px 0; cursor: pointer; }
.a-line1 { display: flex; align-items: center; gap: 8px; }
.a-kind { display: flex; flex: 1 1 auto; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-width: 0; font-size: 16px; font-weight: 600; line-height: 24px; }
.a-time { color: var(--muted); font-size: 14px; line-height: 20px; }
.a-line1 .chev-down { flex: none; margin-left: 4px; }
.a-subject { display: block; overflow: hidden; color: var(--muted); font-size: 14px; line-height: 20px; white-space: nowrap; text-overflow: ellipsis; }
.a-detail { padding: 0 0 12px; }
.a-text { padding: 12px; border-radius: 12px; background: var(--bg); font-size: 14px; line-height: 20px; white-space: pre-wrap; }
.a-reason { padding: 4px 0; color: var(--muted); font-size: 14px; line-height: 20px; }
.a-detail .row { min-height: 32px; padding: 4px 0; }
.a-detail .row-v { font-size: 14px; line-height: 20px; }

/* ---------- 그래프(b-12) ---------- */

.chart { display: block; min-width: 0; margin: 0; cursor: pointer; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; color: var(--muted); font-size: 12px; line-height: 16px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-bar { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--muted); }
.legend-line { display: inline-block; width: 14px; height: 2px; border-radius: 1px; background: var(--text); }
.legend-line.line-gain { background: var(--gain); }
.legend-line.line-loss { background: var(--loss); }
.chart-svg { display: block; width: 100%; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-bar { fill: var(--muted); opacity: 0.55; }
.chart-bar.chart-sel { fill: var(--text); opacity: 1; }
.chart-line { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-line.line-gain { stroke: var(--gain); }
.chart-line.line-loss { stroke: var(--loss); }
.chart-zero { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-base { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-family: var(--font-body); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 140px;
  color: var(--muted);
  font-size: 14px;
}
.chart-tip { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; min-height: 24px; margin-top: 4px; font-size: 14px; line-height: 20px; }
.tip-day { color: var(--muted); }
.tip-item { white-space: nowrap; }
.tip-k { margin-right: 4px; color: var(--muted); }

/* ---------- 입력·단추(b-14) ---------- */

.form { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 400px; margin: 16px auto 0; }
.form-title { font-size: 20px; font-weight: 600; line-height: 28px; }
.form-lead { font-size: 14px; line-height: 20px; }
.form-rule { margin-top: -8px; color: var(--muted); font-size: 12px; line-height: 16px; }
.field .form-rule { margin-top: 0; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { color: var(--muted); font-size: 14px; line-height: 20px; }
.input {
  width: 100%;
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--muted);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.input:focus { outline: 2px solid var(--brass); outline-offset: 1px; }
.form-msg { min-height: 20px; font-size: 14px; line-height: 20px; }
.form-msg:empty { display: none; }
.form-msg.tone-warn { color: var(--warn); }
.form-msg.tone-ok { color: var(--ok); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--muted);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  text-decoration: none;
  cursor: pointer;
}
.btn-quiet { border-color: var(--line); }
.btn-strong {
  width: 100%;
  min-height: 48px;
  border: 0;
  background: var(--text);
  color: var(--bg);
  font-size: 16px;
}
.btn:disabled { cursor: default; opacity: 0.6; }
@media (min-width: 768px) {
  .form { margin-top: 64px; }
}
@media (min-width: 1024px) {
  .form { margin-top: 96px; }
}

/* ---------- 불러오는 중·빈 화면·오류(b-13) ---------- */

.loading {
  padding: 48px 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  animation: dx-appear 0s linear 0.3s both;
}
@keyframes dx-appear {
  from { visibility: hidden; }
  to { visibility: visible; }
}
.state-box { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 48px 0; text-align: center; }
.state-box .empty { padding: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
