/* 주식 투자 매니저 (임시 이름) — 1차 조회 전용 화면 */
:root {
  --bg: #0b1220;
  --bg-2: #101827;
  --surface: #161f33;
  --surface-2: #1c2740;
  --line: #2a3654;
  --text: #f3f6fd;
  --muted: #8b97b0;
  --gold: #e0b84a;
  --gold-dim: rgba(224, 184, 74, 0.16);
  --up: #ff5a5a;
  --down: #4d8eff;
  --ok: #3dd68c;
  --warn: #f5a524;
  --radius: 16px;
  --nav-h: 64px;
  --top-h: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", Pretendard, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100%; }
html { height: 100%; }
body { min-height: 100%; min-height: 100dvh; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--gold); text-decoration: none; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }

#update-bar {
  position: sticky; top: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 8px 16px; padding-top: calc(8px + var(--safe-t));
  background: #3a2a0a; color: #ffe9b0; font-size: 13px;
}
#update-bar button {
  background: var(--gold); color: #1a1404; border-radius: 999px;
  padding: 4px 12px; font-weight: 700; font-size: 13px;
}

/* ----- login ----- */
.login {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b));
}
.login-mark {
  width: 72px; height: 72px; border-radius: 18px; margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.login h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.03em; }
.login .sub { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.login-card {
  width: 100%; max-width: 380px; margin-top: 28px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 20px;
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); }
.field input {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; width: 100%;
}
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 4px 0 16px; }
.btn-primary {
  width: 100%; background: var(--gold); color: #1a1404;
  font-weight: 800; border-radius: 12px; padding: 14px; font-size: 16px;
}
.btn-primary:active { transform: scale(0.99); }
.hint { margin: 14px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.notice {
  max-width: 380px; width: 100%; margin-top: 16px;
  background: var(--gold-dim); color: #f3e3b0; border-radius: 12px;
  padding: 10px 12px; font-size: 12px; line-height: 1.5;
}

/* ----- app shell ----- */
#app { min-height: 100dvh; display: flex; flex-direction: column; }
.app-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  min-height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) 16px 0;
  background: rgba(11,18,32,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.app-header h1 { flex: 1; margin: 0; font-size: 17px; font-weight: 700; }
.back-btn, .icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; color: var(--text);
  background: transparent;
}
.pill {
  font-size: 11px; font-weight: 700; letter-spacing: 0;
  background: var(--gold-dim); color: var(--gold);
  border-radius: 999px; padding: 4px 8px; white-space: nowrap;
}
.fake-banner {
  background: #2a1d08; color: #f0d48a; font-size: 12px;
  text-align: center; padding: 6px 12px; border-bottom: 1px solid #3d2c10;
}
main {
  flex: 1;
  padding: 12px 16px calc(var(--nav-h) + var(--safe-b) + 16px);
  width: 100%; max-width: 760px; margin: 0 auto;
}

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(16,24,39,.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.bottom-nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: 11px; min-height: 44px;
}
.bottom-nav button .ico { font-size: 18px; line-height: 1; }
.bottom-nav button.active { color: var(--gold); font-weight: 700; }

/* ----- cards & lists ----- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card h2, .section-title {
  margin: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.summary-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 12px; }
.summary-card .label { font-size: 12px; color: var(--muted); }
.summary-card .value { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -0.03em; }
.summary-card .sub { font-size: 13px; margin-top: 4px; }

.hold-item, .list-item, .alert-item, .news-item, .rule-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-top: 1px solid var(--line);
  width: 100%; text-align: left; background: none; color: inherit;
}
.hold-item:first-child, .list-item:first-child, .news-item:first-child, .alert-item:first-child, .rule-item:first-child { border-top: 0; padding-top: 0; }
.hold-item:last-child, .list-item:last-child, .news-item:last-child { padding-bottom: 0; }
.hold-item .meta, .grow { flex: 1; min-width: 0; }
.name { font-weight: 700; font-size: 15px; }
.code, .muted { color: var(--muted); font-size: 12px; }
.right { text-align: right; }
.price { font-weight: 700; font-size: 15px; }

.index-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.index-chip {
  flex: 0 0 auto; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; min-width: 132px;
}
.index-chip .name { font-size: 12px; color: var(--muted); font-weight: 600; }
.index-chip .value { font-size: 16px; font-weight: 800; margin-top: 2px; }

/* stock detail */
.detail-head .name { font-size: 20px; }
.detail-head .price { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; margin: 6px 0 2px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 15px; font-weight: 700; margin-top: 2px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; }
.tabs button {
  flex: 0 0 auto; padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: 13px; min-height: 36px;
}
.tabs button.active { background: var(--gold-dim); color: var(--gold); font-weight: 700; }
.chart-wrap { height: 200px; position: relative; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.btn-ghost {
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 12px; padding: 12px; font-weight: 700; min-height: 44px;
}
.btn-ghost.on { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }
.book { display: grid; grid-template-columns: 1fr auto 1fr; gap: 4px 8px; font-size: 13px; }
.book .ask { color: var(--down); text-align: right; }
.book .bid { color: var(--up); }
.book .mid { text-align: center; font-weight: 700; }
.collapse-btn { width: 100%; text-align: left; color: var(--muted); font-size: 13px; padding: 4px 0 8px; }

/* finder / alerts / status */
.seg { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.seg button {
  flex: 1 0 auto; padding: 8px 10px; border-radius: 10px; min-height: 40px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 13px;
}
.seg button.active { color: var(--gold); border-color: var(--gold); background: var(--gold-dim); font-weight: 700; }
.toggle {
  width: 48px; height: 30px; border-radius: 999px; background: #2a3654; position: relative; flex: 0 0 auto;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #c5cde0; transition: transform .15s ease;
}
.toggle.on { background: #6b5420; }
.toggle.on::after { transform: translateX(18px); background: var(--gold); }
.status-dot {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px;
}
.status-dot.off { background: var(--warn); }
.status-dot.ok { background: var(--ok); }
.status-row { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; font-size: 14px; border-top: 1px solid var(--line); }
.status-row:first-of-type { border-top: 0; }
.details { font-size: 13px; color: var(--muted); }
.details[open] { color: var(--text); }
.details summary { cursor: pointer; color: var(--muted); padding: 4px 0; }

/* sheet */
#sheet-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 60;
}
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 12px 16px calc(20px + var(--safe-b));
  max-height: 70vh; overflow: auto;
}
#sheet .grab { width: 40px; height: 4px; background: #3a4866; border-radius: 4px; margin: 0 auto 12px; }
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  transform: translateX(-50%); z-index: 70;
  background: #222b40; border: 1px solid var(--line);
  color: var(--text); padding: 10px 14px; border-radius: 12px;
  font-size: 13px; max-width: 90%; box-shadow: 0 8px 24px rgba(0,0,0,.35);
}

.empty { color: var(--muted); font-size: 13px; padding: 8px 0; line-height: 1.5; }
.news-item .title { font-size: 14px; font-weight: 600; line-height: 1.4; display: block; }
.news-source { font-size: 11px; color: var(--muted); margin-top: 4px; }
.legal { font-size: 11px; color: var(--muted); line-height: 1.5; margin: 0; }

@media (min-width: 720px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .dash-split { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 12px; align-items: start; }
  .bottom-nav { left: 50%; transform: translateX(-50%); max-width: 760px; border-radius: 16px 16px 0 0; }
}

.auth-tabs { display: flex; gap: 8px; width: 100%; max-width: 380px; margin: 20px 0 0; }
.auth-tabs button {
  flex: 1; padding: 10px; border-radius: 12px 12px 0 0;
  background: var(--surface-2); color: var(--muted); font-weight: 700;
}
.auth-tabs button.active { background: var(--surface); color: var(--gold); }
.login-card { border-top-left-radius: 0; }
.form-error { color: var(--up); font-size: 13px; margin: 0 0 12px; line-height: 1.4; }
.user-chip { font-size: 12px; color: var(--muted); max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.admin-row:first-of-type { border-top: 0; }
.role-tag { font-size: 11px; border-radius: 999px; padding: 2px 8px; background: var(--gold-dim); color: var(--gold); }

.app-header .icon-btn { width: auto; min-width: 36px; padding: 0 8px; white-space: nowrap; font-size: 12px; }

/* ----- 1차 범위: 미정 자리·필터·알림 ----- */
.placeholder {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px dashed var(--warn); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px;
  background: rgba(245, 165, 36, 0.07); font-size: 13px;
}
.ph-title { font-weight: 700; }
.ph-tag {
  display: inline-block; font-size: 11px; font-weight: 800; color: #1b1300; background: var(--warn);
  border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.fake-tag { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 6px; margin-left: 4px; }
.bottom-nav button { position: relative; }
.badge {
  position: absolute; top: 6px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--up); color: #fff; font-size: 10px; font-weight: 800; line-height: 16px; text-align: center;
}
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.filter-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.filter-grid input, .filter-grid select {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 15px; width: 100%;
}
.del-btn { color: var(--muted); font-size: 12px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; margin-left: 8px; }
.rule-item .toggle { flex: none; }
.dot-new { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--up); margin-right: 6px; vertical-align: middle; }
#stock-picker button { white-space: nowrap; }
.status-row > div:first-child { flex: 0 0 auto; max-width: 45%; }
