:root {
  --navy: #1D3A5F;
  --navy-2: #2B5283;
  --amber: #F2B233;
  --bg: #EEF1F4;
  --ink: #17202B;
  --sub: #5A6675;
  --line: #D5DBE2;
  --card: #FFFFFF;
  --ok: #2E7D4F;
  --warn: #B87500;
  --bad: #C0392B;
  --r: 14px;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 17px/1.55 'IBM Plex Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy-2); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.boot { padding: 40vh 20px; text-align: center; color: var(--sub); }

/* 상단 바: 로고와 부서명 세로 중앙 정렬 */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand img { width: 36px; height: 36px; border-radius: 50%; background: #fff; object-fit: contain; flex: none; }
.brand-text { display: flex; flex-direction: column; justify-content: center; line-height: 1.2; min-width: 0; }
.brand-text small { font-size: 12px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text b { font-size: 18px; font-weight: 700; }
.icon-btn {
  position: relative; width: 44px; height: 44px; border: 0; border-radius: 12px;
  background: transparent; display: grid; place-items: center; cursor: pointer; font-size: 20px;
}
.top .icon-btn { color: #fff; }
.dot {
  position: absolute; top: 4px; right: 2px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--amber); color: var(--ink); font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}

main { max-width: 760px; margin: 0 auto; padding: 16px 14px 110px; }
h1 { font-size: 24px; margin: 4px 0 14px; letter-spacing: -0.01em; }
h2 { font-size: 19px; margin: 22px 0 10px; }
h3 { font-size: 17px; margin: 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--sub); font-size: 15px; }
.empty { color: var(--sub); text-align: center; padding: 28px 10px; background: var(--card); border-radius: var(--r); border: 1px dashed var(--line); }

/* 하단 탭 */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 9px;
  text-decoration: none; color: var(--sub); font-size: 13px; min-height: 58px; justify-content: center;
}
.tabs a span { font-size: 21px; line-height: 1; }
.tabs a[aria-current="page"] { color: var(--navy); font-weight: 700; }
.tabs a[aria-current="page"] span { transform: translateY(-1px); }

/* 버튼 */
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.amber { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.btn.danger { color: var(--bad); border-color: #EBC2BD; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 15px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: progress; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 8px; }
.quick .btn { flex-direction: column; min-height: 84px; font-size: 15px; gap: 4px; }
.quick .btn span { font-size: 26px; }

/* 카드/목록 */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--card); border-radius: var(--r); padding: 14px; border: 1px solid var(--line);
  display: block; text-decoration: none; color: inherit; width: 100%; text-align: left;
}
button.item { cursor: pointer; font: inherit; }
.item .meta { color: var(--sub); font-size: 15px; margin-top: 4px; }
.item .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.stat b { display: block; font-size: 24px; font-weight: 700; color: var(--navy); }
.stat small { color: var(--sub); font-size: 14px; }

/* 차량 번호판 — 이 앱의 상징 요소 */
.plate {
  display: inline-flex; align-items: center; height: 34px; padding: 0 12px;
  border: 2.5px solid var(--ink); border-radius: 7px; background: #fff;
  font-weight: 700; font-size: 19px; letter-spacing: .04em; white-space: nowrap;
  box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 3px #C9CFD6;
}
.plate.big { height: 52px; font-size: 30px; padding: 0 18px; border-width: 3px; border-radius: 9px; }
.vcard { display: grid; gap: 8px; }
.vcard .name { font-weight: 700; font-size: 18px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; background: #E7EBF0; color: var(--sub); white-space: nowrap; }
.badge.ok { background: #E1F1E7; color: var(--ok); }
.badge.warn { background: #FCEFD3; color: var(--warn); }
.badge.bad { background: #F8E0DD; color: var(--bad); }
.badge.navy { background: #DFE7F2; color: var(--navy); }

.kv { display: grid; grid-template-columns: 112px 1fr; gap: 8px 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.kv dt { color: var(--sub); }
.kv dd { margin: 0; }

.seg { display: flex; background: #DDE3EA; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 12px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; color: var(--sub); cursor: pointer; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--navy); }

.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters select, .filters input { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; background: #fff; flex: 1; min-width: 130px; }

.notice-pin { background: #FFF7E3; border-color: #F1D69A; }
.pre { white-space: pre-wrap; word-break: break-word; }

/* 막대 그래프 */
.bars { display: flex; flex-direction: column; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.bar { display: grid; grid-template-columns: 88px 1fr 90px; gap: 8px; align-items: center; font-size: 14px; }
.bar i { display: block; height: 14px; border-radius: 7px; background: var(--navy-2); min-width: 2px; }
.bar em { font-style: normal; text-align: right; color: var(--sub); }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { background: #F4F6F8; font-weight: 600; }

/* 바텀시트 폼 */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(15,24,36,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto;
  border-radius: 20px 20px 0 0; padding: 6px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 20px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: #fff; padding: 8px 0; z-index: 1; }
.sheet-head h2 { margin: 0; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-weight: 600; font-size: 15px; }
.field input, .field select, .field textarea {
  min-height: 50px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; width: 100%;
}
.field textarea { min-height: 96px; resize: vertical; }
.field .hint { color: var(--sub); font-size: 13px; }
.check { flex-direction: row; align-items: center; gap: 10px; }
.check input { width: 24px; height: 24px; min-height: 0; }
.sheet-actions { display: flex; gap: 8px; margin-top: 8px; }
.sheet-actions .btn.primary { flex: 1; }

/* 로그인 */
.auth { max-width: 420px; margin: 0 auto; padding: 32px 18px 40px; }
.auth .brand { margin-bottom: 26px; }
.auth .brand img { width: 52px; height: 52px; border: 1px solid var(--line); }
.auth .brand-text b { font-size: 24px; color: var(--navy); }
.auth .brand-text small { font-size: 14px; color: var(--sub); opacity: 1; }
.auth .card { background: #fff; border-radius: 18px; padding: 18px; border: 1px solid var(--line); }

#toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 80;
  max-width: calc(100% - 28px); font-size: 15px; display: none;
}
#toast.show { display: block; }
#toast.bad { background: var(--bad); }

.menu { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.menu a { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px 14px; text-decoration: none; color: var(--ink); font-weight: 600; display: flex; gap: 10px; align-items: center; min-height: 64px; }
.menu a span { font-size: 22px; }
.unread { border-left: 4px solid var(--amber); }
