/* JIT Dispatch — 모바일 우선 반응형 (전 사용자가 개인 휴대폰으로 사용) */
:root {
  --navy: #16324f;
  --navy-2: #1f4a73;
  --accent: #f2992c;
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #d9e0e7;
  --text: #1c2733;
  --muted: #63707d;
  --ok: #1e8e4f;
  --ok-bg: #e3f4ea;
  --warn: #b26a00;
  --warn-bg: #fdf0da;
  --bad: #c22f2f;
  --bad-bg: #fbe7e7;
  --info-bg: #e4edf7;
  --radius: 12px;
  --tap: 48px; /* 주요 버튼 최소 터치 영역 */
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}
.hidden { display: none !important; }

/* 상단바 */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px;
  background: var(--navy); color: #fff;
  padding-top: max(8px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-icon { width: 28px; height: 28px; border-radius: 6px; }
.brand-name { font-weight: 700; font-size: 17px; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.account-label { font-size: 13px; opacity: .85; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-toggle { display: flex; border: 1px solid rgba(255,255,255,.4); border-radius: 999px; overflow: hidden; }
.lang-toggle button {
  min-width: 44px; min-height: 38px; padding: 6px 10px;
  background: transparent; color: #fff; border: 0; font-weight: 600; cursor: pointer; font-size: 14px;
}
.lang-toggle button.active { background: #fff; color: var(--navy); }

/* 버튼·입력 — 큰 터치 영역 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 10px 18px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text);
  font-size: 16px; font-weight: 600; cursor: pointer; text-decoration: none;
  touch-action: manipulation;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: inherit; min-height: 40px; padding: 8px 10px; }
#topbar .btn-ghost { color: #fff; }
.btn-big { width: 100%; min-height: 54px; font-size: 17px; }
.btn-sm { min-height: 40px; padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea {
  font-size: 16px; /* iOS 자동 확대 방지 */
  padding: 10px 12px; min-height: var(--tap);
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text);
  width: 100%;
}
input[type="number"] { text-align: center; }
input[type="date"] { width: auto; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }

/* 레이아웃 */
#app { max-width: 1100px; margin: 0 auto; padding: 12px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.view { width: 100%; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.card h2 { margin: 0 0 10px; font-size: 18px; }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.login-card { max-width: 420px; margin: 32px auto; }
.hint { color: var(--muted); font-size: 14px; }
.error { color: var(--bad); background: var(--bad-bg); padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.ok-msg { color: var(--ok); background: var(--ok-bg); padding: 10px 12px; border-radius: 8px; font-size: 14px; }

/* 탭 */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.tabs button {
  flex: 0 0 auto; min-height: 44px; padding: 8px 16px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.tabs button.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* 툴바 */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.shift-toggle { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: #fff; }
.shift-toggle button { min-height: 44px; padding: 8px 18px; border: 0; background: transparent; font-weight: 700; cursor: pointer; font-size: 15px; }
.shift-toggle button.active { background: var(--navy); color: #fff; }

/* 표 — 모바일에서는 가로 스크롤 래퍼로 깨짐 방지 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 10px; }
table.grid { border-collapse: collapse; width: 100%; min-width: 560px; background: #fff; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 8px; text-align: center; vertical-align: middle; }
table.grid th { background: var(--info-bg); font-size: 14px; white-space: nowrap; }
table.grid td:first-child, table.grid th:first-child { text-align: left; font-weight: 700; white-space: nowrap; }
table.grid input[type="number"] { width: 64px; min-height: 44px; padding: 6px; }
table.grid input[type="text"] { min-height: 44px; }

/* 슬롯 입력 행 */
.slot-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.slot-row:last-child { border-bottom: 0; }
.slot-time { font-weight: 700; min-width: 58px; font-size: 17px; }
.slot-row input[type="number"] { width: 84px; }
.slot-total { display: flex; justify-content: space-between; align-items: center; padding-top: 10px; font-size: 18px; font-weight: 800; }

/* 칩·배지 */
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-bad { background: var(--bad-bg); color: var(--bad); }
.chip-info { background: var(--info-bg); color: var(--navy-2); }
.chip-muted { background: #eceff2; color: var(--muted); }
.badge-src { font-size: 12px; color: var(--muted); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }

/* 메시지 박스 */
.msg-box {
  white-space: pre-wrap; word-break: break-word;
  background: #0f2233; color: #eaf3fb; border-radius: 10px; padding: 12px; font-size: 15px;
}

/* 기사 선택 */
.pick-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pick-row .slot-time { min-width: 52px; }
.pick-row select { flex: 1; }
.radio-group { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.radio-group label {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px;
  min-height: var(--tap); cursor: pointer; font-weight: 600; background: #fff;
}
.radio-group input { width: auto; min-height: 0; }
.radio-group label.selected { background: var(--navy); color: #fff; border-color: var(--navy); }

/* 부족 배너 */
.shortage-banner { background: var(--bad-bg); border: 1px solid var(--bad); color: var(--bad); border-radius: 10px; padding: 12px; margin-bottom: 12px; font-weight: 600; }
.shortage-banner ul { margin: 6px 0 0; padding-left: 18px; }

/* 하단 고정 액션 (모바일 저장/컨펌) */
.sticky-actions {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; gap: 8px; padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
}
.sticky-actions .btn { flex: 1; }

/* 토스트 */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 15px; z-index: 100; box-shadow: 0 4px 18px rgba(0,0,0,.25); max-width: 92vw; text-align: center;
}

/* 넓은 화면 */
@media (min-width: 720px) {
  #app { padding: 20px; }
  .cards-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .cards-2 .card { margin-bottom: 0; }
  table.grid input[type="number"] { width: 76px; }
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mt { margin-top: 10px; }
.mb { margin-bottom: 10px; }

/* 후반 화면용 보조 클래스 */
.label { font-weight: 700; margin-bottom: 6px; }
.btn-lg { min-height: 56px; font-size: 17px; width: 100%; }

/* 자금(funds) 전용 최소 스타일 */
.funds-accounts { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
.funds-acct-card { margin-bottom: 0; }
.funds-balance { font-size: 24px; font-weight: 800; line-height: 1.2; }
.funds-amt-in { color: var(--ok); font-weight: 700; }
.funds-amt-out { color: var(--bad); font-weight: 700; }
@media (min-width: 720px) {
  .funds-accounts { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}
