
:root {
  --c2: #00A650; --c3: #EF7C1C; --c4: #00A5DE; --c5: #996CAC; --c6: #CD7C2F;
  --dark: #0f172a; --gray: #64748b; --light: #f1f5f9; --white: #ffffff;
  --red: #ef4444; --green: #22c55e; --amber: #f59e0b; --blue: #0284c7;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--light); min-height: 100vh; }
/* 앱 전체의 기준 프레임: 480px. PC 화면처럼 넓은 곳에서 봐도 이 폭 밖으로는 아무것도 못 나가게
   화면(.screen) 자체에 한 번만 걸어둔다. 안쪽 요소(.main-bg 등)가 개별적으로 max-width를 안 걸어도
   부모(.screen)가 이미 480px로 잘려있어서 자동으로 그 안에 들어오고, position:absolute로 붙는 것들도
   (예: .main-credit) 엉뚱하게 브라우저 창 전체 기준(오른쪽 끝 등)으로 안 튀어나가게 position:relative를 준다. */
.screen { display: none; max-width: 480px; margin: 0 auto; position: relative; }
.screen.active { display: block; }

/* 헤더 */
.header { padding: 16px; text-align: center; position: sticky; top: 0; z-index: 100; max-width: 480px; margin: 0 auto; }
.header h1 { font-size: 18px; font-weight: 800; color: white; }
.header p { font-size: 12px; color: rgba(255,255,255,0.7); margin-top: 3px; }

/* 어느 화면에서든 메인으로 돌아가는 버튼 */
/* 콘텐츠는 max-width:480px로 가운데 정렬되므로, 넓은 화면에서도 뷰포트 구석이 아니라
   그 콘텐츠 박스의 좌상단에 붙도록 위치를 계산한다 (50% - 240px + 12px 여백). */
.home-fab { position: fixed; top: 12px; left: max(12px, calc(50% - 228px)); z-index: 300; width: 40px; height: 40px; border-radius: 50%; background: rgba(15,23,42,0); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); color: white; border: 2px solid rgba(255,255,255,0.85); font-size: 17px; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,0.35); }
.home-fab i, .home-fab svg { width: 20px; height: 20px; stroke-width: 2.2; }
.home-fab:active { background: rgba(15,23,42,0.25); }

/* 로딩 스피너 - 회색-on-회색이라 눈에 잘 안 띈다는 피드백으로 굵기/크기/대비를 키움(2026-07-31) */
.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid rgba(15,23,42,0.15); border-top-color: var(--dark); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box { text-align: center; padding: 24px; color: var(--dark); font-size: 14px; font-weight: 600; }
.thumb-spinner { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #e2e8f0; }

/* 메인 */
.main-bg { background: linear-gradient(160deg, #0f172a 0%, #1e3a5f 100%); min-height: 100vh; padding: 0 0 14px; position: relative; display: flex; flex-direction: column; justify-content: center; }
.main-credit { position: absolute; top: 12px; left: 16px; text-align: left; font-size: 10px; line-height: 1.5; color: rgba(255,255,255,0.35); }
.main-user-btn { position: absolute; top: 12px; right: 16px; background: rgba(255,255,255,0.12); color: white; border: 1px solid rgba(255,255,255,0.3); border-radius: 20px; padding: 6px 14px; font-size: 12px; font-weight: 700; cursor: pointer; }
.main-logo { text-align: center; padding: 14px 24px 10px; max-width: 480px; margin: 0 auto; }
.main-logo .logo-icon { width: 42px; height: 42px; margin: 0 auto 8px; display: block; color: white; stroke-width: 1.8; }
.main-logo h1 { font-size: 22px; font-weight: 900; color: white; letter-spacing: -0.5px; }
.main-logo p { font-size: 12px; color: rgba(255,255,255,0.5); margin-top: 4px; }

.mode-grid { display: flex; flex-direction: column; gap: 6px; padding: 0 16px; max-width: 480px; margin: 0 auto; width: 100%; }
.mode-card { border-radius: 16px; padding: 12px 18px; cursor: pointer; position: relative; overflow: hidden; border: none; text-align: left; width: 100%; }
.mode-card::after { content: "→"; position: absolute; right: 20px; top: 50%; transform: translateY(-50%); font-size: 18px; color: rgba(255,255,255,0.6); }
.mode-card .mode-icon { width: 22px; height: 22px; margin-bottom: 4px; display: block; color: white; stroke-width: 1.8; }
.mode-card .mode-title { font-size: 16px; font-weight: 800; color: white; }
.mode-card .mode-desc { font-size: 11px; color: rgba(255,255,255,0.7); margin-top: 2px; }
.mode-card .mode-badge { display: inline-block; background: rgba(255,255,255,0.2); color: white; font-size: 10px; font-weight: 700; padding: 2px 9px; border-radius: 20px; margin-top: 5px; }

/* 이모지 대신 쓰는 lucide 아이콘: 글자 크기에 맞춰 1em으로 스케일되고, 텍스트와 나란히 놓일 때 살짝 내려서(vertical-align) 베이스라인을 맞춘다 */
.icon-inline { width: 1em; height: 1em; vertical-align: -0.15em; margin-right: 5px; stroke-width: 2.2; flex-shrink: 0; }

.card-clean { background: linear-gradient(135deg, #00A650, #00c96a); }
.card-fault-report { background: linear-gradient(135deg, #ef4444, #dc2626); }
.card-fault-action { background: linear-gradient(135deg, #f59e0b, #d97706); }
.card-dashboard { background: linear-gradient(135deg, #0284c7, #0369a1); }

/* 컨테이너 */
.container { padding: 16px; max-width: 480px; margin: 0 auto; background: white; min-height: 100vh; }

/* 하단 고정 액션바: 저장/이동 같은 주요 버튼을 스크롤과 무관하게 항상 눌리는 위치에 둔다 */
.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 100; max-width: 480px; margin: 0 auto; background: white; box-shadow: 0 -2px 10px rgba(0,0,0,0.08); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.bottom-bar .btn { margin-top: 0; }
.card { background: white; border-radius: 16px; padding: 20px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.card h2 { font-size: 15px; font-weight: 700; color: var(--dark); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* 폼 */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 11px; font-weight: 700; color: var(--gray); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.8px; }
.form-group select, .form-group input, .form-group textarea { width: 100%; padding: 13px; border: 1.5px solid #e2e8f0; border-radius: 10px; font-size: 15px; color: var(--dark); background: white; font-family: inherit; -webkit-appearance: none; }
.form-group select:focus, .form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--blue); }
.form-group textarea { resize: none; }

/* 버튼 */
.btn { width: 100%; padding: 15px; border: none; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 8px; font-family: inherit; }
.btn-dark { background: var(--dark); color: white; }
.btn-green { background: var(--green); color: white; }
.btn-gray { background: var(--light); color: var(--gray); }
.btn-red { background: var(--red); color: white; }
.btn-amber { background: var(--amber); color: white; }
.btn:disabled { opacity: 0.4; }

/* 라운드 */
.round-group { display: flex; gap: 10px; }
.round-btn { flex: 1; padding: 13px; border: 2px solid #e2e8f0; border-radius: 10px; font-size: 15px; font-weight: 700; color: var(--gray); background: white; cursor: pointer; font-family: inherit; transition: all 0.2s; }
.round-btn.sel { border-color: transparent; color: white; }

/* 호선/역사/방향 선택 */
.line-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.line-btn { padding: 20px 8px; border: 2.5px solid; border-radius: 14px; font-size: 14px; font-weight: 800; background: white; cursor: pointer; text-align: center; transition: all 0.2s; font-family: inherit; }
.line-btn.sel { color: white; border-color: transparent !important; }
.station-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.station-btn { padding: 18px 8px; border: 2px solid #e2e8f0; border-radius: 14px; font-size: 15px; font-weight: 700; background: white; cursor: pointer; text-align: center; color: var(--dark); transition: all 0.2s; font-family: inherit; }
.station-btn.sel { color: white; border-color: transparent; }
.dir-grid { display: flex; flex-direction: column; gap: 10px; }
.dir-btn { padding: 20px; border: 2px solid #e2e8f0; border-radius: 14px; font-size: 16px; font-weight: 700; background: white; cursor: pointer; text-align: center; color: var(--dark); transition: all 0.2s; font-family: inherit; }
.dir-btn.sel { color: white; border-color: transparent; }

/* GPS 버튼 */
.gps-btn { width: 100%; padding: 12px; border: 2px dashed #cbd5e1; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--blue); background: #f0f9ff; cursor: pointer; margin-bottom: 12px; font-family: inherit; }

/* 점검 헤더 */
.check-wrap { max-width: 480px; margin: 0 auto; background: white; min-height: 100vh; }
.check-top-fixed { position: fixed; top: 0; left: 0; right: 0; z-index: 100; max-width: 480px; margin: 0 auto; background: white; }
#screen-check .header { position: static; }
.check-sticky { position: static; z-index: 99; background: white; border-bottom: 1px solid #f1f5f9; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; }
.progress-bar { height: 4px; background: #e2e8f0; }
.progress-fill { height: 100%; transition: width 0.4s; border-radius: 2px; }

/* 점검 카드 */
.pos-card { background: white; border-radius: 16px; padding: 18px; margin: 10px 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); border-left: 5px solid #e2e8f0; transition: border-color 0.3s, box-shadow 0.3s; }
.pos-card.done { border-left-color: var(--green); }
.pos-card.partial { border-left-color: var(--amber); }
.pos-card.jump-highlight { box-shadow: 0 0 0 3px var(--red), 0 2px 8px rgba(0,0,0,0.06); }
.pos-title { font-size: 22px; font-weight: 900; color: var(--dark); margin-bottom: 14px; letter-spacing: -0.5px; }
.photo-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.photo-btn { position: relative; width: 100%; min-height: 100px; border: 2px dashed #cbd5e1; border-radius: 12px; font-size: 13px; font-weight: 600; color: var(--gray); background: #f8fafc; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; overflow: hidden; font-family: inherit; padding: 0; }
.photo-btn.has-photo { border-style: solid; border-color: var(--green); background: white; }
.photo-btn.has-photo img { width: 100%; height: 100px; object-fit: cover; }
.photo-btn.locked { opacity: 0.4; cursor: not-allowed; background: #f1f5f9; }
.issue-photo-row { display: flex; gap: 10px; margin: 8px 0 12px; }
.issue-photo-row .photo-btn { flex: 1; border-color: #fca5a5; }
.issue-photo-row .photo-btn.has-photo { border-color: var(--red); }
.photo-label { font-size: 11px; padding: 4px; font-weight: 700; }
.status-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.status-btn { padding: 12px 8px; border: 2px solid #e2e8f0; border-radius: 10px; font-size: 13px; font-weight: 700; color: var(--gray); background: white; cursor: pointer; font-family: inherit; transition: all 0.15s; }
.status-btn.ok { border-color: var(--green); background: #f0fdf4; color: #16a34a; }
.status-btn.bad { border-color: var(--red); background: #fef2f2; color: #dc2626; }
.note-input { width: 100%; padding: 10px 12px; border: 1.5px solid #e2e8f0; border-radius: 10px; font-size: 14px; resize: none; font-family: inherit; }

/* 배지 */
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.b-ok { background: #f0fdf4; color: #16a34a; }
.b-bad { background: #fef2f2; color: #dc2626; }
.b-pending { background: #f1f5f9; color: var(--gray); }
.b-warn { background: #fffbeb; color: #d97706; }
.b-blue { background: #e0f2fe; color: #0369a1; }

/* 토글 스위치 (생체인증 켜기/끄기 등) */
.toggle-switch { position: relative; display: inline-block; width: 46px; height: 26px; border-radius: 13px; background: #cbd5e1; transition: background .15s; flex-shrink: 0; }
.toggle-switch.on { background: var(--green); }
.toggle-switch .toggle-knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: left .15s; }
.toggle-switch.on .toggle-knob { left: 23px; }

/* 대시보드 */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card { background: white; border-radius: 14px; padding: 18px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.stat-num { font-size: 32px; font-weight: 900; letter-spacing: -1px; white-space: nowrap; }
.stat-label { font-size: 12px; color: var(--gray); margin-top: 4px; font-weight: 600; }

/* 장애 카드 */
.fault-card { background: white; border-radius: 14px; padding: 18px; margin-bottom: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); border-left: 5px solid var(--red); transition: box-shadow .3s, outline .3s; }
.fault-card.share-link-highlight { outline: 3px solid var(--blue); outline-offset: 2px; box-shadow: 0 0 0 6px rgba(2,132,199,0.15); }
.fault-card.done { border-left-color: var(--green); }
.fault-title { font-size: 16px; font-weight: 800; color: var(--dark); }
.fault-sub { font-size: 13px; color: var(--red); font-weight: 700; margin-top: 4px; }
.note-sub { font-size: 13px; color: var(--gray); margin-top: 4px; }
.fault-meta { font-size: 12px; color: var(--gray); margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }

/* 역사 현황 */
.station-row { display: flex; flex-direction: column; align-items: flex-start; padding: 12px; padding-right: 30px; background: white; border-radius: 14px; margin-bottom: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); cursor: pointer; position: relative; }
.station-row::after { content: "›"; font-size: 20px; color: var(--gray); position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
.line-tag { color: white; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 800; }
.station-search { display: block; width: 100%; box-sizing: border-box; height: 44px; line-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid #e2e8f0; font-size: 14px; margin-bottom: 10px; background: white; -webkit-appearance: none; appearance: none; }
input[type="month"].station-search::-webkit-calendar-picker-indicator { padding: 0; margin: 0; width: 16px; height: 16px; }

/* 역사 상세 - 개소별 기록 */
.detail-record { background: white; border-radius: 14px; padding: 16px; margin-bottom: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.detail-record-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.detail-record-title { font-size: 15px; font-weight: 800; color: var(--dark); }
.detail-thumb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.detail-thumb { position: relative; border-radius: 10px; overflow: hidden; height: 90px; background: var(--light); border: none; padding: 0; cursor: pointer; }
.detail-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-thumb .thumb-label { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.55); color: white; font-size: 11px; padding: 3px 0; text-align: center; }
.detail-thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--gray); font-size: 12px; }
.img-error-box { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; width: 100%; background: var(--light); color: var(--gray); font-size: 11px; font-weight: 700; text-align: center; line-height: 1.5; }

/* 사진 모달 */
.photo-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 2000; align-items: center; justify-content: center; flex-direction: column; padding: 24px; }
.photo-modal.show { display: flex; }
.photo-modal img { max-width: 100%; max-height: 70vh; border-radius: 8px; touch-action: none; transform-origin: center center; transition: transform .05s ease-out; }
.photo-modal-close { position: absolute; top: 18px; right: 18px; z-index: 10; background: rgba(255,255,255,0.15); color: white; border: none; width: 44px; height: 44px; border-radius: 50%; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.photo-modal-close i, .photo-modal-close svg { width: 20px; height: 20px; }
.photo-modal-actions { display: flex; gap: 10px; margin-top: 18px; width: 100%; max-width: 320px; }
.photo-modal-error { display: none; flex-direction: column; align-items: center; justify-content: center; width: 260px; height: 260px; max-width: 100%; background: #1e293b; border-radius: 8px; color: #94a3b8; font-size: 14px; font-weight: 700; text-align: center; line-height: 1.6; }

/* 장애 사진 화살표 표기 */
.arrow-modal { display: none; position: fixed; inset: 0; background: #000; z-index: 2200; flex-direction: column; }
.arrow-modal.show { display: flex; }
.arrow-modal-canvas-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#arrow-canvas { max-width: 100%; max-height: 100%; touch-action: none; }
.arrow-modal-bar { background: #111; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
.arrow-modal-hint { color: white; font-size: 13px; text-align: center; margin-bottom: 10px; }

/* 엑셀 다운로드 옵션 선택 모달 */
.excel-menu-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 2100; align-items: center; justify-content: center; padding: 24px; }
.excel-menu-modal.show { display: flex; }
.excel-menu-card { background: white; border-radius: 16px; padding: 22px 20px; width: 100%; max-width: 340px; max-height: calc(100vh - 48px); overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.excel-menu-card h3 { margin: 0 0 14px; font-size: 16px; color: var(--dark); text-align: center; }
.excel-menu-card .btn { text-align: left; padding: 14px 16px; }
.photo-modal-actions a, .photo-modal-actions button { flex: 1; text-align: center; padding: 12px; border-radius: 10px; font-size: 14px; font-weight: 700; text-decoration: none; border: none; cursor: pointer; }

/* 커스텀 확인창 (네이티브 confirm 대체) */
.confirm-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 2300; align-items: center; justify-content: center; padding: 24px; }
.confirm-modal.show { display: flex; }
.confirm-modal-card { background: white; border-radius: 16px; padding: 22px 20px; width: 100%; max-width: 340px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.confirm-modal-msg { font-size: 14px; color: var(--dark); line-height: 1.6; margin-bottom: 18px; white-space: pre-line; }
.confirm-modal-actions { display: flex; gap: 8px; }
/* "저장 안하고 나가기"처럼 긴 라벨도 줄바꿈 없이 한 줄에 들어가도록 이 안에서만 글자를 줄이고 여백을 좁힌다 */
.confirm-modal-actions .btn { margin-top: 0; font-size: 13px; padding: 13px 4px; white-space: nowrap; }

/* 장애 대시보드 */
.fault-controls { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.fault-controls input, .fault-controls select { padding: 10px 12px; border-radius: 10px; border: 1px solid #e2e8f0; font-size: 13px; background: white; }
.fault-controls input { flex: 1; min-width: 120px; }
.fault-controls select { min-width: 100px; }
.fault-stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.fault-stat-card { background: white; border-radius: 14px; padding: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); text-align: center; }
.fault-stat-num { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.fault-stat-label { font-size: 12px; color: var(--gray); }
.fault-chart { background: white; border-radius: 14px; padding: 14px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }

/* 요약 */
.summary-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid #f8fafc; }

/* iOS Safari는 display:none인 파일 인풋에서 사진 선택 후 change 처리가 불안정할 수 있다고 알려져 있어,
   화면엔 안 보이되 DOM/레이아웃엔 존재하는 방식으로 숨긴다(display:none 대신 position+opacity). */
input[type="file"] { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; z-index: -1; }

/* 토스트 */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: var(--dark); color: white; padding: 12px 24px; border-radius: 30px; font-size: 14px; font-weight: 600; z-index: 9999; opacity: 0; transition: opacity 0.3s; pointer-events: none; width: max-content; max-width: calc(100% - 48px); text-align: center; }
.toast.show { opacity: 1; }
