:root {
  --ground: #F2F4F6;
  --card: #FFFFFF;
  --ink: #191F28;
  --sub: #5B6573;
  --line: #E5E8EB;
  --soft: #F2F4F6;
  --up: #2F6BEA;
  --up-ink: #1F4FB8;
  --up-bg: #EAF1FE;
  --down: #E8710A;
  --down-ink: #B4520A;
  --down-bg: #FFF1E6;
  --neutral: #9AA3AE;
  --neutral-bar: #C9CED6;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); }
body {
  font-family: 'Noto Sans KR', system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  color: var(--ink); font-size: 14px; line-height: 1.45;
  font-variant-numeric: tabular-nums; -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; }
.view {
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(env(safe-area-inset-bottom, 0px) + 96px);
  display: flex; flex-direction: column; gap: 12px;
}
.loading, .error { color: var(--sub); text-align: center; padding: 40px 0; }

/* 머리말 */
.head { display: flex; justify-content: space-between; align-items: flex-end; padding: 0 4px 4px; gap: 8px; }
.head .date { font-size: 13px; color: var(--sub); }
.head h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.3px; }
.head.back { align-items: center; justify-content: flex-start; }

/* 카드 */
.card { background: var(--card); border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
a.card, button.card { text-decoration: none; color: inherit; border: 0; text-align: left; cursor: pointer; width: 100%; }
.card .label { font-size: 14px; font-weight: 500; color: var(--sub); }
.card .title { font-size: 15px; font-weight: 700; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.muted { color: var(--sub); }
.small { font-size: 12px; }
.big { font-size: 44px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.big small { font-size: 24px; }
.mid { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.15; }
.num { font-size: 22px; font-weight: 800; }
.down { color: var(--down-ink); }
.up { color: var(--up-ink); }
.empty { color: var(--sub); font-size: 14px; padding: 4px 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid2 .card { padding: 16px; gap: 4px; }
.grid2 .name { font-size: 13px; color: var(--sub); }

/* 알림 기준 막대 */
.gauge { position: relative; height: 10px; background: var(--line); border-radius: 5px; }
.gauge .zone { position: absolute; left: 0; top: 0; bottom: 0; background: var(--up); border-radius: 5px 0 0 5px; }
.gauge .mark { position: absolute; top: -4px; width: 4px; height: 18px; margin-left: -2px; background: var(--ink); border-radius: 2px; }
.gauge-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--sub); margin-top: 6px; }
.gauge-labels .zone-label { color: var(--up-ink); font-weight: 700; }

/* 신호 비율 막대 */
.split { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--line); }
.split .u { background: var(--up); } .split .n { background: var(--neutral-bar); } .split .d { background: var(--down); }
.legend { display: flex; gap: 16px; font-size: 13px; color: #4E5968; flex-wrap: wrap; }
.legend .total { margin-left: auto; color: var(--sub); }

/* 온도 막대 */
.temp { position: relative; height: 10px; border-radius: 5px; background: var(--line); }
.temp .center { position: absolute; left: 50%; top: -3px; width: 2px; height: 16px; background: var(--neutral-bar); }
.temp .fill { position: absolute; top: 0; bottom: 0; }
.temp .fill.pos { background: var(--up); border-radius: 0 5px 5px 0; }
.temp .fill.neg { background: var(--down); border-radius: 5px 0 0 5px; }

/* 칩 */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  min-height: 34px; padding: 0 13px; border-radius: 17px; border: 1px solid #D1D6DB;
  background: var(--card); font-size: 13px; color: #4E5968; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.chip.right { margin-left: auto; }

/* 단지 선택 탭 */
.seg { display: flex; background: var(--card); border-radius: 16px; padding: 4px; gap: 4px; }
.seg button {
  flex: 1; min-height: 44px; border: 0; border-radius: 12px; background: none; font-size: 14px;
  color: var(--sub); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px;
}
.seg button[aria-pressed="true"] { background: var(--soft); color: var(--ink); font-weight: 700; }

/* 차트 */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: inherit; font-size: 10px; fill: var(--sub); }
.chart .grid { stroke: #EEF0F3; stroke-width: 1; }
.chart-note { font-size: 12px; color: var(--sub); }

/* 목록 */
.list { display: flex; flex-direction: column; }
.trade { display: grid; grid-template-columns: 64px 1fr auto; padding: 9px 0; border-bottom: 1px solid var(--soft); font-size: 14px; gap: 8px; }
.trade:last-child { border-bottom: 0; }
.trade .amt { font-weight: 700; text-align: right; }
.ind { border-bottom: 1px solid var(--soft); }
.ind:last-child { border-bottom: 0; }
.ind > button {
  width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 64px 52px; align-items: center; gap: 10px;
  padding: 11px 0; background: none; border: 0; text-align: left; cursor: pointer; min-height: 44px;
}
.ind .t { font-size: 14px; font-weight: 700; display: block; }
.ind .s { font-size: 12px; color: var(--sub); display: block; }
.ind .detail { padding: 0 0 14px; }
.badge { font-size: 12px; font-weight: 700; border-radius: 6px; padding: 4px 0; text-align: center; }
.badge.u { color: var(--up-ink); background: var(--up-bg); }
.badge.d { color: var(--down-ink); background: var(--down-bg); }
.badge.n { color: #4E5968; background: var(--soft); }
.list-card { padding: 4px 16px; gap: 0; }
.hint { font-size: 12px; color: var(--sub); text-align: center; }
.kv { display: grid; grid-template-columns: 1fr auto; padding: 9px 0; border-bottom: 1px solid var(--soft); gap: 8px; }
.kv:last-child { border-bottom: 0; }
.kv .v { font-weight: 700; }
.stale { color: var(--down-ink); font-weight: 700; }
.alerts { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.fresh-line { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--sub); padding: 2px 4px; flex-wrap: wrap; }

/* 하단 탭 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 6px max(0px, calc((100% - 480px) / 2)) calc(env(safe-area-inset-bottom, 0px) + 8px);
}
.tabbar a {
  text-decoration: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 48px; color: var(--sub); font-size: 12px;
}
.tabbar a[aria-current="page"] { color: var(--ink); font-weight: 700; }
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
