/* DK 품질검사 앱 */
:root {
  --navy: #12306B;
  --navy-2: #2A4A85;
  --navy-soft: #E6ECF7;
  --navy-text: #D6DEEE;
  --ground: #F3F5F8;
  --card: #FFFFFF;
  --line: #E5E7EB;
  --line-soft: #EEF1F5;
  --text: #111827;
  --muted: #4B5563;
  --fail: #C2410C;
  --fail-bg: #FFF1E8;
  --wait: #92400E;
  --wait-bg: #FEF3C7;
  --pass: #1E40AF;
  --pass-bg: #E0E9FF;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans CJK KR", "Malgun Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ground); }
body { font-family: var(--font); color: var(--text); font-size: 15px; -webkit-font-smoothing: antialiased; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--navy); text-decoration: none; }
h1, h2, p { margin: 0; }
:focus-visible { outline: 3px solid #7FA2E6; outline-offset: 2px; }

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; background: var(--ground); }

.splash { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); min-height: 100dvh; }
.brand { font-size: 22px; font-weight: 800; color: var(--navy); letter-spacing: -0.5px; }
.splash .brand { font-size: 44px; }

/* ---------- 상단 ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line);
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px; display: flex; flex-direction: column; gap: 10px; }
.top-row { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; min-height: 36px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo b { font-size: 15px; }
.chip { font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 999px; border: none; color: var(--navy); background: var(--navy-soft); min-height: 32px; }
.chip.dark { color: #fff; background: var(--navy); }
.title { font-size: 22px; font-weight: 800; }
.count { font-size: 14px; color: var(--muted); }

.month { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; }
.month .nav { width: 44px; height: 44px; border: none; border-radius: 12px; background: transparent; display: flex; align-items: center; justify-content: center; color: var(--text); }
.month .nav:disabled { color: #C4C9D1; cursor: default; }
.month .mid { display: flex; align-items: center; justify-content: center; gap: 8px; }
.month .label { font-size: 18px; font-weight: 800; }
.tag { font-size: 12px; font-weight: 700; color: var(--navy); background: var(--navy-soft); padding: 3px 8px; border-radius: 999px; }
.to-now { height: 30px; padding: 0 10px; border: 1px solid #D1D5DB; border-radius: 999px; background: #fff; color: var(--navy); font-size: 12px; font-weight: 700; }

/* ---------- 본문 ---------- */
main { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
.sec { display: flex; flex-direction: column; gap: 10px; }
.sec-head { display: flex; justify-content: space-between; align-items: center; }
.sec-head h2 { font-size: 17px; font-weight: 700; }
.sec-head a, .sec-head .sub { font-size: 14px; }
.sec-head .sub { color: var(--muted); }
.box { background: var(--card); border-radius: 16px; padding: 16px; }
.small { font-size: 12px; color: var(--muted); }
.center { text-align: center; }
.empty { background: var(--card); border-radius: 16px; padding: 28px 16px; text-align: center; color: var(--muted); }
.group-label { font-size: 14px; font-weight: 700; color: var(--muted); margin: 4px 4px 0; }

/* KPI */
.kpi { background: var(--navy); color: #fff; border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.kpi-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.kpi-top span:first-child { font-size: 14px; color: var(--navy-text); }
.delta { font-size: 13px; font-weight: 700; background: var(--navy-2); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.big { font-size: 48px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; border-top: 1px solid var(--navy-2); padding-top: 14px; }
.kpi-grid div { display: flex; flex-direction: column; gap: 2px; }
.kpi-grid span { font-size: 12px; color: var(--navy-text); }
.kpi-grid b { font-size: 20px; }
.kpi-grid b.hot { color: #FFC9A8; }

/* 카드 */
.card { display: flex; flex-direction: column; gap: 8px; background: var(--card); border-radius: 16px; padding: 16px; color: var(--text); width: 100%; border: none; text-align: left; }
.card:active, .row-link:active { background: #F7F8FA; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-title { font-size: 17px; font-weight: 700; word-break: break-all; }
.card-sub { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--muted); }
.pill { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill.fail { color: var(--fail); background: var(--fail-bg); }
.pill.wait { color: var(--wait); background: var(--wait-bg); }
.pill.pass { color: var(--pass); background: var(--pass-bg); }
.pill.cancel { color: var(--muted); background: var(--line-soft); }

/* 막대 */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 84px minmax(0, 1fr) 32px; align-items: center; gap: 10px; font-size: 14px; }
.bar-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track { height: 10px; background: var(--line-soft); border-radius: 999px; }
.fill { height: 10px; background: var(--navy); border-radius: 999px; }
.bar-row b { text-align: right; }

/* 협력사 순위 */
.rank { display: flex; flex-direction: column; }
.row-link { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px; min-height: 48px; border: none; border-bottom: 1px solid var(--line-soft); background: transparent; color: var(--text); text-align: left; padding: 0; width: 100%; }
.row-link:last-child { border-bottom: none; }
.row-link .nm { font-size: 15px; font-weight: 700; }
.row-link .fc { font-size: 13px; color: var(--muted); }
.row-link .rt { font-size: 16px; font-weight: 800; width: 60px; text-align: right; }
.row-link.worst .fc, .row-link.worst .rt { color: var(--fail); font-weight: 700; }
.row-link.worst .rt { font-weight: 800; }

/* 필터 */
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; background: var(--line-soft); border-radius: 12px; padding: 4px; }
.seg button { height: 40px; border: none; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--navy); font-weight: 700; box-shadow: 0 1px 2px rgba(17,24,39,.12); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid #D1D5DB; background: #fff; color: #374151; font-size: 14px; }
.chips button[aria-pressed="true"] { border-color: var(--navy); background: var(--navy); color: #fff; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); margin: 0 4px; }
select { height: 44px; border: 1px solid #D1D5DB; border-radius: 12px; padding: 0 12px; background: #fff; font-size: 15px; }
.search { display: flex; align-items: center; gap: 8px; height: 52px; border: 2px solid var(--navy); border-radius: 12px; padding: 0 8px 0 14px; background: #fff; }
.search input { flex: 1; min-width: 0; border: none; outline: none; font-size: 17px; font-weight: 700; background: transparent; text-transform: uppercase; }
.search input::placeholder { text-transform: none; font-weight: 400; color: #9CA3AF; }
.clear { width: 36px; height: 36px; border: none; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; }

/* 상세 */
.back-row { display: flex; align-items: center; gap: 4px; margin: 0 -8px; }
.back { width: 44px; height: 44px; border: none; background: transparent; display: flex; align-items: center; justify-content: center; color: var(--text); }
.back-row h1 { font-size: 18px; font-weight: 700; }
.hero { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.hero .pills { display: flex; gap: 8px; flex-wrap: wrap; }
.hero .blk { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; word-break: break-all; }
.hero .sub { font-size: 15px; color: var(--muted); }
dl.info { margin: 0; display: grid; grid-template-columns: 88px minmax(0, 1fr); padding: 8px 20px; }
dl.info dt, dl.info dd { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
dl.info dt { font-size: 14px; color: var(--muted); }
dl.info dd { margin: 0; font-size: 15px; font-weight: 500; word-break: break-all; }
dl.info dt:nth-last-child(2), dl.info dd:last-child { border-bottom: none; }
.comment { font-size: 15px; line-height: 1.6; background: #F9FAFB; border-radius: 12px; padding: 14px; white-space: pre-wrap; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 12px; }
.timeline .rail { display: flex; flex-direction: column; align-items: center; }
.timeline .dot { width: 12px; height: 12px; border-radius: 999px; margin-top: 5px; background: var(--pass); }
.timeline .dot.fail { background: var(--fail); }
.timeline .dot.cancel { background: #9CA3AF; }
.timeline .line { flex: 1; width: 2px; background: var(--line); }
.timeline li:last-child .line { display: none; }
.timeline .tx { display: flex; flex-direction: column; gap: 2px; padding-bottom: 16px; }
.timeline .tx b { font-size: 15px; }
.timeline .tx b.fail { color: var(--fail); }
.timeline .tx span { font-size: 13px; color: var(--muted); }
.timeline li.me .tx b::after { content: "  ← 이 검사"; font-size: 12px; font-weight: 500; color: var(--muted); }

.stat3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat3 div { display: flex; flex-direction: column; gap: 2px; background: var(--ground); border-radius: 12px; padding: 10px 12px; }
.stat3 span { font-size: 12px; color: var(--muted); }
.stat3 b { font-size: 18px; }
.list-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; background: var(--card); border-radius: 14px; padding: 14px 16px; border: none; width: 100%; text-align: left; color: var(--text); }
.list-row .l { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list-row .l b { font-size: 15px; }
.list-row .l span { font-size: 13px; color: var(--muted); }

/* 하단 메뉴 */
.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 520px; z-index: 5;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: #fff; border-top: 1px solid var(--line);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; color: var(--muted); font-size: 12px; font-weight: 500; }
.tabbar a[aria-current="page"] { color: var(--navy); font-weight: 700; }

/* 로그인 */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: space-between; background: #fff; padding: calc(80px + env(safe-area-inset-top)) 24px calc(32px + env(safe-area-inset-bottom)); }
.login .head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 36px; }
.login .head .brand { font-size: 44px; line-height: 1; }
.login h1 { font-size: 26px; font-weight: 800; }
.login p { font-size: 15px; color: var(--muted); line-height: 1.5; }
.login form { display: flex; flex-direction: column; gap: 16px; }
.login .f { display: flex; flex-direction: column; gap: 6px; }
.login .f label { font-size: 14px; font-weight: 500; }
.login input[type=text], .login input[type=password] { height: 52px; border: 1px solid #D1D5DB; border-radius: 12px; padding: 0 16px; font-size: 16px; background: #F9FAFB; }
.login .keep { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #374151; min-height: 44px; }
.login .keep input { width: 20px; height: 20px; accent-color: var(--navy); }
.primary { height: 54px; border: none; border-radius: 12px; background: var(--navy); color: #fff; font-size: 17px; font-weight: 700; }
.primary:disabled { opacity: .6; }
.err { color: var(--fail); font-size: 14px; font-weight: 500; min-height: 20px; }
.foot { font-size: 13px; color: var(--muted); text-align: center; line-height: 1.6; margin-top: 32px; }

/* 메뉴 시트 */
.sheet-bg { position: fixed; inset: 0; background: rgba(17,24,39,.4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; background: #fff; border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { font-size: 18px; }
.sheet .info { font-size: 14px; color: var(--muted); line-height: 1.6; }
.sheet button { height: 50px; border-radius: 12px; font-size: 16px; font-weight: 700; }
.sheet .ghost { border: 1px solid #D1D5DB; background: #fff; color: var(--text); }
.sheet .danger { border: none; background: var(--fail-bg); color: var(--fail); }
