:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --card2: #f0f3f7;
  --text: #141a26;
  --sub: #5b6474;
  --mute: #8a93a3;
  --line: #e3e7ee;
  --accent: #1f8a53;
  --accent-soft: #e3f6ec;
  --on-accent: #ffffff;
  --grid: #edf0f4;
  --good: #1f8a53;  --good-soft: #e3f6ec;
  --warn: #a8690f;  --warn-soft: #fff1d9;
  --bad: #c94a3a;   --bad-soft: #fde8e4;
  --kakao: #fee500; --on-kakao: #191600;
  --google: #ffffff;
  --shadow: 0 1px 2px rgba(20, 26, 38, .06), 0 4px 14px rgba(20, 26, 38, .05);
  --r: 16px;
  --tabh: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f131a; --card: #181d27; --card2: #212836; --text: #eef1f6; --sub: #a3abba; --mute: #737c8c;
    --line: #2a3141; --accent: #3ccf85; --accent-soft: #163626; --on-accent: #06200f; --grid: #222a37;
    --good: #3ccf85; --good-soft: #163626; --warn: #f1bc62; --warn-soft: #3a2c12; --bad: #ff8a7a; --bad-soft: #3d1d19;
    --google: #eef1f6; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f131a; --card: #181d27; --card2: #212836; --text: #eef1f6; --sub: #a3abba; --mute: #737c8c;
  --line: #2a3141; --accent: #3ccf85; --accent-soft: #163626; --on-accent: #06200f; --grid: #222a37;
  --good: #3ccf85; --good-soft: #163626; --warn: #f1bc62; --warn-soft: #3a2c12; --bad: #ff8a7a; --bad-soft: #3d1d19;
  --google: #eef1f6; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard', 'Malgun Gothic', sans-serif;
  -webkit-font-smoothing: antialiased; word-break: keep-all; overflow-wrap: anywhere;
  padding-bottom: calc(var(--tabh) + env(safe-area-inset-bottom) + 16px);
}
body.login { padding-bottom: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* 상단 */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.top h1 { font-size: 21px; margin: 0; font-weight: 800; letter-spacing: -.02em; flex: 1; }
.top .upd { font-size: 12px; color: var(--mute); }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: var(--sub); }
.icon-btn:active, .icon-btn:hover { background: var(--card2); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

main { max-width: 760px; margin: 0 auto; padding: 4px 16px 0; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.card h2 { font-size: 14px; font-weight: 700; margin: 0 0 12px; color: var(--sub); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2 small { font-weight: 500; color: var(--mute); font-size: 12px; }
.sec-title { font-size: 14px; font-weight: 700; color: var(--sub); margin: 20px 4px 8px; }
.note { font-size: 12.5px; color: var(--mute); margin: 8px 2px 0; }
.empty { color: var(--mute); font-size: 14px; text-align: center; padding: 18px 0; }

/* 숫자 타일 */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.tile .k { font-size: 12.5px; color: var(--sub); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tile .v { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.tile .d { font-size: 12px; color: var(--mute); }
.tile .d .up { color: var(--good); font-weight: 700; }
.tile .d .down { color: var(--bad); font-weight: 700; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* 상태 알약 */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.mute { background: var(--card2); color: var(--sub); }

/* 목록 */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); min-height: 44px; }
.row:first-child { border-top: 0; padding-top: 2px; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { font-size: 12.5px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .r { text-align: right; flex-shrink: 0; }
.row .r .big { font-weight: 800; font-size: 16px; }
.row .r .sm { font-size: 12px; color: var(--mute); }
.emo { width: 32px; height: 32px; border-radius: 10px; background: var(--card2); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 17px; }
.thumb { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; background: var(--card2); object-fit: cover; }
.vthumb { width: 96px; aspect-ratio: 16/9; border-radius: 8px; flex-shrink: 0; background: var(--card2); object-fit: cover; }

/* 알림 목록 */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; margin-top: 8px; font-size: 14px; }
.alert:first-of-type { margin-top: 0; }
.alert.bad { background: var(--bad-soft); }
.alert.warn { background: var(--warn-soft); }
.alert b { font-weight: 700; }
.alert .ic { flex-shrink: 0; }
.allgood { display: flex; align-items: center; gap: 8px; color: var(--good); font-weight: 700; font-size: 14.5px; }

/* 로그인 수단 배지 */
.prov { display: inline-flex; align-items: center; justify-content: center; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11.5px; font-weight: 800; gap: 3px; border: 1px solid transparent; }
.prov.kakao { background: var(--kakao); color: var(--on-kakao); }
.prov.google { background: var(--google); color: #3c4043; border-color: var(--line); }
.prov.email { background: var(--card2); color: var(--sub); }
.prov.other { background: var(--accent-soft); color: var(--accent); }
.tag { font-size: 11.5px; color: var(--sub); background: var(--card2); border-radius: 6px; padding: 1px 6px; }

/* 칩 필터 */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; padding: 6px 12px; border-radius: 99px; background: var(--card); box-shadow: var(--shadow); font-size: 13px; font-weight: 600; color: var(--sub); border: 1px solid var(--line); }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.search { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); margin-bottom: 10px; }

/* 차트 */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { font-size: 10.5px; fill: var(--mute); }
.chart .gridl { stroke: var(--grid); stroke-width: 1; }
.chart .bar { fill: var(--accent); }
.chart .bar.dim { fill: color-mix(in srgb, var(--accent) 35%, var(--card2)); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart g.b:hover .bar { fill: color-mix(in srgb, var(--accent) 80%, var(--text)); }
.spark { width: 84px; height: 26px; flex-shrink: 0; }
.spark path.l { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark path.a { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: none; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 600; padding: 5px 8px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); }

/* 게이지 */
.gauges { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.gauge .k { font-size: 12.5px; color: var(--sub); font-weight: 600; display: flex; justify-content: space-between; }
.gauge .k b { color: var(--text); }
.gauge .track { height: 8px; border-radius: 99px; background: var(--card2); margin-top: 6px; overflow: hidden; }
.gauge .fill { height: 100%; border-radius: 99px; background: var(--accent); }
.gauge .fill.warn { background: var(--warn); }
.gauge .fill.bad { background: var(--bad); }

/* 표 */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 12px; color: var(--mute); font-weight: 600; padding: 0 6px 6px; }
.tbl td { padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
.tbl td.n, .tbl th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }

.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.mini { display: flex; align-items: center; gap: 6px; padding: 7px 9px; border-radius: 10px; background: var(--card2); font-size: 12.5px; min-width: 0; color: inherit; text-decoration: none; }
.mini .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--mute); }
.mini.good .dot { background: var(--good); }
.mini.warn { background: var(--warn-soft); } .mini.warn .dot { background: var(--warn); }
.mini.bad { background: var(--bad-soft); } .mini.bad .dot { background: var(--bad); }
.mini .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.mini .st { font-size: 11px; font-weight: 800; color: var(--sub); flex-shrink: 0; }
.mini.mute .nm { color: var(--mute); }
details.more summary { cursor: pointer; font-size: 13px; color: var(--accent); font-weight: 700; list-style: none; padding: 8px 0 0; }
details.more summary::-webkit-details-marker { display: none; }

.seg { display: inline-flex; background: var(--card2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: 8px; color: var(--sub); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

/* 하단 탭 */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  height: calc(var(--tabh) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 92%, transparent); border-top: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--mute); position: relative; }
.tabs button.on { color: var(--accent); }
.tabs button .badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.tabs svg.i { width: 23px; height: 23px; }

/* 로그인 */
.auth-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth { width: 100%; max-width: 380px; }
.auth .logo { width: 64px; height: 64px; border-radius: 18px; display: block; margin: 0 auto 12px; }
.auth h1 { text-align: center; font-size: 22px; margin: 0 0 4px; }
.auth p.lead { text-align: center; color: var(--sub); margin: 0 0 20px; font-size: 14px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; font-weight: 600; color: var(--sub); margin-bottom: 5px; }
.field input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 16px; }
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field input.otp { letter-spacing: .5em; text-align: center; font-size: 24px; font-weight: 800; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 13px; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 800; font-size: 15.5px; }
.btn:disabled { opacity: .55; }
.btn.ghost { background: transparent; color: var(--sub); font-weight: 600; font-size: 14px; padding: 10px; }
.msg { font-size: 13.5px; margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; }
.msg.err { background: var(--bad-soft); color: var(--bad); }
.msg.ok { background: var(--good-soft); color: var(--good); }

/* 시트 */
.sheet-bg { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; background: var(--card); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 85dvh; overflow-y: auto; }
.sheet h3 { margin: 0 0 12px; font-size: 17px; }
@media (min-width: 640px) { .sheet-bg { align-items: center; } .sheet { border-radius: 20px; } }
