/* ui.css — 공통 부품 스타일 (c- 접두사, 토큰만 사용) */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.5 "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; word-break: keep-all; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-d); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ── 셸 ── */
.c-app { display: flex; align-items: flex-start; min-height: 100vh; }
.c-side { width: var(--side); flex: none; position: sticky; left: 0; top: 0; height: 100vh; background: var(--card); padding: var(--s5) var(--s3); display: flex; flex-direction: column; gap: var(--s1); z-index: 5; }
.c-brand { padding: 0 var(--s4) var(--s4); font-size: 17px; font-weight: 800; color: var(--brand); }
.c-nv { display: flex; align-items: center; height: 44px; padding: 0 var(--s4); border-radius: var(--r2); font-weight: 600; color: var(--sub); }
.c-nv:hover { background: var(--bg); color: var(--sub); }
.c-nv.on { background: var(--brand-l); color: var(--brand-d); }
.c-bell { color: var(--red); }
.c-bell:hover { color: var(--red); }
.c-phoneacts { display: flex; align-items: center; gap: var(--s1); }
.c-who { margin-top: auto; padding: 0 var(--s4); font-size: 12px; color: var(--sub); }
.c-main { flex: 1; min-width: 1628px; padding: var(--pad); }
.c-body { flex: 1; min-width: 0; }
.c-phonehead, .c-tabbar, .c-fab { display: none; }
.c-banner { flex: none; background: var(--brand-l); color: var(--brand-d); font-size: 13px; font-weight: 600; padding: var(--s2) var(--s4); }

/* ── 버튼/칩/입력 ── */
.c-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); height: var(--ctl); padding: 0 var(--s4); border-radius: var(--r2); border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
@media (pointer: coarse) { .c-btn { font-size: 15px; } }
.c-btn:hover { background: var(--bg); }
.c-btn:active { background: var(--line); transform: translateY(1px); }
.c-btn:disabled { opacity: .4; cursor: not-allowed; }
.c-btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
.c-btn.pri:hover, .c-btn.pri:active { background: var(--brand-d); border-color: var(--brand-d); }
.c-btn.quiet { border-color: transparent; background: transparent; color: var(--sub); }
.c-btn.quiet:hover { background: var(--bg); }
.c-btn.block { width: 100%; }
.c-chip { display: inline-flex; align-items: center; gap: var(--s2); height: var(--ctl); padding: 0 var(--s3); border-radius: var(--r4); border: 0; background: var(--bg); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; flex: none; }
.c-chip:hover { background: var(--line); }
.c-chip.on { background: var(--brand-l); color: var(--brand-d); }
.c-in { height: var(--ctl); width: 100%; padding: 0 var(--s3); border-radius: var(--r2); border: 1px solid transparent; background: var(--bg); font-size: 13px; }
@media (pointer: coarse) { .c-in { font-size: 15px; } }
.c-in:hover { background: var(--line); }
.c-in:focus { background: var(--card); border-color: var(--brand); outline: none; }
.c-sel { width: auto; min-width: 160px; background: var(--card); }
.c-lbl { display: block; margin-bottom: var(--s1); font-size: 13px; font-weight: 600; color: var(--sub); }
.c-dot { display: inline-block; width: 8px; height: 8px; border-radius: var(--r4); flex: none; }
.c-dot.blu { background: var(--blu); }
.c-dot.org { background: var(--org); }
.c-dot.grn { background: var(--grn); }
.c-dot.red { background: var(--red); }
.c-dot.sub { background: var(--sub); }

/* ── 카드(고정 폭) ── */
.c-card { background: var(--card); border-radius: var(--r3); padding: var(--s5); min-width: 0; position: relative; }
.c-card.flush { padding: 0; overflow: hidden; }
.c1 { width: var(--w1); }
.c2 { width: var(--w2); }
.c3 { width: var(--w3); }
.c4 { width: var(--w4); }
.c-wrap { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: flex-start; }
.c-col { display: flex; flex-direction: column; gap: var(--gap); }

/* ── 화면 머리 ── */
.c-head { width: var(--w4); display: flex; justify-content: space-between; align-items: center; gap: var(--s4); }
.c-head .acts { display: flex; gap: var(--s2); align-items: center; }
.c-scope { margin-top: var(--s2); font-size: 13px; color: var(--sub); display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }

/* ── 목록 행 ── */
.c-row { display: block; padding: var(--s3) var(--s4); border-left: 4px solid transparent; background: var(--card); min-height: 44px; color: var(--ink); cursor: pointer; }
.c-row:hover { background: var(--bg); color: var(--ink); }
.c-row.o { border-left-color: var(--org); }
.c-row.r { border-left-color: var(--red); }
.c-row .l1 { display: flex; justify-content: space-between; gap: var(--s2); font-size: 15px; font-weight: 600; }
.c-row .l1 span:last-child { font-size: 13px; white-space: nowrap; }
.c-row .l2 { margin-top: var(--s1); font-size: 12px; color: var(--sub); display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap; }

/* ── 홈 ── */
.hv { display: flex; gap: var(--gap); margin-top: var(--gap); align-items: flex-start; }
.hl { width: var(--w3); flex: none; display: flex; flex-wrap: wrap; gap: var(--gap); align-items: flex-start; }
.hr { width: var(--w1); flex: none; display: flex; flex-direction: column; gap: var(--gap); }
.ed { outline: 2px dashed var(--brand); }
.wtool { position: absolute; top: var(--s2); right: var(--s2); z-index: 2; display: flex; gap: var(--s1); }
.kpi .t { font-size: 15px; font-weight: 600; color: var(--sub); }
.kpi .v { display: flex; align-items: baseline; gap: var(--s1); margin-top: var(--s2); }
.kpi .v b { font-size: 36px; font-weight: 800; line-height: 1.1; }
.kpi .v i { font-size: 17px; font-weight: 600; font-style: normal; }
.kpi .d { margin-top: var(--s2); font-size: 13px; font-weight: 600; }
.kpi .m { font-size: 12px; color: var(--sub); }
.hero { padding: var(--s5) var(--s5) 0; }
.hero h4, .c-card h4 { margin: 0; font-size: 17px; font-weight: 800; }
.hero .n { display: flex; align-items: baseline; gap: var(--s1); }
.hero .n b { font-size: 36px; font-weight: 800; line-height: 1.1; }
.hero .n i { font-size: 17px; font-weight: 600; font-style: normal; }
.hchips { display: flex; gap: var(--s2); margin: var(--s3) 0; overflow-x: auto; }
.hmore { padding: var(--s3) var(--s5) var(--s5); }
.hnone { padding: var(--s3) var(--s5) var(--s5); font-size: 13px; color: var(--sub); }
.unm { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); }
.unm .t { font-size: 15px; font-weight: 600; color: var(--sub); }
.unm .v { display: flex; align-items: baseline; gap: var(--s1); margin-top: var(--s1); }
.unm .v b { font-size: 28px; font-weight: 800; line-height: 1.2; }
.unm .v i { font-size: 17px; font-weight: 600; font-style: normal; }
.sec-t { display: flex; align-items: baseline; gap: var(--s3); margin-bottom: var(--s3); flex-wrap: wrap; }
.sec-t small { font-size: 12px; color: var(--sub); font-weight: 400; }
.fmt { width: 100%; border-collapse: collapse; table-layout: fixed; }
.fmt th, .fmt td { font-weight: 400; }
.fmt thead th { font-size: 12px; font-weight: 600; color: var(--sub); text-align: right; padding: 0 var(--s1) var(--s2); vertical-align: bottom; cursor: pointer; }
.fmt thead th.rl { width: 80px; cursor: default; }
.fmt thead th em { display: block; font-style: normal; color: var(--red); font-weight: 600; }
.fmt tbody th { text-align: left; padding: var(--s3) 0; border-top: 1px solid var(--line); font-size: 13px; font-weight: 600; vertical-align: top; }
.fmt tbody th small { display: block; font-size: 12px; font-weight: 400; color: var(--sub); }
.fmt td { text-align: right; padding: var(--s3) var(--s1); border-top: 1px solid var(--line); vertical-align: top; cursor: pointer; }
.fmt td b { display: block; font-size: 15px; font-weight: 600; }
.fmt td span { display: block; font-size: 12px; }
.fmt td.z { color: var(--sub); opacity: .4; cursor: default; }
.fscroll { overflow-x: auto; }
.pts { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s3); }
.pt { background: var(--bg); border-radius: var(--r2); padding: var(--s3); cursor: pointer; }
.pt .n { font-size: 13px; font-weight: 600; }
.pt .tot { display: flex; align-items: baseline; gap: var(--s1); }
.pt .tot b { font-size: 17px; font-weight: 800; }
.pt .tot i { font-size: 12px; font-style: normal; color: var(--sub); }
.bars { display: flex; align-items: flex-end; gap: var(--s1); height: 40px; margin: var(--s2) 0 var(--s1); }
.bars span { flex: 1; background: var(--brand); border-radius: var(--r1) var(--r1) 0 0; }
.bars span.z { background: var(--line); }
.pt .w { height: 20px; font-size: 12px; font-weight: 600; color: var(--red); }

/* ── 빈 상태/스켈레톤/토스트 ── */
.c-empty { padding: var(--s8) var(--s5); text-align: center; color: var(--sub); }
.c-state { padding: var(--s8) var(--s5); text-align: center; }
.c-state .t { font-size: 17px; font-weight: 800; }
.c-state .d { margin-top: var(--s1); font-size: 13px; font-weight: 400; color: var(--sub); overflow-wrap: anywhere; }
.c-state .a { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.c-skel { background: var(--line); border-radius: var(--r3); animation: skel 1.2s ease-in-out infinite alternate; }
.c-skel.sk-s { height: 40px; }
.c-skel.sk-m { height: 120px; }
.c-skel.sk-l { height: 240px; }
.c-route-skel { margin-top: var(--s5); }
@keyframes skel { from { opacity: .5; } to { opacity: 1; } }
#toast { position: fixed; left: 50%; bottom: var(--s8); transform: translateX(-50%); background: var(--ink); color: #fff; padding: var(--s3) var(--s5); border-radius: var(--r2); font-size: 13px; opacity: 0; pointer-events: none; z-index: 30; }
#toast.on { opacity: 1; }
#toast.bad { background: var(--red); }
.c-login { max-width: var(--w1); margin: 96px auto; }
.c-login .f { margin-top: var(--s3); }
.c-login .err { min-height: 20px; margin: var(--s2) 0; color: var(--red); font-size: 13px; }

/* ── 휴대폰 (입력 방식 기준) ── */
@media (max-width: 760px) and (pointer: coarse) {
  .c-app { display: block; height: 100dvh; overflow: hidden; }
  .c-side { display: none; }
  .c-phone { display: flex; flex-direction: column; height: 100dvh; }
  .c-phonehead { display: flex; justify-content: space-between; align-items: center; padding: var(--s3) var(--s4) var(--s1); flex: none; }
  .c-phoneacts .c-btn { min-width: var(--ctl); min-height: var(--ctl); padding-inline: var(--s2); font-size: 13px; }
  .c-phoneacts .c-bell { color: var(--red); }
  .c-main { min-width: 0; flex: 1; overflow-y: auto; padding: 0 var(--s4) 96px; }
  .c-tabbar { display: flex; height: var(--tabbar); flex: none; background: var(--card); }
  .c-tabbar a { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: var(--sub); border-top: 3px solid transparent; }
  .c-tabbar a.on { color: var(--brand); border-top-color: var(--brand); }
  .c-fab { display: inline-flex; align-items: center; position: fixed; right: var(--s4); bottom: calc(var(--tabbar) + var(--s4)); height: 48px; padding: 0 var(--s5); border-radius: var(--r4); border: 0; background: var(--brand); color: #fff; font-size: 15px; font-weight: 600; box-shadow: 0 4px 12px rgba(20, 38, 42, .25); z-index: 10; }
  .c-fab:hover { background: var(--brand-d); color: #fff; }
  .c-head { display: none; }
  .c-card { padding: var(--s4); }
  .c1, .c2, .c3, .c4 { width: auto; }
  .hv { flex-direction: column; gap: var(--s3); margin-top: var(--s3); }
  .hl { width: auto; display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
  .hl > .c3, .hl > .c4 { grid-column: span 2; }
  .hl > .k3 { grid-column: span 2; }
  .hr { order: -1; width: auto; gap: var(--s3); }
  .hero { padding: var(--s4) var(--s4) 0; }
  .hchips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: visible; }
  .hchips .c-chip { justify-content: center; min-width: 0; padding-inline: var(--s1); gap: var(--s1); }
  .hmore, .hnone { padding: var(--s3) var(--s4) var(--s4); }
  .kpi .t { font-size: 13px; }
  .kpi .v b { font-size: 28px; line-height: 1.2; }
  .kpi .v i, .hero .n i, .unm .v i { font-size: 15px; }
  .kpi .d { margin-top: var(--s1); }
  .c-route-skel { margin-top: var(--s3); }
  .fmt { min-width: 640px; }
  .fmt thead th.rl { width: 72px; }
  .pts { grid-template-columns: 1fr 1fr; gap: var(--s2); }
  .bars { height: 32px; }
}

/* ── 정보 툴팁 ── */
.c-info { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: var(--r4); border: 1px solid var(--sub); color: var(--sub); font-size: 12px; font-weight: 600; font-style: normal; cursor: help; flex: none; }
.c-info:hover, .c-info:focus-visible { background: var(--brand-l); border-color: var(--brand); color: var(--brand-d); }
.c-info::after { content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); width: max-content; max-width: 320px; padding: var(--s2) var(--s3); border-radius: var(--r2); background: var(--ink); color: #fff; font-size: 12px; font-weight: 400; line-height: 1.5; text-align: left; white-space: normal; opacity: 0; visibility: hidden; pointer-events: none; z-index: 15; }
.c-info:hover::after, .c-info:focus::after { opacity: 1; visibility: visible; }
.c-side .c-sidebtns { margin-top: auto; display: flex; flex-direction: column; gap: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line); }
.c-side .c-sidebtns .c-btn { justify-content: flex-start; height: 44px; }
.c-side #sbs { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; }
.c-sidescope { font-size: 12px; font-weight: 400; color: var(--sub); }
.c-side .c-who { margin-top: var(--s2); padding-bottom: var(--s2); }

.ins-qr { width: 220px; margin: var(--s3) auto; }
.ins-qr svg { width: 100%; height: auto; display: block; }
.ins-bar { padding: var(--s3) 0 0; border: 0; }

/* ── 탭/분할/모달/표/폼 ── */
.c-tabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--line); }
.c-tab { height: 44px; padding: 0 var(--s4); display: inline-flex; align-items: center; border-bottom: 3px solid transparent; font-size: 15px; font-weight: 600; color: var(--sub); cursor: pointer; white-space: nowrap; flex: none; background: none; border-top: 0; border-left: 0; border-right: 0; }
.c-tab:hover { color: var(--ink); }
.c-tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.c-seg { display: inline-flex; background: var(--bg); border-radius: var(--r2); padding: var(--s1); gap: var(--s1); }
.c-seg button { height: var(--ctl); padding: 0 var(--s4); border: 0; border-radius: var(--r1); background: transparent; font-size: 13px; font-weight: 600; color: var(--sub); cursor: pointer; }
.c-seg button:hover { background: var(--line); }
.c-seg button.on { background: var(--card); color: var(--brand); }
.c-modal { position: fixed; inset: 0; background: rgba(20, 38, 42, .45); display: flex; align-items: center; justify-content: center; z-index: 20; padding: var(--s4); }
.c-modal .box { background: var(--card); border-radius: var(--r3); padding: var(--s5); width: var(--w1); max-width: 100%; max-height: 90vh; overflow-y: auto; }
.c-modal .box.wide { width: var(--w2); }
.c-bar { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: var(--s3) var(--s5); border-top: 1px solid var(--line); background: var(--card); }
.c-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); }
.c-tbl { width: 100%; border-collapse: collapse; }
.c-tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--sub); padding: var(--s2) var(--s2); }
.c-tbl td { font-size: 13px; padding: var(--s2); border-top: 1px solid var(--line); }
.c-tbl .r { text-align: right; }
.v-narrow { max-width: var(--w2); }
@media (max-width: 760px) and (pointer: coarse) { .c-grid3 { grid-template-columns: 1fr; } .c-bar { position: sticky; bottom: 0; padding: var(--s3) var(--s4); } }

b, strong { font-weight: 800; }

.c-refresh { width: var(--ctl); padding: 0; color: var(--sub); }
.c-refresh svg { display: block; }
.c-refresh.spin svg { animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 폰: 하단 바 고정 (문서 스크롤/튕김 차단) ── */
@media (max-width: 760px) and (pointer: coarse) {
  html:has(.c-app), body:has(.c-app) { height: 100%; overflow: hidden; overscroll-behavior: none; }
  .c-app { position: fixed; top: var(--vvt, 0px); left: 0; right: 0; bottom: auto; height: var(--vvh, 100%); overflow: hidden; }
  .c-phone { height: 100%; }
  .c-main { overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; }
  .c-tabbar { padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
}

.c-leave { display: flex; flex-direction: column; gap: var(--s2); }
.c-leave .c-btn { width: 100%; }

/* ── 폰: 문서 스크롤 + 화면 하단 고정 탭바 (높이 계산 없음) ── */
@media (max-width: 760px) and (pointer: coarse) {
  html, body, html:has(.c-app), body:has(.c-app) { height: auto; overflow: visible; overscroll-behavior-y: none; }
  body { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  html { scroll-padding-top: 72px; scroll-padding-bottom: 120px; }
  .c-app { position: static; display: block; height: auto; min-height: 100vh; overflow: visible; }
  .c-phone { display: block; height: auto; }
  .c-main { overflow: visible; padding: 0 var(--s4) calc(var(--tabbar) + var(--s8) + env(safe-area-inset-bottom)); }
  .c-phonehead { position: sticky; top: 0; z-index: 6; background: var(--bg); }
  .c-tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); }
  .c-fab { bottom: calc(var(--tabbar) + var(--s4) + env(safe-area-inset-bottom)); }
  input, select, textarea, .c-in { font-size: 17px !important; }
}

@media (pointer: coarse) {
  .c-info { font-size: 0; width: var(--ctl); height: var(--ctl); border: 0; background: transparent; margin: calc(var(--s2) * -1); }
  .c-info::before { content: "i"; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: var(--r4); border: 1px solid var(--sub); }
  .c-info.open::after { position: fixed; left: var(--s4); right: var(--s4); top: var(--tt, 80px); transform: none; width: auto; max-width: none; opacity: 1; visibility: visible; }
}
